Search in sources :

Example 1 with ProcessEditorInput

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

the class OpentRunJobComponentAction method run.

@Override
public void run() {
    List selection = getSelectedObjects();
    Object input = selection.get(0);
    if (input instanceof NodePart) {
        NodePart part = (NodePart) input;
        Node node = (Node) part.getModel();
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        String processName = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
        String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
        if (processName != null && !"".equals(processName)) {
            //$NON-NLS-1$
            try {
                ItemCacheManager.clearCache();
                ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
                if (processItem != null) {
                    ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true);
                    IEditorPart editorPart = page.findEditor(fileEditorInput);
                    if (editorPart == null) {
                        ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(processItem);
                        IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
                        editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(processItem, true));
                    } else {
                        page.activate(editorPart);
                    }
                }
            } catch (PartInitException e) {
                MessageBoxExceptionHandler.process(e);
            } catch (PersistenceException e) {
                MessageBoxExceptionHandler.process(e);
            }
        } else {
            try {
                // modified for feature 2454.
                page.showView(ComponentSettingsView.ID);
            } catch (PartInitException e) {
                ExceptionHandler.process(e);
            }
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IEditorPart(org.eclipse.ui.IEditorPart) IJobEditorHandler(org.talend.core.ui.editor.IJobEditorHandler) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) ProcessItem(org.talend.core.model.properties.ProcessItem) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) List(java.util.List) PartInitException(org.eclipse.ui.PartInitException) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 2 with ProcessEditorInput

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

the class ProcessPart method getAdapter.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
     */
@Override
public Object getAdapter(final Class adapter) {
    if (adapter.equals(RepositoryNode.class)) {
        if (node == null) {
            RootEditPart rootEditPart = getRoot();
            if (rootEditPart instanceof TalendScalableFreeformRootEditPart) {
                TalendScalableFreeformRootEditPart rootEditPart2 = (TalendScalableFreeformRootEditPart) rootEditPart;
                IEditorInput editorInput = rootEditPart2.getEditorInput();
                if (editorInput instanceof ProcessEditorInput) {
                    ProcessEditorInput processEditorInput = (ProcessEditorInput) editorInput;
                    node = processEditorInput.getRepositoryNode();
                }
            }
        }
        return node;
    }
    if (adapter == SnapToHelper.class) {
        List<Object> snapStrategies = new ArrayList<Object>();
        Boolean val = (Boolean) getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
        val = (Boolean) getViewer().getProperty(NodeSnapToGeometry.PROPERTY_SNAP_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new NodeSnapToGeometry(this));
        }
        val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGrid(this));
        }
        if (snapStrategies.size() == 0) {
            return null;
        }
        if (snapStrategies.size() == 1) {
            return snapStrategies.get(0);
        }
        SnapToHelper[] ss = new SnapToHelper[snapStrategies.size()];
        for (int i = 0; i < snapStrategies.size(); i++) {
            ss[i] = (SnapToHelper) snapStrategies.get(i);
        }
        return new CompoundSnapToHelper(ss);
    }
    return super.getAdapter(adapter);
}
Also used : SnapToHelper(org.eclipse.gef.SnapToHelper) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) ArrayList(java.util.ArrayList) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) SnapToGrid(org.eclipse.gef.SnapToGrid) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) IEditorInput(org.eclipse.ui.IEditorInput) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart)

Example 3 with ProcessEditorInput

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

the class OpenExistVersionProcessWizard method getEditorInput.

protected RepositoryEditorInput getEditorInput(final Item item, final boolean readonly, final IWorkbenchPage page) throws SystemException {
    if (item instanceof ProcessItem) {
        ProcessItem processItem = (ProcessItem) item;
        return new ProcessEditorInput(processItem, true, false, readonly);
    } else if (item instanceof BusinessProcessItem) {
        BusinessProcessItem businessProcessItem = (BusinessProcessItem) item;
        IFile file = CorePlugin.getDefault().getDiagramModelService().getDiagramFileAndUpdateResource(page, businessProcessItem);
        return new RepositoryEditorInput(file, businessProcessItem);
    } else if (item instanceof RoutineItem) {
        final RoutineItem routineItem = (RoutineItem) item;
        final ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
        ITalendSynchronizer routineSynchronizer = codeGenService.createRoutineSynchronizer();
        ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        String lastVersion = factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
        String curVersion = routineItem.getProperty().getVersion();
        routineSynchronizer.syncRoutine(routineItem, true, true);
        final IFile file;
        if (curVersion != null && curVersion.equals(lastVersion)) {
            file = routineSynchronizer.getFile(routineItem);
        } else {
            file = routineSynchronizer.getRoutinesFile(routineItem);
        }
        if (file != null) {
            return new RoutineEditorInput(file, routineItem);
        }
    } else if (item instanceof SQLPatternItem) {
        SQLPatternItem patternItem = (SQLPatternItem) item;
        final ICodeGeneratorService codeGenService = (ICodeGeneratorService) GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
        ISQLPatternSynchronizer SQLPatternSynchronizer = codeGenService.getSQLPatternSynchronizer();
        SQLPatternSynchronizer.syncSQLPattern(patternItem, true);
        IFile file = SQLPatternSynchronizer.getSQLPatternFile(patternItem);
        if (file != null) {
            return new RepositoryEditorInput(file, patternItem);
        }
    }
    return null;
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ISQLPatternSynchronizer(org.talend.designer.codegen.ISQLPatternSynchronizer) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) RoutineEditorInput(org.talend.repository.ui.actions.routines.RoutineEditorInput) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem)

