Search in sources :

Example 81 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project tbd-studio-se by Talend.

the class RelationshipTableView method createComboBoxCellEditor.

private ComboBoxViewerCellEditor createComboBoxCellEditor(Table table) {
    ComboBoxViewerCellEditor cellEditor = new ComboBoxViewerCellEditor(table);
    cellEditor.setContenProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object arg0) {
            return (String[]) arg0;
        }
    });
    cellEditor.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return (String) element;
        }
    });
    cellEditor.setInput(Relationship.Direction.getNames());
    cellEditor.setValue(Relationship.Direction.OUTGOING.getName());
    return cellEditor;
}
Also used : IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) Viewer(org.eclipse.jface.viewers.Viewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ComboBoxViewerCellEditor(org.eclipse.jface.viewers.ComboBoxViewerCellEditor)

Example 82 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.

the class RelationshipsMatrixDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.RelationshipsMatrixDialog_0);
    setMessage(Messages.RelationshipsMatrixDialog_1);
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite client = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridData gd;
    GridTableViewer viewer = new GridTableViewer(client);
    gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 800;
    gd.heightHint = 500;
    viewer.getControl().setLayoutData(gd);
    viewer.getGrid().setHeaderVisible(true);
    viewer.getGrid().setRowHeaderVisible(true);
    viewer.getGrid().setRowsResizeable(true);
    viewer.getGrid().setCellSelectionEnabled(true);
    // viewer.setColumnProperties(new String[] {"1", "2", "3"});
    viewer.setRowHeaderLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            cell.setText(ArchiLabelProvider.INSTANCE.getDefaultName((EClass) cell.getElement()));
            cell.setImage(ArchiLabelProvider.INSTANCE.getImage(cell.getElement()));
        }
    });
    GC gc = new GC(viewer.getGrid());
    // $NON-NLS-1$
    int columnWidth = gc.textExtent("acfginorstv").x + 8;
    gc.dispose();
    for (EClass eClass : getData()) {
        GridColumn column = new GridColumn(viewer.getGrid(), SWT.NONE);
        column.setWidth(columnWidth);
        column.setImage(ArchiLabelProvider.INSTANCE.getImage(eClass));
        column.setHeaderTooltip(ArchiLabelProvider.INSTANCE.getDefaultName(eClass));
    }
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return getData().toArray();
        }
    });
    viewer.setLabelProvider(new MyLabelProvider());
    // hookContextMenu(viewer);
    viewer.setInput(getData());
    // $NON-NLS-1$
    String text = "";
    for (Entry<EClass, Character> entry : RelationshipsMatrix.INSTANCE.getRelationshipsValueMap().entrySet()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        text += entry.getValue() + ": " + ArchiLabelProvider.INSTANCE.getDefaultName(entry.getKey()) + "\n";
    }
    Label label = new Label(client, SWT.NULL);
    label.setText(text);
    label.setLayoutData(new GridData(SWT.TOP, SWT.TOP, false, true));
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridTableViewer(org.eclipse.nebula.jface.gridviewer.GridTableViewer) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) GridTableViewer(org.eclipse.nebula.jface.gridviewer.GridTableViewer) ViewerCell(org.eclipse.jface.viewers.ViewerCell) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) EClass(org.eclipse.emf.ecore.EClass) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) GC(org.eclipse.swt.graphics.GC) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Example 83 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.

the class ConnectionsARMPreferencePage method createRelationsTable.

