use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainerLayoutEditPolicy method getCreateCommand.
@Override
protected Command getCreateCommand(CreateRequest request) {
Rectangle constraint = (Rectangle) getConstraintFor(request);
Process linkedProcess = (Process) ((JobletContainer) getHost().getModel()).getNode().getProcess();
Command command = null;
if (Note.class.equals(request.getNewObjectType())) {
command = new CreateNoteCommand(linkedProcess, (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(linkedProcess, nodeContainer, constraint.getLocation());
}
return command;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainerPart method createFigure.
@Override
protected IFigure createFigure() {
IFigure layoutFigure = getLayer(TalendScalableFreeformRootEditPart.MAP_REDUCE_LAYER);
JobletContainerFigure JobletContainerFigure = new JobletContainerFigure((JobletContainer) this.getModel(), layoutFigure);
Node node = ((NodeContainer) getModel()).getNode();
JobletContainerFigure.updateStatus(node.getStatus());
return JobletContainerFigure;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class NodeErrorEditPart method performRequest.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
*/
@Override
public void performRequest(final Request request) {
if (request.getType().equals("open")) {
//$NON-NLS-1$
Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
if (node.isErrorFlag()) {
Shell shell = getViewer().getControl().getShell();
ErrorMessageDialog dialog = new ErrorMessageDialog(new Shell(shell), node);
dialog.open();
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class SubjobContainer method deleteNodeContainer.
/**
* DOC ycbai Comment method "deleteNodeContainer".
*
* @param nodeUniqueName
* @return
*/
public boolean deleteNodeContainer(String nodeUniqueName) {
boolean deleted = false;
if (nodeUniqueName == null) {
return deleted;
}
List<NodeContainer> nContainers = getNodeContainers();
Iterator<NodeContainer> nodeContainerIter = nContainers.iterator();
while (nodeContainerIter.hasNext()) {
NodeContainer nc = nodeContainerIter.next();
if (nodeUniqueName.equals(nc.getNode().getUniqueName())) {
nodeContainerIter.remove();
deleted = true;
}
}
if (deleted) {
updateSubjobContainer();
}
return deleted;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class SubjobContainer method getSubjobContainerRectangle.
/**
* DOC nrousseau Comment method "getSubjobContainerRectangle".
*
* @return
*/
public Rectangle getSubjobContainerRectangle() {
Rectangle totalRectangle = null;
boolean collapsed = isCollapsed();
boolean isTestContainer = false;
ITestContainerGEFService testContainerService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
if (testContainerService != null) {
isTestContainer = testContainerService.isTestContainer(this.process);
}
}
// boolean hasJoblet = false;
for (NodeContainer container : nodeContainers) {
Rectangle curRect = null;
if (container instanceof AbstractJobletContainer) {
curRect = ((AbstractJobletContainer) container).getJobletContainerRectangle();
} else if (isTestContainer && testContainerService != null) {
curRect = testContainerService.getJunitContainerRectangle(container);
} else {
curRect = container.getNodeContainerRectangle();
}
if ((curRect.x + curRect.width) == (container.getNode().getPosX() + container.getNode().getSize().width)) {
curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE, curRect.getSize().height);
}
if ((curRect.y + curRect.height) == (container.getNode().getPosY() + container.getNode().getSize().height)) {
curRect.setSize(curRect.getSize().width, curRect.getSize().height + TalendEditor.GRID_SIZE);
}
if (curRect.y == container.getNode().getPosY()) {
// means have totally no other status or such on the top of the node in the NodeContainerFigure, then we
// add one more space on the top of the subjob
// this could be done only once, but to simplify the calculation, just do for every node
curRect.setLocation(curRect.getLocation().x, curRect.getLocation().y - TalendEditor.GRID_SIZE);
curRect.setSize(curRect.getSize().width, curRect.getSize().height + TalendEditor.GRID_SIZE);
}
if (curRect.x == container.getNode().getPosX()) {
// means if the node container figure is just at the border of the size of the component
// then we add one more space on the left of the component, just to avoid have one subjob background
// "too small" (too close to component)
// this could be done only once, but to simplify the calculation, just do for every node
curRect.setLocation(curRect.getLocation().x - TalendEditor.GRID_SIZE, curRect.getLocation().y);
curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE, curRect.getSize().height);
}
if (collapsed && totalRectangle == null) {
totalRectangle = curRect.getCopy();
} else if (!collapsed) {
if (totalRectangle == null) {
totalRectangle = curRect.getCopy();
} else {
totalRectangle = totalRectangle.getUnion(curRect);
}
} else if (collapsed && testContainerService != null && testContainerService.isJunitContainer(container)) {
INode startNode = this.getSubjobStartNode().getJunitNode();
INode containerNode = container.getNode().getJunitNode();
if (startNode != null && containerNode != null && startNode == containerNode) {
totalRectangle = testContainerService.getJunitContainerRectangle(container).getCopy();
}
}
if (isTestContainer && !collapsed) {
if (curRect.x == totalRectangle.x) {
totalRectangle.setLocation(totalRectangle.getLocation().x - TalendEditor.GRID_SIZE, totalRectangle.getLocation().y);
totalRectangle.setSize(totalRectangle.getSize().width + TalendEditor.GRID_SIZE, totalRectangle.getSize().height);
}
if (curRect.y == totalRectangle.y) {
totalRectangle.setLocation(totalRectangle.getLocation().x, totalRectangle.getLocation().y - TalendEditor.GRID_SIZE);
totalRectangle.setSize(totalRectangle.getSize().width, totalRectangle.getSize().height + TalendEditor.GRID_SIZE);
}
}
}
if (totalRectangle == null) {
return null;
}
Point location = totalRectangle.getLocation();
Point newLocation = new Point();
newLocation.x = (location.x / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
newLocation.y = (location.y / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
// bug 5158
if (newLocation.y <= 0 && location.y < 0) {
newLocation.y = newLocation.y - TalendEditor.GRID_SIZE;
}
if (newLocation.x <= 0 && location.x < 0) {
newLocation.x = newLocation.x - TalendEditor.GRID_SIZE;
}
totalRectangle.setLocation(newLocation);
Dimension diff = location.getDifference(newLocation);
Dimension size = totalRectangle.getSize().expand(diff);
if ((size.height % TalendEditor.GRID_SIZE) == 0) {
size.height = (size.height / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
} else {
size.height = ((size.height / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
}
if ((size.width % TalendEditor.GRID_SIZE) == 0) {
size.width = (size.width / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
} else {
size.width = ((size.width / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
}
// if (hasJoblet) {
// size.width = size.width + TalendEditor.GRID_SIZE;
// }
totalRectangle.setSize(size);
return totalRectangle;
}
Aggregations