Search in sources :

Example 1 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project tdi-studio-se by Talend.

the class VersionSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    composite = getWidgetFactory().createFlatFormComposite(parent);
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { //$NON-NLS-1$
    Messages.getString("VersionSection.Version"), //$NON-NLS-1$
    Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$ 
    Messages.getString("VersionSection.Status") };
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column3.setText(columnProperties[2]);
    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column4.setText(columnProperties[3]);
    tableViewer.setColumnProperties(columnProperties);
    Object layoutData = parent.getLayoutData();
    if (layoutData instanceof GridData) {
        GridData gridData = (GridData) layoutData;
        gridData.grabExcessVerticalSpace = true;
        gridData.verticalAlignment = SWT.FILL;
    }
    FormData formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.top = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.bottom = new FormAttachment(100);
    table.setLayoutData(formData);
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
            if (repositoryObject.getProperty() == null) {
                return null;
            }
            RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
            try {
                List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
                Collections.sort(allVersion, new IRepositoryObjectComparator());
                Object[] objects = new Object[allVersion.size()];
                for (int i = 0; i < objects.length; i++) {
                    IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
                    RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
                    objects[i] = repositoryNode;
                }
                return objects;
            } catch (PersistenceException e) {
                return null;
            }
        }

        private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
            RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
            repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
            repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
            return repositoryNode;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    tableViewer.setLabelProvider(new ITableLabelProvider() {

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

        public String getColumnText(Object element, int columnIndex) {
            RepositoryNode repositoryNode = (RepositoryNode) element;
            switch(columnIndex) {
                case 0:
                    return repositoryNode.getObject().getVersion();
                case 1:
                    if (repositoryNode.getObject().getCreationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getCreationDate());
                    } else {
                        return null;
                    }
                case 2:
                    if (repositoryNode.getObject().getModificationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getModificationDate());
                    } else {
                        return null;
                    }
                case 3:
                    if (repositoryNode.getObject().getStatusCode() != null) {
                        return repositoryNode.getObject().getStatusCode();
                    } else {
                        return null;
                    }
                default:
                    return null;
            }
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager mgr) {
            ISelection selection = tableViewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                for (ITreeContextualAction action : contextualsActions) {
                    if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                        action.init(null, structuredSelection);
                        if (action.isVisible()) {
                            mgr.add(action);
                        }
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
    Listener sortListener = new Listener() {

        private int direction = 1;

        public void handleEvent(Event e) {
            final TableColumn column = (TableColumn) e.widget;
            if (column == table.getSortColumn()) {
                direction = -direction;
            }
            if (direction == 1) {
                table.setSortDirection(SWT.DOWN);
            } else {
                table.setSortDirection(SWT.UP);
            }
            table.setSortColumn(column);
            tableViewer.setSorter(new ViewerSorter() {

                int index = 0;

                @Override
                public void sort(Viewer viewer, Object[] elements) {
                    while (index < table.getColumns().length && table.getColumn(index) != column) {
                        index++;
                    }
                    super.sort(viewer, elements);
                }

                @Override
                public int compare(Viewer viewer, Object e1, Object e2) {
                    ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
                    String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
                    "";
                    String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
                    "";
                    return getComparator().compare(columnText, columnText2) * direction;
                }
            });
        }
    };
    column1.addListener(SWT.Selection, sortListener);
    column2.addListener(SWT.Selection, sortListener);
    column3.addListener(SWT.Selection, sortListener);
    column4.addListener(SWT.Selection, sortListener);
    table.setSortColumn(column1);
    table.setSortDirection(SWT.DOWN);
    aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Image(org.eclipse.swt.graphics.Image) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) TableLayout(org.eclipse.jface.viewers.TableLayout) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) Table(org.eclipse.swt.widgets.Table) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) RepositoryNode(org.talend.repository.model.RepositoryNode) TableColumn(org.eclipse.swt.widgets.TableColumn) IMenuListener(org.eclipse.jface.action.IMenuListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Event(org.eclipse.swt.widgets.Event) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IMenuManager(org.eclipse.jface.action.IMenuManager) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project tdi-studio-se by Talend.

the class BusinessAssignmentComposite method createControls.

public void createControls(Composite parent) {
    composite = widgetFactory.createFlatFormComposite(parent);
    adapterFactory = new BusinessItemProviderAdapterFactory();
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
    Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Messages.getString("AssignmentPropertySection.Comment") };
    TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column3.setText(columnProperties[2]);
    tableViewer.setColumnProperties(columnProperties);
    final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
    tableViewer.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(Object element, String property) {
            return property.equals(columnProperties[2]);
        }

        @Override
        public Object getValue(Object element, String property) {
            return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
        }

        @Override
        public void modify(Object element, String property, Object value) {
            if (element instanceof TableItem) {
                TableItem tableItem = (TableItem) element;
                itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
            }
        }
    });
    CellEditor[] cellEditors = new CellEditor[3];
    cellEditors[2] = new TextCellEditor(table);
    tableViewer.setCellEditors(cellEditors);
    // createKeyListener(table);
    createSelectionListener();
    createPopupMenu();
    createDoubleClickListener();
    handleLayout(parent, table, column1, column2, column3);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.eclipse.swt.widgets.Table) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) RepositoryFactoryProxyLabelProvider(org.talend.designer.business.diagram.custom.properties.RepositoryFactoryProxyLabelProvider) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) ICellModifier(org.eclipse.jface.viewers.ICellModifier) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IItemPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 3 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project cubrid-manager by CUBRID.

