use of org.talend.core.ui.editor.JobEditorInput in project tdi-studio-se by Talend.
the class AbstractTalendEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
//$NON-NLS-1$
monitor.beginTask("begin save job...", 100);
monitor.worked(10);
savePreviewPictures();
// generate the MR infor parameter.
try {
boolean isStormServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class);
boolean isMRServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class);
if (isStormServiceRegistered || isMRServiceRegistered) {
IProcess2 process = getProcess();
if (process != null) {
IRepositoryViewObject repoObjectView = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion(process.getId());
if (repoObjectView != null && repoObjectView.getProperty() != null) {
Item currentItem = repoObjectView.getProperty().getItem();
if (isMRServiceRegistered) {
IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
if (mrService.isMapReduceItem(currentItem)) {
// We make sure that the current item is a Batch item before generating the M/R
// information parameters.
mrService.generateMRInfosParameter(process);
}
}
if (isStormServiceRegistered) {
IStormProcessService stormService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
if (stormService.isStormItem(currentItem)) {
// We make sure that the current item is a Streaming item before generating the Spark
// Streaming information parameters.
stormService.generateSparkStreamingInfosParameter(process);
}
}
}
}
}
} catch (PersistenceException e) {
e.printStackTrace();
}
try {
if (getEditorInput() instanceof JobEditorInput) {
boolean saved = ((JobEditorInput) getEditorInput()).saveProcess(new SubProgressMonitor(monitor, 80), null);
if (!saved) {
monitor.setCanceled(true);
throw new InterruptedException();
}
}
getCommandStack().markSaveLocation();
setDirty(false);
boolean isneedReload = false;
for (int i = 0; i < getProcess().getGraphicalNodes().size(); i++) {
Node node = (Node) getProcess().getGraphicalNodes().get(i);
if (node.isNeedloadLib()) {
isneedReload = true;
node.setNeedLoadLib(false);
}
}
if (isneedReload) {
// / See bug 4821
((ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class)).updateModulesNeededForCurrentJob(getProcess());
}
monitor.worked(10);
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
monitor.setCanceled(true);
} finally {
monitor.done();
}
}
use of org.talend.core.ui.editor.JobEditorInput in project tdi-studio-se by Talend.
the class EditProcess method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
IRepositoryNode node = getSelectedObject();
if (node == null) {
return;
}
Property property = node.getObject().getProperty();
if (property != null) {
Assert.isTrue(property.getItem() instanceof ProcessItem);
ProcessItem processItem = (ProcessItem) property.getItem();
IWorkbenchPage page = getActivePage();
try {
final JobEditorInput fileEditorInput = getEditorInput(processItem);
checkUnLoadedNodeForProcess(fileEditorInput);
final IEditorPart editorPart = page.findEditor(fileEditorInput);
if (editorPart == null) {
fileEditorInput.setRepositoryNode(node);
page.openEditor(fileEditorInput, getEditorId(), true);
} else {
((AbstractMultiPageTalendEditor) editorPart).setReadOnly(fileEditorInput.setForceReadOnly(false));
page.activate(editorPart);
}
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (PersistenceException e) {
MessageBoxExceptionHandler.process(e);
}
}
}
use of org.talend.core.ui.editor.JobEditorInput in project tdi-studio-se by Talend.
the class SaveAsProcessAction method run.
@Override
public void run() {
SaveAsProcessWizard processWizard = new SaveAsProcessWizard(editorPart);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
if (dlg.open() == Window.OK) {
try {
// Set readonly to false since created job will always be editable.
JobEditorInput newJobEditorInput = new ProcessEditorInput(processWizard.getProcess(), true, true, false);
IWorkbenchPage page = getActivePage();
IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(newJobEditorInput.getItem().getProperty().getId(), false);
newJobEditorInput.setRepositoryNode(repositoryNode);
// close the old editor
page.closeEditor(((AbstractTalendEditor) this.editorPart).getParent(), false);
// open the new editor, because at the same time, there will update the jobSetting/componentSetting view
page.openEditor(newJobEditorInput, MultiPageTalendEditor.ID, true);
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Job could not be saved" + " : " + e.getMessage());
ExceptionHandler.process(e);
}
}
}
use of org.talend.core.ui.editor.JobEditorInput in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createContext.
private void createContext(List<Object> sourceList) {
if (sourceList.size() == 0) {
return;
}
boolean created = false;
for (Object source : sourceList) {
if (source instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) source;
Item item = sourceNode.getObject().getProperty().getItem();
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
EList context = contextItem.getContext();
Set<String> contextSet = new HashSet<String>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
EList contextParameters = ((ContextTypeImpl) obj).getContextParameter();
Iterator contextParas = contextParameters.iterator();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
String name = contextParameterType.getName();
contextSet.add(name);
}
}
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
IContextManager contextManager = process.getContextManager();
List<IContext> listContext = contextManager.getListContext();
// 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);
Set<String> addedVars = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, process.getContextManager(), false);
if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem, contextManager, contextSet)) {
// show
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
addedVarsMap.put(item.getProperty().getLabel(), contextSet);
if (ConnectionContextHelper.showContextdialog(process, contextItem, process.getContextManager(), addedVarsMap, contextSet)) {
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;
// }
// }
}
}
}
}
if (created) {
RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
}
}
use of org.talend.core.ui.editor.JobEditorInput in project tesb-studio-se by Talend.
the class CamelEditorDropTargetListener method createContext.
private void createContext() {
if (selectSourceList.size() == 0) {
return;
}
boolean created = false;
for (Object source : selectSourceList) {
if (source instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) source;
Item item = sourceNode.getObject().getProperty().getItem();
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
EList context = contextItem.getContext();
Set<String> contextSet = new HashSet<String>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
EList contextParameters = ((ContextTypeImpl) obj).getContextParameter();
Iterator contextParas = contextParameters.iterator();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
String name = contextParameterType.getName();
contextSet.add(name);
}
}
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
IContextManager contextManager = process.getContextManager();
List<IContext> listContext = contextManager.getListContext();
Set<String> addedVars = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, process.getContextManager(), false);
if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem, contextManager, contextSet)) {
// show
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
addedVarsMap.put(item.getProperty().getLabel(), contextSet);
if (ConnectionContextHelper.showContextdialog(process, contextItem, process.getContextManager(), addedVarsMap, contextSet)) {
created = true;
}
} else {
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
editor.getEditorSite().getShell(), //$NON-NLS-1$
"Adding Context", //$NON-NLS-1$
"Context \"" + contextItem.getProperty().getDisplayName() + "\" already exist.");
}
}
}
}
}
if (created) {
RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
}
}
Aggregations