Search in sources :

Example 1 with IRepositoryNodeActionProvider

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

the class RepositoryNodeActionProviderAdapter method getExtendActionProviders.

private IRepositoryNodeActionProvider[] getExtendActionProviders() {
    if (extendActionProviders == null) {
        boolean isLocalProj = ProjectManager.getInstance().getCurrentProject().isLocal();
        boolean isOffline = ProxyRepositoryFactory.getInstance().getRepositoryContext().isOffline();
        if (!isLocalProj && !isOffline) {
            IRepositoryNodeActionProvider svnProvider = ActionProviderManager.getActionProvider(SVN_ACTION_PROVIDER_ID);
            IRepositoryNodeActionProvider gitProvider = ActionProviderManager.getActionProvider(GIT_ACTION_PROVIDER_ID);
            if (svnProvider != null && gitProvider != null) {
                extendActionProviders = new IRepositoryNodeActionProvider[] { svnProvider, gitProvider };
            } else if (svnProvider != null) {
                extendActionProviders = new IRepositoryNodeActionProvider[] { svnProvider };
            } else if (gitProvider != null) {
                extendActionProviders = new IRepositoryNodeActionProvider[] { gitProvider };
            }
        }
        if (extendActionProviders == null) {
            extendActionProviders = new IRepositoryNodeActionProvider[0];
        }
    }
    return extendActionProviders;
}
Also used : IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider)

Example 2 with IRepositoryNodeActionProvider

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

the class RepositoryNodeActionProviderAdapter method getActions.

@Override
public List<AbstractRepositoryAction> getActions(IRepositoryViewObject viewObj) {
    List<AbstractRepositoryAction> actions = new LinkedList<AbstractRepositoryAction>();
    // 
    Item item = viewObj.getProperty().getItem();
    if (item instanceof MDMItem) {
        if (item instanceof ContainerItem) {
            FolderType type = ((FolderItem) item).getType();
            switch(type.getValue()) {
                case FolderType.SYSTEM_FOLDER:
                    addAction(actions, createFolderAction, viewObj);
                    addAction(actions, pasteAction, viewObj);
                    actions.add(importServerObjectAction);
                    actions.add(importObjectAction);
                    break;
                case FolderType.STABLE_SYSTEM_FOLDER:
                    break;
                case FolderType.FOLDER:
                    addAction(actions, createFolderAction, viewObj);
                    if (!((ContainerItem) item).getRepObjType().equals(ERepositoryObjectType.PROCESS)) {
                        actions.add(removeFromRepositoryAction);
                    }
                    addAction(actions, pasteAction, viewObj);
                    break;
            }
        } else if (item instanceof MDMServerObjectItem) {
            addAction(actions, removeFromRepositoryAction, viewObj);
            addAction(actions, mdmEditPropertyAction, viewObj);
            addAction(actions, openVersionAction, viewObj);
            addAction(actions, copyAction, viewObj);
            addAction(actions, pasteAction, viewObj);
            addAction(actions, duplicateAction, viewObj);
            if (exAdapter != null) {
                exAdapter.addActions(actions, viewObj);
            }
        } else if (item instanceof WorkspaceRootItem) {
            // fix bug TMDM-3168
            actions.add(importObjectAction);
        }
    }
    if (enableDebug) {
        // for debug digestValue
        addAction(actions, debugDigestValueAction, viewObj);
    }
    // 
    actions.add(refreshAction);
    actions.add(exportObjectAction);
    // action provider
    for (IRepositoryNodeActionProvider provider : getExtendActionProviders()) {
        List<AbstractRepositoryAction> providerActions = provider.getActions(viewObj);
        if (providerActions != null) {
            actions.addAll(providerActions);
        }
    }
    if (viewObj.getRepositoryObjectType() != null && IServerObjectRepositoryType.TYPE_EVENTMANAGER.equals(viewObj.getRepositoryObjectType())) {
        actions.add(emAction);
    }
    // 
    return actions;
}
Also used : MDMItem(org.talend.mdm.repository.model.mdmproperties.MDMItem) AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) FolderItem(org.talend.core.model.properties.FolderItem) MDMItem(org.talend.mdm.repository.model.mdmproperties.MDMItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) LinkedList(java.util.LinkedList) FolderType(org.talend.core.model.properties.FolderType)

Example 3 with IRepositoryNodeActionProvider

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

the class MDMRepositoryActionProvider method init.

@Override
public void init(ICommonActionExtensionSite aSite) {
    CommonViewer commonViewer = (CommonViewer) aSite.getStructuredViewer();
    for (IRepositoryNodeConfiguration conf : RepositoryNodeConfigurationManager.getConfigurations()) {
        IRepositoryNodeActionProvider actionProvider = conf.getActionProvider();
        if (actionProvider != null) {
            actionProvider.setRepositoryViewGlobalActionHandler(this);
            actionProvider.initCommonViewer(commonViewer);
        }
    }
    initCommonViewerForActions(commonViewer);
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration)

Example 4 with IRepositoryNodeActionProvider

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

