@Override public void run() { boolean display = isChecked(); getGlobalStore().setValue(TalendDesignerPrefConstants.DISPLAY_SUBJOBS, display); IEditorReference[] editorParts = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); for (IEditorReference reference : editorParts) { if (!(reference.getId().equals(MultiPageTalendEditor.ID) || reference.getId().equals(JOBLET_ID) || MAP_REDUCE_MULTIPAGE_EDITOR_ID.equals(reference.getId()))) { continue; } IEditorPart editorPart = reference.getEditor(false); if (editorPart == null) { continue; } if (editorPart instanceof AbstractMultiPageTalendEditor) { AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) editorPart; IProcess2 process = editor.getTalendEditor().getProcess(); if (process == null) { continue; } List<? extends ISubjobContainer> subjobs = process.getSubjobContainers(); for (ISubjobContainer subjobContainer : subjobs) { subjobContainer.updateSubjobDisplay(); } } } }
/** * Set the process on wich we are selecting context. * * @param process The process. */ public void setProcess(final IProcess2 process) { // Select the first context if (process != null) { if (process.equals(this.process)) { // check the ContextParameter is same or not , avoid to set two times the same object . if (checkIsSameContextParameter()) { return; } } if (this.process != null) { // remove old listeners this.process.getContextManager().removeContextListener(contextListener); contextComboViewer.removeSelectionChangedListener(contextComboListener); } this.process = process; contextComboViewer.getControl().setEnabled(true); getInformationsFromContextManager(process.getContextManager()); contextListener = new IContextListener() { @Override public void contextsChanged() { if (!ProcessContextComposite.this.isDisposed()) { getInformationsFromContextManager(process.getContextManager()); } // contextComboViewer.refresh(); } }; this.process.getContextManager().addContextListener(contextListener); contextComboViewer.addSelectionChangedListener(contextComboListener); } else { if (this.process == null) { // there is no process already return; } if (this.process != null) { this.process.getContextManager().removeContextListener(contextListener); this.process = null; contextListener = null; } contextComboViewer.getControl().setEnabled(false); contextComboViewer.removeSelectionChangedListener(contextComboListener); contextComboViewer.setInput(null); contextTableViewer.setInput(null); } }
/* * check same ContextParameter or not. */ private boolean checkIsSameContextParameter() { List<ContextItem> allContextItem = ContextUtils.getAllContextItem(); for (IContext context : process.getContextManager().getListContext()) { for (IContextParameter param : context.getContextParameterList()) { if (allContextItem != null) { ContextItem contextItem = ContextUtils.getContextItemById(allContextItem, param.getSource()); ContextType contextType = ContextUtils.getContextTypeByName(contextItem, context.getName(), true); ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(contextType, param.getName()); if (!ContextUtils.samePropertiesForContextParameter(param, contextParameterType)) { return false; } // if don't open the job to run it(not use the "Detect and update all jobs"), will show // UpdateDetectionDialog to update the context ,after updated the item, the // contextComboViewer still // set the old one , so need refresh. IContext runJobViewContext = getSelectedContext(); if (runJobViewContext != null) { for (IContextParameter tempContext : runJobViewContext.getContextParameterList()) { if (tempContext.getName().equals(contextParameterType.getName()) && !ContextUtils.samePropertiesForContextParameter( tempContext, contextParameterType)) { return false; } } } } } } return true; }
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); } }); } } } }
/** * DOC zli Comment method "loadProjectsettingsParameters". * * @param parameters */ public static void loadProjectsettingsParameters(ParametersType parameters) { IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService(); designerCoreService.switchToCurJobSettingsView(); List<IProcess2> openedProcess = designerCoreService.getOpenedProcess(reference); for (IProcess2 process : openedProcess) { if (process instanceof Element) { Element processElem = (Element) process; ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null); } process.setNeedRegenerateCode(true); } IProxyRepositoryFactory repositoryFactory = CorePlugin.getDefault().getProxyRepositoryFactory(); IProcess process = null; try { List<IRepositoryViewObject> all = repositoryFactory.getAll(ERepositoryObjectType.PROCESS); for (IRepositoryViewObject object : all) { if (!openedProcess.contains(object)) { Item item = object.getProperty().getItem(); if (item instanceof ProcessItem) { process = designerCoreService.getProcessFromProcessItem((ProcessItem) item); if (process != null && process instanceof IProcess2) { IProcess2 process2 = (IProcess2) process; if (process2 instanceof Element) { Element processElem = (Element) process2; ElementParameter2ParameterType.loadElementParameters(processElem, parameters, null); ProcessType processType = process2.saveXmlFile(); if (processType != null) { ((ProcessItem) item).setProcess(processType); } repositoryFactory.save(item); } } } } } } catch (Exception e) { e.printStackTrace(); } }
protected void getInformationsFromContextManager(IContextManager contextManager) { List<IContext> internalContextList = new ArrayList<IContext>(); IContext newSelectedCopiedContext = null; // if (!contextComboViewer.getSelection().isEmpty()) { // oldSelectedCopiedContext = (IContext) ((StructuredSelection) // contextComboViewer.getSelection()).getFirstElement(); // } if (process != null && process.getLastRunContext() != null) { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (process.getLastRunContext().getName().equals(context.getName())) { newSelectedCopiedContext = copiedContext; } } } else { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (contextManager.getDefaultContext().equals(context)) { newSelectedCopiedContext = copiedContext; } } } Collections.sort(internalContextList, new ContextCompare()); contextComboViewer.setInput(internalContextList); ProcessManager processManager = ProcessManager.getInstance(); if (newSelectedCopiedContext != null) { setContextComboSelection(new StructuredSelection(newSelectedCopiedContext)); processManager.setSelectContext(newSelectedCopiedContext); contextTableViewer.setInput(newSelectedCopiedContext.getContextParameterList()); } else { IContext element = internalContextList.get(0); processManager.setSelectContext(element); setContextComboSelection(new StructuredSelection(element)); contextTableViewer.setInput(element.getContextParameterList()); } }
@Override public void selectionChanged(final SelectionChangedEvent event) { Object input = null; if (!event.getSelection().isEmpty()) { IContext selectedContext = (IContext) ((IStructuredSelection) event.getSelection()).getFirstElement(); input = selectedContext.getContextParameterList(); process.setLastRunContext(selectedContext); rubjobManager.setSelectContext(selectedContext); // see bug 0003924 processNeedGenCode(process); } contextTableViewer.setInput(input); }
@Override public void execute() { if (findProcessProvider != null) { oldImage = findProcessProvider.getIcons(process); findProcessProvider.setIcons((IProcess) elem, newImage); } if (changeCmd != null) { changeCmd.execute(); } // see bug 15062 final Item item = process.getProperty().getItem(); if (item instanceof JobletProcessItem) { String label = item.getProperty().getLabel(); CoreImageProvider.removeComponentImage(label); } // end }
/** bqian Comment method "processNeedGenCode". */ private static void processNeedGenCode(IProcess process) { if (process instanceof IProcess2) { ((IProcess2) process).setNeedRegenerateCode(true); } }