use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class DeleteNodeContainerCommand method undo.
@Override
@SuppressWarnings("unchecked")
public void undo() {
process.setActivate(false);
for (INode node : nodeList) {
if (node.getJobletNode() != null) {
continue;
}
NodeContainer nodeContainer = ((Node) node).getNodeContainer();
this.process.addUniqueNodeName(node.getUniqueName());
((Process) process).addNodeContainer(nodeContainer);
List<Connection> inputList = (List<Connection>) node.getIncomingConnections();
List<Connection> outputList = (List<Connection>) node.getOutgoingConnections();
boolean builtIn = node.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
for (Connection connection : inputList) {
// see bug 0004514: need to undo for 0002633
if (connection != null && connection.getSourceNodeConnector() != null) {
connection.getSourceNodeConnector().setCurLinkNbOutput(connection.getSourceNodeConnector().getCurLinkNbOutput() + 1);
}
INode prevNode = connection.getSource();
if ((prevNode instanceof Node) && ((Node) prevNode).getJobletNode() != null) {
Node jobletnode = (Node) prevNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getOutputs().add(connection);
restoreMetadata(connection, jobletnode);
}
if (!nodeList.contains(prevNode)) {
if (!prevNode.getOutgoingConnections().contains(connection)) {
prevNode.addOutput(connection);
}
restoreMetadata(connection, prevNode);
connection.reconnect();
connection.updateAllId();
boolean builtInPrevNode = prevNode.getConnectorFromType(EConnectionType.FLOW_MAIN).isMultiSchema() | node.getConnectorFromType(EConnectionType.TABLE).isMultiSchema();
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME) && !builtInPrevNode) {
// for bug 10024
// see 10583
String name = connection.getUniqueName();
if (connection.getConnectorName().startsWith("TRIGGER_OUTPUT")) {
if (process.checkValidConnectionName(name)) {
process.addUniqueConnectionName(name);
}
} else {
process.addUniqueConnectionName(name);
}
}
}
}
for (IConnection connection : outputList) {
INode nextNode = connection.getTarget();
if ((nextNode instanceof Node) && ((Node) nextNode).getJobletNode() != null) {
Node jobletnode = (Node) nextNode.getJobletNode();
((AbstractJobletContainer) jobletnode.getNodeContainer()).getInputs().add(connection);
}
if (!nodeList.contains(nextNode)) {
if (!nextNode.getIncomingConnections().contains(connection)) {
nextNode.addInput(connection);
}
INodeConnector nodeConnector = nextNode.getConnectorFromType(connection.getLineStyle());
nodeConnector.setCurLinkNbInput(nodeConnector.getCurLinkNbInput() + 1);
connection.reconnect();
if (nextNode.getExternalNode() instanceof AbstractNode) {
((AbstractNode) nextNode.getExternalNode()).addInput(connection);
}
}
if (!builtIn) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.UNIQUE_NAME)) {
// for bug 10024
// see 10583
String name = connection.getUniqueName();
// name = process.generateUniqueConnectionName(name);
process.addUniqueConnectionName(name);
}
}
}
if (builtIn) {
for (IMetadataTable meta : node.getMetadataList()) {
String metaName = meta.getTableName();
process.addUniqueConnectionName(metaName);
}
// tmap join table
for (String name : joinTableNames) {
process.addUniqueConnectionName(name);
}
}
}
process.setActivate(true);
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class ExternalNodeChangeCommand method changeCollapsedState.
private void changeCollapsedState(boolean state, Map<String, Boolean> map, INode node) {
if (node instanceof Node) {
NodeContainer nc = ((Node) node).getNodeContainer();
if ((nc instanceof AbstractJobletContainer) && nc.getNode().isJoblet()) {
if (((AbstractJobletContainer) nc).isCollapsed() && !state) {
map.put(nc.getNode().getUniqueName(), false);
((AbstractJobletContainer) nc).setCollapsed(state);
} else if (!((AbstractJobletContainer) nc).isCollapsed() && state) {
if (map.get(nc.getNode().getUniqueName()) != null && !map.get(nc.getNode().getUniqueName())) {
((AbstractJobletContainer) nc).setCollapsed(state);
}
}
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class NodesMoveCommond method findLocationForNodeInContainerList.
private Point findLocationForNodeInContainerList(final Point location, Dimension size, int index, int firstIndex, Node copiedNode) {
Rectangle copiedRect = new Rectangle(location, size);
Point newLocation = new Point(location);
if (getCursorLocation() == null) {
for (NodeContainer nodeContainer : nodeContainerList) {
IGraphicalNode node = nodeContainer.getNode();
Rectangle currentRect = new Rectangle((Point) node.getLocation(), (Dimension) node.getSize());
if (currentRect.intersects(copiedRect)) {
newLocation.x += size.width;
newLocation.y += size.height;
// newLocation = computeTheDistance(index, firstIndex, newLocation);
Point tmpPoint = findLocationForNodeInProcess(newLocation, size);
return findLocationForNodeInContainerList(tmpPoint, size, index, firstIndex, copiedNode);
}
}
return newLocation;
}
if (!node.equals(copiedNode)) {
newLocation = computeTheDistance(index, firstIndex, newLocation);
}
return newLocation;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class NodesMoveCommond method undo.
@SuppressWarnings("unchecked")
@Override
public void undo() {
// remove the current selection
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
if (!multipleCommand) {
viewer.deselectAll();
}
for (NodeContainer nodeContainer : nodeContainerList) {
// remove the connections name from the list
for (Connection connection : (List<Connection>) nodeContainer.getNode().getOutgoingConnections()) {
process.removeUniqueConnectionName(connection.getName());
}
((Process) process).removeNodeContainer(nodeContainer);
}
// check that the created connections are removed, remove them if not
for (String newConnectionName : createdNames) {
if (!process.checkValidConnectionName(newConnectionName, true)) {
process.removeUniqueConnectionName(newConnectionName);
}
}
process.checkStartNodes();
process.checkProcess();
// set the old selection active
if (!multipleCommand) {
StructuredSelection s = new StructuredSelection(oldSelection);
viewer.setSelection(s);
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class SubjobContainer method refreshNodesLocation.
public void refreshNodesLocation(boolean jobletCollapsed, AbstractJobletContainer nc, int rightChangewidth, int downChangeheight, int leftChangewidth, int upChangeheight) {
JobletUtil util = new JobletUtil();
Node node = nc.getNode();
Rectangle jobletRec = new Rectangle(node.getLocation(), node.getSize());
boolean isJobletSubjob = nc.getSubjobContainer() == this;
for (NodeContainer container : nodeContainers) {
if (container.getNode().getUniqueName().equals(nc.getNode().getUniqueName())) {
continue;
}
Point nodePoint = container.getNode().getLocation().getCopy();
Rectangle jRec = util.getExpandRectangle(jobletRec);
// Rectangle jNodeConRec = util.getExpandRectangle(nodeConRec);
// Rectangle pointrec = util.getExpandRectangle(container.getNodeContainerRectangle());
jRec.width = jRec.width + rightChangewidth + leftChangewidth;
jRec.height = jRec.height + downChangeheight + upChangeheight;
// jNodeConRec.height = jNodeConRec.height + changeheight;
if (!jobletCollapsed) {
if (!nc.isUpdate()) {
Point origPoint = new Point(nodePoint.x, nodePoint.y);
pointMap.put(container.getNode().getUniqueName(), origPoint);
if (isJobletSubjob) {
if (nodePoint.x > jobletRec.x) {
nodePoint.x = nodePoint.x + rightChangewidth;
}
if (nodePoint.y > jobletRec.y) {
nodePoint.y = nodePoint.y + downChangeheight;
}
if (nodePoint.x < jobletRec.x) {
nodePoint.x = nodePoint.x - leftChangewidth;
}
if (nodePoint.y < jobletRec.y) {
nodePoint.y = nodePoint.y - upChangeheight;
}
} else {
Rectangle jobletSubRec = nc.getSubjobContainer().getSubjobContainerRectangle();
Rectangle currentRec = this.getSubjobContainerRectangle();
if (nodePoint.x > jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
nodePoint.x = nodePoint.x + rightChangewidth;
}
if (nodePoint.y > jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
nodePoint.y = nodePoint.y + downChangeheight;
}
if (nodePoint.x < jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
nodePoint.x = nodePoint.x - leftChangewidth;
}
if (nodePoint.y < jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
nodePoint.y = nodePoint.y - upChangeheight;
}
}
}
} else {
nodePoint = pointMap.get(container.getNode().getUniqueName());
// if (nodePoint.x > nodeRec.x && nodePoint.x > rightChangewidth) {
// nodePoint.x = nodePoint.x - rightChangewidth;
// }
// if (nodePoint.x < nodeRec.x) {
// nodePoint.x = nodePoint.x + leftChangewidth;
// }
// if (nodePoint.y > nodeRec.y && nodePoint.y > downChangeheight) {
// if ((nodePoint.y - downChangeheight) > (nodeRec.y + 64)) {
// nodePoint.y = nodePoint.y - downChangeheight;
// } else {
// nodePoint.y = nodeRec.y + 64;
// }
//
// }
}
container.getNode().setLocation(nodePoint);
}
}
Aggregations