Search in sources :

Example 21 with NodePart

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

the class ActivateSubjobOneComponentAction 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 Node)) {
            return false;
        }
        Node node = (Node) part.getModel();
        if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(node.getProcess().getComponentsType())) {
            return false;
        }
        if (node.getJobletNode() != null) {
            return false;
        }
        if (node.isReadOnly()) {
            return false;
        }
        if (node.getPropertyValue(EParameterName.ACTIVATE.getName()) == null) {
            return false;
        }
        if (node.isSubProcessStart() && node.isStart()) {
            if (node.isActivate()) {
                setText(TEXT_REM_ACTIVATE_PART);
            } else {
                setText(TEXT_SET_ACTIVATE_PART);
            }
            return true;
        } else {
            return false;
        }
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 22 with NodePart

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

the class ConnectionCreateAction method canPerformAction.

/**
     * Test if the selected item is a node.
     * 
     * @return true/false
     */
@SuppressWarnings("unchecked")
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 = (NodePart) o;
        if (!(nodePart.getModel() instanceof Node)) {
            return false;
        }
        Node node = (Node) nodePart.getModel();
        if (!node.isActivate()) {
            return false;
        }
        if (node.getJobletNode() != null) {
            return false;
        }
        if (curNodeConnector != null && "VALIDATION_REJECT".equals(curNodeConnector.getName())) {
            if (node.getProcess() != null && !ComponentCategory.CATEGORY_4_DI.getName().equals(node.getProcess().getComponentsType())) {
                return false;
            }
        }
        if (connecType.hasConnectionCategory(IConnectionCategory.EXECUTION_ORDER)) {
            if (!(Boolean) node.getPropertyValue(EParameterName.STARTABLE.getName()) || (!node.getProcessStartNode(false).equals(node))) {
                if (!node.isELTMapComponent()) {
                    boolean jobletOk = false;
                    if (PluginChecker.isJobLetPluginLoaded()) {
                        IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                        if (service != null && service.isJobletComponent(node)) {
                            jobletOk = true;
                        }
                    }
                    if (!jobletOk) {
                        return false;
                    }
                }
            }
        }
        menuList = new ArrayList<String>();
        if (curNodeConnector == null) {
            curNodeConnector = node.getConnectorFromType(connecType);
            if (curNodeConnector == null) {
                return false;
            }
        }
        if (curNodeConnector.getMaxLinkOutput() != -1) {
            if (curNodeConnector.getCurLinkNbOutput() >= curNodeConnector.getMaxLinkOutput()) {
                return false;
            }
        }
        if (curNodeConnector.getMaxLinkOutput() == 0) {
            return false;
        }
        /**
             * judge whether to show the table link menu in ELTMap components
             */
        if (curNodeConnector.getName().equals(EConnectionType.TABLE.getName())) {
            List<? extends IConnection> tableRefs = node.getOutgoingConnections(EConnectionType.TABLE_REF);
            if (tableRefs != null && 0 < tableRefs.size()) {
                return false;
            }
        }
        if (!curNodeConnector.isMultiSchema()) {
        // setText(curNodeConnector.getMenuName());
        }
        if (curNodeConnector.isMultiSchema()) {
            for (int i = 0; i < node.getMetadataList().size(); i++) {
                IMetadataTable table = (node.getMetadataList().get(i));
                String value = table.getAdditionalProperties().get(ISINPUT);
                if (value != null && value.equals(TRUE)) {
                    continue;
                }
                String name = table.getTableName();
                if (name.equals(node.getUniqueName())) {
                    continue;
                }
                if (table.getAttachedConnector() == null || table.getAttachedConnector().equals(curNodeConnector.getName())) {
                    if (connecType == EConnectionType.TABLE) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        name = table.getLabel() + " (" + name + ")";
                    }
                    boolean nameUsed = false;
                    for (Connection connec : (List<Connection>) node.getOutgoingConnections()) {
                        if (connec.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
                            if (connec.getMetadataTable().getTableName().equals(table.getTableName())) {
                                nameUsed = true;
                            }
                        }
                    }
                    // if the name is not already in the process adds to the list
                    if (!nameUsed) {
                        menuList.add(name);
                    }
                }
            }
            if ((curNodeConnector.getMaxLinkOutput() == -1 || node.getMetadataList().size() < curNodeConnector.getMaxLinkOutput()) && curNodeConnector.isBuiltIn()) {
                menuList.add(getNewOutputMenuName());
            }
        } else {
            String menuName;
            boolean addDefaultName = false;
            // get linked metadata to connector
            IMetadataTable table = null;
            for (int i = 0; i < node.getMetadataList().size(); i++) {
                table = (node.getMetadataList().get(i));
                if (table.getTableName().equals(node.getUniqueName())) {
                    break;
                }
            }
            // if EBCDIC + single schema mode, only have one output maximum
            if (node.getComponent().getName().contains("EBCDIC") && node.checkSchemaForEBCDIC(table) && curNodeConnector.getCurLinkNbOutput() > 0) {
                return false;
            }
            if (connecType == EConnectionType.TABLE) {
                addDefaultName = addDefaultName();
                menuName = getNewOutputMenuName();
            } else {
                menuName = curNodeConnector.getMenuName();
            }
            if (!addDefaultName) {
                setText(menuName);
                menuList.add(menuName);
            }
        }
        return true;
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) Point(org.eclipse.draw2d.geometry.Point) IJobletProviderService(org.talend.core.ui.IJobletProviderService) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 23 with NodePart

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

