Search in sources :

Example 6 with IRepositoryNodeActionProvider

use of org.talend.mdm.repository.core.IRepositoryNodeActionProvider 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 7 with IRepositoryNodeActionProvider

use of org.talend.mdm.repository.core.IRepositoryNodeActionProvider in project tmdm-studio-se by Talend.

the class ActionProviderManager method initProviderDefine.

private static void initProviderDefine() {
    if (!inited) {
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        // 
        IExtensionPoint extensionPoint = registry.getExtensionPoint(RepositoryPlugin.PLUGIN_ID, EXTENSION_POINT_TEMPLATE);
        if (extensionPoint != null && extensionPoint.isValid()) {
            IExtension[] extensions = extensionPoint.getExtensions();
            for (IExtension s : extensions) {
                IConfigurationElement[] elements = s.getConfigurationElements();
                for (IConfigurationElement element : elements) {
                    String id = element.getAttribute(ID);
                    if (id != null && element.getAttribute(PROP_CLASS) != null) {
                        try {
                            IRepositoryNodeActionProvider actionProvider = (IRepositoryNodeActionProvider) element.createExecutableExtension(PROP_CLASS);
                            providerMap.put(id, actionProvider);
                        } catch (CoreException e) {
                            log.error(e.getMessage(), e);
                        }
                    }
                }
            }
        }
        inited = true;
    }
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) IExtension(org.eclipse.core.runtime.IExtension) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Aggregations

IRepositoryNodeActionProvider (org.talend.mdm.repository.core.IRepositoryNodeActionProvider)7 AbstractRepositoryAction (org.talend.mdm.repository.core.AbstractRepositoryAction)3 IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)3 Item (org.talend.core.model.properties.Item)2 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)2 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)2 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IAction (org.eclipse.jface.action.IAction)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 PartInitException (org.eclipse.ui.PartInitException)1 CommonViewer (org.eclipse.ui.navigator.CommonViewer)1 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)1 FolderItem (org.talend.core.model.properties.FolderItem)1 FolderType (org.talend.core.model.properties.FolderType)1