the class MDMRepositoryActionProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
    List<AbstractRepositoryAction> finalActions = null;
    for (Iterator il = selection.iterator(); il.hasNext(); ) {
        Object obj = il.next();
        if (obj instanceof IRepositoryViewObject) {
            IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
            IRepositoryNodeConfiguration conf = RepositoryNodeConfigurationManager.getConfiguration(viewObj);
            IRepositoryNodeActionProvider actionProvider = conf.getActionProvider();
            if (conf != null && actionProvider != null) {
                actionProvider.updateSelection(selection);
                List<AbstractRepositoryAction> actions = actionProvider.getActions(viewObj);
                if (actions != null) {
                    if (finalActions == null) {
                        finalActions = actions;
                    }
                    finalActions = combineActions(finalActions, actions);
                    if (finalActions.size() == 0) {
                        return;
                    }
                }
            }
        }
    }
    // hook action to menu
    for (IAction action : finalActions) {
        if (action instanceof AbstractRepositoryAction) {
            AbstractRepositoryAction groupAction = (AbstractRepositoryAction) action;
            groupAction.selectionChanged(selection);
            if (groupAction.getGroupName() != null) {
                menu.appendToGroup(groupAction.getGroupName(), action);
            } else {
                menu.add(action);
            }
        }
    }
}
Also used : AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) IAction(org.eclipse.jface.action.IAction) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) Iterator(java.util.Iterator) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 5 with IRepositoryNodeActionProvider

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

the class RepositoryNodeActionProviderAdapter method initCommonViewer.

@Override
public void initCommonViewer(CommonViewer commonViewer) {
    importObjectAction = initRepositoryAction(ImportObjectAction.createImportAction(), commonViewer);
    exportObjectAction = initRepositoryAction(new ExportObjectAction(), commonViewer);
    createFolderAction = initRepositoryAction(new CreateFolderAction(), commonViewer);
    removeFromRepositoryAction = initRepositoryAction(new RemoveFromRepositoryAction(), commonViewer);
    renameAction = initRepositoryAction(new RenameObjectAction(), commonViewer);
    duplicateAction = initRepositoryAction(new DuplicateAction(), commonViewer);
    deployToAction = initRepositoryAction(new DeployToAction(), commonViewer);
    deployAnotherToAction = initRepositoryAction(new DeployAnotherVersionAction(), commonViewer);
    deployToLastServerAction = initRepositoryAction(new DeployToLastServerAction(), commonViewer);
    undeployAction = initRepositoryAction(new UndeployAction(), commonViewer);
    deployAllAction = initRepositoryAction(new DeployAllAction(false), commonViewer);
    emAction = initRepositoryAction(new MDMEventManagerAction(), commonViewer);
    importServerObjectAction = initRepositoryAction(new ImportServerObjectAction(), commonViewer);
    mdmEditPropertyAction = initRepositoryAction(new MDMEditPropertyAction(), commonViewer);
    openVersionAction = initRepositoryAction(new MDMOpenExistVersionProcessAction(), commonViewer);
    // for debug digestValue
    debugDigestValueAction = initRepositoryAction(new DebugDigestValueAction(), commonViewer);
    // 
    if (hasValidateService()) {
        validateAction = initRepositoryAction(new ValidateAction(), commonViewer);
    }
    // 
    refreshAction = globalActionHandler.getGlobalAction(IRepositoryViewGlobalActionHandler.REFRESH);
    copyAction = globalActionHandler.getGlobalAction(IRepositoryViewGlobalActionHandler.COPY);
    if (exAdapter != null) {
        exAdapter.initCommonViewer(commonViewer);
    }
    pasteAction = globalActionHandler.getGlobalAction(IRepositoryViewGlobalActionHandler.PASTE);
    // action provider
    for (IRepositoryNodeActionProvider provider : getExtendActionProviders()) {
        provider.initCommonViewer(commonViewer);
    }
    // recycle
    RepositoryNodeConfigurationManager.getRecycleBinNodeConfiguration().getActionProvider().initCommonViewer(commonViewer);
}
Also used : RenameObjectAction(org.talend.mdm.repository.ui.actions.RenameObjectAction) ExportObjectAction(org.talend.mdm.repository.ui.actions.ExportObjectAction) MDMEditPropertyAction(org.talend.mdm.repository.ui.actions.MDMEditPropertyAction) DebugDigestValueAction(org.talend.mdm.repository.ui.actions.DebugDigestValueAction) MDMEventManagerAction(org.talend.mdm.repository.ui.actions.process.MDMEventManagerAction) DeployToLastServerAction(org.talend.mdm.repository.ui.actions.DeployToLastServerAction) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) RemoveFromRepositoryAction(org.talend.mdm.repository.ui.actions.RemoveFromRepositoryAction) UndeployAction(org.talend.mdm.repository.ui.actions.UndeployAction) DeployAllAction(org.talend.mdm.repository.ui.actions.DeployAllAction) DeployToAction(org.talend.mdm.repository.ui.actions.DeployToAction) ImportServerObjectAction(org.talend.mdm.repository.ui.actions.ImportServerObjectAction) CreateFolderAction(org.talend.mdm.repository.ui.actions.CreateFolderAction) ValidateAction(org.talend.mdm.repository.ui.actions.ValidateAction) MDMOpenExistVersionProcessAction(org.talend.mdm.repository.ui.actions.MDMOpenExistVersionProcessAction) DeployAnotherVersionAction(org.talend.mdm.repository.ui.actions.DeployAnotherVersionAction) DuplicateAction(org.talend.mdm.repository.ui.actions.DuplicateAction)

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