Search in sources :

Example 26 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project eclipse-integration-commons by spring-projects.

the class ChooseOneSection method createContents.

@Override
public void createContents(Composite page) {
    Composite composite = new Composite(page, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = (labelText == null || vertical) ? 1 : 2;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    // .hint(SWT.DEFAULT, 150);
    GridDataFactory grab = GridDataFactory.fillDefaults().grab(true, true);
    grab.applyTo(composite);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (labelText != null) {
        Label label = new Label(composite, SWT.NONE);
        label.setText(labelText);
        if (!vertical) {
            GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).hint(UIConstants.fieldLabelWidthHint(label), SWT.DEFAULT).applyTo(label);
        }
    }
    final ListViewer tv = new ListViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
    grab.applyTo(tv.getList());
    tv.setContentProvider(new ContentProvider());
    tv.setLabelProvider(new SimpleLabelProvider());
    tv.setInput(validChoices);
    chosen.addListener(new ValueListener<T>() {

        public void gotValue(LiveExpression<T> exp, T value) {
            if (value == null) {
                tv.setSelection(StructuredSelection.EMPTY);
            } else {
                tv.setSelection(new StructuredSelection(value));
            }
        }
    });
    if (DEBUG) {
        chosen.addListener(new ValueListener<T>() {

            public void gotValue(LiveExpression<T> exp, T value) {
                System.out.println("starter: " + value);
            }
        });
    }
    tv.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            chosen.setValue(getSingleSelection(tv));
        }
    });
    if (owner instanceof IPageWithOkButton) {
        tv.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                ((IPageWithOkButton) owner).clickOk();
            }
        });
    }
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) GridLayout(org.eclipse.swt.layout.GridLayout) SWT(org.eclipse.swt.SWT) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData)

Example 27 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project webtools.sourceediting by eclipse.

the class JSONSyntaxColoringPage 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 28 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project webtools.sourceediting by eclipse.

the class JSPSyntaxColoringPage 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 29 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project webtools.sourceediting by eclipse.

the class XSLSyntaxColoringPage 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() {

        @Override
        public String getText(Object element) {
            Object description = styleToDescriptionMap.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) 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 30 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project dbeaver by serge-rider.

the class ViewClasspathDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText(UIConnectionMessages.dialog_view_classpath_title);
    Composite group = (Composite) super.createDialogArea(parent);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 300;
    gd.widthHint = 400;
    group.setLayoutData(gd);
    {
        ListViewer libsTable = new ListViewer(group, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
        libsTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
        // $NON-NLS-1$
        String classPath = System.getProperty(StandardConstants.ENV_JAVA_CLASSPATH);
        // $NON-NLS-1$
        StringTokenizer st = new StringTokenizer(classPath, ";");
        while (st.hasMoreTokens()) {
            libsTable.getList().add(st.nextToken());
        }
    }
    return group;
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) StringTokenizer(java.util.StringTokenizer) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData)

Aggregations

ListViewer (org.eclipse.jface.viewers.ListViewer)69 Composite (org.eclipse.swt.widgets.Composite)49 Viewer (org.eclipse.jface.viewers.Viewer)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 GridData (org.eclipse.swt.layout.GridData)29 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)26 FillLayout (org.eclipse.swt.layout.FillLayout)26 TableViewer (org.eclipse.jface.viewers.TableViewer)23 TreeViewer (org.eclipse.jface.viewers.TreeViewer)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)21 Table (org.eclipse.swt.widgets.Table)21 Tree (org.eclipse.swt.widgets.Tree)21 ViewerPane (org.eclipse.emf.common.ui.ViewerPane)20 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)20 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)20 ControlAdapter (org.eclipse.swt.events.ControlAdapter)20 ControlEvent (org.eclipse.swt.events.ControlEvent)20 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)19