1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 354793 - References in Project key binding missing

This commit is contained in:
Anton Leherbauer 2011-09-02 11:19:58 +02:00
parent 5af07f83aa
commit 4a04387f57
7 changed files with 185 additions and 95 deletions

View file

@ -94,11 +94,19 @@ ActionDefinition.opendecl.description= Open an editor on the selected element's
ActionDefinition.opencview.name= Show in C/C++ Project view ActionDefinition.opencview.name= Show in C/C++ Project view
ActionDefinition.opencview.description= Show the selected resource in the C/C++ Project view ActionDefinition.opencview.description= Show the selected resource in the C/C++ Project view
ActionDefinition.finddecl.name= Find Declaration ActionDefinition.finddecl.name= Declaration
ActionDefinition.finddecl.description= Find Declaration ActionDefinition.finddecl.description= Search for declarations of the selected element in the workspace
ActionDefinition.finddecl.project.name= Declaration in Project
ActionDefinition.finddecl.project.description= Search for declarations of the selected element in the enclosing project
ActionDefinition.finddecl.workingset.name= Declaration in Working Set
ActionDefinition.finddecl.workingset.description= Search for declarations of the selected element in a working set
ActionDefinition.findrefs.name= Find References ActionDefinition.findrefs.name= References
ActionDefinition.findrefs.description= Find References ActionDefinition.findrefs.description= Search for references to the selected element in the workspace
ActionDefinition.findrefs.project.name= References in Project
ActionDefinition.findrefs.project.description= Search for references to the selected element in the enclosing project
ActionDefinition.findrefs.workingset.name= References in Working Set
ActionDefinition.findrefs.workingset.description= Search for references to the selected element in a working set
ActionDefinition.openCallHierarchy.name= Open Call Hierarchy ActionDefinition.openCallHierarchy.name= Open Call Hierarchy
ActionDefinition.openCallHierarchy.description= Open the call hierarchy for the selected element ActionDefinition.openCallHierarchy.description= Open the call hierarchy for the selected element

View file