the class ModifyMergeOrderAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object o = parts.get(0);
    INode node = null;
    if (o instanceof ConnectionPart) {
        ConnectionPart part = (ConnectionPart) o;
        IConnection connection = (IConnection) part.getModel();
        node = connection.getTarget();
    } else if (o instanceof ConnLabelEditPart) {
        ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
        Connection connection = (Connection) part.getModel();
        node = connection.getTarget();
    } else if (o instanceof NodePart) {
        node = (Node) ((NodePart) o).getModel();
    }
    if ((node == null) || (!node.getComponent().useMerge())) {
        return false;
    }
    mergeComponent = node;
    setText(TEXT_MERGE_ORDER);
    return true;
}
Also used : INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) 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 24 with NodePart

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

the class ModifyOutputOrderAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object o = parts.get(0);
    EConnectionType tmpConnType = null;
    INode node = null;
    if (o instanceof ConnectionPart) {
        ConnectionPart part = (ConnectionPart) o;
        Connection connection = (Connection) part.getModel();
        node = connection.getSource();
        tmpConnType = connection.getLineStyle();
    } else if (o instanceof ConnLabelEditPart) {
        ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
        Connection connection = (Connection) part.getModel();
        node = connection.getSource();
        tmpConnType = connection.getLineStyle();
    } else if (o instanceof NodePart) {
        node = (Node) ((NodePart) o).getModel();
    }
    if (node == null) {
        return false;
    }
    usedConnType = false;
    //$NON-NLS-1$
    String midStr = "output";
    int nb = 0;
    for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
        if (getConnectionCategory() != null && connection.getLineStyle().hasConnectionCategory(getConnectionCategory())) {
            // avoid the not useful action, on connection.
            if (tmpConnType == null || tmpConnType != null && tmpConnType.hasConnectionCategory(getConnectionCategory())) {
                nb++;
            }
        } else // feature 4505 & 8087
        if (getConnectionType() != null && connection.getLineStyle() == getConnectionType()) {
            midStr = getConnectionType().getDefaultLinkName();
            usedConnType = true;
            // avoid the not useful action, on connection.
            if (tmpConnType == null || tmpConnType != null && tmpConnType == getConnectionType()) {
                nb++;
            }
        }
    }
    if (nb < 2) {
        return false;
    }
    multipleOutputNode = node;
    //$NON-NLS-1$
    setText(Messages.getString("ModifyOutputOrderAction.text", midStr));
    return true;
}
Also used : INode(org.talend.core.model.process.INode) Connection(org.talend.designer.core.ui.editor.connections.Connection) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) EConnectionType(org.talend.core.model.process.EConnectionType) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 25 with NodePart

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

the class NodeBreakpointAction method canPerformAction.

/**
     * Test if the selected item is a node.
     * 
     * @return true / false
     */
private boolean canPerformAction() {
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (!brandingService.getBrandingConfiguration().isAllowDebugMode()) {
        return false;
    }
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    if (PluginUtil.isMediation()) {
        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();
        if (node.getJobletNode() != null) {
            return false;
        }
        EditPart parentPart = part.getParent();
        while (!(parentPart instanceof ProcessPart)) {
            parentPart = parentPart.getParent();
        }
        if (!(parentPart instanceof ProcessPart)) {
            return false;
        }
        process = (IProcess) ((ProcessPart) parentPart).getModel();
        if (CorePlugin.getContext().getBreakpointNodes(process).contains(node)) {
            //$NON-NLS-1$
            setText(Messages.getString("NodeBreakpointAction.removeBreakpoint"));
        } else {
            //$NON-NLS-1$
            setText(Messages.getString("NodeBreakpointAction.addBreakPoint"));
        }
        return true;
    }
    return false;
}
Also used : INode(org.talend.core.model.process.INode) EditPart(org.eclipse.gef.EditPart) List(java.util.List) IBrandingService(org.talend.core.ui.branding.IBrandingService) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) 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