use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainer method changeWidth.
private void changeWidth(Rectangle totalRectangle) {
if (!this.node.isMapReduce()) {
return;
}
Rectangle oracleRec = totalRectangle.getCopy();
boolean subjobCollapsed = false;
if (this.node.getNodeContainer().getSubjobContainer() != null) {
subjobCollapsed = this.node.getNodeContainer().getSubjobContainer().isCollapsed();
}
int temWidth = 114;
if (isMRGroupContainesReduce() && !subjobCollapsed) {
temWidth = 240;
}
if (totalRectangle.width < temWidth && this.getNode().isMapReduceStart()) {
Integer distance = null;
for (NodeContainer nc : this.getSubjobContainer().getNodeContainers()) {
if (nc.getNode().getUniqueName().equals(this.getNode().getUniqueName())) {
continue;
}
if (this.getNode().getMrGroupId() != null && nc.getNode().getMrGroupId() != null && this.getNode().getMrGroupId().equals(nc.getNode().getMrGroupId())) {
continue;
}
int w = nc.getNodeContainerRectangle().x - totalRectangle.x;
if (w <= 0) {
continue;
}
if (totalRectangle.y + totalRectangle.height < nc.getNodeContainerRectangle().y) {
continue;
}
if (totalRectangle.y > nc.getNodeContainerRectangle().y + nc.getNodeContainerRectangle().height) {
continue;
}
if (distance == null) {
distance = w;
} else if (w < distance) {
distance = w;
}
if (totalRectangle.contains(nc.getNodeContainerRectangle().getLocation())) {
distance = w;
}
}
// } else
if (temWidth == 240 && (temWidth > this.getNodeContainerRectangle().width)) {
int dis = temWidth - oracleRec.width;
if (totalRectangle.x > dis / 2) {
totalRectangle.x = totalRectangle.x - dis / 2;
if (distance != null) {
if (distance < this.getNodeContainerRectangle().width) {
distance = this.getNodeContainerRectangle().width;
}
distance = distance + dis / 2;
}
}
}
// if (distance == null) {
totalRectangle.width = temWidth;
// } else if (distance >= temWidth) {
// totalRectangle.width = temWidth;
// } else if (distance < totalRectangle.width) {
// return;
// } else {
// totalRectangle.width = distance;
// }
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainer method refreshJobletNodes.
public void refreshJobletNodes(boolean update, boolean coll) {
if (this.node.isJoblet()) {
if (!coll || update) {
boolean componentUpdated = false;
IComponent oldComponent = node.getComponent();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IJobletProviderService.class)) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
IComponent newComponent = service.getUpdatedJobletComponent(oldComponent);
if (oldComponent != newComponent) {
node.setComponent(newComponent);
componentUpdated = true;
}
}
JobletUtil util = new JobletUtil();
IProcess jobletProcess = this.getNode().getComponent().getProcess();
Set<IConnection> conns = new HashSet<IConnection>();
List<? extends INode> jobletNodes = jobletProcess.getGraphicalNodes();
boolean lockByOther = false;
if (jobletProcess instanceof IProcess2) {
lockByOther = util.lockByOthers(((IProcess2) jobletProcess).getProperty().getItem());
}
Map<String, List<? extends IElementParameter>> paraMap = new HashMap<String, List<? extends IElementParameter>>();
// List<NodeContainer> temList = new ArrayList<NodeContainer>(nodeContainers);
if (!componentUpdated) {
for (NodeContainer nc : nodeContainers) {
if (this.node.getProcess() instanceof IProcess2) {
if (!update) {
paraMap.put(nc.getNode().getJoblet_unique_name(), nc.getNode().getElementParameters());
}
((IProcess2) this.node.getProcess()).removeUniqueNodeName(nc.getNode().getUniqueName());
}
}
}
nodeContainers.clear();
jobletElements.clear();
// boolean canRemove = false;
for (INode inode : jobletNodes) {
// canAdd = util.canAdd(temList, inode);
if ((inode instanceof Node)) {
Node temNode = (Node) inode;
// if (canAdd) {
conns.addAll(temNode.getIncomingConnections());
conns.addAll(temNode.getOutgoingConnections());
Node jnode = util.cloneNode(temNode, this.node.getProcess(), paraMap, lockByOther);
if (!this.node.isActivate()) {
jnode.setActivate(this.node.isActivate());
}
NodeContainer nodeContainer = util.cloneNodeContainer(temNode.getNodeContainer(), jnode);
jnode.setJobletnode(this.node);
jnode.setJoblet_unique_name(temNode.getUniqueName());
this.nodeContainers.add(nodeContainer);
this.jobletElements.add(jnode);
this.jobletElements.add(jnode.getNodeLabel());
this.jobletElements.add(jnode.getNodeError());
this.jobletElements.add(jnode.getNodeProgressBar());
// } else if (update) {
// for (NodeContainer nodeC : nodeContainers) {
// if (nodeC.getNode().getJoblet_unique_name().equals(temNode.getUniqueName())) {
// util.updateNode(nodeC.getNode(), temNode);
// break;
// }
// }
// }
}
}
// }
for (IConnection con : conns) {
String sourceName = con.getSource().getUniqueName();
String targetName = con.getTarget().getUniqueName();
Node sourceNode = null;
Node targetNode = null;
for (NodeContainer nodeC : nodeContainers) {
Node connNode = nodeC.getNode();
if (connNode.getJoblet_unique_name().equals(sourceName)) {
sourceNode = connNode;
}
if (connNode.getJoblet_unique_name().equals(targetName)) {
targetNode = connNode;
}
if (sourceNode != null && targetNode != null) {
util.cloneConnection(con, sourceNode, targetNode);
break;
}
}
}
}
} else if (this.node.isMapReduceStart()) {
Integer mrGroupId = node.getMrGroupId();
List<? extends INode> mapReduceNodes = this.node.getProcess().getGraphicalNodes();
List<Node> nodeList = new ArrayList<Node>();
if (node.getNodeContainer().getSubjobContainer() != null && node.getNodeContainer().getSubjobContainer().isCollapsed()) {
nodeList.add(node);
} else {
for (INode inode : mapReduceNodes) {
if ((inode instanceof Node)) {
Node temNode = (Node) inode;
if (temNode.getMrGroupId() != null && mrGroupId != null && temNode.getMrGroupId().equals(mrGroupId)) {
nodeList.add(temNode);
}
}
}
}
nodeContainers.clear();
jobletElements.clear();
for (Node inode : nodeList) {
if (!inode.isActivate()) {
continue;
}
NodeContainer nodeContainer = inode.getNodeContainer();
// inode.setJoblet_unique_name(inode.getUniqueName());
if (nodeContainer instanceof JobletContainer) {
((JobletContainer) nodeContainer).setMrStartContainer(this);
}
this.nodeContainers.add(nodeContainer);
this.jobletElements.add(inode);
this.jobletElements.add(inode.getNodeLabel());
this.jobletElements.add(inode.getNodeError());
this.jobletElements.add(inode.getNodeProgressBar());
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainer method transferLocation.
private void transferLocation(boolean update) {
this.update = update;
if (update) {
// do nothing
}
if ((this.isCollapsed() == true)) {
// && !this.getNode().isMapReduceStart()
return;
}
if (this.getNode().isMapReduce()) {
return;
}
if (this.nodeContainers.size() <= 0) {
return;
}
Point oragPoint = this.getNode().getLocation();
Node startNode = getJobletStartNode();
if (startNode == null) {
return;
}
Point stratPoint = startNode.getLocation();
int withe_x = oragPoint.x - stratPoint.x;
int hight_y = oragPoint.y - stratPoint.y;
for (NodeContainer nodeCon : this.nodeContainers) {
Node jobNode = nodeCon.getNode();
if (jobNode.getJoblet_unique_name() != null && jobNode.getJoblet_unique_name().equals(startNode.getUniqueName())) {
jobNode.setLocation(oragPoint);
} else {
Point nodePoint = jobNode.getLocation();
jobNode.setLocation(new Point(nodePoint.x + withe_x, nodePoint.y + hight_y));
hasChange = true;
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainer method transferLocation.
public void transferLocation(Point oldPos) {
this.update = false;
if ((this.isCollapsed() == true)) {
// && !this.getNode().isMapReduceStart()
return;
}
if (this.getNode().isMapReduce()) {
return;
}
if (this.nodeContainers.size() <= 0) {
return;
}
Point oragPoint = this.getNode().getLocation();
Node startNode = getJobletStartNode();
if (startNode == null) {
return;
}
// Point stratPoint = startNode.getLocation();
int withe_x = oragPoint.x - oldPos.x;
int hight_y = oragPoint.y - oldPos.y;
for (NodeContainer nodeCon : this.nodeContainers) {
Node jobNode = nodeCon.getNode();
if (jobNode.getJoblet_unique_name().equals(startNode.getUniqueName())) {
jobNode.setLocation(oragPoint);
} else {
Point nodePoint = jobNode.getLocation();
jobNode.setLocation(new Point(nodePoint.x + withe_x, nodePoint.y + hight_y));
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainer method canCollapse.
public boolean canCollapse() {
List<String> connList = new ArrayList<String>();
List<String> triConnList = new ArrayList<String>();
List<String> metaList = new ArrayList<String>();
if (node.getIncomingConnections().size() > 1) {
for (IConnection conn : node.getIncomingConnections()) {
if (conn.getConnectorName().startsWith("TRIGGER")) {
metaList.add(conn.getMetaName());
}
}
for (NodeContainer nodeContainer : this.nodeContainers) {
Node connNode = nodeContainer.getNode();
IElementParameter elePa = this.node.getElementParameter(connNode.getJoblet_unique_name());
if (elePa != null) {
boolean isTri = false;
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
isTri = service.isTriggerNode(connNode);
}
if (isTri) {
IElementParameter elechild = elePa.getChildParameters().get("COMPONENT_LIST");
if (elechild != null) {
if (elechild.getValue() == null || ((String) elechild.getValue()).length() <= 0) {
return false;
} else {
if (triConnList.contains(elechild.getValue())) {
return false;
} else {
triConnList.add((String) elechild.getValue());
}
}
if (elechild.getValue() != null && (elechild.getValue() instanceof String)) {
metaList.remove(elechild.getValue());
}
}
} else {
IElementParameter elechild = elePa.getChildParameters().get("CONNECTION");
if (elechild != null) {
if ((elechild.getValue() == null || "".equals(elechild.getValue()))) {
return false;
} else {
if (elechild.getValue() instanceof String) {
if (connList.contains(elechild.getValue())) {
return false;
} else {
connList.add((String) elechild.getValue());
}
}
}
}
}
}
}
if (metaList.size() > 0) {
return false;
}
}
return true;
}
Aggregations