Search in sources :

Example 11 with ProcessPart

use of org.talend.designer.core.ui.editor.process.ProcessPart 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 12 with ProcessPart

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

the class JobletContainerPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
@Override
public void propertyChange(PropertyChangeEvent changeEvent) {
    String prop = changeEvent.getPropertyName();
    boolean needUpdateSubjob = false;
    if (prop.equals(EParameterName.HINT.getName())) {
        Node node = ((NodeContainer) getModel()).getNode();
    // ((JobletContainerFigure) figure).setInfoHint(node.getShowHintText());
    } else if (JobletContainer.UPDATE_JOBLET_CONTENT.equals(prop)) {
        refresh();
        List<AbstractGraphicalEditPart> childrens = getChildren();
        for (AbstractGraphicalEditPart part : childrens) {
            part.refresh();
        }
        needUpdateSubjob = true;
    } else if (JobletContainer.UPDATE_JOBLET_CONNECTIONS.equals(prop)) {
        refreshSourceConnections();
    } else if (JobletContainer.UPDATE_JOBLET_TITLE_COLOR.equals(prop)) {
        if (getFigure() instanceof JobletContainerFigure) {
            ((JobletContainerFigure) getFigure()).updateJobletContainerColor();
            refreshVisuals();
        }
    } else if (JobletContainer.UPDATE_JOBLET_DISPLAY.equals(prop)) {
        if (getFigure() instanceof JobletContainerFigure) {
            ((JobletContainerFigure) getFigure()).updateJobletContainerColor();
            refreshVisuals();
        }
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals("UPDATE_STATUS")) {
        // ((JobletContainer) getModel()).updateJobletNodes(true);
        if (getFigure() instanceof JobletContainerFigure) {
            String newValue = (String) changeEvent.getNewValue();
            if (newValue != null && newValue.equals("CLEAR")) {
                ((JobletContainerFigure) getFigure()).refreshNodes(true);
            } else {
                ((JobletContainerFigure) getFigure()).refreshNodes(false);
            }
            if (((JobletContainer) getModel()).getNode().isMapReduce()) {
                JobletContainer jCon = (JobletContainer) getModel();
                if (jCon.getNode().isMapReduceStart()) {
                    jCon.updateJobletNodes(true);
                    ((JobletContainerFigure) getFigure()).updateData();
                } else if (jCon.getMrStartContainer() != null) {
                    jCon.getMrStartContainer().updateJobletNodes(true);
                }
            }
        }
        refreshVisuals();
    } else if (changeEvent.getPropertyName().equals("UPDATE_MR_STATUS")) {
        if (getFigure() instanceof JobletContainerFigure) {
            ((JobletContainerFigure) getFigure()).refreshMRstatus();
        }
        refreshVisuals();
    } else {
        // can only be UPDATE_SUBJOB_DATA, need to modify if some others are added
        if (getFigure() instanceof JobletContainerFigure) {
            if (((JobletContainer) getModel()).getNode().isMapReduce()) {
                JobletContainer jCon = (JobletContainer) getModel();
                if (jCon.getNode().isMapReduceStart()) {
                    jCon.updateJobletNodes(true);
                } else if (jCon.getMrStartContainer() != null) {
                    jCon.getMrStartContainer().updateJobletNodes(true);
                }
            }
            ((JobletContainerFigure) getFigure()).updateData();
            refreshVisuals();
        }
    }
    if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
        Node node = ((NodeContainer) getModel()).getNode();
        if (node.isActivate()) {
            // ((JobletContainerFigure) figure).setAlpha(-1);
            ((JobletContainerFigure) figure).repaint();
            refreshVisuals();
        } else {
            // ((JobletContainerFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((JobletContainerFigure) figure).repaint();
            refreshVisuals();
        }
    }
    if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
        refreshVisuals();
    }
    if (needUpdateSubjob) {
        EditPart editPart = getParent();
        if (editPart != null) {
            while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
                editPart = editPart.getParent();
            }
            Node node = ((NodeContainer) getModel()).getNode();
            List<ISubjobContainer> proSubList = new ArrayList<ISubjobContainer>(((IProcess2) node.getProcess()).getSubjobContainers());
            if (editPart instanceof SubjobContainerPart) {
                // Node node = ((NodeContainer) getModel()).getNode();
                JobletContainer nc = (JobletContainer) this.getModel();
                // Rectangle rec = new Rectangle(node.getLocation(), node.getSize());
                boolean isCollapse = nc.isCollapsed() && !nc.getNode().isMapReduceStart();
                int rightChangewidth = nc.getRightChangeWidth();
                int downChangeheight = nc.getDownChangeHeight();
                int leftChangewidth = nc.getLeftChangeWidth();
                int upChangeheight = nc.getUpChangeHeight();
                if (nc.getNode().isJoblet()) {
                    if (editPart instanceof SubjobContainerPart) {
                        ((SubjobContainer) ((SubjobContainerPart) editPart).getModel()).refreshNodesLocation(isCollapse, nc, rightChangewidth, downChangeheight, leftChangewidth, upChangeheight);
                    }
                // for (ISubjobContainer sb : proSubList) {
                // ((SubjobContainer) sb).refreshNodesLocation(isCollapse, nc, rightChangewidth,
                // downChangeheight,
                // leftChangewidth, upChangeheight);
                // }
                }
                editPart.refresh();
            }
        }
    }
    if (changeEvent.getPropertyName().equals(Node.UPDATE_STATUS)) {
        Node node = ((NodeContainer) getModel()).getNode();
        if (node != null && node.isMapReduce()) {
            ((JobletContainerFigure) this.getFigure()).updateErrorFlag(node.isErrorFlag());
            ((JobletContainerFigure) this.getFigure()).setShowCompareMark(node.isCompareFlag() && !node.isErrorFlag());
            IElementParameter param = node.getElementParameter(EParameterName.INFORMATION.getName());
            if (param != null) {
                boolean showInfoFlag = Boolean.TRUE.equals(param.getValue());
                if (changeEvent.getNewValue() instanceof Integer) {
                    Integer status = (Integer) changeEvent.getNewValue();
                    if (status != null) {
                        ((JobletContainerFigure) this.getFigure()).updateStatus(status, showInfoFlag);
                    }
                    ((JobletContainerFigure) this.getFigure()).setInfoHint(node.getShowHintText());
                }
                refreshVisuals();
            }
        } else {
            ((JobletContainerFigure) getFigure()).updateStatus(node.getStatus());
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) ISubjobContainer(org.talend.core.model.process.ISubjobContainer) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart)