Example 4 with ProcessEditorInput

use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tmdm-studio-se by Talend.

the class UpdateLastServerCommand method saveLastServer.

private void saveLastServer(Item item, MDMServerDef serverDef) {
    if (item.eResource() == null) {
        try {
            IRepositoryViewObject viewObj = factory.getLastVersion(item.getProperty().getId());
            if (viewObj == null) {
                // when object is match rule map info object,it must not exist and return null
                return;
            }
            Property property = viewObj.getProperty();
            item = property.getItem();
            ContainerCacheService.put(property, viewObj);
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        }
    }
    RepositoryResourceUtil.setLastServerDef(item, serverDef);
    if (!(item instanceof ProcessItem)) {
        // for common object except job
        try {
            factory.save(item);
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        }
    } else {
        if (isWorkInUI()) {
            // for job object
            try {
                RepositoryViewObjectResourceChangeManager.stopListening();
                IEditorReference editorRef = getJobEditor(item);
                if (editorRef != null) {
                    IEditorPart editor = editorRef.getEditor(false);
                    if (editor != null && editor.isDirty()) {
                        // when save job editor, it only keep the additional properties that Process have
                        ProcessEditorInput processEditorInput = (ProcessEditorInput) editor.getEditorInput();
                        EMap additionalProperties = item.getProperty().getAdditionalProperties();
                        Iterator iterator = additionalProperties.keySet().iterator();
                        Map<Object, Object> processAdditionalProperties = processEditorInput.getLoadedProcess().getAdditionalProperties();
                        processAdditionalProperties.putAll(additionalProperties.map());
                        editor.doSave(new NullProgressMonitor());
                        return;
                    }
                }
                factory.save(item);
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            } finally {
                RepositoryViewObjectResourceChangeManager.startListening();
            }
        } else {
            // save under command line
            try {
                factory.save(item);
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) EMap(org.eclipse.emf.common.util.EMap) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Iterator(java.util.Iterator) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorPart(org.eclipse.ui.IEditorPart) Property(org.talend.core.model.properties.Property) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 5 with ProcessEditorInput

use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tmdm-studio-se by Talend.

the class NewProcessAction method refreshJobEditorTitle.

private void refreshJobEditorTitle(Item item) {
    String label = item.getProperty().getLabel();
    // job name can not contains '#' and '$', see job's create procedure
    // $NON-NLS-1$ //$NON-NLS-2$
    label = label.replaceAll("#|\\$", "");
    IWorkbenchPage activePage = getActivePage();
    IEditorReference[] editorReferences = activePage.getEditorReferences();
    if (editorReferences != null) {
        for (IEditorReference editorPart : editorReferences) {
            IEditorInput editorInput = editorPart.getEditor(false).getEditorInput();
            if (editorInput instanceof ProcessEditorInput) {
                ProcessEditorInput processInput = (ProcessEditorInput) editorInput;
                ProcessItem jobItem = (ProcessItem) processInput.getItem();
                MultiPageTalendEditor jobEditor = (MultiPageTalendEditor) editorPart.getEditor(false);
                String jobLabel = jobItem.getProperty().getLabel();
                if (jobLabel.equals(label)) {
                    jobEditor.refreshName();
                    break;
                }
            }
        }
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) MultiPageTalendEditor(org.talend.designer.core.ui.MultiPageTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Aggregations

ProcessEditorInput (org.talend.designer.core.ui.editor.ProcessEditorInput)15 ProcessItem (org.talend.core.model.properties.ProcessItem)8 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 PartInitException (org.eclipse.ui.PartInitException)6 PersistenceException (org.talend.commons.exception.PersistenceException)6 IEditorInput (org.eclipse.ui.IEditorInput)5 IEditorPart (org.eclipse.ui.IEditorPart)5 IEditorReference (org.eclipse.ui.IEditorReference)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 IFile (org.eclipse.core.resources.IFile)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1