Search in sources :

Example 21 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project InformationSystem by ObeoNetwork.

the class ExportProjectAsLibraryProjectSelectionPage method createControl.

/**
 * Create contents of the wizard.
 * @param parent
 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(3, false));
    Label lblModelingProject = new Label(container, SWT.NONE);
    lblModelingProject.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    lblModelingProject.setText("Modeling project");
    listViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL);
    List list = listViewer.getList();
    list.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setPageComplete(isInfoComplete());
        }
    });
    GridData gd_list = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    gd_list.heightHint = 176;
    list.setLayoutData(gd_list);
    Label lblExportToFile = new Label(container, SWT.NONE);
    lblExportToFile.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblExportToFile.setText("Export to MAR file");
    txtMarFile = new Text(container, SWT.BORDER);
    txtMarFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Button btnBrowse = new Button(container, SWT.NONE);
    btnBrowse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dlg = new FileDialog(getShell());
            dlg.setFileName(txtMarFile.getText());
            dlg.setOverwrite(true);
            dlg.setFilterExtensions(new String[] { "*.mar", "*.*" });
            dlg.setFilterNames(new String[] { "MAR files (*.mar)", "All files (*.*)" });
            String exportFile = dlg.open();
            if (exportFile != null) {
                txtMarFile.setText(exportFile);
                setPageComplete(isInfoComplete());
            }
        }
    });
    btnBrowse.setText("Browse...");
    m_bindingContext = initDataBindings();
    setPageComplete(isInfoComplete());
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IObservableList(org.eclipse.core.databinding.observable.list.IObservableList) List(org.eclipse.swt.widgets.List) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 22 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project gemoc-studio by eclipse.

the class FsmEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            selectionViewer = (TreeViewer) viewerPane.getViewer();
            selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            selectionViewer.setInput(editingDomain.getResourceSet());
            selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
            viewerPane.setTitle(editingDomain.getResourceSet());
            new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
            createContextMenuFor(selectionViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        }
        // Create a page for the parent tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            parentViewer = (TreeViewer) viewerPane.getViewer();
            parentViewer.setAutoExpandLevel(30);
            parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
            parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(parentViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ParentPage_label"));
        }
        // This is the page for the list viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new ListViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            listViewer = (ListViewer) viewerPane.getViewer();
            listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(listViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ListPage_label"));
        }
        // This is the page for the tree viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewer = (TreeViewer) viewerPane.getViewer();
            treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
            createContextMenuFor(treeViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreePage_label"));
        }
        // This is the page for the table viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TableViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            tableViewer = (TableViewer) viewerPane.getViewer();
            Table table = tableViewer.getTable();
            TableLayout layout = new TableLayout();
            table.setLayout(layout);
            table.setHeaderVisible(true);
            table.setLinesVisible(true);
            TableColumn objectColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(3, 100, true));
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            TableColumn selfColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(2, 100, true));
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            tableViewer.setColumnProperties(new String[] { "a", "b" });
            tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(tableViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TablePage_label"));
        }
        // This is the page for the table tree viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), FsmEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();
            Tree tree = treeViewerWithColumns.getTree();
            tree.setLayoutData(new FillLayout());
            tree.setHeaderVisible(true);
            tree.setLinesVisible(true);
            TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            objectColumn.setWidth(250);
            TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            selfColumn.setWidth(200);
            treeViewerWithColumns.setColumnProperties(new String[] { "a", "b" });
            treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(treeViewerWithColumns);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
        }
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ListViewer(org.eclipse.jface.viewers.ListViewer) AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ViewerPane(org.eclipse.emf.common.ui.ViewerPane) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 23 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project gemoc-studio by eclipse.

the class GexpressionsEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            selectionViewer = (TreeViewer) viewerPane.getViewer();
            selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            selectionViewer.setInput(editingDomain.getResourceSet());
            selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
            viewerPane.setTitle(editingDomain.getResourceSet());
            new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
            createContextMenuFor(selectionViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        }
        // Create a page for the parent tree view.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    Tree tree = new Tree(composite, SWT.MULTI);
                    TreeViewer newTreeViewer = new TreeViewer(tree);
                    return newTreeViewer;
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            parentViewer = (TreeViewer) viewerPane.getViewer();
            parentViewer.setAutoExpandLevel(30);
            parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
            parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(parentViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ParentPage_label"));
        }
        // This is the page for the list viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new ListViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            listViewer = (ListViewer) viewerPane.getViewer();
            listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(listViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_ListPage_label"));
        }
        // This is the page for the tree viewer
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewer = (TreeViewer) viewerPane.getViewer();
            treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
            createContextMenuFor(treeViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreePage_label"));
        }
        // This is the page for the table viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TableViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            tableViewer = (TableViewer) viewerPane.getViewer();
            Table table = tableViewer.getTable();
            TableLayout layout = new TableLayout();
            table.setLayout(layout);
            table.setHeaderVisible(true);
            table.setLinesVisible(true);
            TableColumn objectColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(3, 100, true));
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            TableColumn selfColumn = new TableColumn(table, SWT.NONE);
            layout.addColumnData(new ColumnWeightData(2, 100, true));
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            tableViewer.setColumnProperties(new String[] { "a", "b" });
            tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(tableViewer);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TablePage_label"));
        }
        // This is the page for the table tree viewer.
        // 
        {
            ViewerPane viewerPane = new ViewerPane(getSite().getPage(), GexpressionsEditor.this) {

                @Override
                public Viewer createViewer(Composite composite) {
                    return new TreeViewer(composite);
                }

                @Override
                public void requestActivation() {
                    super.requestActivation();
                    setCurrentViewerPane(this);
                }
            };
            viewerPane.createControl(getContainer());
            treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();
            Tree tree = treeViewerWithColumns.getTree();
            tree.setLayoutData(new FillLayout());
            tree.setHeaderVisible(true);
            tree.setLinesVisible(true);
            TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
            objectColumn.setText(getString("_UI_ObjectColumn_label"));
            objectColumn.setResizable(true);
            objectColumn.setWidth(250);
            TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
            selfColumn.setText(getString("_UI_SelfColumn_label"));
            selfColumn.setResizable(true);
            selfColumn.setWidth(200);
            treeViewerWithColumns.setColumnProperties(new String[] { "a", "b" });
            treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
            treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
            createContextMenuFor(treeViewerWithColumns);
            int pageIndex = addPage(viewerPane.getControl());
            setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
        }
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ListViewer(org.eclipse.jface.viewers.ListViewer) AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ViewerPane(org.eclipse.emf.common.ui.ViewerPane) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) FillLayout(org.eclipse.swt.layout.FillLayout) TableColumn(org.eclipse.swt.widgets.TableColumn) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 24 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project mdw-designer by CenturyLinkCloud.

the class ListComposer method createControls.

protected void createControls() {
    int buttonWidth = 30;
    // create the listener for the bunch of buttons
    SelectionListener buttonListener = new ButtonListener();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = isReadOnly() ? 2 : 3;
    gridLayout.marginWidth = 0;
    gridLayout.marginTop = 0;
    this.setLayout(gridLayout);
    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    if (!isReadOnly()) {
        Label srcLabelWidget = new Label(this, SWT.LEFT);
        srcLabelWidget.setLayoutData(gd);
        if (unselectedTitle != null)
            srcLabelWidget.setText(unselectedTitle);
        else
            srcLabelWidget.setText(isReadOnly() ? "" : "Unselected " + title);
        gd = new GridData();
        Label destLabelWidget = new Label(this, SWT.LEFT);
        destLabelWidget.setLayoutData(gd);
        if (selectedTitle != null)
            destLabelWidget.setText(selectedTitle);
        else
            destLabelWidget.setText("Selected " + title);
    }
    gd = new GridData(SWT.LEFT | GridData.FILL_BOTH);
    gd.widthHint = getWidth();
    srcViewer = new ListViewer(this);
    srcViewer.getList().setLayoutData(gd);
    srcViewer.setContentProvider(new IStructuredContentProvider() {

        @SuppressWarnings("unchecked")
        public Object[] getElements(Object inputElement) {
            return ((List<String>) inputElement).toArray();
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    srcViewer.addFilter(new Filter());
    if (!isReadOnly()) {
        Composite buttons = new Composite(this, SWT.NULL);
        buttons.setLayout(new RowLayout(SWT.VERTICAL));
        addButton = new Button(buttons, SWT.PUSH);
        addButton.setText(">");
        Point size = addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        RowData rd = new RowData(buttonWidth, size.y);
        addButton.setLayoutData(rd);
        addButton.addSelectionListener(buttonListener);
        remButton = new Button(buttons, SWT.PUSH);
        remButton.setText("<");
        size = remButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        rd = new RowData(buttonWidth, size.y);
        remButton.setLayoutData(rd);
        remButton.addSelectionListener(buttonListener);
        gd = new GridData(SWT.LEFT | GridData.FILL_BOTH);
        gd.widthHint = getWidth();
        destViewer = new ListViewer(this);
        destViewer.getList().setLayoutData(gd);
    }
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) ListViewer(org.eclipse.jface.viewers.ListViewer) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 25 with ListViewer

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

the class HTMLSyntaxColoringPage 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

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