use of org.eclipse.jface.viewers.ViewerComparator in project webtools.sourceediting by eclipse.
the class SortAction method update.
public void update() {
super.update();
treeViewer.getControl().setRedraw(false);
Object[] expandedElements = treeViewer.getExpandedElements();
if (isChecked()) {
treeViewer.setComparator(new ViewerComparator());
} else {
treeViewer.setComparator(null);
}
treeViewer.setInput(treeViewer.getInput());
treeViewer.setExpandedElements(expandedElements);
treeViewer.getControl().setRedraw(true);
}
use of org.eclipse.jface.viewers.ViewerComparator in project webtools.sourceediting by eclipse.
the class HTMLSourcePreferencePage method createContentsForFormattingGroup.
private void createContentsForFormattingGroup(Composite parent) {
Group formattingGroup = createGroup(parent, 2);
formattingGroup.setText(HTMLUIMessages.Formatting_UI_);
createLabel(formattingGroup, HTMLUIMessages.Line_width__UI_);
fLineWidthText = new Text(formattingGroup, SWT.SINGLE | SWT.BORDER);
GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.BEGINNING);
gData.widthHint = 25;
fLineWidthText.setLayoutData(gData);
fLineWidthText.addModifyListener(this);
fSplitMultiAttrs = createCheckBox(formattingGroup, HTMLUIMessages.Split_multiple_attributes);
((GridData) fSplitMultiAttrs.getLayoutData()).horizontalSpan = 2;
fAlignEndBracket = createCheckBox(formattingGroup, HTMLUIMessages.Align_final_bracket);
((GridData) fAlignEndBracket.getLayoutData()).horizontalSpan = 2;
fClearAllBlankLines = createCheckBox(formattingGroup, HTMLUIMessages.Clear_all_blank_lines_UI_);
((GridData) fClearAllBlankLines.getLayoutData()).horizontalSpan = 2;
// [269224] - Place the indent controls in their own composite for proper tab ordering
Composite indentComposite = createComposite(formattingGroup, 1);
((GridData) indentComposite.getLayoutData()).horizontalSpan = 2;
((GridLayout) indentComposite.getLayout()).marginWidth = 0;
((GridLayout) indentComposite.getLayout()).marginHeight = 0;
fIndentUsingTabs = createRadioButton(indentComposite, HTMLUIMessages.Indent_using_tabs);
((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 1;
fIndentUsingSpaces = createRadioButton(indentComposite, HTMLUIMessages.Indent_using_spaces);
((GridData) fIndentUsingSpaces.getLayoutData()).horizontalSpan = 1;
createLabel(formattingGroup, HTMLUIMessages.Indentation_size);
fIndentationSize = new Spinner(formattingGroup, SWT.BORDER);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
fIndentationSize.setLayoutData(gd);
fIndentationSize.setToolTipText(HTMLUIMessages.Indentation_size_tip);
fIndentationSize.setMinimum(MIN_INDENTATION_SIZE);
fIndentationSize.setMaximum(MAX_INDENTATION_SIZE);
fIndentationSize.setIncrement(1);
fIndentationSize.setPageIncrement(4);
fIndentationSize.addModifyListener(this);
GridData data;
Composite inlineGroup = new Composite(formattingGroup, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.marginHeight = 0;
inlineGroup.setLayout(layout);
data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 2;
inlineGroup.setLayoutData(data);
Label label = createLabel(inlineGroup, HTMLUIMessages.Inline_elements_table_label);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
label.setLayoutData(data);
final TableViewer viewer = new TableViewer(inlineGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 1;
data.verticalAlignment = SWT.BEGINNING;
data.heightHint = convertHeightInCharsToPixels(10);
viewer.getTable().setLayoutData(data);
Composite buttonContainer = new Composite(inlineGroup, SWT.NONE);
data = new GridData(GridData.FILL_VERTICAL);
buttonContainer.setLayoutData(data);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
buttonContainer.setLayout(layout);
fAddButton = new Button(buttonContainer, SWT.PUSH);
fAddButton.setText(HTMLUIMessages.Add_inline);
fAddButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
HTMLElementDialog dialog = new HTMLElementDialog(getShell());
dialog.setMessage(HTMLUIMessages.Elements_Dialog_message);
dialog.setTitle(HTMLUIMessages.Elements_Dialog_title);
dialog.setMultipleSelection(true);
dialog.setAllowDuplicates(false);
dialog.open();
Object[] result = dialog.getResult();
if (result != null) {
for (int i = 0; i < result.length; i++) {
fContentProvider.addElement(result[i].toString());
}
fViewer.refresh();
}
}
});
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
data.widthHint = Math.max(widthHint, fAddButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
data.horizontalSpan = 1;
fAddButton.setLayoutData(data);
fRemoveButton = new Button(buttonContainer, SWT.PUSH);
fRemoveButton.setText(HTMLUIMessages.Remove_inline);
fRemoveButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ISelection selection = viewer.getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof StructuredSelection) {
Object[] remove = ((StructuredSelection) selection).toArray();
for (int i = 0; i < remove.length; i++) {
fContentProvider.removeElement(remove[i].toString());
}
if (remove.length > 0) {
fViewer.refresh();
}
}
}
});
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
data.horizontalSpan = 1;
fRemoveButton.setLayoutData(data);
fViewer = viewer;
fContentProvider = new ContentProvider();
viewer.setContentProvider(fContentProvider);
viewer.setInput(this);
viewer.setComparator(new ViewerComparator(Collator.getInstance()));
}
use of org.eclipse.jface.viewers.ViewerComparator in project webtools.sourceediting by eclipse.
the class OccurrencesSearchViewPage method configureTableViewer.
/**
* @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTableViewer(org.eclipse.jface.viewers.TableViewer)
*/
protected void configureTableViewer(TableViewer viewer) {
// sort results by line number, low to high
viewer.setComparator(new ViewerComparator() {
public int compare(Viewer v, Object obj1, Object obj2) {
BasicSearchMatchElement elem1 = (BasicSearchMatchElement) obj1;
BasicSearchMatchElement elem2 = (BasicSearchMatchElement) obj2;
return elem1.getLineNum() - elem2.getLineNum();
}
});
// allow for formated labels
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new BasicSearchLabelProvider(this)));
this.fContentProvider = new OccurrencesContentProvider();
viewer.setContentProvider(this.fContentProvider);
}
use of org.eclipse.jface.viewers.ViewerComparator in project epp.mpc by eclipse.
the class ShowNatureProposalsDialog method createDialogArea.
@Override
public Control createDialogArea(Composite parent) {
setTitle(Messages.MissingNatureDetector_Title);
setMessage(Messages.MissingNatureDetector_Desc);
wizban = DiscoveryImages.BANNER_DISOVERY.createImage();
setTitleImage(wizban);
Composite res = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(res);
GridLayoutFactory.fillDefaults().margins(LayoutConstants.getMargins()).equalWidth(false).applyTo(res);
Label label = new Label(res, SWT.WRAP);
label.setText(Messages.MissingNatureDetector_Message);
naturesCheckList = CheckboxTableViewer.newCheckList(res, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
naturesCheckList.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return ((Set<?>) inputElement).toArray();
}
});
naturesCheckList.setComparator(new ViewerComparator());
naturesCheckList.setInput(candidates.keySet());
naturesCheckList.setAllChecked(true);
GridDataFactory.fillDefaults().applyTo(naturesCheckList.getControl());
naturesCheckList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
Button okButton = getButton(IDialogConstants.OK_ID);
if (okButton != null) {
okButton.setEnabled(canComplete());
}
updateSelectedNatures();
}
});
Link preferencesLink = new Link(res, SWT.NONE);
preferencesLink.setText(Messages.MissingNatureDetector_linkToPreferences);
preferencesLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(getShell(), ProjectNaturesPreferencePage.ID, null, null);
pref.setBlockOnOpen(false);
pref.open();
}
});
return res;
}
use of org.eclipse.jface.viewers.ViewerComparator in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method createControl.
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
switchResultLayout = new StackLayout();
container.setLayout(switchResultLayout);
GridData data = new GridData(GridData.FILL_BOTH);
container.setLayoutData(data);
defaultComposite = new Composite(container, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(defaultComposite);
Composite treeContainer = new Composite(defaultComposite, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(treeContainer);
TreeColumnLayout columnLayout = new TreeColumnLayout();
treeContainer.setLayout(columnLayout);
viewer = new CheckboxTreeViewer(treeContainer, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setUseHashlookup(true);
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 == e2) {
return 0;
}
String s1;
String s2;
if (e1 instanceof CatalogItemEntry) {
s1 = ((CatalogItemEntry) e1).getItem().getName();
s2 = ((CatalogItemEntry) e2).getItem().getName();
} else {
FeatureEntry fe1 = (FeatureEntry) e1;
FeatureEntry fe2 = (FeatureEntry) e2;
if (fe1.getInstallableUnitItem().isOptional() != fe2.getInstallableUnitItem().isOptional()) {
// required items first
return fe1.getInstallableUnitItem().isOptional() ? 1 : -1;
}
s1 = fe1.getFeatureDescriptor().getName();
s2 = fe2.getFeatureDescriptor().getName();
}
int i = s1.compareToIgnoreCase(s2);
if (i == 0) {
i = s1.compareTo(s2);
if (i == 0) {
i = new Integer(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
}
}
return i;
}
});
viewer.setContentProvider(new ContentProvider());
viewer.setInput(getWizard().getSelectionModel());
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
if (event.getElement() instanceof CatalogItemEntry) {
CatalogItemEntry entry = (CatalogItemEntry) event.getElement();
for (FeatureEntry child : entry.getChildren()) {
child.setChecked(checked);
}
} else if (event.getElement() instanceof FeatureEntry) {
FeatureEntry featureEntry = (FeatureEntry) event.getElement();
featureEntry.setChecked(checked);
}
refreshState();
}
});
column = new TreeViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new DelegatingStyledCellLabelProvider(new LabelProvider()));
columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(100, 100, true));
detailsControl = new Group(defaultComposite, SWT.SHADOW_IN);
detailsControl.setText(Messages.FeatureSelectionWizardPage_details);
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 300).exclude(true).applyTo(detailsControl);
GridLayoutFactory.fillDefaults().applyTo(detailsControl);
detailStatusText = new Text(detailsControl, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(detailStatusText);
setControl(container);
Dialog.applyDialogFont(container);
MarketplaceClientUi.setDefaultHelp(getControl());
flipToDefaultComposite();
}
Aggregations