1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Added Rebuild Index Object Contribution for ICProject.

This commit is contained in:
Doug Schaefer 2006-05-23 03:17:52 +00:00
parent 489d4ca139
commit 1e3290c88c
3 changed files with 73 additions and 1 deletions

View file

@ -327,4 +327,4 @@ CDTIndexer.nullindexer=No Indexer (search-based features will not work correctly
CDTIndexer.fastindexer=Fast C/C++ Indexer (faster but less accurate)
IndexView.name=C/C++ Index
UpdateIndex.name=Update Index
RebuildIndex.name=Rebuild Index

View file

@ -1344,5 +1344,18 @@
id="PDOM"
priority="3"/>
</extension>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="org.eclipse.cdt.ui.rebuildIndexContribution"
objectClass="org.eclipse.cdt.core.model.ICProject">
<action
class="org.eclipse.cdt.internal.ui.indexview.RebuildIndexActionDelegate"
id="org.eclipse.cdt.ui.rebuildIndexAction"
label="%RebuildIndex.name"
menubarPath="buildGroup"/>
</objectContribution>
</extension>
</plugin>

View file

@ -0,0 +1,59 @@
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.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
/*******************************************************************************
* 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
*******************************************************************************/
/**
* @author Doug Schaefer
*
*/
public class RebuildIndexActionDelegate implements IObjectActionDelegate {
private IWorkbenchPart targetPart;
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
this.targetPart = targetPart;
}
public void run(IAction action) {
ISelection selection = targetPart.getSite().getSelectionProvider().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 void selectionChanged(IAction action, ISelection selection) {
}
}