Search in sources :

Example 6 with ITreeContextualAction

use of org.talend.commons.ui.swt.actions.ITreeContextualAction in project tdi-studio-se by Talend.

the class ProcessVersionComposite method getEditPropertiesAction.

/**
     * 
     * DOC xye Comment method "getEditPropertiesAction".
     * 
     * @return
     */
public ITreeContextualAction getEditPropertiesAction(final Class<?> klazz) {
    ISelection selection = tableViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
        for (ITreeContextualAction action : contextualsActions) {
            if (action.getClass() == klazz) {
                if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                    action.init(null, structuredSelection);
                    if (action.isVisible()) {
                        return action;
                    }
                }
            }
        }
    }
    return null;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction)

Example 7 with ITreeContextualAction

use of org.talend.commons.ui.swt.actions.ITreeContextualAction in project tdi-studio-se by Talend.

the class BusinessAssignmentComposite method createPopupMenu.

private void createPopupMenu() {
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager mgr) {
            BusinessAssignment businessAssignment = getBusinessAssignment(tableViewer.getSelection());
            if (businessAssignment != null) {
                repositoryNode = createRepositoryNode(businessAssignment);
                if (repositoryNode != null) {
                    List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                    for (ITreeContextualAction action : contextualsActions) {
                        if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                            action.init(null, new StructuredSelection(repositoryNode));
                            if (action.isVisible()) {
                                ((AContextualAction) action).setAvoidUnloadResources(true);
                                mgr.add(action);
                            }
                        }
                    }
                    if (ProjectManager.getInstance().isInCurrentMainProject(repositoryNode)) {
                        CorePlugin.getDefault().getDiagramModelService().addDeleteAssignmentAction(mgr, tableViewer.getSelection());
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener)

Aggregations

ITreeContextualAction (org.talend.commons.ui.swt.actions.ITreeContextualAction)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 IMenuListener (org.eclipse.jface.action.IMenuListener)5 List (java.util.List)4 IMenuManager (org.eclipse.jface.action.IMenuManager)4 MenuManager (org.eclipse.jface.action.MenuManager)4 Menu (org.eclipse.swt.widgets.Menu)4 ISelection (org.eclipse.jface.viewers.ISelection)3 IRepositoryObject (org.talend.core.model.repository.IRepositoryObject)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2