Example 13 with ProcessPart

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

the class NodeLabelEditPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
public void propertyChange(final PropertyChangeEvent evt) {
    String request = evt.getPropertyName();
    if (request.equals(NodeLabel.OFFSET_CHANGE)) {
        //$NON-NLS-1$ //$NON-NLS-2$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(NodeLabel.TEXT_CHANGE)) {
        refreshVisuals();
        // set the new size to update the node container
        ((NodeLabel) getModel()).setLabelSize(((SimpleHtmlFigure) figure).getPreferredSize());
        NodeLabel label = (NodeLabel) getModel();
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ISQLBuilderService.class)) {
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            service.updateSqlBuilderDialogTitle(label.getLabelText(), label.getNode().getProcess().getName(), label.getNode().getUniqueName());
        }
        getParent().refresh();
        // refresh the title of component setting view.
        ComponentSettingsView viewer = (ComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ComponentSettingsView.ID);
        if (viewer != null) {
            viewer.updatePropertiesViewerTitle();
        }
    }
    if (request.equals(NodeLabel.LOCATION)) {
        //$NON-NLS-1$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(EParameterName.ACTIVATE.getName())) {
        if (((NodeLabel) getModel()).isActivate()) {
            ((SimpleHtmlFigure) figure).setAlpha(-1);
            ((SimpleHtmlFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((SimpleHtmlFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((SimpleHtmlFigure) figure).repaint();
            refreshVisuals();
        }
    }
    EditPart editPart = getParent();
    if (editPart != null) {
        while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
            editPart = editPart.getParent();
        }
        if (editPart instanceof SubjobContainerPart) {
            editPart.refresh();
        }
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ISQLBuilderService(org.talend.core.ui.services.ISQLBuilderService) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 14 with ProcessPart

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

the class NodeErrorEditPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
public void propertyChange(final PropertyChangeEvent evt) {
    String request = evt.getPropertyName();
    if (request.equals("UPDATE_STATUS")) {
        //$NON-NLS-1$
        NodeErrorFigure figure = (NodeErrorFigure) this.getFigure();
        Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
        figure.updateVisible(node.isErrorFlag(), node.getErrorInfo());
        ((NodeError) getModel()).setErrorSize((figure).getSize());
        refreshVisuals();
    }
    if (request.equals(NodeError.LOCATION)) {
        //$NON-NLS-1$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(EParameterName.ACTIVATE.getName())) {
        if (((NodeError) getModel()).isActivate()) {
            ((NodeErrorFigure) figure).setAlpha(-1);
            ((NodeErrorFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeErrorFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((NodeErrorFigure) figure).repaint();
            refreshVisuals();
        }
    }
    EditPart editPart = getParent();
    if (editPart != null) {
        while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
            editPart = editPart.getParent();
        }
        if (editPart instanceof SubjobContainerPart) {
            editPart.refresh();
        }
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 15 with ProcessPart

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

the class OpenJobHierarchyAction method calculateEnabled.

@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object o = parts.get(0);
    if (o instanceof NodePart) {
        NodePart part = (NodePart) o;
        Node node = (Node) part.getModel();
        if (DesignerUtilities.isTRunJobComponent(node)) {
            return true;
        }
    } else if (o instanceof ProcessPart) {
        return true;
    }
    return false;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Aggregations

ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)29 EditPart (org.eclipse.gef.EditPart)19 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)17 List (java.util.List)15 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)15 ArrayList (java.util.ArrayList)13 Node (org.talend.designer.core.ui.editor.nodes.Node)12 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)9 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)9 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)8 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)8 GraphicalViewer (org.eclipse.gef.GraphicalViewer)7 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)7 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)7 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 INode (org.talend.core.model.process.INode)6 Process (org.talend.designer.core.ui.editor.process.Process)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)5 NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)5