mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Bug 144236 - Fixed the NPE cause by not registering a selection provider for the IndexView's site. Now that the object contributed rebuild index works, I have removed the hardcoded one from the Index View.
This commit is contained in:
parent
263add60a9
commit
8df1d9249d
2 changed files with 1 additions and 68 deletions
|
@ -66,7 +66,6 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
|
|||
private TreeViewer viewer;
|
||||
// private DrillDownAdapter drillDownAdapter;
|
||||
private ToggleLinkingAction toggleLinkingAction;
|
||||
private IndexAction rebuildAction;
|
||||
private IndexAction countSymbolsAction;
|
||||
private IndexAction discardExternalDefsAction;
|
||||
private IndexAction openDefinitionAction;
|
||||
|
@ -310,6 +309,7 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
|
|||
viewer.getControl().setMenu(menu);
|
||||
getSite().registerContextMenu(menuMgr, viewer);
|
||||
|
||||
getSite().setSelectionProvider(viewer);
|
||||
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
handleSelectionChanged(event);
|
||||
|
@ -334,7 +334,6 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
|
|||
}
|
||||
|
||||
private void makeActions() {
|
||||
rebuildAction = new RebuildIndexAction(viewer);
|
||||
countSymbolsAction = new CountNodeAction(viewer);
|
||||
discardExternalDefsAction = new DiscardExternalDefsAction(viewer, this);
|
||||
toggleLinkingAction = new ToggleLinkingAction(this);
|
||||
|
@ -357,8 +356,6 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
|
|||
}
|
||||
|
||||
private void fillContextMenu(IMenuManager manager) {
|
||||
if (rebuildAction.valid())
|
||||
manager.add(rebuildAction);
|
||||
if (countSymbolsAction.valid())
|
||||
manager.add(countSymbolsAction);
|
||||
if (discardExternalDefsAction.valid())
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems 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:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class RebuildIndexAction extends IndexAction {
|
||||
|
||||
public RebuildIndexAction(TreeViewer viewer) {
|
||||
super(viewer, CUIPlugin.getResourceString("IndexView.rebuildIndex.name")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void run() {
|
||||
ISelection selection = viewer.getSelection();
|
||||
if (!(selection instanceof IStructuredSelection))
|
||||
return;
|
||||
|
||||
Object[] objs = ((IStructuredSelection)selection).toArray();
|
||||
for (int i = 0; i < objs.length; ++i) {
|
||||
if (!(objs[i] instanceof ICProject))
|
||||
continue;
|
||||
|
||||
ICProject project = (ICProject)objs[i];
|
||||
IPDOMIndexer indexer = CCorePlugin.getPDOMManager().getIndexer(project);
|
||||
try {
|
||||
indexer.reindex();
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue