Search in sources :

Example 1 with IRepositoryViewEditorInput

use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput 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 2 with IRepositoryViewEditorInput

use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput in project tmdm-studio-se by Talend.

the class LockedDirtyObjectDialog method isDirtyMdmViewObj.

private boolean isDirtyMdmViewObj(List<IRepositoryViewObject> inputObjs, IRepositoryViewObject viewObj) {
    if (editorRefMap == null) {
        editorRefMap = new HashMap<String, IEditorPart>();
        // collect all ids
        Set<String> ids = new HashSet<String>();
        for (IRepositoryViewObject viewObject : inputObjs) {
            String id = viewObject.getId();
            if (id != null) {
                ids.add(id);
            }
        }
        // 
        if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
            IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            for (IEditorReference ref : activePage.getEditorReferences()) {
                try {
                    String id = null;
                    IEditorInput editorInput = ref.getEditorInput();
                    if (editorInput instanceof IRepositoryViewEditorInput) {
                        IRepositoryViewObject viewObject = ((IRepositoryViewEditorInput) editorInput).getViewObject();
                        if (viewObject != null) {
                            id = viewObject.getId();
                        }
                    } else if (editorInput instanceof ProcessEditorInput) {
                        id = ((ProcessEditorInput) editorInput).getId();
                    }
                    if (id != null && ids.contains(id)) {
                        IEditorPart editor = ref.getEditor(false);
                        if (editor != null && editor.isDirty()) {
                            editorRefMap.put(id, editor);
                        }
                    }
                } catch (PartInitException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }
    return editorRefMap.containsKey(viewObj.getId());
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) IRepositoryViewEditorInput(org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) HashSet(java.util.HashSet) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 3 with IRepositoryViewEditorInput

use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput in project tmdm-studio-se by Talend.

the class OpenObjectAction method openItem.

private void openItem(IRepositoryViewObject viewObject) {
    Item item = viewObject.getProperty().getItem();
    item = RepositoryResourceUtil.assertItem(item);
    IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
    if (configuration != null) {
        IRepositoryNodeActionProvider actionProvider = configuration.getActionProvider();
        if (actionProvider != null) {
            IRepositoryViewEditorInput editorInput = actionProvider.getOpenEditorInput(viewObject);
            if (editorInput != null) {
                if (page == null) {
                    this.page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
                }
                // do extra action
                MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
                if (!checkMissingJar(serverObject)) {
                    return;
                }
                boolean selected = doSelectServer(item, editorInput);
                if (!selected) {
                    return;
                }
                try {
                    // svn lock
                    ERepositoryStatus status = factory.getStatus(item);
                    boolean isEditable = factory.isEditableAndLockIfPossible(item);
                    if (isEditable) {
                        getCommonViewer().refresh(viewObject);
                    }
                    // 
                    editorInput.setReadOnly(status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.READ_ONLY || !isEditable);
                    if (!editorInput.isReadOnly()) {
                        editorInput.setReadOnly(item.getState().isDeleted());
                    }
                    updateEditorInputVersionInfo(editorInput, viewObject);
                    activeEditor = this.page.openEditor(editorInput, editorInput.getEditorId());
                    if (marker != null) {
                        IDE.gotoMarker(activeEditor, marker);
                    }
                } catch (PartInitException e) {
                    log.error(e.getMessage(), e);
                }
            } else {
                AbstractRepositoryAction openAction = actionProvider.getOpenAction(viewObject);
                if (openAction != null) {
                    openAction.selectionChanged(getStructuredSelection());
                    openAction.run();
                }
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IRepositoryViewEditorInput(org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) PartInitException(org.eclipse.ui.PartInitException) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 4 with IRepositoryViewEditorInput

use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method closeEditor.

public static void closeEditor(IRepositoryViewObject viewObj, boolean save) {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editorReferences = activePage.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)) {
                            activePage.closeEditors(new IEditorReference[] { ref }, save);
                        }
                    }
                }
            } catch (PartInitException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}
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) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

PartInitException (org.eclipse.ui.PartInitException)4 IRepositoryViewEditorInput (org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput)4 IEditorInput (org.eclipse.ui.IEditorInput)3 IEditorReference (org.eclipse.ui.IEditorReference)3 Item (org.talend.core.model.properties.Item)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)3 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)2 FolderItem (org.talend.core.model.properties.FolderItem)2 TDQMatchRuleItem (org.talend.dataquality.properties.TDQMatchRuleItem)2 ProcessEditorInput (org.talend.designer.core.ui.editor.ProcessEditorInput)2 WorkspaceRootItem (org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem)2 HashSet (java.util.HashSet)1 IEditorPart (org.eclipse.ui.IEditorPart)1 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)1 Property (org.talend.core.model.properties.Property)1 AbstractRepositoryAction (org.talend.mdm.repository.core.AbstractRepositoryAction)1 IRepositoryNodeActionProvider (org.talend.mdm.repository.core.IRepositoryNodeActionProvider)1