org.eclipse.search.ui.IContextMenuConstants Java Examples

The following examples show how to use org.eclipse.search.ui.IContextMenuConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init(IPageSite site) {
	super.init(site);
	IMenuManager menuManager = site.getActionBars().getMenuManager();
	menuManager.insertBefore(IContextMenuConstants.GROUP_PROPERTIES, new Separator(GROUP_FILTERING));
	fActionGroup.fillActionBars(site.getActionBars());
	menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new Action(SearchMessages.JavaSearchResultPage_preferences_label) {
		@Override
		public void run() {
			String pageId= "org.eclipse.search.preferences.SearchPreferencePage"; //$NON-NLS-1$
			String[] displayedPages= { pageId,
					"org.eclipse.ui.editors.preferencePages.Annotations", //$NON-NLS-1$
					"org.eclipse.ui.preferencePages.ColorsAndFonts" //$NON-NLS-1$
			};
			PreferencesUtil.createPreferenceDialogOn(JavaPlugin.getActiveWorkbenchShell(), pageId, displayedPages, null).open();
		}
	});
}
 
Example #2
Source File: NewTextSearchActionGroup.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
    if (selection == null) {
        return;
    }

    fOpenAction.selectionChanged(selection);
    if (fOpenAction.isEnabled()) {
        menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenAction);
    }

    if (selection.size() != 1) {
        return;
    }

    Object o = selection.getFirstElement();
    if (!(o instanceof IAdaptable)) {
        return;
    }

    // Create menu
    IMenuManager submenu = new MenuManager(SearchMessages.OpenWithMenu_label);
    submenu.add(new OpenWithMenu(fPage, (IAdaptable) o));

    // Add the submenu.
    menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
 
Example #3
Source File: FileSearchPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void fillContextMenu(IMenuManager mgr) {
    super.fillContextMenu(mgr);
    addSortActions(mgr);
    fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
    fActionGroup.fillContextMenu(mgr);
    AbstractPythonSearchQuery query = (AbstractPythonSearchQuery) getInput().getQuery();
    if (query.getSearchString().length() > 0) {
        IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
        if (!selection.isEmpty()) {
            ReplaceAction replaceSelection = new ReplaceAction(getSite().getShell(),
                    getInput(), selection.toArray(), true);
            replaceSelection.setText(SearchMessages.ReplaceAction_label_selected);
            mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceSelection);

        }
        ReplaceAction replaceAll = new ReplaceAction(getSite().getShell(), getInput(),
                null, true);
        replaceAll.setText(SearchMessages.ReplaceAction_label_all);
        mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll);
    }
}
 
Example #4
Source File: NewTextSearchActionGroup.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
    if (selection == null) {
        return;
    }

    fOpenAction.selectionChanged(selection);
    if (fOpenAction.isEnabled()) {
        menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenAction);
    }

    if (selection.size() != 1) {
        return;
    }

    Object o = selection.getFirstElement();
    if (!(o instanceof IAdaptable)) {
        return;
    }

    // Create menu
    IMenuManager submenu = new MenuManager("Open Wit&h");
    submenu.add(new OpenWithMenu(fPage, (IAdaptable) o));

    // Add the submenu.
    menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
 
Example #5
Source File: OpenEditorActionGroup.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void addOpenWithMenu(IMenuManager menu) {
	ISelection selection= getContext().getSelection();
	if (selection.isEmpty() || !(selection instanceof IStructuredSelection))
		return;
	IStructuredSelection ss= (IStructuredSelection)selection;
	if (ss.size() != 1)
		return;

	Object o= ss.getFirstElement();
	if (!(o instanceof IAdaptable))
		return;

	IAdaptable element= (IAdaptable)o;
	Object resource= element.getAdapter(IResource.class);
	if (!(resource instanceof IFile))
		return;

	// Create a menu.
	IMenuManager submenu= new MenuManager("Open With");
	submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource));

	// Add the submenu.
	menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
 
