use of org.eclipse.jface.viewers.ViewerComparator in project yamcs-studio by yamcs.
the class ConnectionsDialog method createServerPanel.
private Composite createServerPanel(Composite parent, ResourceManager resourceManager) {
Composite serverPanel = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
serverPanel.setLayoutData(gd);
TableColumnLayout tcl = new TableColumnLayout();
serverPanel.setLayout(tcl);
Image serverImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ConnectionsDialog.class, "icons/obj16/server.gif"));
connViewer = new TableViewer(serverPanel, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
connViewer.getTable().setHeaderVisible(true);
connViewer.getTable().setLinesVisible(false);
TableViewerColumn nameColumn = new TableViewerColumn(connViewer, SWT.NONE);
nameColumn.getColumn().setText("Connection Name");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
return serverImage;
}
@Override
public String getText(Object element) {
YamcsConfiguration conf = (YamcsConfiguration) element;
return conf.getName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(400));
connViewer.setContentProvider(new ArrayContentProvider());
connViewer.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.getFirstElement() != null) {
YamcsConfiguration conf = (YamcsConfiguration) sel.getFirstElement();
yamcsInstanceText.setText(forceString(conf.getInstance()));
yamcsUserText.setText(forceString(conf.getUser()));
yamcsPasswordText.setText(forceString(conf.getPassword()));
savePasswordButton.setSelection(conf.isSavePassword());
yamcsPrimaryHostText.setText(forceString(conf.getPrimaryHost()));
yamcsPrimaryPortText.setText(forceString(conf.getPrimaryPort()));
yamcsFailoverHostText.setText(forceString(conf.getFailoverHost()));
yamcsFailoverPortText.setText(forceString(conf.getFailoverPort()));
nameText.setText(forceString(conf.getName()));
updateState();
}
});
connViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
YamcsConfiguration c1 = (YamcsConfiguration) o1;
YamcsConfiguration c2 = (YamcsConfiguration) o2;
if (c1.getName() != null && c2.getName() != null)
return c1.getName().compareTo(c2.getName());
else
return 0;
}
});
return serverPanel;
}
use of org.eclipse.jface.viewers.ViewerComparator in project webtools.sourceediting by eclipse.
the class XMLSyntaxColoringPage method createStylesViewer.
/**
* Creates the List viewer where we see the various syntax element display
* names--would it ever be a Tree like JDT's?
*
* @param parent
* @return
*/
private StructuredViewer createStylesViewer(Composite parent) {
StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
stylesViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
Object description = fStyleToDescriptionMap.get(element);
if (description != null)
return description.toString();
return super.getText(element);
}
});
stylesViewer.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return getStylePreferenceKeys().toArray();
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return getStylePreferenceKeys();
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
return stylesViewer;
}
use of org.eclipse.jface.viewers.ViewerComparator in project webtools.sourceediting by eclipse.
the class DTDSyntaxColoringPage method createStylesViewer.
/**
* Creates the List viewer where we see the various syntax element display
* names--would it ever be a Tree like JDT's?
*
* @param parent
* @return
*/
private StructuredViewer createStylesViewer(Composite parent) {
StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
stylesViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
Object description = fStyleToDescriptionMap.get(element);
if (description != null)
return description.toString();
return super.getText(element);
}
});
stylesViewer.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return getStylePreferenceKeys().toArray();
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return getStylePreferenceKeys();
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
return stylesViewer;
}
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 CSSSyntaxColoringPage method createStylesViewer.
/**
* Creates the List viewer where we see the various syntax element display
* names--would it ever be a Tree like JDT's?
*
* @param parent
* @return
*/
private StructuredViewer createStylesViewer(Composite parent) {
StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
stylesViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
Object description = fStyleToDescriptionMap.get(element);
if (description != null)
return description.toString();
return super.getText(element);
}
});
stylesViewer.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return getStylePreferenceKeys().toArray();
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return getStylePreferenceKeys();
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
return stylesViewer;
}
Aggregations