Search in sources :

Example 6 with JobEditorInput

use of org.talend.core.ui.editor.JobEditorInput in project tdi-studio-se by Talend.

the class TalendImportUtil method openJobs.

private static void openJobs(List<IRepositoryNode> nodes) {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    for (IRepositoryNode node : nodes) {
        Property property = node.getObject().getProperty();
        if (property != null) {
            Item item = property.getItem();
            if (!(item instanceof ProcessItem)) {
                continue;
            }
            try {
                ProcessItem processItem = (ProcessItem) item;
                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 (Throwable e) {
                CommonExceptionHandler.process(e);
            }
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProcessItem(org.talend.core.model.properties.ProcessItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) Property(org.talend.core.model.properties.Property)

Example 7 with JobEditorInput

use of org.talend.core.ui.editor.JobEditorInput in project tesb-studio-se by Talend.

the class SaveAsRoutesAction method run.

@Override
public void run() {
    SaveAsRoutesWizard processWizard = new SaveAsRoutesWizard((JobEditorInput) editorPart.getEditorInput());
    WizardDialog dlg = new WizardDialog(editorPart.getSite().getShell(), processWizard);
    if (dlg.open() == Window.OK) {
        try {
            // Set readonly to false since created routes will always be editable.
            JobEditorInput newRoutesEditorInput = new CamelProcessEditorInput(processWizard.getProcess(), true, true, false);
            IWorkbenchPage page = editorPart.getSite().getPage();
            IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(newRoutesEditorInput.getItem().getProperty().getId(), false);
            newRoutesEditorInput.setRepositoryNode(repositoryNode);
            // close the old editor
            page.closeEditor(editorPart, false);
            // open the new editor, because at the same time, there will update the routes view
            page.openEditor(newRoutesEditorInput, CamelMultiPageTalendEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(editorPart.getSite().getShell(), "Error", "Routes could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CamelProcessEditorInput(org.talend.camel.designer.ui.editor.CamelProcessEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) SaveAsRoutesWizard(org.talend.camel.designer.ui.wizards.SaveAsRoutesWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 8 with JobEditorInput

use of org.talend.core.ui.editor.JobEditorInput in project tesb-studio-se by Talend.

the class RunContainerPreferencePage method performOk.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.esb.runcontainer.preferences.FieldLayoutPreferencePage#performOk()
     */
@Override
public boolean performOk() {
    boolean performOk = super.performOk();
    if (runtimeEnable != getPreferenceStore().getBoolean(RunContainerPreferenceInitializer.P_ESB_IN_OSGI)) {
        IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        if (service != null) {
            service.refreshView();
        }
        List<IEditorReference> editorRefs = new ArrayList();
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IEditorReference[] reference = page.getEditorReferences();
        for (IEditorReference editorRef : reference) {
            IEditorPart part = editorRef.getEditor(false);
            if (part.getEditorInput() instanceof JobEditorInput) {
                editorRefs.add(editorRef);
            }
        }
        if (editorRefs.size() > 0 && MessageDialog.openConfirm(getShell(), "Running Container Changed", "All editors need to be closed to apply the changes, do you want to close all opening editors now?")) {
            page.closeEditors(editorRefs.toArray(new IEditorReference[editorRefs.size()]), true);
        }
    }
    return performOk;
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 9 with JobEditorInput

use of org.talend.core.ui.editor.JobEditorInput in project tdi-studio-se by Talend.

the class ContextsView method setCompositeReadonly.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.context.view.AbstractContextView#setCompositeReadonly(org.eclipse.ui.IEditorInput)
     */
@Override
protected void setCompositeReadonly(IEditorInput editorInput) {
    if (editorInput != null && editorInput instanceof JobEditorInput) {
        JobEditorInput jobInput = (JobEditorInput) editorInput;
        IProcess2 process = jobInput.getLoadedProcess();
        if (process != null) {
            contextComposite.setReadOnly(process.isReadOnly());
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IProcess2(org.talend.core.model.process.IProcess2)

Example 10 with JobEditorInput

use of org.talend.core.ui.editor.JobEditorInput in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method doSave.

/**
     * Saves the multi-page editor's document.
     */
@Override
public void doSave(final IProgressMonitor monitor) {
    Item curItem = getProcess().getProperty().getItem();
    IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
    IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
    try {
        // For TDI-23825, if not lock by user try to lock again.
        if (!getProcess().isReadOnly()) {
            repFactory.lock(curItem);
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    if (getProcess().isReadOnly() || repFactory.isUserReadOnlyOnCurrentProject()) {
        MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.readonly"), Messages.getString("AbstractMultiPageTalendEditor.readonlyMessage"));
        return;
    }
    ERepositoryStatus status = repFactory.getStatus(curItem);
    if (!status.equals(ERepositoryStatus.LOCK_BY_USER) && !repFactory.getRepositoryContext().isEditableAsReadOnly()) {
        MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveTitle"), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveMessage"));
        return;
    }
    if (!isDirty()) {
        return;
    }
    Map<String, Boolean> jobletMap = new HashMap<String, Boolean>();
    changeCollapsedState(true, jobletMap);
    updateRunJobContext();
    designerEditor.getProcess().getProperty().eAdapters().remove(dirtyListener);
    repFactory.addRepositoryWorkUnitListener(repositoryWorkListener);
    if (jobletEditor == getActiveEditor()) {
        boolean isDirty = jobletEditor.isDirty();
        refreshPropertyDirtyStatus();
        jobletEditor.doSave(monitor);
        try {
            IProcess2 oldProcess = getProcess();
            ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
            ProcessType processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
            IProcess2 newProcess = null;
            Item item = getProcess().getProperty().getItem();
            if (item instanceof ProcessItem) {
                ((Process) designerEditor.getProcess()).updateProcess(processType);
                if (isDirty) {
                    getProcess().setProcessModified(true);
                    getProcess().setNeedRegenerateCode(true);
                }
            } else if (item instanceof JobletProcessItem) {
                AbstractProcessProvider processProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
                if (processProvider != null) {
                    newProcess = processProvider.buildNewGraphicProcess(item);
                }
                designerEditor.setProcess(newProcess);
                Boolean lastVersion = null;
                if (oldProcess instanceof ILastVersionChecker) {
                    lastVersion = ((ILastVersionChecker) oldProcess).isLastVersion(item);
                }
                if (designerEditor.getEditorInput() instanceof JobEditorInput) {
                    ((JobEditorInput) designerEditor.getEditorInput()).checkInit(lastVersion, null, true);
                }
            }
            getEditor(0).doSave(monitor);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    } else {
        refreshPropertyDirtyStatus();
        getEditor(0).doSave(monitor);
    }
    /*
         * refresh should be executed before add the listener,or it will has eProxy on the property,it will cause a
         * editor dirty problem. hywang commet bug 17357
         */
    if (processEditorInput != null) {
        propertyInformation = new ArrayList(processEditorInput.getItem().getProperty().getInformations());
        propertyIsDirty = false;
    }
    if (designerEditor != null && dirtyListener != null) {
        designerEditor.getProcess().getProperty().eAdapters().add(dirtyListener);
    }
    refreshJobSettingsView();
    changeCollapsedState(false, jobletMap);
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
        ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
        if (testContainerService != null) {
            testContainerService.updateDetect(getProcess(), false);
        }
    }
    if (isCheckout) {
        CommandStack stack = (CommandStack) getAdapter(CommandStack.class);
        stack.flush();
        isCheckout = false;
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ICreateXtextProcessService(org.talend.core.services.ICreateXtextProcessService) Process(org.talend.designer.core.ui.editor.process.Process) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) IRepositoryService(org.talend.repository.model.IRepositoryService) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ILastVersionChecker(org.talend.core.ui.ILastVersionChecker) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) CommandStack(org.eclipse.gef.commands.CommandStack) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) ProcessorException(org.talend.designer.runprocess.ProcessorException) BusinessException(org.talend.commons.exception.BusinessException) PersistenceException(org.talend.commons.exception.PersistenceException) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IResource(org.eclipse.core.resources.IResource)

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