Search in sources :

Example 1 with NodePart

use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.

the class AbstractTalendEditor method getCommonKeyHandler.

/**
     * DOC qzhang Comment method "getCommonKeyHandler".
     * 
     * @return
     */
public KeyHandler getCommonKeyHandler() {
    if (sharedKeyHandler == null) {
        sharedKeyHandler = new KeyHandler();
        sharedKeyHandler.put(KeyStroke.getPressed(SWT.F1, 0), new Action() {

            @Override
            public void run() {
                ISelection selection = getGraphicalViewer().getSelection();
                if (selection != null) {
                    if (selection instanceof IStructuredSelection) {
                        Object input = ((IStructuredSelection) selection).getFirstElement();
                        Node node = null;
                        if (input instanceof NodeTreeEditPart) {
                            NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
                            node = (Node) nTreePart.getModel();
                        } else {
                            if (input instanceof NodePart) {
                                EditPart editPart = (EditPart) input;
                                node = (Node) editPart.getModel();
                            }
                        }
                        if (node != null) {
                            String helpLink = (String) node.getPropertyValue(EParameterName.HELP.getName());
                            String requiredHelpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
                            if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
                                helpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
                            }
                            PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
                        }
                    }
                }
            }
        });
        sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    // deactivate the F2 shortcut as it's not used anymore
    // sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
    // getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
    }
    return sharedKeyHandler;
}
Also used : ModifyConnectionOrderAction(org.talend.designer.core.ui.action.ModifyConnectionOrderAction) GEFDeleteAction(org.talend.designer.core.ui.action.GEFDeleteAction) GEFPasteAction(org.talend.designer.core.ui.action.GEFPasteAction) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) ToggleSubjobsAction(org.talend.designer.core.ui.action.ToggleSubjobsAction) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) ModifyOutputOrderAction(org.talend.designer.core.ui.action.ModifyOutputOrderAction) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ModifyMergeOrderAction(org.talend.designer.core.ui.action.ModifyMergeOrderAction) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) Action(org.eclipse.jface.action.Action) GEFRedoAction(org.talend.designer.core.ui.action.GEFRedoAction) GEFCopyAction(org.talend.designer.core.ui.action.GEFCopyAction) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) GEFUndoAction(org.talend.designer.core.ui.action.GEFUndoAction) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) ISelection(org.eclipse.jface.viewers.ISelection) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EventObject(java.util.EventObject) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) KeyHandler(org.eclipse.gef.KeyHandler)

Example 2 with NodePart

use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.

the class AbstractTalendEditor method setFocus.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.parts.GraphicalEditor#setFocus()
     */
@Override
public void setFocus() {
    IComponentSettingsView viewer = (IComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);
    if (viewer != null) {
        IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
        if (selection.size() == 1 && (selection.getFirstElement() instanceof NodePart || selection.getFirstElement() instanceof ConnectionPart || selection.getFirstElement() instanceof SubjobContainerPart || selection.getFirstElement() instanceof ConnLabelEditPart)) {
            viewer.setElement((Element) ((AbstractEditPart) selection.getFirstElement()).getModel());
        } else {
            viewer.cleanDisplay();
        }
    }
    JobSettings.switchToCurJobSettingsView();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
        ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
        if (testContainerService != null) {
            testContainerService.switchToCurTestContainerView();
        }
    }
    super.setFocus();
    if (!readOnly) {
        // When gain focus, check read-only to disable read-only mode if process has been restore while opened :
        // 1. Enabled/disabled components :
        // process.checkReadOnly();
        // 2. Set backgroung color :
        List children = getViewer().getRootEditPart().getChildren();
        if (!children.isEmpty()) {
            ProcessPart rep = (ProcessPart) children.get(0);
            rep.ajustReadOnly();
        }
    }
}
Also used : IComponentSettingsView(org.talend.core.views.IComponentSettingsView) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService)

Example 3 with NodePart

use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.

the class ShowComponentSettingViewerAction method canPerformAction.

/**
     * Test if the selected item is a node.
     * 
     * @return true / false
     */
private boolean canPerformAction() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (!(o instanceof NodePart)) {
            return false;
        }
        NodePart part = (NodePart) o;
        if (!(part.getModel() instanceof INode)) {
            return false;
        }
        node = (Node) part.getModel();
        EditPart parentPart = part.getParent();
        while (!(parentPart instanceof ProcessPart)) {
            parentPart = parentPart.getParent();
        }
        if (!(parentPart instanceof ProcessPart)) {
            return false;
        }
        process = (IProcess) ((ProcessPart) parentPart).getModel();
        //$NON-NLS-1$
        setText(Messages.getString("PropertiesContextAction.Properties"));
    }
    return true;
}
Also used : INode(org.talend.core.model.process.INode) EditPart(org.eclipse.gef.EditPart) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 4 with NodePart

use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.

the class NodeContainerLayoutEditPolicy method createChangeConstraintCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
     * java.lang.Object)
     */
@Override
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
    if (child instanceof NodeLabelEditPart) {
        boolean nodeSelected;
        // if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
        // nodeSelected = true;
        // } else {
        nodeSelected = false;
        // }
        MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
        return locationCommand;
    } else if (child instanceof NodePart) {
        if (((Node) child.getModel()).isReadOnly() && !((Node) child.getModel()).isForceReadOnly()) {
            return null;
        }
        MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
        return locationCommand;
    } else {
        return null;
    }
}
Also used : MoveNodeLabelCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand) MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 5 with NodePart

