Search in sources :

Example 61 with ViewerComparator

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;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TextUtils.forceString(org.yamcs.studio.core.ui.utils.TextUtils.forceString) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 62 with ViewerComparator

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;
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 63 with ViewerComparator

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;
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 64 with ViewerComparator

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);
}
Also used : ViewerComparator(org.eclipse.jface.viewers.ViewerComparator)

Example 65 with ViewerComparator

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;
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)110 Viewer (org.eclipse.jface.viewers.Viewer)64 Composite (org.eclipse.swt.widgets.Composite)59 TableViewer (org.eclipse.jface.viewers.TableViewer)50 GridData (org.eclipse.swt.layout.GridData)50 GridLayout (org.eclipse.swt.layout.GridLayout)34 Label (org.eclipse.swt.widgets.Label)29 LabelProvider (org.eclipse.jface.viewers.LabelProvider)23 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)22 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)22 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)21 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)19 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)18 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)17 Button (org.eclipse.swt.widgets.Button)17 TreeViewer (org.eclipse.jface.viewers.TreeViewer)16 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)15 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)15