Example #6
Source File: ReferencesSearchGroup.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
	super.fillContextMenu(menu);
	
	IMenuManager incomingMenu = menu;

	IMenuManager declarationsMenu = new MenuManager(Messages.ReferencesSearchGroup_References, IContextMenuConstants.GROUP_SEARCH); 
	
	if (editor != null){
		menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);	
	} else {
		incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
	}
	incomingMenu = declarationsMenu;
	
	incomingMenu.add(findReferencesAction);
	incomingMenu.add(findReferencesProjectAction);
}
 
Example #7
Source File: DeclarationsSearchGroup.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
	super.fillContextMenu(menu);
	
	IMenuManager incomingMenu = menu;

	IMenuManager declarationsMenu = new MenuManager(Messages.DeclarationsSearchGroup_Declarations, IContextMenuConstants.GROUP_SEARCH); 
	
	if (editor != null){
		menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);	
	} else {
		incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
	}
	incomingMenu = declarationsMenu;
	
	incomingMenu.add(findDeclarationsAction);
	incomingMenu.add(findDeclarationsProjectAction);
}
 
Example #8
Source File: TypeScriptSearchResultPage.java    From typescript.java with MIT License 5 votes vote down vote up
private void addSortActions(IMenuManager mgr) {
	if (getLayout() != FLAG_LAYOUT_FLAT)
		return;
	MenuManager sortMenu= new MenuManager(SearchMessages.FileSearchPage_sort_by_label);
	sortMenu.add(fSortByNameAction);
	sortMenu.add(fSortByPathAction);

	fSortByNameAction.setChecked(fCurrentSortOrder == fSortByNameAction.getSortOrder());
	fSortByPathAction.setChecked(fCurrentSortOrder == fSortByPathAction.getSortOrder());

	mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
}
 
Example #9
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void fillContextMenu(IMenuManager mgr) {
	super.fillContextMenu(mgr);
	addSortActions(mgr);

	mgr.appendToGroup(IContextMenuConstants.GROUP_EDIT, getCopyQualifiedNameAction());

	fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
	fActionGroup.fillContextMenu(mgr);
}
 
Example #10
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addSortActions(IMenuManager mgr) {
	if (getLayout() != FLAG_LAYOUT_FLAT)
		return;
	MenuManager sortMenu= new MenuManager(SearchMessages.JavaSearchResultPage_sortBylabel);
	sortMenu.add(fSortByNameAction);
	sortMenu.add(fSortByPathAction);
	sortMenu.add(fSortByParentName);

	fSortByNameAction.setChecked(fCurrentSortOrder == fSortByNameAction.getSortOrder());
	fSortByPathAction.setChecked(fCurrentSortOrder == fSortByPathAction.getSortOrder());
	fSortByParentName.setChecked(fCurrentSortOrder == fSortByParentName.getSortOrder());

	mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
}
 
Example #11
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addGroupActions(IToolBarManager mgr) {
	mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, new Separator(GROUP_GROUPING));
	mgr.appendToGroup(GROUP_GROUPING, fGroupProjectAction);
	mgr.appendToGroup(GROUP_GROUPING, fGroupPackageAction);
	mgr.appendToGroup(GROUP_GROUPING, fGroupFileAction);
	mgr.appendToGroup(GROUP_GROUPING, fGroupTypeAction);

	updateGroupingActions();
}
 
Example #12
Source File: ReferenceSearchViewPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void fillToolbar(IToolBarManager tbm) {
	tbm.appendToGroup(IContextMenuConstants.GROUP_SHOW, showNextAction);
	tbm.appendToGroup(IContextMenuConstants.GROUP_SHOW, showPreviousAction);
	IActionBars actionBars = getSite().getActionBars();
	if (actionBars != null) {
		actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), showNextAction);
		actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), showPreviousAction);
	}
	tbm.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, expandAllAction);
	tbm.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, collapseAllAction);
}
 
