Search in sources :

Example 11 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project tdq-studio-se by Talend.

the class AbstractCommonActionProviderTest method setUp.

/**
 * DOC qiongli Comment method "setUp".
 *
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    absCommonActionProvider = new AbstractCommonActionProvider();
    ActionContext context = mock(ActionContext.class);
    treeSel = mock(TreeSelection.class);
    when(context.getSelection()).thenReturn(treeSel);
    absCommonActionProvider.setContext(context);
    // $NON-NLS-1$
    UnitTestBuildHelper.initProjectStructure("testForDeleteActionTDQ");
}
Also used : TreeSelection(org.eclipse.jface.viewers.TreeSelection) ActionContext(org.eclipse.ui.actions.ActionContext) Before(org.junit.Before)

Example 12 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project tdq-studio-se by Talend.

the class SemanticDiscoveryActionProviderTest method testFillContextMenuIMenuManager.

/**
 * Test method for {@link org.talend.dataprofiler.core.ui.action.provider.SemanticDiscoveryActionProvider#fillContextMenu(org.eclipse.jface.action.IMenuManager)}.
 */
@Test
public void testFillContextMenuIMenuManager() {
    SemanticDiscoveryActionProvider semanticDiscoveryActionProvider = new SemanticDiscoveryActionProvider();
    IRepositoryNode createNewColumnRepNode = createNewColumnRepNode();
    TreePath treePath = new TreePath(new IRepositoryNode[] { createNewColumnRepNode });
    TreeSelection treeSelection = new TreeSelection(new TreePath[] { treePath });
    semanticDiscoveryActionProvider.setContext(new ActionContext(treeSelection));
    MenuManager menuManager = new MenuManager();
    semanticDiscoveryActionProvider.fillContextMenu(menuManager);
    Assert.assertEquals(1, menuManager.getSize());
    // $NON-NLS-1$
    Assert.assertTrue(// $NON-NLS-1$
    "Current action must be SemanticDiscoveryAction", ((ActionContributionItem) menuManager.getItems()[0]).getAction() instanceof SemanticDiscoveryAction);
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) MenuManager(org.eclipse.jface.action.MenuManager) ActionContext(org.eclipse.ui.actions.ActionContext) SemanticDiscoveryAction(org.talend.dataprofiler.core.ui.action.actions.predefined.SemanticDiscoveryAction) Test(org.junit.Test)

Example 13 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project tdi-studio-se by Talend.

the class JobHierarchyViewPart method fillDependencyViewerContextMenu.

/*
     * Creates the context menu for the method viewer
     */
private void fillDependencyViewerContextMenu(IMenuManager menu) {
    // viewer entries
    fActionGroups.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
    fActionGroups.fillContextMenu(menu);
    fActionGroups.setContext(null);
}
Also used : ActionContext(org.eclipse.ui.actions.ActionContext)

Example 14 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project eclipse.platform.text by eclipse.

the class FileSearchPage method fillContextMenu.

@Override
protected void fillContextMenu(IMenuManager mgr) {
    super.fillContextMenu(mgr);
    addSortActions(mgr);
    fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
    fActionGroup.fillContextMenu(mgr);
    FileSearchQuery query = (FileSearchQuery) getInput().getQuery();
    if (query.getSearchString().length() > 0) {
        IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
        if (!selection.isEmpty()) {
            ReplaceAction replaceSelection = new ReplaceAction(getSite().getShell(), (FileSearchResult) getInput(), selection.toArray());
            replaceSelection.setText(SearchMessages.ReplaceAction_label_selected);
            mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceSelection);
        }
        ReplaceAction replaceAll = new ReplaceAction(getSite().getShell(), (FileSearchResult) getInput(), null);
        replaceAll.setText(SearchMessages.ReplaceAction_label_all);
        mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionContext(org.eclipse.ui.actions.ActionContext)

Example 15 with ActionContext

use of org.eclipse.ui.actions.ActionContext in project linuxtools by eclipse.

the class OSIOWorkitemLinkAttributeEditor method createControl.

@Override
public void createControl(Composite parent, FormToolkit toolkit) {
    initialize();
    selectionProvider = new SelectionProviderAdapter();
    actionGroup = new CommentActionGroup();
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            // get comment and add reply action as first item in the menu
            ISelection selection = selectionProvider.getSelection();
            if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
                ReplyToCommentAction replyAction = new ReplyToCommentAction(currentViewer);
                manager.add(replyAction);
            }
            actionGroup.setContext(new ActionContext(selectionProvider.getSelection()));
            actionGroup.fillContextMenu(manager);
            if (currentViewer != null && currentViewer.getEditor() instanceof RichTextAttributeEditor) {
                RichTextAttributeEditor editor = (RichTextAttributeEditor) currentViewer.getEditor();
                if (editor.getViewSourceAction().isEnabled()) {
                    // $NON-NLS-1$
                    manager.add(new Separator("planning"));
                    manager.add(editor.getViewSourceAction());
                }
            }
        }
    });
    getTaskEditorPage().getEditorSite().registerContextMenu(ID_POPUP_MENU, menuManager, selectionProvider, false);
    commentMenu = menuManager.createContextMenu(parent);
    section = createSection(parent, toolkit, hasIncoming);
    // $NON-NLS-1$ //$NON-NLS-2$
    section.setText(section.getText() + " (" + commentAttributes.size() + ")");
    if (commentAttributes.isEmpty()) {
        section.setEnabled(false);
    } else {
        if (hasIncoming) {
            expandSection(toolkit, section);
        } else {
            section.addExpansionListener(new ExpansionAdapter() {

                @Override
                public void expansionStateChanged(ExpansionEvent event) {
                    if (section.getClient() == null) {
                        try {
                            expandAllInProgress = true;
                            getTaskEditorPage().setReflow(false);
                            expandSection(toolkit, section);
                        } finally {
                            expandAllInProgress = false;
                            getTaskEditorPage().setReflow(true);
                        }
                        reflow();
                    }
                }
            });
        }
    }
    setSection(toolkit, section);
}
Also used : RichTextAttributeEditor(org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor) SelectionProviderAdapter(org.eclipse.mylyn.commons.ui.SelectionProviderAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) CommentActionGroup(org.eclipse.mylyn.internal.tasks.ui.actions.CommentActionGroup) ActionContext(org.eclipse.ui.actions.ActionContext) IMenuListener(org.eclipse.jface.action.IMenuListener) AbstractReplyToCommentAction(org.eclipse.mylyn.internal.tasks.ui.editors.AbstractReplyToCommentAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ISelection(org.eclipse.jface.viewers.ISelection) IMenuManager(org.eclipse.jface.action.IMenuManager) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) Separator(org.eclipse.jface.action.Separator)

Aggregations

ActionContext (org.eclipse.ui.actions.ActionContext)22 ISelection (org.eclipse.jface.viewers.ISelection)5 IMenuManager (org.eclipse.jface.action.IMenuManager)4 MenuManager (org.eclipse.jface.action.MenuManager)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IMenuListener (org.eclipse.jface.action.IMenuListener)3 TreeSelection (org.eclipse.jface.viewers.TreeSelection)3 Separator (org.eclipse.jface.action.Separator)2 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)1 Inject (com.google.inject.Inject)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IProject (org.eclipse.core.resources.IProject)1 IContextMenuConstants (org.eclipse.jdt.ui.IContextMenuConstants)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 ColumnViewer (org.eclipse.jface.viewers.ColumnViewer)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1