diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 9897cc2cbe5..356cea095b7 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -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.description= Show the selected resource in the C/C++ Project view
-ActionDefinition.finddecl.name= Find Declaration
-ActionDefinition.finddecl.description= Find Declaration
+ActionDefinition.finddecl.name= 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.description= Find References
+ActionDefinition.findrefs.name= 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.description= Open the call hierarchy for the selected element
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 8bdb81c1c9c..b6fcfa05921 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -2378,11 +2378,31 @@
categoryId="org.eclipse.cdt.ui.category.source"
name="%ActionDefinition.finddecl.name"
id="org.eclipse.cdt.ui.search.finddecl"/>
+
+
+
+
add block comment action
* (value "org.eclipse.cdt.ui.edit.text.c.add.block.comment"
).
@@ -48,20 +48,20 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* @since 3.0
*/
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
* (value "org.eclipse.cdt.ui.edit.text.c.join.lines"
).
* @since 3.0.2
*/
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
* (value "org.eclipse.cdt.ui.edit.text.c.indent"
).
*/
public static final String INDENT = "org.eclipse.cdt.ui.edit.text.c.indent"; //$NON-NLS-1$
-
+
/**
* Action definition ID of the source -> format action
* (value "org.eclipse.cdt.ui.edit.text.c.format"
).
@@ -72,20 +72,20 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* Action definition ID of the source -> add include action
* (value "org.eclipse.cdt.ui.edit.text.c.add.include"
).
*/
- 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
* (value "org.eclipse.cdt.ui.edit.opendecl"
).
*/
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
* (value "org.eclipse.cdt.ui.edit.opencview"
).
*/
public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
-
+
/**
* Action definition ID of the refactor -> rename element action
* (value "org.eclipse.cdt.ui.edit.text.rename.element"
).
@@ -103,7 +103,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value "org.eclipse.cdt.ui.refactor.extract.local.variable"
).
*/
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
* "org.eclipse.cdt.ui.refactor.extract.function"
).
@@ -121,7 +121,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value "org.eclipse.cdt.ui.refactor.hide.method"
).
*/
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
* (value "org.eclipse.cdt.ui.refactor.implement.method"
).
@@ -139,24 +139,48 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* (value "org.eclipse.cdt.ui.edit.text.undo.action"
).
*/
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
* (value "org.eclipse.cdt.ui.edit.text.redo.action"
).
*/
- 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
* (value "org.eclipse.cdt.ui.search.findrefs"
).
*/
- 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 "org.eclipse.cdt.ui.search.findrefs.project"
).
+ */
+ 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 "org.eclipse.cdt.ui.search.findrefs.workingset"
).
+ */
+ 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
* (value "org.eclipse.cdt.ui.search.finddecl"
).
*/
- 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 "org.eclipse.cdt.ui.search.finddecl.project"
).
+ */
+ 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 "org.eclipse.cdt.ui.search.finddecl.workingset"
).
+ */
+ 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
@@ -218,18 +242,18 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
* Action definition ID for goto next bookmark action
* (value "org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"
).
*/
- 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
* (value "org.eclipse.cdt.ui.edit.text.c.find.word"
).
*/
- 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.
* (value "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"
)
- *
+ *
* @since 4.0
*/
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 "org.eclipse.cdt.ui.edit.text.c.select.enclosing"
).
*/
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
* (value "org.eclipse.cdt.ui.edit.text.c.select.next"
).
*/
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
* (value "org.eclipse.cdt.ui.edit.text.c.select.previous"
).
*/
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
* (value "org.eclipse.cdt.ui.edit.text.c.select.last"
).
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
index b4bf6344960..6cfedede9f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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.IStructuredSelection;
import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.actions.ActionGroup;
@@ -35,18 +36,21 @@ import org.eclipse.cdt.internal.ui.search.CSearchUtil;
public class DeclarationsSearchGroup extends ActionGroup {
-
+
private CEditor fEditor;
private IWorkbenchSite fSite;
-
+
private FindDeclarationsAction fFindDeclarationsAction;
private FindDeclarationsProjectAction fFindDeclarationsProjectAction;
private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
-
+
public DeclarationsSearchGroup(IWorkbenchSite site) {
fFindDeclarationsAction= new FindDeclarationsAction(site);
+ fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site);
+ fFindDeclarationsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null);
+ fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
fSite = site;
}
/**
@@ -57,45 +61,53 @@ public class DeclarationsSearchGroup extends ActionGroup {
fFindDeclarationsAction= new FindDeclarationsAction(editor);
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.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_PROJECT);
+ editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_PROJECT, fFindDeclarationsProjectAction);
fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null);
+ fFindDeclarationsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET);
+ editor.setAction(ICEditorActionDefinitionIds.FIND_DECL_WORKING_SET, fFindDeclarationsInWorkingSetAction);
}
- /*
+ /*
* Method declared on ActionGroup.
*/
@Override
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(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){
- menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
} else {
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
}
incomingMenu = declarationsMenu;
-
+
FindAction[] actions = getWorkingSetActions();
incomingMenu.add(fFindDeclarationsAction);
incomingMenu.add(fFindDeclarationsProjectAction);
incomingMenu.add(fFindDeclarationsInWorkingSetAction);
-
+
for (FindAction action : actions) {
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() {
ArrayList actions= new ArrayList(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
-
+
Iterator iter= CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) {
IWorkingSet[] workingSets= iter.next();
@@ -104,10 +116,10 @@ public class DeclarationsSearchGroup extends ActionGroup {
action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
else
action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
-
+
actions.add(action);
}
-
+
return actions.toArray(new FindAction[actions.size()]);
}
public static boolean canActionBeAdded(ISelection selection) {
@@ -116,7 +128,7 @@ public class DeclarationsSearchGroup extends ActionGroup {
}
return getElement(selection) != null;
}
-
+
private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List> list= ((IStructuredSelection)sel).toList();
@@ -129,8 +141,8 @@ public class DeclarationsSearchGroup extends ActionGroup {
}
return null;
}
-
- /*
+
+ /*
* Overrides method declared in ActionGroup
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
index 1a1d1bb9780..df863fdca63 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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.MenuManager;
import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.actions.ActionGroup;
@@ -31,66 +32,78 @@ public class ReferencesSearchGroup extends ActionGroup {
private FindRefsAction fFindRefsAction;
private FindRefsProjectAction fFindRefsProjectAction;
private FindRefsInWorkingSetAction fFindRefsInWorkingSetAction;
-
+
private CEditor fEditor;
private IWorkbenchSite fSite;
-
+
public ReferencesSearchGroup(IWorkbenchSite site) {
fFindRefsAction= new FindRefsAction(site);
+ fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
fFindRefsProjectAction = new FindRefsProjectAction(site);
+ fFindRefsProjectAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null);
+ fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
fSite=site;
}
-
+
/**
* @param editor
*/
public ReferencesSearchGroup(CEditor editor) {
fEditor = editor;
-
+
fFindRefsAction= new FindRefsAction(editor);
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.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_PROJECT);
+ editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_PROJECT, fFindRefsProjectAction);
fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(editor, null);
+ fFindRefsInWorkingSetAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET);
+ editor.setAction(ICEditorActionDefinitionIds.FIND_REFS_WORKING_SET, fFindRefsInWorkingSetAction);
}
-
- /*
+
+ /*
* Method declared on ActionGroup.
*/
@Override
public void fillContextMenu(IMenuManager menu) {
-
+
super.fillContextMenu(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){
- menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
} else {
incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu);
}
-
+
incomingMenu = refsMenu;
-
+
FindAction[] actions = getWorkingSetActions();
incomingMenu.add(fFindRefsAction);
incomingMenu.add(fFindRefsProjectAction);
incomingMenu.add(fFindRefsInWorkingSetAction);
-
+
for (FindAction action : actions) {
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() {
ArrayList actions= new ArrayList(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
-
+
Iterator iter= CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) {
IWorkingSet[] workingSets= iter.next();
@@ -99,14 +112,14 @@ public class ReferencesSearchGroup extends ActionGroup {
action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
else
action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
-
+
actions.add(action);
}
-
+
return actions.toArray(new FindAction[actions.size()]);
}
-
- /*
+
+ /*
* Overrides method declared in ActionGroup
*/
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
index 4b90bf40bf0..82a91226ff1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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 org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionGroup;
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;
public class SelectionSearchGroup extends ActionGroup {
-
+
private CEditor fEditor;
-
+
private DeclarationsSearchGroup fDeclarationsSearchGroup;
private ReferencesSearchGroup fRefSearchGroup;
-
+
public SelectionSearchGroup(CEditor editor){
- //TODO: Assert editor not null
+ Assert.isNotNull(editor);
fEditor= editor;
-
+
fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor);
fRefSearchGroup = new ReferencesSearchGroup(fEditor);
}
@@ -51,24 +53,32 @@ public class SelectionSearchGroup extends ActionGroup {
fDeclarationsSearchGroup= new DeclarationsSearchGroup(site);
fRefSearchGroup = new ReferencesSearchGroup(site);
}
- /*
+ /*
* Method declared on ActionGroup.
*/
@Override
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
-
+
fDeclarationsSearchGroup.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) {
if(selection instanceof ITextSelection) {
return (((ITextSelection)selection).getLength() > 0);
}
return getElement(selection) != null;
}
-
+
private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List> list= ((IStructuredSelection)sel).toList();
@@ -81,7 +91,7 @@ public class SelectionSearchGroup extends ActionGroup {
}
return null;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionGroup#dispose()
*/
@@ -91,14 +101,14 @@ public class SelectionSearchGroup extends ActionGroup {
fDeclarationsSearchGroup.dispose();
fDeclarationsSearchGroup= null;
}
-
+
if (fRefSearchGroup != null) {
fRefSearchGroup.dispose();
fRefSearchGroup= null;
}
-
+
fEditor= null;
-
+
super.dispose();
}
}