Search in sources :

Example 96 with IStructuredSelection

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

the class GefEditorLabelProvider method getImage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
public Image getImage(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
        return null;
    }
    if (!(objects instanceof IStructuredSelection)) {
        return null;
    }
    final boolean[] multiple = { false };
    Object object = getObject(objects, multiple);
    if (object == null) {
        return null;
    }
    if ((object instanceof NodeTreeEditPart)) {
        node = (Node) ((NodeTreeEditPart) object).getModel();
    } else {
        if (object instanceof NodeReturnsTreeEditPart) {
            node = lastNode;
        } else {
            if (object instanceof ProcessPart) {
                return ImageProvider.getImage(ECoreImage.PROCESS_ICON);
            }
            if (object instanceof ConnectionPart) {
                return ImageProvider.getImage(EImage.RIGHT_ICON);
            }
            if (object instanceof NoteEditPart) {
                return ImageProvider.getImage(ECoreImage.CODE_ICON);
            }
            if (object instanceof ConnLabelEditPart) {
                return ImageProvider.getImage(EImage.RIGHT_ICON);
            }
            if ((object instanceof NodeLabelEditPart)) {
                node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
            }
            if (!(object instanceof NodePart)) {
                return null;
            }
            if (node == null) {
                node = (Node) ((NodePart) object).getModel();
            }
        }
    }
    if (lastNode != node) {
        lastNode = node;
    }
    return CoreImageProvider.getComponentIcon(node.getComponent(), ICON_SIZE.ICON_24);
}
Also used : NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 97 with IStructuredSelection

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

the class GefEditorLabelProvider method getText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
     */
public String getText(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
        //$NON-NLS-1$
        return "No items selected";
    }
    if (!(objects instanceof IStructuredSelection)) {
        return null;
    }
    final boolean[] multiple = { false };
    Object object = getObject(objects, multiple);
    if (object == null) /* || ((IStructuredSelection) objects).size() > 1 */
    {
        //$NON-NLS-1$
        return "No items selected";
    } else {
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nContainer = (NodeContainerPart) object;
            Process process = (Process) nContainer.getParent().getModel();
            return process.getName();
        } else if (object instanceof ProcessPart) {
            Process process = (Process) ((ProcessPart) object).getModel();
            return process.getLabel();
        } else if (object instanceof ProcessTreeEditPart) {
            Process process = (Process) ((ProcessTreeEditPart) object).getModel();
            return process.getName();
        }
        if (object instanceof ConnectionPart) {
            Connection conn = (Connection) ((ConnectionPart) object).getModel();
            return conn.getName();
        }
        if (object instanceof NoteEditPart) {
            return Note.class.getSimpleName();
        }
        if (object instanceof ConnLabelEditPart) {
            Connection conn = (Connection) ((ConnectionLabel) ((ConnLabelEditPart) object).getModel()).getConnection();
            return conn.getName();
        }
        if (object instanceof NodeTreeEditPart) {
            node = (Node) ((NodeTreeEditPart) object).getModel();
        } else {
            if (object instanceof NodeReturnsTreeEditPart) {
                node = lastNode;
            } else {
                if (object instanceof NodeLabelEditPart) {
                    node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
                }
                if (!(object instanceof NodePart)) {
                    return null;
                }
                if (node == null) {
                    node = (Node) ((NodePart) object).getModel();
                }
            }
        }
        if (lastNode != node) {
            lastNode = node;
        }
        String name = node.getUniqueName();
        // }
        return name;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ProcessTreeEditPart(org.talend.designer.core.ui.editor.outline.ProcessTreeEditPart) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 98 with IStructuredSelection

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

the class HL7MultiSchemaUI method updateCurrentMetadataTable.

