Search in sources :

Example 66 with IEditorReference

use of org.eclipse.ui.IEditorReference 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 67 with IEditorReference

use of org.eclipse.ui.IEditorReference 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)

Example 68 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tmdm-studio-se by Talend.

the class RemoveFromRepositoryAction method removeServerObject.

private void removeServerObject(IRepositoryViewObject viewObj) {
    if (removed.contains(viewObj.getId())) {
        return;
    }
    removed.add(viewObj.getId());
    try {
        Item item = viewObj.getProperty().getItem();
        IEditorReference ref = RepositoryResourceUtil.isOpenedInEditor(viewObj);
        if (ref != null) {
            RepositoryResourceUtil.closeEditor(ref, true);
        }
        factory.deleteObjectLogical(viewObj);
        if (item instanceof MDMServerObjectItem) {
            MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
            CommandManager.getInstance().pushCommand(ICommand.CMD_DELETE, viewObj.getId(), serverObj.getName());
        }
    } catch (BusinessException e) {
        MessageDialog.openError(getShell(), Messages.Common_Error, e.getMessage());
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : TDQItem(org.talend.core.model.properties.TDQItem) Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) FolderItem(org.talend.core.model.properties.FolderItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) BusinessException(org.talend.commons.exception.BusinessException) IEditorReference(org.eclipse.ui.IEditorReference) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) BusinessException(org.talend.commons.exception.BusinessException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 69 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method isOpenedInEditor.

public static IEditorReference isOpenedInEditor(IRepositoryViewObject viewObj) {
    IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    for (IEditorReference ref : editorReferences) {
        if (ref != null) {
            try {
                IEditorInput editorInput = ref.getEditorInput();
                if (editorInput instanceof IRepositoryViewEditorInput) {
                    Item inputItem = ((IRepositoryViewEditorInput) editorInput).getInputItem();
                    if (inputItem != null) {
                        IRepositoryViewObject vObj = ContainerCacheService.get(inputItem.getProperty());
                        if (vObj != null && vObj.equals(viewObj)) {
                            return ref;
                        }
                    }
                }
                if (exAdapter != null) {
                    IEditorReference wfEditor = exAdapter.getOpenedWFEditor(viewObj, ref);
                    if (wfEditor != null) {
                        return wfEditor;
                    }
                }
                if (editorInput instanceof ProcessEditorInput) {
                    ProcessEditorInput processEditorInput = (ProcessEditorInput) editorInput;
                    Property property = processEditorInput.getItem().getProperty();
                    if (viewObj.getProperty().getId().equals(property.getId())) {
                        return ref;
                    }
                }
            } catch (PartInitException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return null;
}
Also used : ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IEditorReference(org.eclipse.ui.IEditorReference) IRepositoryViewEditorInput(org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IEditorInput(org.eclipse.ui.IEditorInput) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 70 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method isLockedAndEdited.

public static boolean isLockedAndEdited(IRepositoryViewObject viewObj) {
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    ERepositoryStatus status = factory.getStatus(viewObj);
    if (status == ERepositoryStatus.LOCK_BY_OTHER) {
        return true;
    } else if (status == ERepositoryStatus.LOCK_BY_USER) {
        IEditorReference openRef = RepositoryResourceUtil.isOpenedInEditor(viewObj);
        return openRef != null;
    }
    return false;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IEditorReference(org.eclipse.ui.IEditorReference) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

IEditorReference (org.eclipse.ui.IEditorReference)174 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)83 IEditorPart (org.eclipse.ui.IEditorPart)78 PartInitException (org.eclipse.ui.PartInitException)59 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)55 IFile (org.eclipse.core.resources.IFile)50 IEditorInput (org.eclipse.ui.IEditorInput)49 ArrayList (java.util.ArrayList)34 FileEditorInput (org.eclipse.ui.part.FileEditorInput)28 Item (org.talend.core.model.properties.Item)17 IWorkbench (org.eclipse.ui.IWorkbench)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 IOException (java.io.IOException)12 CoreException (org.eclipse.core.runtime.CoreException)12 ProcessItem (org.talend.core.model.properties.ProcessItem)11 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)10 Path (org.eclipse.core.runtime.Path)10 IProcess2 (org.talend.core.model.process.IProcess2)10