use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method updateItemsVersion.
protected void updateItemsVersion() {
List<ItemVersionObject> JobsOpenedInEditor = new ArrayList<ItemVersionObject>();
List<ItemVersionObject> closedJobs = new ArrayList<ItemVersionObject>();
boolean hasJobOpenedInEditor = false;
StringBuilder builder = new StringBuilder();
for (ItemVersionObject object : checkedObjects) {
if (RepositoryManager.isOpenedItemInEditor(object.getRepositoryNode().getObject())) {
hasJobOpenedInEditor = true;
JobsOpenedInEditor.add(object);
//$NON-NLS-1$
builder.append(object.getRepositoryNode().getObject().getLabel() + ", ");
} else {
closedJobs.add(object);
}
}
if (builder.length() > 0) {
builder.delete(builder.length() - 2, builder.length());
}
if (hasJobOpenedInEditor) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.WarningTitle2"), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.openedInEditorMessage", builder.toString()));
IWorkbenchWindow workBench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workBench != null) {
IWorkbenchPage page = workBench.getActivePage();
IEditorReference[] editorRefs = page.getEditorReferences();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreUIService.class)) {
IDesignerCoreUIService service = (IDesignerCoreUIService) GlobalServiceRegister.getDefault().getService(IDesignerCoreUIService.class);
if (service != null) {
for (IEditorReference editorRef : editorRefs) {
IEditorPart editor = editorRef.getEditor(false);
if (editor instanceof IMultiPageTalendEditor) {
IProcess2 process = ((IMultiPageTalendEditor) editor).getProcess();
String version = null;
for (ItemVersionObject object : JobsOpenedInEditor) {
if (object.getItem().getProperty().getId().equals(process.getId())) {
version = object.getNewVersion();
break;
}
}
if (version != null) {
String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(process.getProperty().getVersion());
if (version.equals(jobDefaultVersion)) {
// if default, set null to remove key from property.
version = null;
}
Command command = service.crateMavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, version);
if (process instanceof IGEFProcess) {
service.executeCommand((IGEFProcess) process, command);
}
}
}
}
}
}
}
}
final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
RepositoryWorkUnit<Object> rwu = new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
project, //$NON-NLS-1$
"Update items Maven version") {
@Override
protected void run() throws LoginException, PersistenceException {
//$NON-NLS-1$
monitor.beginTask("Update items Maven version", closedJobs.size());
for (ItemVersionObject object : closedJobs) {
final Item item = object.getItem();
Property itemProperty = item.getProperty();
MavenVersionUtils.setItemMavenVersion(itemProperty, object.getNewVersion());
monitor.subTask(itemProperty.getLabel());
FACTORY.save(project, itemProperty);
monitor.worked(1);
}
try {
FACTORY.saveProject(project);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
};
rwu.setAvoidUnloadResources(true);
rwu.executeRun();
monitor.done();
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException | InterruptedException e) {
ExceptionHandler.process(e);
}
}
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;
}
Aggregations