@ -2378,11 +2378,31 @@
categoryId="org.eclipse.cdt.ui.category.source" categoryId="org.eclipse.cdt.ui.category.source"
name="%ActionDefinition.finddecl.name" name="%ActionDefinition.finddecl.name"
id="org.eclipse.cdt.ui.search.finddecl"/> id="org.eclipse.cdt.ui.search.finddecl"/>
<command
description="%ActionDefinition.finddecl.project.description"
categoryId="org.eclipse.cdt.ui.category.source"
name="%ActionDefinition.finddecl.project.name"
id="org.eclipse.cdt.ui.search.finddecl.project"/>
<command
description="%ActionDefinition.finddecl.workingset.description"
categoryId="org.eclipse.cdt.ui.category.source"
name="%ActionDefinition.finddecl.workingset.name"
id="org.eclipse.cdt.ui.search.finddecl.workingset"/>
<command <command
categoryId="org.eclipse.cdt.ui.category.source" categoryId="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.findrefs.description" description="%ActionDefinition.findrefs.description"
name="%ActionDefinition.findrefs.name" name="%ActionDefinition.findrefs.name"
id="org.eclipse.cdt.ui.search.findrefs"/> id="org.eclipse.cdt.ui.search.findrefs"/>
<command
categoryId="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.findrefs.project.description"
name="%ActionDefinition.findrefs.project.name"
id="org.eclipse.cdt.ui.search.findrefs.project"/>
<command
categoryId="org.eclipse.cdt.ui.category.source"
description="%ActionDefinition.findrefs.workingset.description"
name="%ActionDefinition.findrefs.workingset.name"
id="org.eclipse.cdt.ui.search.findrefs.workingset"/>
<command <command
categoryId="org.eclipse.ui.category.navigate" categoryId="org.eclipse.ui.category.navigate"
description="%ActionDefinition.openCallHierarchy.description" description="%ActionDefinition.openCallHierarchy.description"

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others. * Copyright (c) 2005, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -510,7 +510,8 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
// Do this before setting input but after the initializations of the fields filtering // Do this before setting input but after the initializations of the fields filtering
registerActionBars(bars); registerActionBars(bars);
bars.updateActionBars();
fTreeViewer.setInput(fInput); fTreeViewer.setInput(fInput);
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW); PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
} }
@ -591,7 +592,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
if (fRefactoringActionGroup != null) { if (fRefactoringActionGroup != null) {
fRefactoringActionGroup.fillActionBars(actionBars); fRefactoringActionGroup.fillActionBars(actionBars);
} }
if (fSelectionSearchGroup != null) {
fSelectionSearchGroup.fillActionBars(actionBars);
}
IMenuManager menu= actionBars.getMenuManager(); IMenuManager menu= actionBars.getMenuManager();
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$ menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2010 QNX Software Systems and others. * Copyright (c) 2000, 2011 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -34,7 +34,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* @since 4.0.0 * @since 4.0.0
*/ */
public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.edit.text.c.toggle.comment"; //$NON-NLS-1$ public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.edit.text.c.toggle.comment"; //$NON-NLS-1$
/** /**
* Action definition ID of the source -> add block comment action * Action definition ID of the source -> add block comment action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.block.comment"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.add.block.comment"</code>).
@ -48,20 +48,20 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* @since 3.0 * @since 3.0
*/ */
public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.remove.block.comment"; //$NON-NLS-1$ public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.remove.block.comment"; //$NON-NLS-1$
/** /**
* Action definition ID of the source -> join lines action * Action definition ID of the source -> join lines action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.join.lines"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.join.lines"</code>).
* @since 3.0.2 * @since 3.0.2
*/ */
public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$ public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
/** /**
* Action definition ID of the source -> indent action * Action definition ID of the source -> indent action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.indent"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.indent"</code>).
*/ */
public static final String INDENT = "org.eclipse.cdt.ui.edit.text.c.indent"; //$NON-NLS-1$ public static final String INDENT = "org.eclipse.cdt.ui.edit.text.c.indent"; //$NON-NLS-1$
/** /**
* Action definition ID of the source -> format action * Action definition ID of the source -> format action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>).
@ -72,20 +72,20 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* Action definition ID of the source -> add include action * Action definition ID of the source -> add include action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.add.include"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.add.include"</code>).
*/ */
public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$ public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$
/** /**
* Action definition ID of the open declaration action * Action definition ID of the open declaration action
* (value <code>"org.eclipse.cdt.ui.edit.opendecl"</code>). * (value <code>"org.eclipse.cdt.ui.edit.opendecl"</code>).
*/ */
public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$ public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$
/** /**
* Action definition ID of the show in C/C++ Projects View action * Action definition ID of the show in C/C++ Projects View action
* (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>). * (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
*/ */
public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$ public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
/** /**
* Action definition ID of the refactor -> rename element action * Action definition ID of the refactor -> rename element action
* (value <code>"org.eclipse.cdt.ui.edit.text.rename.element"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.rename.element"</code>).
@ -103,7 +103,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value <code>"org.eclipse.cdt.ui.refactor.extract.local.variable"</code>). * (value <code>"org.eclipse.cdt.ui.refactor.extract.local.variable"</code>).
*/ */
public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.refactor.extract.local.variable"; //$NON-NLS-1$ public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.refactor.extract.local.variable"; //$NON-NLS-1$
/** /**
* Action definition ID of the refactor -> extract function action (value * Action definition ID of the refactor -> extract function action (value
* <code>"org.eclipse.cdt.ui.refactor.extract.function"</code>). * <code>"org.eclipse.cdt.ui.refactor.extract.function"</code>).
@ -121,7 +121,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value <code>"org.eclipse.cdt.ui.refactor.hide.method"</code>). * (value <code>"org.eclipse.cdt.ui.refactor.hide.method"</code>).
*/ */
public static final String HIDE_METHOD= "org.eclipse.cdt.ui.refactor.hide.method"; //$NON-NLS-1$ public static final String HIDE_METHOD= "org.eclipse.cdt.ui.refactor.hide.method"; //$NON-NLS-1$
/** /**
* Action definition ID of the refactor -> implement method action * Action definition ID of the refactor -> implement method action
* (value <code>"org.eclipse.cdt.ui.refactor.implement.method"</code>). * (value <code>"org.eclipse.cdt.ui.refactor.implement.method"</code>).
@ -139,24 +139,48 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value <code>"org.eclipse.cdt.ui.edit.text.undo.action"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.undo.action"</code>).
*/ */
public static final String UNDO_ACTION= "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$ public static final String UNDO_ACTION= "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$
/** /**
* Action definition ID of the refactor -> redo action * Action definition ID of the refactor -> redo action
* (value <code>"org.eclipse.cdt.ui.edit.text.redo.action"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.redo.action"</code>).
*/ */
public static final String REDO_ACTION= "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$ public static final String REDO_ACTION= "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$
/** /**
* Action definition ID of the find references in workspace action * Action definition ID of the find references in workspace action
* (value <code>"org.eclipse.cdt.ui.search.findrefs"</code>). * (value <code>"org.eclipse.cdt.ui.search.findrefs"</code>).
*/ */
public static final String FIND_REFS= "org.eclipse.cdt.ui.search.findrefs"; //$NON-NLS-1$ public static final String FIND_REFS= "org.eclipse.cdt.ui.search.findrefs"; //$NON-NLS-1$
/**
* Action definition ID of the find references in project action
* (value <code>"org.eclipse.cdt.ui.search.findrefs.project"</code>).
*/
public static final String FIND_REFS_PROJECT= "org.eclipse.cdt.ui.search.findrefs.project"; //$NON-NLS-1$
/**
* Action definition ID of the find references in working set action
* (value <code>"org.eclipse.cdt.ui.search.findrefs.workingset"</code>).
*/
public static final String FIND_REFS_WORKING_SET= "org.eclipse.cdt.ui.search.findrefs.workingset"; //$NON-NLS-1$
/** /**
* Action definition ID of the find declarations in workspace action * Action definition ID of the find declarations in workspace action
* (value <code>"org.eclipse.cdt.ui.search.finddecl"</code>). * (value <code>"org.eclipse.cdt.ui.search.finddecl"</code>).
*/ */
public static final String FIND_DECL= "org.eclipse.cdt.ui.search.finddecl"; //$NON-NLS-1$ public static final String FIND_DECL= "org.eclipse.cdt.ui.search.finddecl"; //$NON-NLS-1$
/**
* Action definition ID of the find declarations in project action
* (value <code>"org.eclipse.cdt.ui.search.finddecl.project"</code>).
*/
public static final String FIND_DECL_PROJECT= "org.eclipse.cdt.ui.search.finddecl.project"; //$NON-NLS-1$
/**
* Action definition ID of the find declarations in working set action
* (value <code>"org.eclipse.cdt.ui.search.finddecl.workingset"</code>).
*/
public static final String FIND_DECL_WORKING_SET= "org.eclipse.cdt.ui.search.finddecl.workingset"; //$NON-NLS-1$
/** /**
* Action definition ID of the navigate -> open type hierarchy action * Action definition ID of the navigate -> open type hierarchy action
@ -218,18 +242,18 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* Action definition ID for goto next bookmark action * Action definition ID for goto next bookmark action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"</code>).
*/ */
public static final String GOTO_NEXT_BOOKMARK = "org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"; //$NON-NLS-1$ public static final String GOTO_NEXT_BOOKMARK = "org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"; //$NON-NLS-1$
/** /**
* Action definition ID for find word action * Action definition ID for find word action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.find.word"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.find.word"</code>).
*/ */
public static final String FIND_WORD = "org.eclipse.cdt.ui.edit.text.c.find.word"; //$NON-NLS-1$ public static final String FIND_WORD = "org.eclipse.cdt.ui.edit.text.c.find.word"; //$NON-NLS-1$
/** /**
* Action definition ID for toggle source/header action. * Action definition ID for toggle source/header action.
* (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.source.header"</code>) * (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.source.header"</code>)
* *
* @since 4.0 * @since 4.0
*/ */
public static final String TOGGLE_SOURCE_HEADER = "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"; //$NON-NLS-1$ public static final String TOGGLE_SOURCE_HEADER = "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"; //$NON-NLS-1$
@ -260,19 +284,19 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.enclosing"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.enclosing"</code>).
*/ */
public static final String SELECT_ENCLOSING = "org.eclipse.cdt.ui.edit.text.c.select.enclosing"; //$NON-NLS-1$ public static final String SELECT_ENCLOSING = "org.eclipse.cdt.ui.edit.text.c.select.enclosing"; //$NON-NLS-1$
/** /**
* Action definition ID of the edit -> select next action * Action definition ID of the edit -> select next action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.next"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.next"</code>).
*/ */
public static final String SELECT_NEXT = "org.eclipse.cdt.ui.edit.text.c.select.next"; //$NON-NLS-1$ public static final String SELECT_NEXT = "org.eclipse.cdt.ui.edit.text.c.select.next"; //$NON-NLS-1$
/** /**
* Action definition ID of the edit -> select previous action * Action definition ID of the edit -> select previous action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.previous"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.previous"</code>).
*/ */
public static final String SELECT_PREVIOUS = "org.eclipse.cdt.ui.edit.text.c.select.previous"; //$NON-NLS-1$ public static final String SELECT_PREVIOUS = "org.eclipse.cdt.ui.edit.text.c.select.previous"; //$NON-NLS-1$
/** /**
* Action definition ID of the edit -> select restore last action * Action definition ID of the edit -> select restore last action
* (value <code>"org.eclipse.cdt.ui.edit.text.c.select.last"</code>). * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.last"</code>).

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation and others. * Copyright (c) 2004, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -21,6 +21,7 @@ import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.search.ui.IContextMenuConstants; import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.ActionGroup;
@ -35,18 +36,21 @@ import org.eclipse.cdt.internal.ui.search.CSearchUtil;
public class DeclarationsSearchGroup extends ActionGroup { public class DeclarationsSearchGroup extends ActionGroup {
private CEditor fEditor; private CEditor fEditor;
private IWorkbenchSite fSite; private IWorkbenchSite fSite;
private FindDeclarationsAction fFindDeclarationsAction; private FindDeclarationsAction fFindDeclarationsAction;
private FindDeclarationsProjectAction fFindDeclarationsProjectAction; private FindDeclarationsProjectAction fFindDeclarationsProjectAction;
private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction; private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
public DeclarationsSearchGroup(IWorkbenchSite site) { public DeclarationsSearchGroup(IWorkbenchSite site) {
fFindDeclarationsAction= new FindDeclarationsAction(site); fFindDeclarationsAction= new FindDeclarationsAction(site);
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site); fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site);
fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null); fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null);
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
fSite = site; fSite = site;
} }
/** /**
@ -57,45 +61,53 @@ public class DeclarationsSearchGroup extends ActionGroup {
fFindDeclarationsAction= new FindDeclarationsAction(editor); fFindDeclarationsAction= new FindDeclarationsAction(editor);
fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL); fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
if (editor != null){ editor.setAction(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
}
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(editor); fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(editor);
fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null); fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null);
fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
} }
/* /*
* Method declared on ActionGroup. * Method declared on ActionGroup.
*/ */
@Override @Override
public void fillContextMenu(IMenuManager menu) { public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu); super.fillContextMenu(menu);
IMenuManager incomingMenu = menu; IMenuManager incomingMenu = menu;
IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations, IContextMenuConstants.GROUP_SEARCH); IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations, IContextMenuConstants.GROUP_SEARCH);
if (fEditor != null){ if (fEditor != null){
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu); menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
} else { } else {
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu); incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
} }
incomingMenu = declarationsMenu; incomingMenu = declarationsMenu;
FindAction[] actions = getWorkingSetActions(); FindAction[] actions = getWorkingSetActions();
incomingMenu.add(fFindDeclarationsAction); incomingMenu.add(fFindDeclarationsAction);
incomingMenu.add(fFindDeclarationsProjectAction); incomingMenu.add(fFindDeclarationsProjectAction);
incomingMenu.add(fFindDeclarationsInWorkingSetAction); incomingMenu.add(fFindDeclarationsInWorkingSetAction);
for (FindAction action : actions) { for (FindAction action : actions) {
incomingMenu.add(action); incomingMenu.add(action);
} }
} }
@Override
public void fillActionBars(IActionBars actionBars) {
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
}
private FindAction[] getWorkingSetActions() { private FindAction[] getWorkingSetActions() {
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE); ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator(); Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IWorkingSet[] workingSets= iter.next(); IWorkingSet[] workingSets= iter.next();
@ -104,10 +116,10 @@ public class DeclarationsSearchGroup extends ActionGroup {
action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets)); action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
else else
action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets)); action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
actions.add(action); actions.add(action);
} }
return actions.toArray(new FindAction[actions.size()]); return actions.toArray(new FindAction[actions.size()]);
} }
public static boolean canActionBeAdded(ISelection selection) { public static boolean canActionBeAdded(ISelection selection) {
@ -116,7 +128,7 @@ public class DeclarationsSearchGroup extends ActionGroup {
} }
return getElement(selection) != null; return getElement(selection) != null;
} }
private static ICElement getElement(ISelection sel) { private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List<?> list= ((IStructuredSelection)sel).toList(); List<?> list= ((IStructuredSelection)sel).toList();
@ -129,8 +141,8 @@ public class DeclarationsSearchGroup extends ActionGroup {
} }
return null; return null;
} }
/* /*
* Overrides method declared in ActionGroup * Overrides method declared in ActionGroup
*/ */
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation and others. * Copyright (c) 2004, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,6 +16,7 @@ import java.util.Iterator;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.MenuManager;
import org.eclipse.search.ui.IContextMenuConstants; import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.ActionGroup;
@ -31,66 +32,78 @@ public class ReferencesSearchGroup extends ActionGroup {
private FindRefsAction fFindRefsAction; private FindRefsAction fFindRefsAction;
private FindRefsProjectAction fFindRefsProjectAction; private FindRefsProjectAction fFindRefsProjectAction;
private FindRefsInWorkingSetAction fFindRefsInWorkingSetAction; private FindRefsInWorkingSetAction fFindRefsInWorkingSetAction;
private CEditor fEditor; private CEditor fEditor;
private IWorkbenchSite fSite; private IWorkbenchSite fSite;
public ReferencesSearchGroup(IWorkbenchSite site) { public ReferencesSearchGroup(IWorkbenchSite site) {
fFindRefsAction= new FindRefsAction(site); fFindRefsAction= new FindRefsAction(site);
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
fFindRefsProjectAction = new FindRefsProjectAction(site); fFindRefsProjectAction = new FindRefsProjectAction(site);
fFindRefsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null); fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null);
fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
fSite=site; fSite=site;
} }
/** /**
* @param editor * @param editor
*/ */
public ReferencesSearchGroup(CEditor editor) { public ReferencesSearchGroup(CEditor editor) {
fEditor = editor; fEditor = editor;
fFindRefsAction= new FindRefsAction(editor); fFindRefsAction= new FindRefsAction(editor);
fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS); fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
if (editor != null){ editor.setAction(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
}
fFindRefsProjectAction = new FindRefsProjectAction(editor); fFindRefsProjectAction = new FindRefsProjectAction(editor);
fFindRefsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_PROJECT, fFindRefsProjectAction);
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(editor, null); fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(editor, null);
fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET, fFindRefsInWorkingSetAction);
} }
/* /*
* Method declared on ActionGroup. * Method declared on ActionGroup.
*/ */
@Override @Override
public void fillContextMenu(IMenuManager menu) { public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu); super.fillContextMenu(menu);
IMenuManager incomingMenu = menu; IMenuManager incomingMenu = menu;
IMenuManager refsMenu = new MenuManager(CSearchMessages.group_references, IContextMenuConstants.GROUP_SEARCH); IMenuManager refsMenu = new MenuManager(CSearchMessages.group_references, IContextMenuConstants.GROUP_SEARCH);
if (fEditor != null){ if (fEditor != null){
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu); menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
} else { } else {
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu); incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu);
} }
incomingMenu = refsMenu; incomingMenu = refsMenu;
FindAction[] actions = getWorkingSetActions(); FindAction[] actions = getWorkingSetActions();
incomingMenu.add(fFindRefsAction); incomingMenu.add(fFindRefsAction);
incomingMenu.add(fFindRefsProjectAction); incomingMenu.add(fFindRefsProjectAction);
incomingMenu.add(fFindRefsInWorkingSetAction); incomingMenu.add(fFindRefsInWorkingSetAction);
for (FindAction action : actions) { for (FindAction action : actions) {
incomingMenu.add(action); incomingMenu.add(action);
} }
} }
@Override
public void fillActionBars(IActionBars actionBars) {
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_REFS_PROJECT, fFindRefsProjectAction);
actionBars.setGlobalActionHandler(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
}
private FindAction[] getWorkingSetActions() { private FindAction[] getWorkingSetActions() {
ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE); ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator(); Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IWorkingSet[] workingSets= iter.next(); IWorkingSet[] workingSets= iter.next();
@ -99,14 +112,14 @@ public class ReferencesSearchGroup extends ActionGroup {
action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets)); action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
else else
action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets)); action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
actions.add(action); actions.add(action);
} }
return actions.toArray(new FindAction[actions.size()]); return actions.toArray(new FindAction[actions.size()]);
} }
/* /*
* Overrides method declared in ActionGroup * Overrides method declared in ActionGroup
*/ */
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2008 IBM Corporation and others. * Copyright (c) 2004, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,10 +12,12 @@ package org.eclipse.cdt.internal.ui.search.actions;
import java.util.List; import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.part.Page; import org.eclipse.ui.part.Page;
@ -25,16 +27,16 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CEditor;
public class SelectionSearchGroup extends ActionGroup { public class SelectionSearchGroup extends ActionGroup {
private CEditor fEditor; private CEditor fEditor;
private DeclarationsSearchGroup fDeclarationsSearchGroup; private DeclarationsSearchGroup fDeclarationsSearchGroup;
private ReferencesSearchGroup fRefSearchGroup; private ReferencesSearchGroup fRefSearchGroup;
public SelectionSearchGroup(CEditor editor){ public SelectionSearchGroup(CEditor editor){
//TODO: Assert editor not null Assert.isNotNull(editor);
fEditor= editor; fEditor= editor;
fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor); fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor);
fRefSearchGroup = new ReferencesSearchGroup(fEditor); fRefSearchGroup = new ReferencesSearchGroup(fEditor);
} }
@ -51,24 +53,32 @@ public class SelectionSearchGroup extends ActionGroup {
fDeclarationsSearchGroup= new DeclarationsSearchGroup(site); fDeclarationsSearchGroup= new DeclarationsSearchGroup(site);
fRefSearchGroup = new ReferencesSearchGroup(site); fRefSearchGroup = new ReferencesSearchGroup(site);
} }
/* /*
* Method declared on ActionGroup. * Method declared on ActionGroup.
*/ */
@Override @Override
public void fillContextMenu(IMenuManager menu) { public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu); super.fillContextMenu(menu);
fDeclarationsSearchGroup.fillContextMenu(menu); fDeclarationsSearchGroup.fillContextMenu(menu);
fRefSearchGroup.fillContextMenu(menu); fRefSearchGroup.fillContextMenu(menu);
} }
@Override
public void fillActionBars(IActionBars actionBars) {
if (fEditor == null) {
fDeclarationsSearchGroup.fillActionBars(actionBars);
fRefSearchGroup.fillActionBars(actionBars);
}
}
public static boolean canActionBeAdded(ISelection selection) { public static boolean canActionBeAdded(ISelection selection) {
if(selection instanceof ITextSelection) { if(selection instanceof ITextSelection) {
return (((ITextSelection)selection).getLength() > 0); return (((ITextSelection)selection).getLength() > 0);
} }
return getElement(selection) != null; return getElement(selection) != null;
} }
private static ICElement getElement(ISelection sel) { private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List<?> list= ((IStructuredSelection)sel).toList(); List<?> list= ((IStructuredSelection)sel).toList();
@ -81,7 +91,7 @@ public class SelectionSearchGroup extends ActionGroup {
} }
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionGroup#dispose() * @see org.eclipse.ui.actions.ActionGroup#dispose()
*/ */
@ -91,14 +101,14 @@ public class SelectionSearchGroup extends ActionGroup {
fDeclarationsSearchGroup.dispose(); fDeclarationsSearchGroup.dispose();
fDeclarationsSearchGroup= null; fDeclarationsSearchGroup= null;
} }
if (fRefSearchGroup != null) { if (fRefSearchGroup != null) {
fRefSearchGroup.dispose(); fRefSearchGroup.dispose();
fRefSearchGroup= null; fRefSearchGroup= null;
} }
fEditor= null; fEditor= null;
super.dispose(); super.dispose();
} }
} }