Search in sources :

Example 1 with OpenExistVersionProcessAction

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

the class ProcessVersionComposite method addPopUpMenu.

/**
     * DOC Administrator Comment method "addPoppuMenu".
     */
private void addPopUpMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager mgr) {
            if (getParentWizard() == null) {
                ISelection selection = tableViewer.getSelection();
                if (selection instanceof IStructuredSelection) {
                    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                    List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                    for (ITreeContextualAction action : contextualsActions) {
                        if (action instanceof OpenExistVersionProcessAction) {
                            continue;
                        }
                        if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                            action.init(null, structuredSelection);
                            Object o = structuredSelection.getFirstElement();
                            if (o instanceof RepositoryNode) {
                                ((AContextualAction) action).setAvoidUnloadResources(true);
                            }
                            if (action.isVisible()) {
                                mgr.add(action);
                            }
                        }
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Menu(org.eclipse.swt.widgets.Menu) RepositoryNode(org.talend.repository.model.RepositoryNode) OpenExistVersionProcessAction(org.talend.designer.core.ui.action.OpenExistVersionProcessAction) IMenuListener(org.eclipse.jface.action.IMenuListener)

Aggregations

List (java.util.List)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Menu (org.eclipse.swt.widgets.Menu)1 ITreeContextualAction (org.talend.commons.ui.swt.actions.ITreeContextualAction)1 IRepositoryObject (org.talend.core.model.repository.IRepositoryObject)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 OpenExistVersionProcessAction (org.talend.designer.core.ui.action.OpenExistVersionProcessAction)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1