use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer 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());
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletUtil method getModifyMap.
public Map<String, List<AbstractJobletContainer>> getModifyMap(List<Element> elem) {
Map<String, List<AbstractJobletContainer>> jobletNodeMap = new HashMap<String, List<AbstractJobletContainer>>();
for (Element element : elem) {
if (element instanceof SubjobContainer) {
for (NodeContainer container : ((SubjobContainer) element).getNodeContainers()) {
if (container instanceof AbstractJobletContainer) {
String processID = container.getNode().getProcess().getId();
if (!jobletNodeMap.containsKey(processID)) {
List<AbstractJobletContainer> nodeList = new ArrayList<AbstractJobletContainer>();
nodeList.add((AbstractJobletContainer) container);
jobletNodeMap.put(processID, nodeList);
} else {
jobletNodeMap.get(processID).add((AbstractJobletContainer) container);
}
}
}
}
}
return jobletNodeMap;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletUtil method getConnSubjob.
public List<SubjobContainer> getConnSubjob(SubjobContainer sub, List<ISubjobContainer> proSubList) {
List<SubjobContainer> subList = new ArrayList<SubjobContainer>();
if (!proSubList.contains(sub)) {
return subList;
}
for (NodeContainer container : sub.getNodeContainers()) {
List<IConnection> inList = new ArrayList<IConnection>();
List<IConnection> outList = new ArrayList<IConnection>();
if ((container instanceof AbstractJobletContainer)) {
// && ((JobletContainer) container).isCollapsed()
inList.addAll(((JobletContainer) container).getInputs());
outList.addAll(((JobletContainer) container).getOutputs());
} else {
inList.addAll(container.getNode().getIncomingConnections());
outList.addAll(container.getNode().getOutgoingConnections());
}
for (IConnection conn : inList) {
INode source = conn.getSource();
if (source instanceof Node) {
SubjobContainer tem = ((Node) conn.getSource()).getNodeContainer().getSubjobContainer();
if (tem != null && sub != tem) {
if (subList.contains(tem) || !proSubList.contains(tem)) {
continue;
}
subList.add(tem);
proSubList.remove(tem);
subList.addAll(getConnSubjob(tem, proSubList));
}
}
}
for (IConnection conn : outList) {
INode target = conn.getTarget();
if (target instanceof Node) {
SubjobContainer tem = ((Node) conn.getTarget()).getNodeContainer().getSubjobContainer();
if (tem != null && sub != tem) {
if (subList.contains(tem) || !proSubList.contains(tem)) {
continue;
}
subList.add(tem);
proSubList.remove(tem);
subList.addAll(getConnSubjob(tem, proSubList));
}
}
}
}
return subList;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class NodeErrorEditPart method refreshVisuals.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
*/
@Override
protected void refreshVisuals() {
Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
NodeLabel nodeLabel = node.getNodeLabel();
NodeErrorFigure errorFig = (NodeErrorFigure) this.getFigure();
Point loc = node.getLocation().getCopy();
Dimension size = errorFig.getSize();
loc.x = loc.x + (node.getSize().width - size.width) / 2;
loc.y = loc.y + node.getSize().height + (nodeLabel.getLabelSize().height);
Rectangle rectangle = new Rectangle(loc, size);
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer 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();
}
}
}
Aggregations