the class BatchRunComposite method createTableGroup.

private void createTableGroup(Composite composite) {
    final String[] columnNames = new String[] { "", com.cubrid.common.ui.query.Messages.msgBatchRunSqlFile, com.cubrid.common.ui.query.Messages.msgBatchRunMemo, com.cubrid.common.ui.query.Messages.msgBatchRunRegdate };
    tv = (CheckboxTableViewer) CommonUITool.createCheckBoxTableViewer(composite, null, columnNames, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    tv.setInput(listData);
    TableLayout tableLayout = new TableLayout();
    tv.getTable().setLayout(tableLayout);
    tableLayout.addColumnData(new ColumnPixelData(30));
    tableLayout.addColumnData(new ColumnPixelData(209));
    tableLayout.addColumnData(new ColumnPixelData(272));
    tableLayout.addColumnData(new ColumnPixelData(118));
    editor = new TableEditor(tv.getTable());
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    tv.getTable().addListener(SWT.MouseUp, new Listener() {

        public void handleEvent(Event event) {
            if (event.button != 1) {
                return;
            }
            validateCheck();
            Point pt = new Point(event.x, event.y);
            int newIndex = tv.getTable().getSelectionIndex();
            if (tv.getTable().getItemCount() <= newIndex || newIndex < 0) {
                return;
            }
            final TableItem item = tv.getTable().getItem(newIndex);
            if (item == null) {
                return;
            }
            Rectangle rect = item.getBounds(2);
            if (rect.contains(pt)) {
                focusCell(item, newIndex, 2);
            }
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) TraverseListener(org.eclipse.swt.events.TraverseListener) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) TraverseEvent(org.eclipse.swt.events.TraverseEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) TableLayout(org.eclipse.jface.viewers.TableLayout) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 4 with ColumnPixelData

use of org.eclipse.jface.viewers.ColumnPixelData in project cubrid-manager by CUBRID.

the class SqlmapNavigatorView method createCondView.

/**
	 * Create the main view.
	 *
	 * @param parent {@link Composite} the parent composite
	 */
private void createCondView(Composite parent) {
    String[] columnNames = { Messages.lblSqlmapUse, Messages.lblSqlmapCondition };
    Label lblCondTitle = new Label(parent, SWT.NONE);
    lblCondTitle.setText(Messages.lblSqlmapConditions);
    condView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 80));
    condView.setColumnProperties(columnNames);
    condView.setContentProvider(new TableContentProvider());
    condView.setLabelProvider(new SqlmapLabelProvider(this));
    condView.setCellModifier(new SqlmapCellModifier(this));
    CellEditor[] cellEditor = new CellEditor[columnNames.length];
    cellEditor[0] = new CheckboxCellEditor(condView.getTable());
    condView.setCellEditors(cellEditor);
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(30));
    tableLayout.addColumnData(new ColumnPixelData(160));
    condView.getTable().setLayout(tableLayout);
    condView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == ' ') {
                toggleUsedBySelectedCondition();
            }
            super.keyPressed(e);
        }
    });
}
Also used : CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) KeyEvent(org.eclipse.swt.events.KeyEvent) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 5 with ColumnPixelData

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

