use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ActiveProcessTracker method getJobFromActivatedEditor.
public IProcess2 getJobFromActivatedEditor(IWorkbenchPart part) {
IWorkbenchPart testedPart = part;
if (!(part instanceof AbstractMultiPageTalendEditor)) {
testedPart = part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
}
if (testedPart instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) testedPart;
mpte.setName();
IProcess2 process = mpte.getTalendEditor().getProcess();
return process;
} else {
// No editor
}
return null;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ActiveProcessTracker method partOpened.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void partOpened(IWorkbenchPart part) {
boolean existedJobOpened = false;
if (part instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
if (mpte.isJobAlreadyOpened()) {
mpte.updateChildrens();
// close the first editor and keep the new one. (so only one will remain)
IEditorReference[] ref = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditors(mpte.getEditorInput(), mpte.getEditorId(), IWorkbenchPage.MATCH_INPUT);
IEditorPart editorPart = ref[0].getEditor(false);
editorPart.doSave(new NullProgressMonitor());
((AbstractMultiPageTalendEditor) editorPart).setKeepPropertyLocked(true);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editorPart, false);
existedJobOpened = true;
}
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class)) {
CorePlugin.getDefault().getDiagramModelService().handleNewEditorAction(part);
}
}
IProcess2 process = getJobFromActivatedEditor(part);
if (part instanceof AbstractMultiPageTalendEditor && process instanceof Process) {
((Process) process).setEditor((AbstractMultiPageTalendEditor) part);
}
if (process != null && currentProcess != process && lastProcessOpened != process) {
lastProcessOpened = process;
addJobInProblemView(process);
} else if (existedJobOpened) {
currentProcess = process;
for (IJobTrackerListener listener : jobTrackerListeners) {
listener.focusOnJob(process);
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ActiveProcessTracker method partBroughtToTop.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void partBroughtToTop(IWorkbenchPart part) {
IProcess2 process = getJobFromActivatedEditor(part);
if (process != null && currentProcess != process) {
changedProcess = true;
currentProcess = process;
Contexts.setTitle(process.getLabel());
setContextsView(process, part);
// setStatsAndLogsView(process);
JobSettings.switchToCurJobSettingsView();
refreshProcessView();
for (IJobTrackerListener listener : jobTrackerListeners) {
listener.focusOnJob(process);
}
// if (process instanceof Process) {
// Process p = (Process) process;
// if (!p.isReadOnly() && p.isActivate()) {
// p.checkDifferenceWithRepository();
// }
// }
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method covertJobscriptOnPageChange.
private void covertJobscriptOnPageChange() {
try {
boolean isDirty = jobletEditor.isDirty();
jobletEditor.doSave(null);
IProcess2 oldProcess = getProcess();
ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
Item item = oldProcess.getProperty().getItem();
ProcessType processType = null;
if (item instanceof ProcessItem) {
processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
} else if (item instanceof JobletProcessItem) {
processType = n.convertJobletDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
}
if (item instanceof ProcessItem) {
((Process) oldProcess).updateProcess(processType);
} else if (item instanceof JobletProcessItem) {
((Process) oldProcess).updateProcess(processType);
}
oldProcess.getUpdateManager().updateAll();
designerEditor.setDirty(isDirty);
List<Node> nodes = (List<Node>) oldProcess.getGraphicalNodes();
List<Node> newNodes = new ArrayList<Node>();
newNodes.addAll(nodes);
for (Node node : newNodes) {
node.getProcess().checkStartNodes();
node.checkAndRefreshNode();
IElementParameter ep = node.getElementParameter("ACTIVATE");
if (ep != null && ep.getValue().equals(Boolean.FALSE)) {
node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
} else if (ep != null && ep.getValue().equals(Boolean.TRUE)) {
node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
}
for (IElementParameter param : node.getElementParameters()) {
if (!param.getChildParameters().isEmpty()) {
if (param.getValue() != null && param.getValue() instanceof String && ((String) param.getValue()).contains(":")) {
String[] splited = ((String) param.getValue()).split(":");
String childNameNeeded = splited[0].trim();
String valueChild = TalendQuoteUtils.removeQuotes(splited[1].trim());
if (param.getChildParameters().containsKey(childNameNeeded)) {
param.getChildParameters().get(childNameNeeded).setValue(valueChild);
}
}
}
}
if (node.getNodeContainer() instanceof JobletContainer) {
JobletContainer jc = (JobletContainer) node.getNodeContainer();
if (node.isMapReduceStart()) {
//$NON-NLS-1$
jc.updateState("UPDATE_STATUS", "", jc.getPercentMap(), jc.getPercentReduce());
}
}
}
} catch (PersistenceException e) {
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractProcessAction method checkUnLoadedNodeForProcess.
public 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() {
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);
}
});
}
}
}
}
Aggregations