Search in sources :

Example 11 with JobEditorInput

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();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILibrariesService(org.talend.core.model.general.ILibrariesService) IMRProcessService(org.talend.core.service.IMRProcessService) IStormProcessService(org.talend.core.service.IStormProcessService) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) Point(org.eclipse.draw2d.geometry.Point) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IContributionItem(org.eclipse.jface.action.IContributionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 12 with JobEditorInput

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);
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProcessItem(org.talend.core.model.properties.ProcessItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property)

Example 13 with JobEditorInput

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);
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) SaveAsProcessWizard(org.talend.designer.core.ui.wizards.SaveAsProcessWizard) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 14 with JobEditorInput

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();
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) IContext(org.talend.core.model.process.IContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ContextParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) EList(org.eclipse.emf.common.util.EList) Iterator(java.util.Iterator) IProcess2(org.talend.core.model.process.IProcess2) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) ContextTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl) IContextManager(org.talend.core.model.process.IContextManager) IEditorInput(org.eclipse.ui.IEditorInput) HashSet(java.util.HashSet)

Example 15 with JobEditorInput

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();
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) IContext(org.talend.core.model.process.IContext) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ContextParameterTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl) RepositoryNode(org.talend.repository.model.RepositoryNode) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) EList(org.eclipse.emf.common.util.EList) Iterator(java.util.Iterator) IProcess2(org.talend.core.model.process.IProcess2) ContextTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl) IContextManager(org.talend.core.model.process.IContextManager) IEditorInput(org.eclipse.ui.IEditorInput) HashSet(java.util.HashSet)

Aggregations

JobEditorInput (org.talend.core.ui.editor.JobEditorInput)15 IProcess2 (org.talend.core.model.process.IProcess2)8 ProcessItem (org.talend.core.model.properties.ProcessItem)8 Item (org.talend.core.model.properties.Item)6 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 PersistenceException (org.talend.commons.exception.PersistenceException)5 IRepositoryNode (org.talend.repository.model.IRepositoryNode)5 CoreException (org.eclipse.core.runtime.CoreException)4 IEditorPart (org.eclipse.ui.IEditorPart)4 PartInitException (org.eclipse.ui.PartInitException)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 IEditorInput (org.eclipse.ui.IEditorInput)3 IContextManager (org.talend.core.model.process.IContextManager)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Set (java.util.Set)2