Search in sources :

Example 46 with NodePart

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

the class DisableParallelizationAction method calculateEnabled.

@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.isEmpty()) {
        return false;
    }
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (o instanceof SubjobContainerPart) {
            SubjobContainerPart part = (SubjobContainerPart) o;
            SubjobContainer subjob = (SubjobContainer) part.getModel();
            Node subStartNode = subjob.getSubjobStartNode();
            if (subjob.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
                if (subjob.isDisplayed() && ParallelExecutionUtils.isExistPartitioningCon(subStartNode)) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else if (o instanceof NodePart) {
            NodePart part = (NodePart) o;
            Node node = (Node) part.getModel();
            if (node.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
                if (node.isStart() && ParallelExecutionUtils.isExistPartitioningCon(node)) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    return false;
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 47 with NodePart

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

the class DisplaySubjobAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
public void run() {
    List editparts = getSelectedObjects();
    if (editparts.size() == 1) {
        Object o = editparts.get(0);
        if (o instanceof NodePart) {
            NodePart part = (NodePart) o;
            Node node = (Node) part.getModel();
            if (node.getJobletNode() != null) {
                node = (Node) node.getJobletNode();
            }
            DisplaySubjobCommand displaySubjobCommand = new DisplaySubjobCommand(node.getNodeContainer().getSubjobContainer());
            execute(displaySubjobCommand);
        } else if (o instanceof SubjobContainerPart) {
            SubjobContainerPart part = (SubjobContainerPart) o;
            SubjobContainer subjob = (SubjobContainer) part.getModel();
            DisplaySubjobCommand displaySubjobCommand = new DisplaySubjobCommand(subjob);
            execute(displaySubjobCommand);
        }
    }
}
Also used : DisplaySubjobCommand(org.talend.designer.core.ui.editor.cmd.DisplaySubjobCommand) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 48 with NodePart

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

the class ParallelExecutionAction method getCurrentNode.

protected Node getCurrentNode() {
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return null;
    }
    Object o = parts.get(0);
    if (o instanceof NodePart) {
        NodePart nodePart = (NodePart) o;
        node = (Node) nodePart.getModel();
        return node;
    }
    return null;
}
Also used : List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 49 with NodePart

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

the class OpenTalendJobRefAction method run.

/* Will send a "open" request to the selected nodePart, so it will try to open the reference job.
     * If the "open" command success, then will try to switch the perspective to Integration.
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    //diable switch perspective suggestion dialog. just for defense.
    String notAskAutoSwitchToDIKey = "notAskAutoSwitchToDI";
    boolean oldValueNotSwitchToDiKey = PlatformUI.getPreferenceStore().getBoolean(notAskAutoSwitchToDIKey);
    PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, true);
    //need to be  restore at the end .
    // open in editor, type and count already checked in calculateEnabled()
    List<?> selectedObjects = getSelectedObjects();
    Object select = selectedObjects.get(0);
    NodePart nodePart = (NodePart) select;
    nodePart.performRequest(new org.eclipse.gef.Request(REQUEST_TYPE_OPEN_NODE_PART));
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (activePage == null) {
        return;
    }
    IEditorPart activeEditor = activePage.getActiveEditor();
    if (activeEditor == null || activeEditor.getEditorSite() == null) {
        return;
    }
    Node node = (Node) nodePart.getModel();
    String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
    String openJobName = activeEditor.getEditorInput().getName();
    if (!selectedJobName.equals(openJobName)) {
        return;
    }
    // open/switch editor success and then  try to switch perspective.
    try {
        //if current perspective is ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, will do nothing in under layer.
        PlatformUI.getWorkbench().showPerspective(ORG_TALEND_RCP_INTEGRATION_PERSPECTIVE, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
    } catch (WorkbenchException e) {
        e.printStackTrace();
    } finally {
        //Restore config of switch perspective suggestion dialog. just for defense.
        PlatformUI.getPreferenceStore().setValue(notAskAutoSwitchToDIKey, oldValueNotSwitchToDiKey);
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 50 with NodePart

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

the class OpenTalendJobRefAction method calculateEnabled.

/* Check if this action enable. Will ensure the cTalendJob was selected and has legal value.
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     * 
     */
@Override
protected boolean calculateEnabled() {
    List<?> selectedObjects = getSelectedObjects();
    if (selectedObjects.size() != 1) {
        //not select one object.
        return false;
    }
    Object select = selectedObjects.get(0);
    if (!(select instanceof NodePart)) {
        //not select a node.
        return false;
    }
    NodePart nodePart = (NodePart) select;
    Node node = (Node) nodePart.getModel();
    if (!(node.getComponent() instanceof EmfComponent)) {
        //not select a component.
        return false;
    }
    EmfComponent component = (EmfComponent) node.getComponent();
    if (!C_TALEND_JOB_COMPONENT_NAME.equals(component.getName())) {
        //not cTalendJob component.
        return false;
    }
    Boolean isRepositoryJob = (Boolean) node.getElementParameter(NODE_PARAM_FROM_REPOSITORY_JOB).getValue();
    if (isRepositoryJob == null || !isRepositoryJob) {
        //not from repository job.
        return false;
    }
    String selectedJobName = (String) node.getElementParameter(NODE_PARAM_SELECTED_JOB_NAME).getValue();
    if (selectedJobName == null || selectedJobName.equals("")) {
        //no reference job been choice.
        return false;
    }
    return true;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) EmfComponent(org.talend.designer.core.model.components.EmfComponent) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

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