Example #13
Source File: NewTextSearchActionGroup.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
    // view must exist if we create a context menu for it.

    ISelection selection = getContext().getSelection();
    if (selection instanceof IStructuredSelection) {
        addOpenWithMenu(menu, (IStructuredSelection) selection);
        if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled()
                && fOpenPropertiesDialog.isApplicableForSelection((IStructuredSelection) selection)) {
            menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
        }
    }

}
 
Example #14
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void fillContextMenu(IMenuManager mgr) {
    super.fillContextMenu(mgr);
    fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
    fActionGroup.fillContextMenu(mgr);
    AbstractSearchIndexQuery query = (AbstractSearchIndexQuery) getInput().getQuery();
    if (query.getSearchString().length() > 0) {
        IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
        if (!selection.isEmpty()) {
            ReplaceAction replaceSelection = new ReplaceAction(getSite().getShell(), getInput(),
                    selection.toArray(), true);
            replaceSelection.setText(SearchMessages.ReplaceAction_label_selected);
            mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceSelection);

        }
        ICallback<Boolean, Match> skipMatch = new ICallback<Boolean, Match>() {

            @Override
            public Boolean call(Match match) {
                StructuredViewer viewer = getViewer();
                ViewerFilter[] filters = viewer.getFilters();
                if (filters == null || filters.length == 0) {
                    return false;
                }
                for (ViewerFilter viewerFilter : filters) {
                    if (viewerFilter instanceof AbstractSearchResultsViewerFilter) {
                        AbstractSearchResultsViewerFilter searchResultsViewerFilter = (AbstractSearchResultsViewerFilter) viewerFilter;
                        if (searchResultsViewerFilter.isLeafMatch(viewer, match)) {
                            return false;
                        }
                    }
                }
                return true;
            }
        };
        ReplaceAction replaceAll = new ReplaceAction(getSite().getShell(), getInput(), null, true, skipMatch);
        replaceAll.setText(SearchMessages.ReplaceAction_label_all);
        mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll);
    }
}
 
Example #15
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void fillToolbar(IToolBarManager tbm) {
    super.fillToolbar(tbm);
    for (Action a : fGroupByActions) {
        String id = IContextMenuConstants.GROUP_PROPERTIES + "." + a.hashCode();
        a.setId(id);
        tbm.add(a);
    }
}
 
Example #16
Source File: FileSearchPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void addSortActions(IMenuManager mgr) {
    if (getLayout() != FLAG_LAYOUT_FLAT) {
        return;
    }
    MenuManager sortMenu = new MenuManager(SearchMessages.FileSearchPage_sort_by_label);
    sortMenu.add(fSortByNameAction);
    sortMenu.add(fSortByPathAction);

    fSortByNameAction.setChecked(fCurrentSortOrder == fSortByNameAction.getSortOrder());
    fSortByPathAction.setChecked(fCurrentSortOrder == fSortByPathAction.getSortOrder());

    mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
}
 
Example #17
Source File: NewTextSearchActionGroup.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
    // view must exist if we create a context menu for it.

    ISelection selection = getContext().getSelection();
    if (selection instanceof IStructuredSelection) {
        addOpenWithMenu(menu, (IStructuredSelection) selection);
        if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled()
                && fOpenPropertiesDialog.isApplicableForSelection((IStructuredSelection) selection)) {
            menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
        }
    }

}
 
Example #18
Source File: TypeScriptSearchResultPage.java    From typescript.java with MIT License 4 votes vote down vote up
public void init(IPageSite site) {
	super.init(site);
	IMenuManager menuManager = site.getActionBars().getMenuManager();
	menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new OpenSearchPreferencesAction());
}
 
Example #19
Source File: OpenEditorActionGroup.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
private void appendToGroup(IMenuManager menu, IAction action) {
	if (action.isEnabled())
		menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
}
 
Example #20
Source File: FileSearchPage.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void init(IPageSite site) {
    super.init(site);
    IMenuManager menuManager = site.getActionBars().getMenuManager();
    menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new OpenSearchPreferencesAction());
}