use of org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer in project tdi-studio-se by Talend.
the class GEFPasteAction method canPasteJobletNode.
private boolean canPasteJobletNode(IProcess2 curNodeProcess, Node copiedNode) {
Item temIten = curNodeProcess.getProperty().getItem();
if (!(temIten instanceof JobletProcessItem)) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
if (service.isJobletInOutComponent(copiedNode)) {
MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Paste Error", "Can not paste joblet component in job!");
return false;
}
}
}
Node jobletNode = (Node) copiedNode.getJobletNode();
AbstractJobletContainer jnc = (AbstractJobletContainer) jobletNode.getNodeContainer();
List<NodeContainer> ncs = jnc.getNodeContainers();
if (ncs != null) {
for (NodeContainer nc : ncs) {
if (nc.getNode() == copiedNode) {
return true;
}
}
}
return false;
}
use of org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer 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.jobletcontainer.AbstractJobletContainer in project tdi-studio-se by Talend.
the class UpdateJobletNodeCommand method execute.
/**
* this function is moved from the method updateGraphicalNodes.
*/
@SuppressWarnings("unchecked")
@Override
public void execute() {
Object job = result.getJob();
if (job == null) {
return;
}
if (job instanceof Process) {
Process process = (Process) job;
Object parameter = result.getParameter();
// update property change events
if (parameter instanceof PropertyChangeEvent) {
PropertyChangeEvent evt = (PropertyChangeEvent) parameter;
updatePropertyChangeEvents(process, evt);
} else {
//
IUpdateItemType updateType = result.getUpdateType();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case JOBLET_RENAMED:
if (!(parameter instanceof List)) {
return;
}
List<Object> params = (List<Object>) parameter;
if (params.size() != 3) {
return;
}
final String oldName = (String) params.get(1);
final String newName = (String) params.get(2);
updateRenaming(process, oldName, newName);
break;
case RELOAD:
List<Node> jobletNodes = (List<Node>) result.getUpdateObject();
if (jobletNodes != null && !jobletNodes.isEmpty()) {
for (Node node : jobletNodes) {
IComponent newComponent = ComponentsFactoryProvider.getInstance().get(node.getComponent().getName(), process.getComponentsType());
if (newComponent == null) {
continue;
}
// node loaded is from loading in the check.
// need to get the instance from process, or this process will be done with wrong
// instance
// of node.
Node currentNode = getOriginalNodeFromProcess(node);
boolean neesPro = needPropagate(currentNode);
if (currentNode.isJoblet() || currentNode.isMapReduce()) {
// maybe no need modify
List<IElementParameter> tempList = new ArrayList<IElementParameter>(currentNode.getElementParameters());
if (result.isNeedReloadJoblet()) {
reloadNode(currentNode, newComponent);
}
if (currentNode.getNodeContainer() instanceof AbstractJobletContainer) {
for (IElementParameter para : tempList) {
currentNode.getElementParameter(para.getName()).setValue(para.getValue());
}
((AbstractJobletContainer) currentNode.getNodeContainer()).updateJobletNodes(true);
}
} else {
reloadNode(currentNode, newComponent);
}
propagate(currentNode, neesPro);
}
process.checkProcess();
}
break;
case JOBLET_SCHEMA:
updateSchema(process, (Node) result.getUpdateObject());
break;
default:
}
}
// else { // for extension
}
}
}
use of org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer 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.jobletcontainer.AbstractJobletContainer in project tdi-studio-se by Talend.
the class NodeContainer method prepareStatus.
private Rectangle prepareStatus(Point nodeLocation, Dimension nodeSize) {
Rectangle statusRectangle = null;
Rectangle breakpointRectangle, warningRectangle, infoRectangle, parallelLocationRectangle, windowLocationRectangle, validationRuleRectangle, collapseRectangle;
int status = node.getStatus();
if ((status & Process.BREAKPOINT_STATUS) != 0) {
breakpointLocation.x = nodeLocation.x - breakpointSize.width;
breakpointLocation.y = nodeLocation.y - breakpointSize.height;
breakpointRectangle = new Rectangle(breakpointLocation, breakpointSize);
statusRectangle = breakpointRectangle;
}
if ((status & Process.ERROR_STATUS) != 0) {
errorLocation.x = nodeLocation.x + nodeSize.width;
errorLocation.y = nodeLocation.y - errorSize.height;
errorRectangle = new Rectangle(errorLocation, errorSize);
if (statusRectangle == null) {
statusRectangle = errorRectangle;
} else {
statusRectangle.union(errorRectangle);
}
}
if ((status & Process.WARNING_STATUS) != 0) {
warningLocation.x = nodeLocation.x + nodeSize.width;
warningLocation.y = nodeLocation.y - warningSize.height;
warningRectangle = new Rectangle(warningLocation, warningSize);
if (statusRectangle == null) {
statusRectangle = warningRectangle;
} else {
statusRectangle.union(warningRectangle);
}
}
if (this instanceof AbstractJobletContainer) {
Dimension collapseSize = new Dimension(20, 20);
collapseLocation.x = nodeLocation.x - 20;
collapseLocation.y = nodeLocation.y - collapseSize.height;
collapseRectangle = new Rectangle(collapseLocation, collapseSize);
if (statusRectangle == null) {
Point extendPoint = new Point();
extendPoint.x = nodeLocation.x + nodeSize.width;
extendPoint.y = nodeLocation.y - warningSize.height;
Rectangle extendRectangle = new Rectangle(extendPoint, warningSize);
statusRectangle = extendRectangle;
}
statusRectangle.union(collapseRectangle);
}
if ((status & Process.INFO_STATUS) != 0) {
infoLocation.x = nodeLocation.x + nodeSize.width;
infoLocation.y = nodeLocation.y - infoSize.height;
infoRectangle = new Rectangle(infoLocation, infoSize);
if (statusRectangle == null) {
statusRectangle = infoRectangle;
} else {
statusRectangle.union(infoRectangle);
}
}
if ((status & Process.VALIDATION_RULE_STATUS) != 0) {
validationRuleLocation.x = nodeLocation.x + nodeSize.width / 2 + nodeSize.width / 4;
validationRuleLocation.y = nodeLocation.y - validationRuleSize.height / 2;
validationRuleRectangle = new Rectangle(validationRuleLocation, validationRuleSize);
if (statusRectangle == null) {
statusRectangle = validationRuleRectangle;
} else {
statusRectangle.union(validationRuleRectangle);
}
}
if (node.isErrorFlag()) {
markLocation.x = nodeLocation.x - nodeSize.width / 2;
markLocation.y = nodeLocation.y;
errorMarkLocation.x = nodeLocation.x - (errorMarkSize.width - nodeSize.width) / 2;
errorMarkLocation.y = markLocation.y - errorMarkSize.height;
errorMarkRectangle = new Rectangle(errorMarkLocation, errorMarkSize);
if (statusRectangle == null) {
statusRectangle = errorMarkRectangle;
} else {
statusRectangle.union(errorMarkRectangle);
}
}
boolean parallelize = false;
IElementParameter enableParallelizeParameter = node.getElementParameter(EParameterName.PARALLELIZE.getName());
if (enableParallelizeParameter != null) {
parallelize = (Boolean) enableParallelizeParameter.getValue();
}
if (parallelize) {
parallelLocation.x = nodeLocation.x - parallelSize.width;
parallelLocation.y = nodeLocation.y - parallelSize.height;
parallelLocationRectangle = new Rectangle(parallelLocation, parallelSize);
if (statusRectangle == null) {
statusRectangle = parallelLocationRectangle;
} else {
statusRectangle.union(parallelLocationRectangle);
}
}
IElementParameter window = node.getElementParameter(EParameterName.WINDOW_DURATION.getName());
String windowDuration = null;
if (window != null) {
windowDuration = (String) window.getValue();
}
if (windowDuration != null) {
windowLocation.x = nodeLocation.x - ((nodeLocation.x + (windowSize.width / 2)) - (nodeLocation.x + (nodeSize.width / 2)));
windowLocation.y = nodeLocation.y - windowSize.height;
windowLocationRectangle = new Rectangle(windowLocation, windowSize);
if (statusRectangle == null) {
statusRectangle = windowLocationRectangle;
} else {
statusRectangle.union(windowLocationRectangle);
}
}
return statusRectangle;
}
Aggregations