private CheckboxTableViewer createRelationsTable(Composite parent) {
    final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
    GridDataFactory.create(GridData.FILL_HORIZONTAL).hint(SWT.DEFAULT, 100).applyTo(viewer.getTable());
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ArchiLabelProvider.INSTANCE.getDefaultName((EClass) element);
        }

        @Override
        public Image getImage(Object element) {
            return ArchiLabelProvider.INSTANCE.getImage(element);
        }
    });
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return ConnectionPreferences.RELATION_KEYMAP.keySet().toArray();
        }
    });
    viewer.setCheckStateProvider(new ICheckStateProvider() {

        @Override
        public boolean isGrayed(Object element) {
            return false;
        }

        @Override
        public boolean isChecked(Object element) {
            int value = (Integer) viewer.getInput();
            return (value & ConnectionPreferences.RELATION_KEYMAP.get(element)) != 0;
        }
    });
    return viewer;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) ICheckStateProvider(org.eclipse.jface.viewers.ICheckStateProvider) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Image(org.eclipse.swt.graphics.Image) ArchiLabelProvider(com.archimatetool.editor.ui.ArchiLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 84 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.

the class DropinsPluginDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.DropinsPluginDialog_1);
    setMessage(Messages.DropinsPluginDialog_2);
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    container.setLayout(new GridLayout(1, false));
    Composite tableComp = new Composite(container, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    tableComp.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    tableComp.setLayoutData(gd);
    viewer = new TableViewer(tableComp, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    // Mac Silicon Item height
    UIUtils.fixMacSiliconItemHeight(viewer.getTable());
    viewer.getTable().setHeaderVisible(true);
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_3);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(8, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_4);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_5);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_6);
    column = new TableViewerColumn(viewer, SWT.NONE);
    layout.setColumnData(column.getColumn(), new ColumnWeightData(10, false));
    column.getColumn().setText(Messages.DropinsPluginDialog_14);
    DropinsPluginHandler handler = new DropinsPluginHandler();
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            try {
                return handler.getInstalledPlugins().toArray();
            } catch (IOException ex) {
                // $NON-NLS-1$
                Logger.logError("Error getting installed plug-in", ex);
            }
            return new Object[0];
        }
    });
    class LabelCellProvider extends LabelProvider implements ITableLabelProvider {

        @Override
        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        @Override
        public String getColumnText(Object element, int columnIndex) {
            if (element instanceof Bundle) {
                Bundle bundle = (Bundle) element;
                switch(columnIndex) {
                    case 0:
                        // $NON-NLS-1$
                        return bundle.getHeaders().get("Bundle-Name");
                    case 1:
                        return bundle.getVersion().toString();
                    case 2:
                        return bundle.getSymbolicName();
                    case 3:
                        // $NON-NLS-1$
                        return bundle.getHeaders().get("Bundle-Vendor");
                    case 4:
                        try {
                            File file = handler.getDropinsBundleFile(bundle);
                            return file == null ? Messages.DropinsPluginDialog_13 : file.getParentFile().getPath();
                        } catch (IOException ex) {
                            return Messages.DropinsPluginDialog_13;
                        }
                    default:
                        break;
                }
            }
            return element.toString();
        }
    }
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            Bundle b1 = (Bundle) e1;
            Bundle b2 = (Bundle) e2;
            // $NON-NLS-1$ //$NON-NLS-2$
            return b1.getHeaders().get("Bundle-Name").compareToIgnoreCase(b2.getHeaders().get("Bundle-Name"));
        }
    });
    viewer.setLabelProvider(new LabelCellProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            getButton(UNINSTALL).setEnabled(!event.getSelection().isEmpty());
        }
    });
    // anything will do //$NON-NLS-1$
    viewer.setInput("");
    return area;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) Bundle(org.osgi.framework.Bundle) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IOException(java.io.IOException) GridLayout(org.eclipse.swt.layout.GridLayout) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) File(java.io.File) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 85 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project archi by archimatetool.

the class AppearancePreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    Composite client = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = layout.marginHeight = 0;
    client.setLayout(layout);
    // Enable Theming
    fUseThemes = new Button(client, SWT.CHECK);
    fUseThemes.setText(Messages.AppearancePreferencePage_4);
    fUseThemes.setLayoutData(createHorizontalGridData(2));
    // Themes, if enabled
    if (themeEngine != null) {
        Label label = new Label(client, SWT.NULL);
        label.setText(Messages.AppearancePreferencePage_1);
        fThemeComboViewer = new ComboViewer(client, SWT.READ_ONLY);
        fThemeComboViewer.getCombo().setLayoutData(createHorizontalGridData(1));
        fThemeComboViewer.setContentProvider(new IStructuredContentProvider() {

            @Override
            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            }

            @Override
            public void dispose() {
            }

            @Override
            public Object[] getElements(Object inputElement) {
                return (Object[]) inputElement;
            }
        });
        fThemeComboViewer.setLabelProvider(new LabelProvider() {

            @Override
            public String getText(Object element) {
                return ((ITheme) element).getLabel();
            }
        });
        fThemeComboViewer.setComparator(new ViewerComparator());
    }
    // Use Round Tabs
    fUseRoundTabsButton = new Button(client, SWT.CHECK);
    fUseRoundTabsButton.setText(Messages.AppearancePreferencePage_3);
    fUseRoundTabsButton.setLayoutData(createHorizontalGridData(2));
    // Show Status Line
    fShowStatusLineButton = new Button(client, SWT.CHECK);
    fShowStatusLineButton.setText(Messages.AppearancePreferencePage_2);
    fShowStatusLineButton.setLayoutData(createHorizontalGridData(2));
    setValues();
    if (themeEngine != null) {
        fThemeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                ITheme theme = (ITheme) ((IStructuredSelection) fThemeComboViewer.getSelection()).getFirstElement();
                setTheme(theme, false);
            }
        });
    }
    return client;
}
Also used : ITheme(org.eclipse.e4.ui.css.swt.theme.ITheme) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)99 Viewer (org.eclipse.jface.viewers.Viewer)77 Composite (org.eclipse.swt.widgets.Composite)58 GridData (org.eclipse.swt.layout.GridData)54 TableViewer (org.eclipse.jface.viewers.TableViewer)45 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)43 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)42 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)40 GridLayout (org.eclipse.swt.layout.GridLayout)40 LabelProvider (org.eclipse.jface.viewers.LabelProvider)32 Image (org.eclipse.swt.graphics.Image)29 Button (org.eclipse.swt.widgets.Button)28 Label (org.eclipse.swt.widgets.Label)28 SelectionEvent (org.eclipse.swt.events.SelectionEvent)26 Table (org.eclipse.swt.widgets.Table)24 ArrayList (java.util.ArrayList)23 ComboViewer (org.eclipse.jface.viewers.ComboViewer)19 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)19 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)18 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)18