private void updateCurrentMetadataTable() {
    IStructuredSelection selection = (IStructuredSelection) metaTableViewer.getSelection();
    Object selectedObj = selection.getFirstElement();
    if (selectedObj != null) {
        String key = ((IModel) selectedObj).getDisplayName();
        Map m = hl7Manager.getSchemaRelationMap();
        List<MetadataColumn> beans = (List<MetadataColumn>) m.get(key);
        MetadataTable currentTable = getCurrentTable(key, beans);
        if (currentTable != null) {
            metadataEditor.setMetadataTable(currentTable);
            hl7SchemaEditorView.setExtendedTableModel(metadataEditor);
        } else {
            currentTable = ConnectionFactory.eINSTANCE.createMetadataTable();
            metadataEditor.setMetadataTable(currentTable);
        }
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IModel(org.talend.designer.hl7.model.IModel) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Map(java.util.Map)

Example 99 with IStructuredSelection

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

the class HotSpotsTabPage method createHotSpotsViewer.

/**
     * Creates the hot spots viewer.
     * 
     * @param composite The parent composite
     * @param propertySheet The property sheet
     */
private void createHotSpotsViewer(Composite composite, PropertySheet propertySheet) {
    filteredTree = new HotSpotsFilteredTree(composite, propertySheet.getViewSite().getActionBars()) {

        @Override
        protected void addMenus(IMenuManager manager) {
            manager.add(new Separator());
            manager.add(new ConfigureCpuProfilerAction(cpuSection));
        }
    };
    TreeViewer hotSpotsViewer = filteredTree.getViewer();
    hotSpotsViewer.setContentProvider(new AbstractContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICpuModel) {
                return ((ICpuModel) inputElement).getHotSpotRoots();
            }
            return new Object[0];
        }
    });
    hotSpotsViewer.setLabelProvider(new HotSpotsLabelProvider(filteredTree));
    hotSpotsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            filteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
    filteredTree.sortColumn(hotSpotsViewer.getTree().getColumn(1));
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel) ConfigureCpuProfilerAction(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.ConfigureCpuProfilerAction) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 100 with IStructuredSelection

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

the class CallerCalleeTabPage method createCalleeViewer.

/**
     * Creates the callee viewer.
     * 
     * @param parent The parent composite
     * @param propertySheet The property sheet
     */
private void createCalleeViewer(Composite parent, PropertySheet propertySheet) {
    calleeFilteredTree = new HotSpotsFilteredTree(parent, propertySheet.getViewSite().getActionBars()) {

        @Override
        protected void addMenus(IMenuManager manager) {
            manager.add(new Separator());
            manager.add(new ConfigureCpuProfilerAction(cpuSection));
        }

        @Override
        public ViewerType getViewerType() {
            return ViewerType.Callee;
        }

        @Override
        protected String getMethodColumnName() {
            return Messages.calleeColumnLabel;
        }

        @Override
        protected String getMethodColumnToolTip() {
            return Messages.calleeColumnToolTip;
        }
    };
    TreeViewer calleeViewer = calleeFilteredTree.getViewer();
    calleeViewer.setContentProvider(new AbstractContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICpuModel) {
                return ((ICpuModel) inputElement).getCallees();
            }
            return new Object[0];
        }
    });
    calleeViewer.setLabelProvider(new HotSpotsLabelProvider(calleeFilteredTree));
    calleeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            calleeFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
    calleeFilteredTree.sortColumn(calleeViewer.getTree().getColumn(1));
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel) ConfigureCpuProfilerAction(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.ConfigureCpuProfilerAction) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Aggregations

IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)416 ISelection (org.eclipse.jface.viewers.ISelection)135 ArrayList (java.util.ArrayList)72 GridData (org.eclipse.swt.layout.GridData)70 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)67 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)66 SelectionEvent (org.eclipse.swt.events.SelectionEvent)62 Composite (org.eclipse.swt.widgets.Composite)61 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)60 GridLayout (org.eclipse.swt.layout.GridLayout)57 List (java.util.List)50 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)45 TableViewer (org.eclipse.jface.viewers.TableViewer)41 RepositoryNode (org.talend.repository.model.RepositoryNode)41 Iterator (java.util.Iterator)39 IFile (org.eclipse.core.resources.IFile)35 Button (org.eclipse.swt.widgets.Button)35 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 Table (org.eclipse.swt.widgets.Table)30 Label (org.eclipse.swt.widgets.Label)29