1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Got rid of the old search context menus in CEditor, COutlineView, CView.

This commit is contained in:
Bogdan Gheorghe 2004-05-05 16:21:22 +00:00
parent 1f9900d9e0
commit c241ddb3ed
8 changed files with 67 additions and 82 deletions

View file

@ -1,3 +1,14 @@
2004-05-05 Bogdan Gheorghe
Got rid of the old search context menus in CEditor, COutlineView, CView.
* src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
* src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties
* src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
* src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
* src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
* src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
2004-05-05 Andrew Niefer
externalize "Libraries" string in LibraryRefContainer

View file

@ -43,7 +43,7 @@ ToggleLinkingAction.label=Lin&k With Editor
ToggleLinkingAction.toolTip=Link with Editor
ToggleLinkingAction.description=Link with active editor
SearchAction.label=Search
SearchAction.label=Search For
FileSearchAction.label=Search
FilterSelectionAction.label= Filters ...

View file

@ -69,10 +69,6 @@ public class MainActionGroup extends CViewActionGroup {
CollapseAllAction collapseAllAction;
ToggleLinkingAction toggleLinkingAction;
//Search
FileSearchAction fFileSearchAction;
FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
SearchDialogAction fSearchDialogAction;
BuildGroup buildGroup;
OpenFileGroup openFileGroup;
@ -160,10 +156,6 @@ public class MainActionGroup extends CViewActionGroup {
toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$
toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
fFileSearchAction = new FileSearchAction(viewer);
fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(viewer);
fSearchDialogAction = new SearchDialogAction(viewer, getCView().getViewSite().getWorkbenchWindow());
selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
refactoringActionGroup = new RefactoringActionGroup(getCView().getSite(), null);
@ -186,10 +178,11 @@ public class MainActionGroup extends CViewActionGroup {
menu.add(importAction);
exportAction.selectionChanged(resources);
menu.add(exportAction);
menu.add(new Separator());
addSearchMenu(menu, celements);
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
menu.add(new Separator());
addSelectionSearchMenu(menu, resources);
return;
}
@ -210,8 +203,6 @@ public class MainActionGroup extends CViewActionGroup {
menu.add(new Separator());
openProjectGroup.fillContextMenu(menu);
addBookMarkMenu(menu, resources);
menu.add(new Separator());
addSearchMenu(menu, resources);
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
addPropertyMenu(menu, resources);
@ -266,28 +257,14 @@ public class MainActionGroup extends CViewActionGroup {
MenuManager search = new MenuManager(CViewMessages.getString("SearchAction.label"), IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
if (SearchDialogAction.canActionBeAdded(selection)) {
search.add(fSearchDialogAction);
if (SelectionSearchGroup.canActionBeAdded(selection)){
selectionSearchGroup.fillContextMenu(search);
}
if (FileSearchAction.canActionBeAdded(selection)) {
MenuManager fileSearch = new MenuManager(CViewMessages.getString("FileSearchAction.label"));//$NON-NLS-1$
fileSearch.add(fFileSearchAction);
fileSearch.add(fFileSearchActionInWorkingSet);
search.add(fileSearch);
}
menu.add(search);
}
/**
* @param menu
*/
void addSelectionSearchMenu(IMenuManager menu, IStructuredSelection selection) {
selectionSearchGroup.fillContextMenu(menu);
}
public void runDefaultAction(IStructuredSelection selection) {
openFileGroup.runDefaultAction(selection);
openProjectGroup.runDefaultAction(selection);

View file

@ -7,10 +7,11 @@ package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
import org.eclipse.cdt.internal.ui.cview.CViewMessages;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
import org.eclipse.cdt.ui.CElementContentProvider;
@ -37,8 +38,10 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
public class CContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener {
@ -50,9 +53,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
private String fContextMenuId;
private OpenIncludeAction fOpenIncludeAction;
private FileSearchAction fFileSearchAction;
private FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
private SearchDialogAction fSearchDialogAction;
private MemberFilterActionGroup fMemberFilterActionGroup;
@ -73,9 +73,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
fTogglePresentation.setEditor(editor);
fOpenIncludeAction= new OpenIncludeAction(this);
fFileSearchAction= new FileSearchAction(this);
fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(this);
fSearchDialogAction = new SearchDialogAction(this, editor);
}
public ICElement getRoot() {
@ -129,21 +126,20 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
menu.add(fOpenIncludeAction);
}
if (SearchDialogAction.canActionBeAdded(getSelection())) {
menu.add(fSearchDialogAction);
}
if (FileSearchAction.canActionBeAdded(getSelection())) {
MenuManager fileSearch = new MenuManager(CEditorMessages.getString("CContentOutlinePage.menu.fileSearch")); //$NON-NLS-1$
fileSearch.add(fFileSearchAction);
fileSearch.add(fFileSearchActionInWorkingSet);
menu.add(fileSearch);
}
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
fSelectionSearchGroup.fillContextMenu(menu);
if (SelectionSearchGroup.canActionBeAdded(getSelection())){
MenuManager search = new MenuManager(CViewMessages.getString("SearchAction.label"), IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
fSelectionSearchGroup.fillContextMenu(search);
menu.add(search);
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
fRefactoringActionGroup.fillContextMenu(menu);
}
/**

View file

@ -102,12 +102,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
protected CContentOutlinePage fOutlinePage;
/** Search actions **/
private FileSearchAction fFileSearchAction;
private FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
private SearchDialogAction fSearchDialogAction;
private ActionGroup fSelectionSearchGroup;
private ActionGroup fRefactoringActionGroup;
@ -519,13 +513,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fSelectionSearchGroup = new SelectionSearchGroup(this);
fRefactoringActionGroup = new RefactoringActionGroup(this, null);
//Search items
fFileSearchAction = new FileSearchAction(getSelectionProvider());
fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(getSelectionProvider());
fSearchDialogAction = new SearchDialogAction(getSelectionProvider(), this);
if (hyperLinkEnabled()){
enableBrowserLikeLinks();
}
@ -545,23 +532,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
// @@@ disabled for now until we get it to do something...
//addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$
MenuManager search = new MenuManager(CEditorMessages.getString("CEditor.menu.search"), IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, search);
if (SearchDialogAction.canActionBeAdded(getSelectionProvider().getSelection())){
search.add(fSearchDialogAction);
}
if (FileSearchAction.canActionBeAdded(getSelectionProvider().getSelection())) {
MenuManager fileSearch = new MenuManager(CEditorMessages.getString("CEditor.menu.fileSearch")); //$NON-NLS-1$
fileSearch.add(fFileSearchAction);
fileSearch.add(fFileSearchActionInWorkingSet);
search.add(fileSearch);
}
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDeclarations"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "AddIncludeOnSelection"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "OpenDeclarations"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ShowInCView"); //$NON-NLS-1$
fRefactoringActionGroup.fillContextMenu(menu);

View file

@ -69,11 +69,11 @@ OpenHierarchy.dialog.title=Open Type Hierarchy
OpenHierarchy.label=Open Type &Hierarchy@F4
OpenHierarchy.tooltip=Show the type hierarchy of the selected element
OpenDeclarations.description=Open an editor on the selected element's declaration(s)
OpenDeclarations.description=Open an editor on the selected element's declaration
OpenDeclarations.dialog.message=&Select or enter the element to open:
OpenDeclarations.dialog.title=Open Declarations
OpenDeclarations.label=&Open Declarations@F3
OpenDeclarations.tooltip=Open an editor on the selected element's declaration(s)
OpenDeclarations.dialog.title=Open Declaration
OpenDeclarations.label=&Open Declaration@F3
OpenDeclarations.tooltip=Open an editor on the selected element's declaration
OrganizeImports.description=Evaluate all required imports and replace the current imports
OrganizeImports.error.message2=Syntax errors in compilation unit prevent correct evaluation\nof type references. Fix errors first.

View file

@ -9,9 +9,9 @@
# IBM Corporation - initial API and implementation
###############################################################################
group.search=Selection S&earch
group.declarations= Dec&larations
group.references= Re&ferences
group.search=S&earch For
group.declarations= All Dec&larations
group.references= All Re&ferences
Search.Error.search.title=Search Error

View file

@ -10,10 +10,15 @@
******************************************************************************/
package org.eclipse.cdt.internal.ui.search.actions;
import java.util.List;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
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.IWorkbenchSite;
import org.eclipse.ui.actions.ActionGroup;
@ -64,4 +69,25 @@ public class SelectionSearchGroup extends ActionGroup {
fDeclarationsSearchGroup.fillContextMenu(incomingMenu);
fRefSearchGroup.fillContextMenu(incomingMenu);
}
public static boolean canActionBeAdded(ISelection selection) {
if(selection instanceof ITextSelection) {
return (((ITextSelection)selection).getLength() > 0);
} else {
return getElement(selection) != null;
}
}
private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List list= ((IStructuredSelection)sel).toList();
if (list.size() == 1) {
Object element= list.get(0);
if (element instanceof ICElement) {
return (ICElement)element;
}
}
}
return null;
}
}