Search in sources :

Example 1 with AbstractGraphicalEditPart

use of org.eclipse.gef.editparts.AbstractGraphicalEditPart 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 2 with AbstractGraphicalEditPart

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

the class TalendSelectionManager method appendSelection.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.SelectionManager#appendSelection(org.eclipse.gef.EditPart)
     */
@Override
public void appendSelection(EditPart arg0) {
    // judge whether the refresh operation is executed.
    // see bug 3315.
    boolean needRefresh = false;
    if (getSelection() instanceof StructuredSelection) {
        StructuredSelection selection = (StructuredSelection) getSelection();
        Object selected = null;
        for (Object element : selection.toArray()) {
            selected = element;
        }
        if (getSelection().isEmpty() || (selected instanceof ProcessPart)) {
            this.selectionType = ETalendSelectionType.SINGLE;
            needRefresh = true;
        }
        if (!(arg0 instanceof NodeLabelEditPart) && !(arg0 instanceof ConnLabelEditPart) && !(arg0 instanceof ConnectionPart)) {
            // removes old selections of labels by calling setSelection
            for (Object element : selection.toArray()) {
                if (element instanceof NodeLabelEditPart) {
                    this.deselect(((AbstractGraphicalEditPart) element));
                } else if (element instanceof ConnLabelEditPart) {
                    this.deselect(((AbstractGraphicalEditPart) element));
                } else if (element instanceof ConnectionPart) {
                    this.deselect(((AbstractConnectionEditPart) element));
                }
            }
            needRefresh = true;
        }
        if (arg0 instanceof ConnectionPerformanceEditPart && getSelectPoint() != null) {
            if (needRefresh) {
                EditPart transferPart = transferFocus((ConnectionPerformanceEditPart) arg0);
                if (transferPart == null) {
                    needRefresh = false;
                    setSelectPoint(null);
                    return;
                }
                super.appendSelection(transferPart);
                needRefresh = false;
                return;
            }
        }
        if (needRefresh) {
            super.appendSelection(arg0);
            needRefresh = false;
            setSelectPoint(null);
        }
    }
}
Also used : AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 3 with AbstractGraphicalEditPart

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

the class XmlDropTargetListener method updateTargetEditPart.

@Override
protected void updateTargetEditPart() {
    super.updateTargetEditPart();
    Point dropLocation = getDropLocation();
    if (getTargetEditPart() != null) {
        targetFigure = ((AbstractGraphicalEditPart) getTargetEditPart()).getFigure().findFigureAt(dropLocation.x, dropLocation.y);
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with AbstractGraphicalEditPart

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

the class DragAndDropEditPolicy method eraseTargetFeedback.

@Override
public void eraseTargetFeedback(Request request) {
    if (indicator != null) {
        if (request instanceof CreateNodeConnectionRequest) {
            CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
            AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
            if (targetEditPart != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
                try {
                    getFeedbackLayer().remove(indicator);
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
}
Also used : CreateNodeConnectionRequest(org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart)

Example 5 with AbstractGraphicalEditPart

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

the class SubjobContainerPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
@Override
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    if (SubjobContainer.UPDATE_SUBJOB_CONTENT.equals(prop)) {
        refresh();
        List<AbstractGraphicalEditPart> childrens = getChildren();
        for (AbstractGraphicalEditPart part : childrens) {
            part.refresh();
        }
    } else if (SubjobContainer.UPDATE_SUBJOB_CONNECTIONS.equals(prop)) {
        refreshSourceConnections();
    } else if (SubjobContainer.UPDATE_SUBJOB_TITLE_COLOR.equals(prop)) {
        if (getFigure() instanceof SubjobContainerFigure) {
            ((SubjobContainerFigure) getFigure()).updateSubJobTitleColor();
            refreshVisuals();
        }
    } else if (SubjobContainer.UPDATE_SUBJOB_DISPLAY.equals(prop)) {
        List<NodeContainer> tmpList = new ArrayList<NodeContainer>(((SubjobContainer) getModel()).getNodeContainers());
        ((SubjobContainer) getModel()).getNodeContainers().clear();
        refreshChildren();
        List elems = ((Process) getParent().getModel()).getElements();
        elems.remove(getModel());
        EditPart parent = getParent();
        parent.refresh();
        ((SubjobContainer) getModel()).getNodeContainers().addAll(tmpList);
        elems.add(getModel());
        parent.refresh();
    } else if ("UPDATE_SPARKSTREAMING_STATUS".equals(prop)) {
        if (getFigure() instanceof SparkStreamingSubjobContainerFigure) {
            ((SparkStreamingSubjobContainerFigure) getFigure()).updateData();
            refreshVisuals();
        }
    } else {
        // can only be UPDATE_SUBJOB_DATA, need to modify if some others are added
        if (getFigure() instanceof SubjobContainerFigure) {
            ((SubjobContainerFigure) getFigure()).updateData();
            refreshVisuals();
        }
    }
}
Also used : SparkStreamingSubjobContainerFigure(org.talend.designer.core.ui.editor.subjobcontainer.sparkstreaming.SparkStreamingSubjobContainerFigure) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) SparkStreamingSubjobContainerFigure(org.talend.designer.core.ui.editor.subjobcontainer.sparkstreaming.SparkStreamingSubjobContainerFigure) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)7 EditPart (org.eclipse.gef.EditPart)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IFigure (org.eclipse.draw2d.IFigure)2 Point (org.eclipse.draw2d.geometry.Point)2 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)2 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)2 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)2 CreateNodeConnectionRequest (org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest)2 HashMap (java.util.HashMap)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)1 NodeEditPart (org.eclipse.gef.NodeEditPart)1 RootEditPart (org.eclipse.gef.RootEditPart)1 AbstractConnectionEditPart (org.eclipse.gef.editparts.AbstractConnectionEditPart)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 ISubjobContainer (org.talend.core.model.process.ISubjobContainer)1