mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +02:00
Fixed IndexView "link To Editor" and "hide externally defined symbols"
This commit is contained in:
parent
be98867d5d
commit
b86598e23f
4 changed files with 82 additions and 10 deletions
|
@ -325,3 +325,4 @@ IndexView.openDefinition.name = Open Definition
|
|||
IndexView.findReferences.name = Find References
|
||||
IndexView.findDeclarations.name = Find Declarations
|
||||
IndexView.ToggleExternals.name = Toggle Show Externals
|
||||
IndexView.ToggleExternals.tooltip = Show Externaly Defined Symbols
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
|
||||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
|
@ -25,7 +26,9 @@ import org.eclipse.jface.viewers.TreeViewer;
|
|||
public class DiscardExternalDefsAction extends IndexAction {
|
||||
final IndexView view;
|
||||
public DiscardExternalDefsAction(TreeViewer viewer, IndexView view) {
|
||||
super(viewer, CUIPlugin.getResourceString("IndexView.ToggleExternals.name")); //$NON-NLS-1$
|
||||
super(viewer, CUIPlugin.getResourceString("IndexView.ToggleExternals.name"), IAction.AS_CHECK_BOX); //$NON-NLS-1$
|
||||
setToolTipText(CUIPlugin.getResourceString("IndexView.ToggleExternals.tooltip")); //$NON-NLS-1$
|
||||
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "public_co.gif"); //$NON-NLS-1$
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
|
@ -37,13 +40,6 @@ public class DiscardExternalDefsAction extends IndexAction {
|
|||
}
|
||||
|
||||
public boolean valid() {
|
||||
ISelection selection = viewer.getSelection();
|
||||
if (!(selection instanceof IStructuredSelection))
|
||||
return false;
|
||||
Object[] objs = ((IStructuredSelection)selection).toArray();
|
||||
for (int i = 0; i < objs.length; ++i)
|
||||
if (objs[i] instanceof ICProject)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,11 @@ import org.eclipse.jface.action.MenuManager;
|
|||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -69,18 +72,40 @@ public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
|||
|
||||
private TreeViewer viewer;
|
||||
// private DrillDownAdapter drillDownAdapter;
|
||||
private ToggleLinkingAction toggleLinkingAction;
|
||||
private IndexAction rebuildAction;
|
||||
private IndexAction discardExternalDefsAction;
|
||||
private IndexAction openDefinitionAction;
|
||||
private IndexAction findDeclarationsAction;
|
||||
private IndexAction findReferencesAction;
|
||||
Filter filter = new Filter();
|
||||
public boolean isLinking = false;
|
||||
|
||||
public void toggleExternalDefs() {
|
||||
filter.showExternalDefs = ! filter.showExternalDefs;
|
||||
viewer.refresh();
|
||||
}
|
||||
|
||||
public void toggleLinking() {
|
||||
isLinking = ! isLinking;
|
||||
if (isLinking) {
|
||||
openDefinitionAction.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles selection changed in viewer. Updates global actions. Links to
|
||||
* editor (if option enabled)
|
||||
*/
|
||||
void handleSelectionChanged(SelectionChangedEvent event) {
|
||||
final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
||||
// updateStatusLine(selection);
|
||||
// updateActionBars(selection);
|
||||
if (isLinking) {
|
||||
openDefinitionAction.run();
|
||||
}
|
||||
}
|
||||
private static class Filter {
|
||||
public boolean showExternalDefs = false;
|
||||
public boolean accept(PDOMBinding binding) {
|
||||
|
@ -438,11 +463,19 @@ public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
|||
Menu menu = menuMgr.createContextMenu(viewer.getControl());
|
||||
viewer.getControl().setMenu(menu);
|
||||
getSite().registerContextMenu(menuMgr, viewer);
|
||||
|
||||
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
handleSelectionChanged(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void makeActions() {
|
||||
rebuildAction = new RebuildIndexAction(viewer);
|
||||
discardExternalDefsAction = new DiscardExternalDefsAction(viewer, this);
|
||||
toggleLinkingAction = new ToggleLinkingAction(this);
|
||||
openDefinitionAction = new OpenDefinitionAction(viewer);
|
||||
findDeclarationsAction = new FindDeclarationsAction(viewer);
|
||||
findReferencesAction = new FindReferencesAction(viewer);
|
||||
|
@ -492,7 +525,9 @@ public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
|||
}
|
||||
|
||||
private void fillLocalToolBar(IToolBarManager manager) {
|
||||
//drillDownAdapter.addNavigationActions(manager);
|
||||
// drillDownAdapter.addNavigationActions(manager);
|
||||
manager.add(toggleLinkingAction);
|
||||
manager.add(discardExternalDefsAction);
|
||||
}
|
||||
|
||||
public void setFocus() {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
|
||||
|
||||
/**
|
||||
* This action toggles whether this navigator links its selection to the active
|
||||
* editor.
|
||||
*
|
||||
*/
|
||||
public class ToggleLinkingAction extends AbstractToggleLinkingAction {
|
||||
|
||||
IndexView fCView;
|
||||
|
||||
/**
|
||||
* Constructs a new action.
|
||||
*/
|
||||
public ToggleLinkingAction(IndexView cView) {
|
||||
fCView = cView;
|
||||
setChecked(cView.isLinking);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the action.
|
||||
*/
|
||||
public void run() {
|
||||
fCView.toggleLinking();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue