Search in sources :

Example 16 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method selectNode.

/**
     * DOC bqian Comment method "selectNode".
     * 
     * @param node
     */
public void selectNode(INode node) {
    GraphicalViewer viewer = designerEditor.getViewer();
    Object object = viewer.getRootEditPart().getChildren().get(0);
    if (object instanceof ProcessPart) {
        for (EditPart editPart : (List<EditPart>) ((ProcessPart) object).getChildren()) {
            if (editPart instanceof NodePart) {
                if (((NodePart) editPart).getModel().equals(node)) {
                    viewer.select(editPart);
                }
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 17 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project tdi-studio-se by Talend.

the class NodePart method setSelected.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#setSelected(int)
     */
@Override
@SuppressWarnings("unchecked")
public void setSelected(final int value) {
    if (value == SELECTED) {
        super.setSelected(SELECTED_PRIMARY);
    } else {
        super.setSelected(value);
    }
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (value == SELECTED_NONE) {
        ComponentSettingsView viewer = (ComponentSettingsView) page.findView(ComponentSettingsView.ID);
        if (viewer == null) {
            return;
        }
        ComponentSettingsView compSettings = viewer;
        compSettings.cleanDisplay();
        return;
    }
    IEditorPart activeEditor = page.getActiveEditor();
    if (activeEditor instanceof AbstractMultiPageTalendEditor) {
        GraphicalViewer designerViewer = ((AbstractMultiPageTalendEditor) activeEditor).getTalendEditor().getViewer();
        Control ctrl = designerViewer.getControl();
        String helpLink = (String) ((Node) getModel()).getPropertyValue(EParameterName.HELP.getName());
        String requiredHelpLink = ((Process) ((Node) getModel()).getProcess()).getBaseHelpLink() + ((Node) getModel()).getComponent().getName();
        if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
            //$NON-NLS-1$
            helpLink = ((Process) ((Node) getModel()).getProcess()).getBaseHelpLink() + ((Node) getModel()).getComponent().getName();
        }
        if (ctrl != null) {
            PlatformUI.getWorkbench().getHelpSystem().setHelp(ctrl, helpLink);
        }
        // This code was to update automatically the help view, to set the documentation of the selected component
        // remove for TDI-24396
        //            IViewPart view = page.findView("org.eclipse.help.ui.HelpView"); //$NON-NLS-1$
        // if (view != null) {
        // PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
        // }
        TalendSelectionManager selectionManager = (TalendSelectionManager) designerViewer.getSelectionManager();
        if (value == SELECTED || value == SELECTED_PRIMARY) {
            ComponentSettingsView viewer = (ComponentSettingsView) page.findView(ComponentSettingsView.ID);
            if (viewer == null) {
                return;
            }
            if (selectionManager.getSelectionType() == ETalendSelectionType.SINGLE) {
                ComponentSettingsView compSettings = viewer;
                compSettings.setElement((Node) getModel());
                if (((Node) getModel()).getComponent() instanceof DummyComponent) {
                    MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), //$NON-NLS-1$
                    Messages.getString("NodePart_warning"), //$NON-NLS-1$
                    Messages.getString("NodePart_componentNotLoaded"));
                    return;
                }
                CodeView.refreshCodeView((Node) getModel());
            } else if (!viewer.isCleaned() && selectionManager.getSelectionType() == ETalendSelectionType.MULTIPLE) {
                ComponentSettingsView compSettings = viewer;
                compSettings.cleanDisplay();
            } else if (isDrop()) {
                if (value == SELECTED || value == SELECTED_PRIMARY) {
                    ComponentSettingsView compSettings = viewer;
                    compSettings.setElement((Node) getModel());
                    if (((Node) getModel()).getComponent() instanceof DummyComponent) {
                        MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), //$NON-NLS-1$
                        Messages.getString("NodePart_warning"), //$NON-NLS-1$
                        Messages.getString("NodePart_componentNotLoaded"));
                        return;
                    }
                    CodeView.refreshCodeView((Node) getModel());
                }
            }
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) GraphicalViewer(org.eclipse.gef.GraphicalViewer) DummyComponent(org.talend.designer.core.model.components.DummyComponent) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView) TalendSelectionManager(org.talend.designer.core.ui.editor.TalendSelectionManager)

Example 18 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project tdi-studio-se by Talend.

the class ProcessLayoutEditPolicy method getConnectionAndEndCommands.

protected Command getConnectionAndEndCommands(CreateConnectionRequest request) {
    CompoundCommand cc = new CompoundCommand("CreateNodeCommand");
    ProcessPart processPart = (ProcessPart) this.getHost();
    final GraphicalViewer graphicalViewer = (GraphicalViewer) processPart.getViewer();
    final CommandStack commandStack = processPart.getViewer().getEditDomain().getCommandStack();
    final String categoryName = ComponentsFactoryProvider.getInstance().getComponentsHandler().extractComponentsCategory().getName();
    final IProcess2 process = (IProcess2) processPart.getModel();
    TalendEditorConnectionTargetAssist assist = new TalendEditorConnectionTargetAssist(categoryName, graphicalViewer, commandStack, process);
    char start = '*';
    assist.showComponentCreationAssist(start);
    ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
    if (assist.getComponentName() == null) {
        assist.releaseText();
        return cmd;
    }
    IComponent component = TalendEditorComponentCreationUtil.getComponentsInCategory(categoryName).get(assist.getComponentName());
    if (component == null) {
        assist.releaseText();
        return cmd;
    }
    assist.releaseText();
    Node newNode = new Node(component);
    NodeContainer nodeContainer = ((Process) newNode.getProcess()).loadNodeContainer(newNode, false);
    CreateNodeContainerCommand command = new CreateNodeContainerCommand((org.talend.designer.core.ui.editor.process.Process) newNode.getProcess(), nodeContainer, request.getLocation());
    cc.add(command);
    cmd.setTarget(newNode);
    cc.add(cmd);
    return cc;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) GraphicalViewer(org.eclipse.gef.GraphicalViewer) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) IProcess2(org.talend.core.model.process.IProcess2) TalendEditorConnectionTargetAssist(org.talend.designer.core.assist.TalendEditorConnectionTargetAssist)

Aggregations

GraphicalViewer (org.eclipse.gef.GraphicalViewer)18 ArrayList (java.util.ArrayList)11 List (java.util.List)10 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)10 EditPart (org.eclipse.gef.EditPart)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)7 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)6 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)5 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)5 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)5 Node (org.talend.designer.core.ui.editor.nodes.Node)5 IProcess (org.talend.core.model.process.IProcess)4 Process (org.talend.designer.core.ui.editor.process.Process)4 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)4 PlatformObject (org.eclipse.core.runtime.PlatformObject)3 IExternalNode (org.talend.core.model.process.IExternalNode)3 INode (org.talend.core.model.process.INode)3 Note (org.talend.designer.core.ui.editor.notes.Note)3 KeyHandler (org.eclipse.gef.KeyHandler)2