the class UserPropertiesSection method createTableControl.

private void createTableControl(Composite parent) {
    // Table Composite
    Composite tableComp = createTableComposite(parent, SWT.NULL);
    TableColumnLayout tableLayout = (TableColumnLayout) tableComp.getLayout();
    // Table Viewer
    fTableViewer = new TableViewer(tableComp, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    fTableViewer.getTable().setHeaderVisible(true);
    fTableViewer.getTable().setLinesVisible(true);
    addDragSupport();
    addDropSupport();
    // Help ID on table
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fTableViewer.getTable(), HELP_ID);
    // Columns
    TableViewerColumn columnBlank = new TableViewerColumn(fTableViewer, SWT.NONE, 0);
    tableLayout.setColumnData(columnBlank.getColumn(), new ColumnPixelData(24, false));
    TableViewerColumn columnKey = new TableViewerColumn(fTableViewer, SWT.NONE, 1);
    columnKey.getColumn().setText(Messages.UserPropertiesSection_0);
    tableLayout.setColumnData(columnKey.getColumn(), new ColumnWeightData(20, true));
    columnKey.setEditingSupport(new KeyEditingSupport(fTableViewer));
    // Click on Key Table Header
    columnKey.getColumn().addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            sortKeys();
        }
    });
    TableViewerColumn columnValue = new TableViewerColumn(fTableViewer, SWT.NONE, 2);
    columnValue.getColumn().setText(Messages.UserPropertiesSection_1);
    tableLayout.setColumnData(columnValue.getColumn(), new ColumnWeightData(80, true));
    columnValue.setEditingSupport(new ValueEditingSupport(fTableViewer));
    // Content Provider
    fTableViewer.setContentProvider(new IStructuredContentProvider() {

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

        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            return ((IProperties) inputElement).getProperties().toArray();
        }
    });
    // Label Provider
    fTableViewer.setLabelProvider(new LabelCellProvider());
    // Toolbar
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.VERTICAL);
    GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).applyTo(toolBar);
    ToolBarManager toolBarmanager = new ToolBarManager(toolBar);
    // New Property
    fActionNewProperty = new Action(Messages.UserPropertiesSection_2) {

        @Override
        public void run() {
            if (isAlive(fPropertiesElement)) {
                int index = -1;
                IProperty selected = (IProperty) ((IStructuredSelection) fTableViewer.getSelection()).getFirstElement();
                if (selected != null) {
                    index = fPropertiesElement.getProperties().indexOf(selected) + 1;
                }
                IProperty property = IArchimateFactory.eINSTANCE.createProperty();
                executeCommand(new NewPropertyCommand(fPropertiesElement.getProperties(), property, index));
                fTableViewer.editElement(property, 1);
            }
        }

        @Override
        public String getToolTipText() {
            return getText();
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_PLUS);
        }
    };
    // New Multiple Properties
    fActionNewMultipleProperty = new Action(Messages.UserPropertiesSection_3) {

        @Override
        public void run() {
            if (isAlive(fPropertiesElement)) {
                MultipleAddDialog dialog = new MultipleAddDialog(fPage.getSite().getShell());
                if (dialog.open() == Window.OK) {
                    executeCommand(dialog.getCommand());
                }
            }
        }

        @Override
        public String getToolTipText() {
            return getText();
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_MUTIPLE);
        }
    };
    // Remove Property
    fActionRemoveProperty = new Action(Messages.UserPropertiesSection_4) {

        @Override
        public void run() {
            if (isAlive(fPropertiesElement)) {
                CompoundCommand compoundCmd = new EObjectNonNotifyingCompoundCommand(fPropertiesElement) {

                    @Override
                    public String getLabel() {
                        return getCommands().size() > 1 ? Messages.UserPropertiesSection_5 : Messages.UserPropertiesSection_6;
                    }
                };
                for (Object o : ((IStructuredSelection) fTableViewer.getSelection()).toList()) {
                    Command cmd = new RemovePropertyCommand(fPropertiesElement.getProperties(), (IProperty) o);
                    compoundCmd.add(cmd);
                }
                executeCommand(compoundCmd);
            }
        }

        @Override
        public String getToolTipText() {
            return getText();
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_SMALL_X);
        }
    };
    fActionRemoveProperty.setEnabled(false);
    // Manage
    fActionShowKeyEditor = new Action(Messages.UserPropertiesSection_7) {

        @Override
        public void run() {
            if (isAlive(fPropertiesElement)) {
                UserPropertiesManagerDialog dialog = new UserPropertiesManagerDialog(fPage.getSite().getShell(), getArchimateModel());
                dialog.open();
            }
        }

        @Override
        public String getToolTipText() {
            return getText();
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
            return IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.ICON_COG);
        }
    };
    toolBarmanager.add(fActionNewProperty);
    toolBarmanager.add(fActionNewMultipleProperty);
    toolBarmanager.add(fActionRemoveProperty);
    toolBarmanager.add(fActionShowKeyEditor);
    toolBarmanager.update(true);
    /*
         * Selection Listener
         */
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            fActionRemoveProperty.setEnabled(!event.getSelection().isEmpty());
        }
    });
    /*
         * Table Double-click on cell
         */
    fTableViewer.getTable().addListener(SWT.MouseDoubleClick, new Listener() {

        @Override
        public void handleEvent(Event event) {
            // Get Table item
            TableItem item = fTableViewer.getTable().getItem(new Point(event.x, event.y));
            // Double-click into empty table creates new Property
            if (item == null) {
                fActionNewProperty.run();
            } else // Handle selected item property double-clicked
            {
                if (item.getData() instanceof IProperty) {
                    handleDoubleClick((IProperty) item.getData());
                }
            }
        }
    });
    hookContextMenu();
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) EObjectNonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.EObjectNonNotifyingCompoundCommand) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IMenuListener(org.eclipse.jface.action.IMenuListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Listener(org.eclipse.swt.widgets.Listener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) TableItem(org.eclipse.swt.widgets.TableItem) TableViewer(org.eclipse.jface.viewers.TableViewer) ColumnViewer(org.eclipse.jface.viewers.ColumnViewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IProperties(com.archimatetool.model.IProperties) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ToolBarManager(org.eclipse.jface.action.ToolBarManager) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectNonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.EObjectNonNotifyingCompoundCommand) UpdatingTableColumnLayout(com.archimatetool.editor.ui.components.UpdatingTableColumnLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IProperty(com.archimatetool.model.IProperty) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Point(org.eclipse.swt.graphics.Point) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) EObjectFeatureCommand(com.archimatetool.editor.model.commands.EObjectFeatureCommand) Command(org.eclipse.gef.commands.Command) EObjectNonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.EObjectNonNotifyingCompoundCommand) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ToolBar(org.eclipse.swt.widgets.ToolBar) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) EObject(org.eclipse.emf.ecore.EObject) TableViewer(org.eclipse.jface.viewers.TableViewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer)

Aggregations

ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)46 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)21 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)17 TableLayout (org.eclipse.jface.viewers.TableLayout)16 Composite (org.eclipse.swt.widgets.Composite)16 TableViewer (org.eclipse.jface.viewers.TableViewer)15 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)14 Image (org.eclipse.swt.graphics.Image)13 GridData (org.eclipse.swt.layout.GridData)13 TableColumn (org.eclipse.swt.widgets.TableColumn)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Point (org.eclipse.swt.graphics.Point)9 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)8 Table (org.eclipse.swt.widgets.Table)8 Viewer (org.eclipse.jface.viewers.Viewer)7 ArrayList (java.util.ArrayList)6 TreeColumnLayout (org.eclipse.jface.layout.TreeColumnLayout)6 GridLayout (org.eclipse.swt.layout.GridLayout)6