use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class OpenExistVersionProcessAction method checkUnLoadedNodeForProcess.
private void checkUnLoadedNodeForProcess(JobEditorInput fileEditorInput) {
if (fileEditorInput == null || fileEditorInput.getLoadedProcess() == null) {
return;
}
IProcess2 loadedProcess = fileEditorInput.getLoadedProcess();
List<NodeType> unloadedNode = loadedProcess.getUnloadedNode();
if (unloadedNode != null && !unloadedNode.isEmpty()) {
String message = "Some Component are not loaded:\n";
for (int i = 0; i < unloadedNode.size(); i++) {
message = message + unloadedNode.get(i).getComponentName() + "\n";
}
if (!CommonsPlugin.isHeadless() && PlatformUI.isWorkbenchRunning()) {
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
final Display tmpDis = display;
final String tmpMess = message;
display.syncExec(new Runnable() {
@Override
public void run() {
Shell shell = null;
final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
shell = activeWorkbenchWindow.getShell();
} else {
if (tmpDis != null) {
shell = tmpDis.getActiveShell();
} else {
shell = new Shell();
}
}
MessageDialog.openWarning(shell, "Warning", tmpMess);
}
});
}
}
}
}
use of org.talend.core.model.process.IProcess2 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.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class JobletContainerFigure method reSelection.
private void reSelection() {
// select the start node.
if (jobletContainer.isCollapsed()) {
IProcess2 process = jobletContainer.getProcess();
if (process == null) {
return;
}
AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) process.getEditor();
Node startNode = jobletContainer.getJobletStartNode();
if (startNode != null && editor != null) {
editor.selectNode(startNode);
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ContextsView method handleDropContext.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.context.view.AbstractContextView#handleDrop(org.talend.core.model.properties.ContextItem,
* java.util.Set, org.eclipse.ui.IEditorInput)
*/
@Override
protected boolean handleDropContext(ContextItem contextItem, Set<String> contextSet, IEditorInput editorInput) {
boolean created = false;
if (editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
IContextManager contextManager = process.getContextManager();
// context group will reflect absolutely if no context variable in contextViewer
if (!ConnectionContextHelper.containsVariable(contextManager)) {
// for bug 15608
ConnectionContextHelper.addContextVarForJob(process, contextItem, contextManager);
// ConnectionContextHelper.checkAndAddContextsVarDND(contextItem,
// contextManager);
created = true;
} else {
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, contextManager, false);
if (addedContext != null && addedContext.size() > 0) {
ConnectionContextHelper.addContextVarForJob(process, contextItem, contextSet);
created = true;
}
}
}
return created;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class SaveJobBeforeRunAction method run.
@Override
public void run() {
List<? extends INode> nodes = activeProcess.getGraphicalNodes();
if (nodes.isEmpty()) {
return;
}
IEditorPart part = null;
if (activeProcess instanceof IProcess2) {
// save the editor directly.
part = ((IProcess2) activeProcess).getEditor();
} else {
// try to save current active editor
part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
}
if (part != null && part.isDirty()) {
if (part != null && part instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
editor.doSave(new NullProgressMonitor());
}
}
}
Aggregations