use of org.talend.designer.core.ui.editor.nodes.NodePart in project tdi-studio-se by Talend.

the class JobletUtil method cloneNode.

public Node cloneNode(Node node, IProcess process, Map<String, List<? extends IElementParameter>> paraMap, boolean lockByOther) {
    NodePart nodePart = new NodePart();
    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    boolean isInOut = false;
    if (service != null) {
        isInOut = service.isJobletInOutComponent(node);
    }
    Node cloneNode = new Node(node.getComponent(), (IProcess2) process, node.getUniqueName());
    nodePart.setModel(cloneNode);
    if (lockByOther) {
        cloneNode.setReadOnly(true);
    } else {
        cloneNode.setReadOnly(false);
    }
    cloneNode.setDummy(node.isDummy());
    cloneNode.setActivate(node.isActivate());
    List<? extends IElementParameter> elementParas = null;
    if (paraMap.containsKey(node.getUniqueName())) {
        elementParas = paraMap.get(node.getUniqueName());
    } else {
        elementParas = node.getElementParameters();
    }
    for (IElementParameter elementPara : elementParas) {
        if (elementPara.getName() != null && !elementPara.getName().equals("UNIQUE_NAME")) {
            IElementParameter cloneElement = cloneNode.getElementParameter(elementPara.getName());
            Object paValue = elementPara.getValue();
            if (paValue instanceof List) {
                List list = new ArrayList();
                list.addAll((List) paValue);
                cloneElement.setValue(list);
            } else {
                // TDI-25599
                cloneElement.setContextMode(elementPara.isContextMode());
                cloneElement.setValue(elementPara.getValue());
            }
            if (lockByOther) {
                cloneElement.setReadOnly(true);
            } else {
                cloneElement.setReadOnly(elementPara.isReadOnly());
            }
            if (elementPara.getChildParameters() != null) {
                Map<String, IElementParameter> elementParaChild = elementPara.getChildParameters();
                Map<String, IElementParameter> cloneElementChild = cloneElement.getChildParameters();
                Iterator<Entry<String, IElementParameter>> ite = elementParaChild.entrySet().iterator();
                while (ite.hasNext()) {
                    Entry<String, IElementParameter> entry = ite.next();
                    String key = entry.getKey();
                    IElementParameter c = entry.getValue();
                    if (key != null && c != null) {
                        IElementParameter cloneC = cloneElementChild.get(key);
                        if (cloneC != null) {
                            cloneC.setValue(c.getValue());
                            if (lockByOther) {
                                cloneC.setReadOnly(true);
                            } else {
                                cloneC.setReadOnly(c.isReadOnly());
                            }
                        }
                    }
                }
            }
        }
    }
    for (IElementParameter param : cloneNode.getElementParameters()) {
        String repositoryValue = param.getRepositoryValue();
        if (param.isShow(cloneNode.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && param.getFieldType() != EParameterFieldType.MEMO_SQL) {
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        }
    }
    cloneNode.setMetadataList(node.getMetadataList());
    cloneNode.setListConnector(node.getListConnector());
    cloneNode.setConnectionName(node.getConnectionName());
    cloneNode.setLocation(node.getLocation());
    IExternalNode externalNode = cloneNode.getExternalNode();
    if (externalNode != null) {
        if (node.getExternalData() != null) {
            try {
                externalNode.setExternalData(node.getExternalData().clone());
            } catch (CloneNotSupportedException e) {
                ExceptionHandler.process(e);
            }
            cloneNode.setExternalData(externalNode.getExternalData());
        }
        if (node.getExternalNode().getExternalEmfData() != null) {
            externalNode.setExternalEmfData(EcoreUtil.copy(node.getExternalNode().getExternalEmfData()));
        }
        // when copy a external node, should also copy screeshot
        if (node.getExternalNode() != null) {
            ImageDescriptor screenshot = node.getExternalNode().getScreenshot();
            if (screenshot != null) {
                externalNode.setScreenshot(screenshot);
            }
        }
    }
    if (node.getElementParameter(EParameterName.LABEL.getName()) != null) {
        cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getElementParameter(EParameterName.LABEL.getName()).getValue());
    } else {
        cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getLabel());
    }
    boolean found = false;
    for (INode inode : process.getGraphicalNodes()) {
        if (inode.getUniqueName().equals(cloneNode.getUniqueName())) {
            found = true;
        }
    }
    if (!found) {
        ((IProcess2) process).removeUniqueNodeName(cloneNode.getUniqueName());
    }
    return cloneNode;
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) JobletNode(org.talend.designer.joblet.model.JobletNode) ArrayList(java.util.ArrayList) IJobletProviderService(org.talend.core.ui.IJobletProviderService) Entry(java.util.Map.Entry) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) IExternalNode(org.talend.core.model.process.IExternalNode)

Aggregations

NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)59 List (java.util.List)45 Node (org.talend.designer.core.ui.editor.nodes.Node)39 ArrayList (java.util.ArrayList)27 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)23 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)17 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)17 EditPart (org.eclipse.gef.EditPart)16 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)15 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)14 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)14 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)14 Connection (org.talend.designer.core.ui.editor.connections.Connection)12 INode (org.talend.core.model.process.INode)10 Point (org.eclipse.draw2d.geometry.Point)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)9 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)9 NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)7 GraphicalViewer (org.eclipse.gef.GraphicalViewer)6 IConnection (org.talend.core.model.process.IConnection)6