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");
}
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);
}
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);
}
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);
}
}
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);
}
Aggregations