use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method getAllMiddleConnections.
private Map<List<INode>, List<IConnection>> getAllMiddleConnections() {
Map<List<INode>, List<IConnection>> middConnMap = new HashMap<List<INode>, List<IConnection>>();
Process process;
if (nodeList.size() > 0) {
process = (Process) nodeList.get(0).getProcess();
} else {
process = (Process) connectionList.get(0).getSource().getProcess();
}
List<? extends INode> nodes = process.getGraphicalNodes();
List<INode> jobletandnodeList = new ArrayList<INode>();
for (INode node : nodes) {
if (((Node) node).isJoblet() && !((Node) node).getNodeContainer().isCollapsed() && (((Node) node).getNodeContainer() instanceof AbstractJobletContainer)) {
for (NodeContainer nc : ((AbstractJobletContainer) ((Node) node).getNodeContainer()).getNodeContainers()) {
jobletandnodeList.add(nc.getNode());
}
} else {
jobletandnodeList.add(node);
}
}
for (INode node : jobletandnodeList) {
if (node.isActivate()) {
Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
Set<Entry<IConnection, Node>> outSet = outMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> outIte = outSet.iterator();
boolean haveActivateTarget = false;
List<INode> nodeList = new ArrayList<INode>();
List<IConnection> connList = new ArrayList<IConnection>();
while (outIte.hasNext()) {
Entry<IConnection, Node> en = outIte.next();
Node enNode = en.getValue();
IConnection enConn = en.getKey();
if (enNode != null) {
haveActivateTarget = true;
if (!nodeList.contains(node)) {
nodeList.add(node);
}
if (!nodeList.contains(enNode)) {
nodeList.add(enNode);
}
}
if (enConn != null && !connList.contains(enConn)) {
connList.add(enConn);
}
}
if (!haveActivateTarget) {
outMiddleNodes.clear();
}
if (!nodeList.isEmpty() && !connList.isEmpty()) {
Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
boolean exist = false;
while (middIte.hasNext()) {
Entry<List<INode>, List<IConnection>> entry = middIte.next();
List<INode> enNodeList = entry.getKey();
if (enNodeList.size() == 2 && nodeList.size() == 2) {
if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
exist = true;
} else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
exist = true;
}
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
}
}
Set<Entry<IConnection, Node>> inSet = inMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> inIte = inSet.iterator();
boolean haveActivateSource = false;
nodeList = new ArrayList<INode>();
connList = new ArrayList<IConnection>();
while (inIte.hasNext()) {
Entry<IConnection, Node> en = inIte.next();
Node enNode = en.getValue();
IConnection enConn = en.getKey();
if (enNode != null) {
haveActivateSource = true;
if (!nodeList.contains(node)) {
nodeList.add(node);
}
if (!nodeList.contains(enNode)) {
nodeList.add(enNode);
}
}
if (enConn != null && !connList.contains(enConn)) {
connList.add(enConn);
}
}
if (!haveActivateSource) {
inMiddleNodes.clear();
}
if (!nodeList.isEmpty() && !connList.isEmpty()) {
Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
boolean exist = false;
while (middIte.hasNext()) {
Entry<List<INode>, List<IConnection>> entry = middIte.next();
List<INode> enNodeList = entry.getKey();
if (enNodeList.size() == 2 && nodeList.size() == 2) {
if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
exist = true;
} else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
exist = true;
}
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
}
}
}
}
return middConnMap;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class NodeProgressBarPart 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();
NodeProgressBarFigure progressFig = (NodeProgressBarFigure) this.getFigure();
Point loc = node.getLocation().getCopy();
NodeError nodeError = node.getNodeError();
Dimension size = progressFig.getSize();
loc.x = loc.x + (node.getSize().width - size.width) / 2 + size.width / 7;
loc.y = loc.y + node.getSize().height + nodeLabel.getLabelSize().height + nodeError.getErrorSize().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 NodeResizableEditPolicy method getResizeCommand.
@Override
protected Command getResizeCommand(ChangeBoundsRequest request) {
Object parent = getHost().getParent().getModel();
if (!(parent instanceof NodeContainer)) {
return null;
}
Node node = (Node) getHost().getModel();
if (node.isReadOnly()) {
return null;
}
TalendScalableFreeformRootEditPart rootEditPart = (TalendScalableFreeformRootEditPart) getHost().getRoot();
double scale = 1 / rootEditPart.getZoomManager().getZoom();
return new ResizeNodeCommand(node, new Dimension(node.getSize().width + request.getSizeDelta().getScaled(scale).width, node.getSize().height + request.getSizeDelta().getScaled(scale).height));
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method getCreateCommand.
// ------------------------------------------------------------------------
// Abstract methods from LayoutEditPolicy
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
*/
@Override
protected Command getCreateCommand(final CreateRequest request) {
if (((Process) getHost().getModel()).isReadOnly()) {
return null;
}
Rectangle constraint = (Rectangle) getConstraintFor(request);
Command command = null;
if (Note.class.equals(request.getNewObjectType())) {
command = new CreateNoteCommand((Process) getHost().getModel(), (Note) request.getNewObject(), constraint.getLocation());
} else if (request.getNewObject() instanceof Node) {
Node node = (Node) request.getNewObject();
NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
command = new CreateNodeContainerCommand((Process) getHost().getModel(), nodeContainer, constraint.getLocation());
}
return command;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method createChangeConstraintCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
@Override
public Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
// return a command to move the part to the location given by the constraint
if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof NoteEditPart) {
if (((Note) child.getModel()).isReadOnly()) {
return null;
}
MoveNoteCommand locationCommand = new MoveNoteCommand((Note) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof SubjobContainerPart) {
SubjobContainer sjc = (SubjobContainer) child.getModel();
Point sjcLocation = sjc.getSubjobContainerRectangle().getLocation();
Point translationNeeded = new Point(((Rectangle) constraint).getLocation().x - sjcLocation.x, ((Rectangle) constraint).getLocation().y - sjcLocation.y);
CompoundCommand cc = new CompoundCommand();
for (NodeContainer nc : sjc.getNodeContainers()) {
if (nc.isReadOnly()) {
return null;
}
IGraphicalNode node = nc.getNode();
Point nodeLocation = node.getLocation();
MoveNodeCommand locationCommand = new MoveNodeCommand(nc.getNode(), nodeLocation.getTranslated(translationNeeded));
cc.add(locationCommand);
}
return cc;
}
return null;
}
Aggregations