mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Fix for 166991, indexer preferences and project specific settings.
This commit is contained in:
parent
3e5e1b02ea
commit
5dfbff2013
46 changed files with 1325 additions and 918 deletions
|
@ -72,7 +72,6 @@ public class AST2FileBasePluginTest extends TestCase {
|
|||
className = aClassName;
|
||||
numProjects++;
|
||||
}
|
||||
CCorePlugin.getPDOMManager().setIndexerId(cPrj, IPDOMManager.ID_NO_INDEXER);
|
||||
} catch ( CoreException e ) {
|
||||
/*boo*/
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -79,11 +80,11 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
|
||||
public void testFastIndexer() throws Exception {
|
||||
CCoreInternals.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_FAST_INDEXER);
|
||||
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, false);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
|
||||
waitForIndexer();
|
||||
checkHeader(false);
|
||||
|
||||
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, true);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
waitForIndexer();
|
||||
checkHeader(true);
|
||||
|
||||
|
@ -96,11 +97,11 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
|
||||
public void testFullIndexer() throws Exception {
|
||||
CCoreInternals.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_FULL_INDEXER);
|
||||
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, false);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
|
||||
waitForIndexer();
|
||||
checkHeader(false);
|
||||
|
||||
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, true);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
waitForIndexer();
|
||||
checkHeader(true);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Symbian Software Systems and others.
|
||||
* Copyright (c) 2006, 2007 Symbian 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
|
@ -19,7 +20,7 @@ import org.eclipse.cdt.core.index.IndexFilter;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
@ -55,7 +56,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
|||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||
TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
|
||||
try {
|
||||
CCoreInternals.getPDOMManager().setIndexAllFiles(cproject, true);
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
long start = System.currentTimeMillis();
|
||||
CCorePlugin.getPDOMManager().reindex(cproject);
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 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
|
||||
|
@ -73,10 +73,6 @@ abstract public class BaseTestFramework extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void disableIndexing() throws CoreException {
|
||||
CCorePlugin.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_NO_INDEXER);
|
||||
}
|
||||
|
||||
public BaseTestFramework()
|
||||
{
|
||||
super();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.testplugin;
|
||||
import java.io.File;
|
||||
|
@ -32,6 +33,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
|
@ -94,7 +96,7 @@ public class CProjectHelper {
|
|||
}
|
||||
newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||
if (indexerID != null) {
|
||||
CCoreInternals.getPDOMManager().setIndexAllFiles(newProject[0], true);
|
||||
IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
CCoreInternals.getPDOMManager().setIndexerId(newProject[0], indexerID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ Export-Package: org.eclipse.cdt.core,
|
|||
org.eclipse.cdt.internal.core.pdom.dom;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.pdom.dom.c;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom.dom.cpp;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom.indexer;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom.indexer;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.pdom.indexer.fast;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom.indexer.full;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom.indexer.nulli;x-internal:=true,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 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
|
||||
|
@ -51,6 +51,7 @@ import org.eclipse.cdt.core.model.ISourceRoot;
|
|||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.LocalProjectScope;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -770,6 +771,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
case IResourceChangeEvent.POST_CHANGE :
|
||||
try {
|
||||
if (delta != null) {
|
||||
checkForProjectRename(delta);
|
||||
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
|
||||
if (translatedDeltas.length > 0) {
|
||||
for (int i = 0; i < translatedDeltas.length; i++) {
|
||||
|
@ -1160,6 +1162,21 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
}
|
||||
|
||||
private void checkForProjectRename(IResourceDelta delta) {
|
||||
IResourceDelta[] rem= delta.getAffectedChildren(IResourceDelta.REMOVED);
|
||||
for (int i = 0; i < rem.length; i++) {
|
||||
delta = rem[i];
|
||||
IResource res= delta.getResource();
|
||||
if (res.getType() == IResource.PROJECT) {
|
||||
IPath movedTo= null;
|
||||
if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
|
||||
movedTo= delta.getMovedToPath();
|
||||
}
|
||||
LocalProjectScope.deletePreferences(res.getFullPath(), movedTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleting(IProject project, IResourceDelta delta) {
|
||||
// stop the binary runner for this project
|
||||
removeBinaryRunner(project);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2007 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
|
||||
|
@ -8,10 +8,13 @@
|
|||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.dom;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -37,21 +40,21 @@ public interface IPDOMIndexer {
|
|||
public String getID();
|
||||
|
||||
/**
|
||||
* Returns whether to index source files that are not actually part of the build.
|
||||
* Returns the value of a property.
|
||||
* @since 4.0
|
||||
*/
|
||||
public boolean getIndexAllFiles();
|
||||
public String getProperty(String key);
|
||||
|
||||
/**
|
||||
* Clients are not allowed to call this method, it is called by the framework.
|
||||
* @since 4.0
|
||||
*/
|
||||
public void setIndexAllFiles(boolean value);
|
||||
public void setProperties(Properties props);
|
||||
|
||||
/**
|
||||
* Clients are not allowed to call this method, it is called by the framework.
|
||||
* Used to check whether we need to reindex a project.
|
||||
* @since 4.0
|
||||
*/
|
||||
public boolean isIndexAllFiles(boolean value);
|
||||
public boolean hasProperties(Properties props);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. 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
|
||||
|
@ -19,7 +19,6 @@ public class Messages extends NLS {
|
|||
public static String PDOMManager_JoinIndexerTask;
|
||||
public static String PDOMManager_notifyJob_label;
|
||||
public static String PDOMManager_notifyTask_message;
|
||||
public static String PDOMManager_savePrefsJob;
|
||||
public static String PDOMManager_StartJob_name;
|
||||
public static String WritablePDOM_error_unknownLinkage;
|
||||
static {
|
||||
|
|
|
@ -189,7 +189,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
protected void clear() throws CoreException {
|
||||
Database db = getDB();
|
||||
// Clear out the database
|
||||
db.clear(0);
|
||||
db.clear(1);
|
||||
|
||||
// Zero out the File Index and Linkages
|
||||
db.putInt(FILE_INDEX, 0);
|
||||
|
@ -535,7 +535,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
}
|
||||
|
||||
public IIndexFragmentBinding adaptBinding(IIndexFragmentBinding binding) throws CoreException {
|
||||
if (binding instanceof IBinding) {
|
||||
if (binding != null) {
|
||||
return adaptBinding((IBinding) binding);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2005, 2007 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
|
||||
|
@ -18,10 +18,9 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||
|
@ -33,6 +32,7 @@ import org.eclipse.cdt.core.model.CoreModel;
|
|||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||
import org.eclipse.cdt.internal.core.index.IndexChangeEvent;
|
||||
|
@ -40,11 +40,10 @@ import org.eclipse.cdt.internal.core.index.IndexFactory;
|
|||
import org.eclipse.cdt.internal.core.index.IndexerStateEvent;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM.IListener;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
|
@ -58,14 +57,8 @@ import org.eclipse.core.runtime.SafeRunner;
|
|||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IPreferencesService;
|
||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* The PDOM Provider. This is likely temporary since I hope
|
||||
|
@ -85,11 +78,20 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
}
|
||||
}
|
||||
|
||||
private final class PCL implements IPreferenceChangeListener {
|
||||
private IProject fProject;
|
||||
public PCL(IProject prj) {
|
||||
fProject= prj;
|
||||
}
|
||||
public void preferenceChange(PreferenceChangeEvent event) {
|
||||
onPreferenceChange(fProject, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final QualifiedName indexerProperty= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomIndexer"); //$NON-NLS-1$
|
||||
private static final QualifiedName dbNameProperty= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomName"); //$NON-NLS-1$
|
||||
|
||||
public static final String INDEXER_ID_KEY = "indexerId"; //$NON-NLS-1$
|
||||
public static final String INDEX_ALL_FILES = "indexAllFiles"; //$NON-NLS-1$
|
||||
private static final ISchedulingRule NOTIFICATION_SCHEDULING_RULE = new PerInstanceSchedulingRule();
|
||||
private static final ISchedulingRule INDEXER_SCHEDULING_RULE = new PerInstanceSchedulingRule();
|
||||
|
||||
|
@ -122,11 +124,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
* not allowed to hold a lock on fPDOMs.
|
||||
*/
|
||||
private Object fIndexerMutex= new Object();
|
||||
private IPreferenceChangeListener fPreferenceChangeListener= new IPreferenceChangeListener(){
|
||||
public void preferenceChange(PreferenceChangeEvent event) {
|
||||
onPreferenceChange(event);
|
||||
}
|
||||
};
|
||||
private HashMap fPrefListeners= new HashMap();
|
||||
|
||||
/**
|
||||
* Startup the PDOM. This mainly sets us up to handle model
|
||||
|
@ -209,135 +207,38 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
return project.getElementName() + "." + System.currentTimeMillis() + ".pdom"; //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
public String getDefaultIndexerId() {
|
||||
IPreferencesService prefService = Platform.getPreferencesService();
|
||||
return prefService.getString(CCorePlugin.PLUGIN_ID, INDEXER_ID_KEY,
|
||||
CCorePlugin.DEFAULT_INDEXER, null);
|
||||
}
|
||||
public String getDefaultIndexerId() {
|
||||
return getIndexerId(null);
|
||||
}
|
||||
|
||||
public void setDefaultIndexerId(String indexerId) {
|
||||
IEclipsePreferences prefs = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs != null) {
|
||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setDefaultIndexerId(String indexerId) {
|
||||
setIndexerId(null, indexerId);
|
||||
}
|
||||
|
||||
public String getIndexerId(ICProject project) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs == null)
|
||||
return getDefaultIndexerId();
|
||||
|
||||
String indexerId = prefs.get(INDEXER_ID_KEY, null);
|
||||
if (indexerId == null) {
|
||||
// See if it is in the ICDescriptor
|
||||
try {
|
||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(project.getProject(), false);
|
||||
if (desc != null) {
|
||||
ICExtensionReference[] ref = desc.get(CCorePlugin.INDEXER_UNIQ_ID);
|
||||
if (ref != null && ref.length > 0) {
|
||||
indexerId = ref[0].getID();
|
||||
}
|
||||
if (indexerId != null) {
|
||||
// Make sure it is a valid indexer
|
||||
IExtension indexerExt = Platform.getExtensionRegistry()
|
||||
.getExtension(CCorePlugin.INDEXER_UNIQ_ID, indexerId);
|
||||
if (indexerExt == null) {
|
||||
// It is not, forget about it.
|
||||
indexerId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
// if Indexer still null schedule a job to get it
|
||||
if (indexerId == null || indexerId.equals("org.eclipse.cdt.core.ctagsindexer")) //$NON-NLS-1$
|
||||
// make it the default, ctags is gone
|
||||
indexerId = getDefaultIndexerId();
|
||||
|
||||
// Start a job to set the id.
|
||||
setIndexerId(project, indexerId);
|
||||
}
|
||||
|
||||
return indexerId;
|
||||
IProject prj= project != null ? project.getProject() : null;
|
||||
return IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, ID_NO_INDEXER);
|
||||
}
|
||||
|
||||
public void setIndexerId(final ICProject project, String indexerId) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs == null)
|
||||
return; // TODO why would this be null?
|
||||
|
||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||
Job job= new Job(Messages.PDOMManager_savePrefsJob) {
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs != null) {
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.setSystem(true);
|
||||
job.setRule(project.getProject());
|
||||
job.schedule(2000);
|
||||
}
|
||||
|
||||
public void setIndexAllFiles(final ICProject project, boolean val) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs == null)
|
||||
return; // TODO why would this be null?
|
||||
|
||||
prefs.putBoolean(INDEX_ALL_FILES, val);
|
||||
Job job= new Job(Messages.PDOMManager_savePrefsJob) {
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs != null) {
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.setSystem(true);
|
||||
job.setRule(project.getProject());
|
||||
job.schedule(2000);
|
||||
}
|
||||
|
||||
public boolean getIndexAllFiles(ICProject project) {
|
||||
IScopeContext[] scope= new IScopeContext[] {new ProjectScope(project.getProject()), new InstanceScope()};
|
||||
return Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, INDEX_ALL_FILES, false, scope);
|
||||
IProject prj= project.getProject();
|
||||
IndexerPreferences.set(prj, IndexerPreferences.KEY_INDEXER_ID, indexerId);
|
||||
CCoreInternals.savePreferences(prj);
|
||||
}
|
||||
|
||||
public IPDOMIndexer getIndexer(ICProject project) {
|
||||
return getIndexer(project, true);
|
||||
}
|
||||
|
||||
public void onPreferenceChange(PreferenceChangeEvent event) {
|
||||
Object key= event.getKey();
|
||||
if (key.equals(INDEXER_ID_KEY) || key.equals(INDEX_ALL_FILES)) {
|
||||
Preferences node = event.getNode();
|
||||
if (CCorePlugin.PLUGIN_ID.equals(node.name())) {
|
||||
node= node.parent();
|
||||
IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(node.name());
|
||||
if (project.exists() && project.isOpen()) {
|
||||
ICProject cproject= CoreModel.getDefault().create(project);
|
||||
if (cproject != null) {
|
||||
try {
|
||||
changeIndexer(cproject);
|
||||
}
|
||||
catch (Exception e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
protected void onPreferenceChange(IProject project, PreferenceChangeEvent event) {
|
||||
if (project.exists() && project.isOpen()) {
|
||||
ICProject cproject= CoreModel.getDefault().create(project);
|
||||
if (cproject != null) {
|
||||
try {
|
||||
changeIndexer(cproject);
|
||||
}
|
||||
catch (Exception e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,17 +247,19 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
private void changeIndexer(ICProject cproject) throws CoreException {
|
||||
assert !Thread.holdsLock(fProjectToPDOM);
|
||||
IPDOMIndexer oldIndexer= null;
|
||||
String newid= getIndexerId(cproject);
|
||||
boolean allFiles= getIndexAllFiles(cproject);
|
||||
IProject prj= cproject.getProject();
|
||||
|
||||
String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, ID_NO_INDEXER);
|
||||
Properties props= IndexerPreferences.getProperties(prj);
|
||||
|
||||
synchronized (fIndexerMutex) {
|
||||
oldIndexer= getIndexer(cproject, false);
|
||||
if (oldIndexer != null) {
|
||||
if (oldIndexer.getID().equals(newid) && oldIndexer.isIndexAllFiles(allFiles)) {
|
||||
if (oldIndexer.getID().equals(newid) && oldIndexer.hasProperties(props)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
createIndexer(cproject, newid, allFiles, true);
|
||||
createIndexer(cproject, newid, props, true);
|
||||
}
|
||||
|
||||
if (oldIndexer != null) {
|
||||
|
@ -367,14 +270,14 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
public IPDOMIndexer getIndexer(ICProject project, boolean create) {
|
||||
assert !Thread.holdsLock(fProjectToPDOM);
|
||||
synchronized (fIndexerMutex) {
|
||||
IProject rproject = project.getProject();
|
||||
if (!rproject.isOpen()) {
|
||||
IProject prj = project.getProject();
|
||||
if (!prj.isOpen()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IPDOMIndexer indexer;
|
||||
try {
|
||||
indexer = (IPDOMIndexer)rproject.getSessionProperty(indexerProperty);
|
||||
indexer = (IPDOMIndexer)prj.getSessionProperty(indexerProperty);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
|
@ -386,7 +289,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
|
||||
if (create) {
|
||||
try {
|
||||
return createIndexer(project, getIndexerId(project), getIndexAllFiles(project), false);
|
||||
Properties props= IndexerPreferences.getProperties(prj);
|
||||
return createIndexer(project, getIndexerId(project), props, false);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
@ -395,7 +299,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
}
|
||||
}
|
||||
|
||||
private IPDOMIndexer createIndexer(ICProject project, String indexerId, boolean allHeaders, boolean forceReindex) throws CoreException {
|
||||
private IPDOMIndexer createIndexer(ICProject project, String indexerId, Properties props, boolean forceReindex) throws CoreException {
|
||||
assert Thread.holdsLock(fIndexerMutex);
|
||||
|
||||
PDOM pdom= (PDOM) getPDOM(project);
|
||||
|
@ -411,7 +315,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
if ("run".equals(element.getName())) { //$NON-NLS-1$
|
||||
try {
|
||||
indexer = (IPDOMIndexer)element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
indexer.setIndexAllFiles(allHeaders);
|
||||
indexer.setProperties(props);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
@ -496,17 +400,21 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
}
|
||||
|
||||
private void registerPreferenceListener(ICProject project) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs != null) {
|
||||
prefs.addPreferenceChangeListener(fPreferenceChangeListener);
|
||||
}
|
||||
IProject prj= project.getProject();
|
||||
PCL pcl= (PCL) fPrefListeners.get(prj);
|
||||
if (pcl == null) {
|
||||
pcl= new PCL(prj);
|
||||
fPrefListeners.put(prj, pcl);
|
||||
}
|
||||
IndexerPreferences.addChangeListener(prj, pcl);
|
||||
}
|
||||
|
||||
private void unregisterPreferenceListener(ICProject project) {
|
||||
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
|
||||
if (prefs != null) {
|
||||
prefs.removePreferenceChangeListener(fPreferenceChangeListener);
|
||||
}
|
||||
IProject prj= project.getProject();
|
||||
PCL pcl= (PCL) fPrefListeners.remove(prj);
|
||||
if (pcl != null) {
|
||||
IndexerPreferences.removeChangeListener(prj, pcl);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeProject(ICProject project, ICElementDelta delta) throws CoreException {
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
||||
public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
||||
|
||||
protected ICProject project;
|
||||
protected Properties fProperties= new Properties();
|
||||
|
||||
public AbstractPDOMIndexer() {
|
||||
fProperties.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(false));
|
||||
}
|
||||
|
||||
public ICProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(ICProject project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
return fProperties.getProperty(key);
|
||||
}
|
||||
|
||||
public boolean hasProperties(Properties props) {
|
||||
for (Iterator i= fProperties.entrySet().iterator(); i.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
String key = (String) entry.getKey();
|
||||
String myval = (String) entry.getValue();
|
||||
|
||||
if (myval != null) { // relevant property
|
||||
String v2= (String) props.get(key);
|
||||
if (v2 != null && !myval.equals(v2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setProperties(Properties props) {
|
||||
// only set relevant properties as initialized in the constructor
|
||||
for (Iterator i= props.entrySet().iterator(); i.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
String key = (String) entry.getKey();
|
||||
String val = (String) entry.getValue();
|
||||
|
||||
if (val != null && fProperties.get(key) != null) {
|
||||
fProperties.put(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.LocalProjectScope;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IPreferencesService;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* Access to indexer properties.
|
||||
* @since 4.0
|
||||
*/
|
||||
public class IndexerPreferences {
|
||||
public static final String KEY_INDEXER_ID= "indexerId"; //$NON-NLS-1$
|
||||
public static final String KEY_INDEX_ALL_FILES= "indexAllFiles"; //$NON-NLS-1$
|
||||
|
||||
private static final String QUALIFIER = CCorePlugin.PLUGIN_ID;
|
||||
private static final String INDEXER_NODE = "indexer"; //$NON-NLS-1$
|
||||
private static final String KEY_INDEXER_PREFS_SCOPE = "preferenceScope"; //$NON-NLS-1$
|
||||
|
||||
public static final int SCOPE_INSTANCE = 0;
|
||||
public static final int SCOPE_PROJECT_PRIVATE = 1;
|
||||
public static final int SCOPE_PROJECT_SHARED = 2;
|
||||
|
||||
/**
|
||||
* Returns the scope that is selected for the project.
|
||||
* @param project
|
||||
* @return one of {@link #SCOPE_INSTANCE}, {@link #SCOPE_PROJECT_SHARED} or
|
||||
* {@link #SCOPE_PROJECT_PRIVATE}.
|
||||
*/
|
||||
public static int getScope(IProject project) {
|
||||
int scope= SCOPE_INSTANCE;
|
||||
if (project != null) {
|
||||
Preferences ppp= getLocalPreferences(project);
|
||||
scope= ppp.getInt(KEY_INDEXER_PREFS_SCOPE, -1);
|
||||
if (scope == -1) {
|
||||
scope= determineScopeOnFirstUse(project);
|
||||
}
|
||||
if (scope != SCOPE_INSTANCE) {
|
||||
if (get(project, scope, KEY_INDEXER_ID, null) == null) {
|
||||
scope= SCOPE_INSTANCE;
|
||||
ppp.putInt(KEY_INDEXER_PREFS_SCOPE, scope);
|
||||
CCoreInternals.savePreferences(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scope that shall be used for the project.
|
||||
* Must be one of {@link #SCOPE_INSTANCE}, {@link #SCOPE_PROJECT_SHARED} or
|
||||
* {@link #SCOPE_PROJECT_PRIVATE}.
|
||||
*/
|
||||
public static int setScope(IProject project, int scope) {
|
||||
if (project == null)
|
||||
throw new IllegalArgumentException();
|
||||
boolean makeCopy= false;
|
||||
switch (scope) {
|
||||
case SCOPE_INSTANCE:
|
||||
break;
|
||||
case SCOPE_PROJECT_PRIVATE:
|
||||
case SCOPE_PROJECT_SHARED:
|
||||
makeCopy= true;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
if (makeCopy) {
|
||||
Preferences[] prefs= getPreferences(project, scope);
|
||||
if (prefs[0].get(KEY_INDEXER_ID, null) == null) {
|
||||
Properties props= getProperties(project, SCOPE_INSTANCE);
|
||||
setProperties(prefs[0], props);
|
||||
}
|
||||
}
|
||||
|
||||
Preferences ppp= getLocalPreferences(project);
|
||||
ppp.putInt(KEY_INDEXER_PREFS_SCOPE, scope);
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the properties for the indexer of a project.
|
||||
*/
|
||||
public static Properties getProperties(IProject project) {
|
||||
return getProperties(project, getScope(project));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the properties for the indexer of a project for a
|
||||
* specific scope.
|
||||
*/
|
||||
public static Properties getProperties(IProject project, int scope) {
|
||||
Preferences[] prefs= getPreferences(project, scope);
|
||||
Properties props= new Properties();
|
||||
for (int i=prefs.length-1; i>=0; i--) {
|
||||
addProperties(prefs[i], props);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or changes indexer properties for a project.
|
||||
*/
|
||||
public static void setProperties(IProject project, int scope, Properties props) {
|
||||
Preferences[] prefs= getPreferences(project, scope);
|
||||
setProperties(prefs[0], props);
|
||||
}
|
||||
|
||||
private static void setProperties(Preferences prefs, Properties props) {
|
||||
for (Iterator i = props.entrySet().iterator(); i.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
String key = (String) entry.getKey();
|
||||
String val = (String) entry.getValue();
|
||||
prefs.put(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an indexer property for the given project.
|
||||
* @since 4.0
|
||||
*/
|
||||
public static String get(IProject project, String key, String defval) {
|
||||
IPreferencesService prefService = Platform.getPreferencesService();
|
||||
Preferences[] prefs= IndexerPreferences.getPreferences(project);
|
||||
return prefService.get(key, defval, prefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an indexer property in a scope for the given project.
|
||||
* @since 4.0
|
||||
*/
|
||||
private static String get(IProject project, int scope, String key, String defval) {
|
||||
IPreferencesService prefService = Platform.getPreferencesService();
|
||||
Preferences[] prefs= IndexerPreferences.getPreferences(project, scope);
|
||||
return prefService.get(key, defval, prefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or changes an indexer property for the given project.
|
||||
*/
|
||||
public static void set(final IProject project, String key, String value) {
|
||||
if (getScope(project) == SCOPE_INSTANCE) {
|
||||
setScope(project, SCOPE_PROJECT_PRIVATE);
|
||||
}
|
||||
final Preferences[] prefs= IndexerPreferences.getPreferences(project.getProject());
|
||||
prefs[0].put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the initial indexing preferences for the project.
|
||||
*/
|
||||
private static int determineScopeOnFirstUse(IProject project) {
|
||||
int scope= SCOPE_INSTANCE;
|
||||
Preferences prjPrefs= getProjectPreferences(project);
|
||||
if (prjPrefs.get(KEY_INDEXER_ID, null) != null) {
|
||||
scope= SCOPE_PROJECT_SHARED;
|
||||
}
|
||||
else {
|
||||
Preferences oldStyle= prjPrefs.parent();
|
||||
String id= oldStyle.get(KEY_INDEXER_ID, null);
|
||||
if (id != null) {
|
||||
prjPrefs.put(KEY_INDEXER_ID, id);
|
||||
String value= oldStyle.get(KEY_INDEX_ALL_FILES, null);
|
||||
if (value != null) {
|
||||
prjPrefs.put(KEY_INDEX_ALL_FILES, value);
|
||||
}
|
||||
scope= SCOPE_PROJECT_SHARED;
|
||||
}
|
||||
}
|
||||
getLocalPreferences(project).putInt(KEY_INDEXER_PREFS_SCOPE, scope);
|
||||
CCoreInternals.savePreferences(project);
|
||||
return scope;
|
||||
}
|
||||
|
||||
private static Preferences[] getPreferences(IProject project) {
|
||||
return getPreferences(project, getScope(project));
|
||||
}
|
||||
|
||||
private static Preferences[] getPreferences(IProject project, int scope) {
|
||||
if (project != null) {
|
||||
switch (scope) {
|
||||
case SCOPE_PROJECT_PRIVATE:
|
||||
return new Preferences[] {getLocalPreferences(project)};
|
||||
case SCOPE_PROJECT_SHARED:
|
||||
return new Preferences[] {getProjectPreferences(project)};
|
||||
}
|
||||
}
|
||||
return getInstancePreferencesArray();
|
||||
}
|
||||
|
||||
private static Preferences[] getInstancePreferencesArray() {
|
||||
return new Preferences[] {
|
||||
getInstancePreferences(),
|
||||
new ConfigurationScope().getNode(QUALIFIER).node(INDEXER_NODE),
|
||||
new DefaultScope().getNode(QUALIFIER).node(INDEXER_NODE)
|
||||
};
|
||||
}
|
||||
|
||||
private static Preferences getInstancePreferences() {
|
||||
return new InstanceScope().getNode(QUALIFIER).node(INDEXER_NODE);
|
||||
}
|
||||
|
||||
private static Preferences getProjectPreferences(IProject project) {
|
||||
return new ProjectScope(project).getNode(QUALIFIER).node(INDEXER_NODE);
|
||||
}
|
||||
|
||||
private static Preferences getLocalPreferences(IProject project) {
|
||||
return new LocalProjectScope(project).getNode(QUALIFIER).node(INDEXER_NODE);
|
||||
}
|
||||
|
||||
private static void addProperties(Preferences preferences, Properties props) {
|
||||
try {
|
||||
String[] keys = preferences.keys();
|
||||
for (int i=0; i < keys.length; i++) {
|
||||
String key= keys[i];
|
||||
String val= preferences.get(key, null);
|
||||
if (val != null) {
|
||||
props.put(key, val);
|
||||
}
|
||||
}
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void initializeDefaultPreferences(IEclipsePreferences defaultPreferences) {
|
||||
Preferences prefs= defaultPreferences.node(INDEXER_NODE);
|
||||
prefs.put(KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
prefs.putBoolean(KEY_INDEX_ALL_FILES, false);
|
||||
}
|
||||
|
||||
public static void addChangeListener(IProject prj, IPreferenceChangeListener pcl) {
|
||||
Preferences node= getProjectPreferences(prj);
|
||||
addListener(node, pcl);
|
||||
node= getLocalPreferences(prj);
|
||||
addListener(node, pcl);
|
||||
node= getInstancePreferences();
|
||||
addListener(node, pcl);
|
||||
}
|
||||
|
||||
private static void addListener(Preferences node, IPreferenceChangeListener pcl) {
|
||||
if (node instanceof IEclipsePreferences) {
|
||||
IEclipsePreferences enode= (IEclipsePreferences) node;
|
||||
enode.addPreferenceChangeListener(pcl);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeChangeListener(IProject prj, IPreferenceChangeListener pcl) {
|
||||
Preferences node= getProjectPreferences(prj);
|
||||
removeListener(node, pcl);
|
||||
node= getLocalPreferences(prj);
|
||||
removeListener(node, pcl);
|
||||
node= getInstancePreferences();
|
||||
removeListener(node, pcl);
|
||||
}
|
||||
|
||||
private static void removeListener(Preferences node, IPreferenceChangeListener pcl) {
|
||||
if (node instanceof IEclipsePreferences) {
|
||||
IEclipsePreferences enode= (IEclipsePreferences) node;
|
||||
enode.removePreferenceChangeListener(pcl);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -95,6 +95,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
|||
|
||||
private static final Object NO_CONTEXT = new Object();
|
||||
protected static final int MAX_ERRORS = 500;
|
||||
private static final String TRUE = String.valueOf(true);
|
||||
|
||||
protected volatile int fTotalSourcesEstimate= 0;
|
||||
protected volatile int fCompletedSources= 0;
|
||||
|
@ -283,7 +284,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
|||
}
|
||||
|
||||
protected boolean getIndexAllFiles() {
|
||||
return getIndexer().getIndexAllFiles();
|
||||
return TRUE.equals(getIndexer().getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
}
|
||||
|
||||
protected ITranslationUnit findContext(IIndex index, IIndexFileLocation location) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2007 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
|
||||
|
@ -13,37 +13,25 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.indexer.fast;
|
||||
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMFastIndexer implements IPDOMIndexer {
|
||||
public class PDOMFastIndexer extends AbstractPDOMIndexer {
|
||||
|
||||
// Must match extension id
|
||||
public static final String ID = IPDOMManager.ID_FAST_INDEXER;
|
||||
|
||||
protected ICProject project;
|
||||
|
||||
private boolean fIndexAllFiles;
|
||||
|
||||
public PDOMFastIndexer() {
|
||||
}
|
||||
|
||||
public ICProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(ICProject project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void handleDelta(ICElementDelta delta) throws CoreException {
|
||||
PDOMFastHandleDelta fhd= new PDOMFastHandleDelta(this, delta);
|
||||
if (fhd.estimateRemainingSources() > 0) {
|
||||
|
@ -58,16 +46,4 @@ public class PDOMFastIndexer implements IPDOMIndexer {
|
|||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setIndexAllFiles(boolean val) {
|
||||
fIndexAllFiles= val;
|
||||
}
|
||||
|
||||
public boolean getIndexAllFiles() {
|
||||
return fIndexAllFiles;
|
||||
}
|
||||
|
||||
public boolean isIndexAllFiles(boolean val) {
|
||||
return fIndexAllFiles==val;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2007 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
|
||||
|
@ -7,15 +7,15 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer.full;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -25,21 +25,9 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMFullIndexer implements IPDOMIndexer {
|
||||
public class PDOMFullIndexer extends AbstractPDOMIndexer {
|
||||
public static final String ID = IPDOMManager.ID_FULL_INDEXER;
|
||||
|
||||
private boolean fIndexAllFiles= true;
|
||||
private ICProject project;
|
||||
|
||||
|
||||
public ICProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(ICProject project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void handleDelta(ICElementDelta delta) throws CoreException {
|
||||
PDOMFullHandleDelta task = new PDOMFullHandleDelta(this, delta);
|
||||
if (task.estimateRemainingSources() > 0) {
|
||||
|
@ -54,16 +42,4 @@ public class PDOMFullIndexer implements IPDOMIndexer {
|
|||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setIndexAllFiles(boolean val) {
|
||||
fIndexAllFiles= val;
|
||||
}
|
||||
|
||||
public boolean getIndexAllFiles() {
|
||||
return fIndexAllFiles;
|
||||
}
|
||||
|
||||
public boolean isIndexAllFiles(boolean val) {
|
||||
return fIndexAllFiles==val;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2007 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
|
||||
|
@ -17,10 +17,10 @@ import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
|||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
|
@ -29,18 +29,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
*
|
||||
* The Null Indexer which does nothing.
|
||||
*/
|
||||
public class PDOMNullIndexer implements IPDOMIndexer {
|
||||
public class PDOMNullIndexer extends AbstractPDOMIndexer {
|
||||
|
||||
public static final String ID = IPDOMManager.ID_NO_INDEXER;
|
||||
|
||||
private ICProject project;
|
||||
|
||||
public ICProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(ICProject project) {
|
||||
this.project = project;
|
||||
public PDOMNullIndexer() {
|
||||
fProperties.clear(); // don't accept any properties
|
||||
}
|
||||
|
||||
public void handleDelta(ICElementDelta delta) {
|
||||
|
@ -93,15 +87,4 @@ public class PDOMNullIndexer implements IPDOMIndexer {
|
|||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public boolean getIndexAllFiles() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setIndexAllFiles(boolean value) {
|
||||
}
|
||||
|
||||
public boolean isIndexAllFiles(boolean val) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2006, 2007 Wind River Systems, Inc. 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:
|
||||
# Markus Schorn (Wind River Systems)
|
||||
###############################################################################
|
||||
WritablePDOM_error_unknownLinkage=AST specifies unknown linkage ''{0}''
|
||||
PDOMManager_notifyJob_label=Notify Index Change Listeners
|
||||
PDOMManager_JoinIndexerTask=Join Indexer
|
||||
PDOMManager_savePrefsJob=Save Project Preferences
|
||||
PDOMManager_StartJob_name=Initialize Indexing
|
||||
PDOMManager_notifyTask_message=Notify Listeners
|
||||
PDOMManager_indexMonitorDetail={0}/{1} sources, {2} headers
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||
import org.eclipse.cdt.core.resources.ScannerProvider;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. 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
|
||||
|
@ -13,10 +13,46 @@ package org.eclipse.cdt.internal.core;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
|
||||
public class CCoreInternals {
|
||||
|
||||
public static PDOMManager getPDOMManager() {
|
||||
return (PDOMManager) CCorePlugin.getPDOMManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the local project preferences, shared project preferences and the
|
||||
* scope preferences for the core plugin.
|
||||
* @param project the project for which to save preferences, may be <code>null</code>
|
||||
* @since 4.0
|
||||
*/
|
||||
public static void savePreferences(final IProject project) {
|
||||
Job job= new Job(CCorePlugin.getResourceString("CCoreInternals.savePreferencesJob")) { //$NON-NLS-1$
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
if (project != null) {
|
||||
new LocalProjectScope(project).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
}
|
||||
new InstanceScope().getNode(CCorePlugin.PLUGIN_ID).flush();
|
||||
} catch (BackingStoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.setSystem(true);
|
||||
if (project != null) {
|
||||
job.setRule(project);
|
||||
}
|
||||
job.schedule(2000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
# Copyright (c) 2000, 2007 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
#
|
||||
# Contributors:
|
||||
# QNX Software Systems - Initial API and implementation
|
||||
# Markus Schorn (Wind River Systems)
|
||||
###############################################################################
|
||||
CBuilder.build_error= Build Error
|
||||
CoreModel.BinaryRunner.Binary_Search_Thread=Searching for Binaries
|
||||
|
@ -75,6 +76,5 @@ indexer.notFound = Indexer not found
|
|||
pdom.requestTooLarge=Request too large
|
||||
pdom.indexer.name=C/C++ Indexer
|
||||
pdom.indexer.task=Indexing
|
||||
pdom.indexer.filling=Counting files
|
||||
pdom.indexer.message=file {0} of {1}: {2}
|
||||
PDOMIndexerJob.updateMonitorJob=Update Monitor
|
||||
CCoreInternals.savePreferencesJob=Save preferences
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Sergey Prigogin, Google
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core;
|
||||
|
||||
|
@ -17,10 +18,9 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
|
@ -54,8 +54,6 @@ public class CCorePreferenceInitializer extends AbstractPreferenceInitializer {
|
|||
}
|
||||
|
||||
// indexer defaults
|
||||
defaultPreferences.putBoolean(PDOMManager.INDEX_ALL_FILES, false);
|
||||
defaultPreferences.put(PDOMManager.INDEXER_ID_KEY, IPDOMManager.ID_FAST_INDEXER);
|
||||
IndexerPreferences.initializeDefaultPreferences(defaultPreferences);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class LocalProjectScope implements IScopeContext {
|
||||
private static final String QUALIFIER_EXT = ".prj-"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* String constant (value of <code>"project-local"</code>) used for the
|
||||
* scope name for this preference scope.
|
||||
*/
|
||||
public static final String SCOPE = "project-local"; //$NON-NLS-1$
|
||||
|
||||
private String fContext;
|
||||
|
||||
/**
|
||||
* Create and return a new local project scope for the given project. The given
|
||||
* project must not be <code>null</code>.
|
||||
*
|
||||
* @param context the project
|
||||
* @exception IllegalArgumentException if the project is <code>null</code>
|
||||
*/
|
||||
public LocalProjectScope(IProject context) {
|
||||
if (context == null)
|
||||
throw new IllegalArgumentException();
|
||||
fContext= context.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a new local project scope for the given project. The given
|
||||
* project must not be <code>null</code>.
|
||||
*
|
||||
* @param context the project
|
||||
* @exception IllegalArgumentException if the project is <code>null</code>
|
||||
*/
|
||||
public LocalProjectScope(String projectName) {
|
||||
if (projectName == null)
|
||||
throw new IllegalArgumentException();
|
||||
fContext= projectName;
|
||||
}
|
||||
|
||||
public IPath getLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return SCOPE;
|
||||
}
|
||||
|
||||
public IEclipsePreferences getNode(String qualifier) {
|
||||
return new InstanceScope().getNode(qualifier + QUALIFIER_EXT + fContext);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (!(obj instanceof LocalProjectScope))
|
||||
return false;
|
||||
LocalProjectScope other = (LocalProjectScope) obj;
|
||||
return fContext.equals(other.fContext);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return fContext.hashCode();
|
||||
}
|
||||
|
||||
|
||||
private static Preferences getPPP(String name) {
|
||||
return new LocalProjectScope(name).getNode(CCorePlugin.PLUGIN_ID);
|
||||
}
|
||||
|
||||
public static void deletePreferences(IPath prjToDelete, IPath movedTo) {
|
||||
try {
|
||||
Preferences prefs= getPPP(prjToDelete.lastSegment());
|
||||
if (movedTo != null) {
|
||||
Preferences target= getPPP(movedTo.lastSegment());
|
||||
copyPrefs(prefs, target);
|
||||
}
|
||||
Preferences parent= prefs.parent();
|
||||
prefs.removeNode();
|
||||
parent.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyPrefs(Preferences prefs, Preferences target) throws BackingStoreException {
|
||||
String[] keys= prefs.keys();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
String key = keys[i];
|
||||
String val= prefs.get(key, null);
|
||||
if (val != null) {
|
||||
target.put(key, val);
|
||||
}
|
||||
}
|
||||
String[] children= prefs.childrenNames();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
String child = children[i];
|
||||
copyPrefs(prefs.node(child), target.node(child));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2007 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core;
|
||||
|
||||
|
@ -1712,7 +1713,8 @@ public final class CharOperation {
|
|||
// offsets inside pattern
|
||||
int pSegmentStart, pLength = pattern.length;
|
||||
|
||||
if (freeLeadingDoubleStar = pattern[0] != pathSeparator){
|
||||
freeLeadingDoubleStar= (pattern[0] != pathSeparator);
|
||||
if (freeLeadingDoubleStar){
|
||||
pSegmentStart = 0;
|
||||
} else {
|
||||
pSegmentStart = 1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. 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
|
||||
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
|
||||
public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
|
||||
|
@ -74,7 +75,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
|
|||
public void _testInclusionAccrossProjects() throws Exception {
|
||||
ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||
try {
|
||||
CCoreInternals.getPDOMManager().setIndexAllFiles(op, true);
|
||||
IndexerPreferences.set(op.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
CCoreInternals.getPDOMManager().reindex(op);
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {getProject(), op});
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
|
|||
org.eclipse.cdt.ui.actions,
|
||||
org.eclipse.cdt.ui.browser.typeinfo,
|
||||
org.eclipse.cdt.ui.dialogs,
|
||||
org.eclipse.cdt.ui.index,
|
||||
org.eclipse.cdt.ui.text,
|
||||
org.eclipse.cdt.ui.text.c.hover,
|
||||
org.eclipse.cdt.ui.text.contentassist,
|
||||
|
|
|
@ -1495,15 +1495,14 @@
|
|||
</enabledWhen>
|
||||
</page>
|
||||
<page
|
||||
adaptable="true"
|
||||
class="org.eclipse.cdt.internal.ui.language.ProjectLanguageMappingPropertyPage"
|
||||
id="org.eclipse.cdt.ui.projectLanguageMappings"
|
||||
name="%CDTLanguagesProperty.name"
|
||||
objectClass="org.eclipse.core.resources.IProject">
|
||||
<filter
|
||||
name="nature"
|
||||
value="org.eclipse.cdt.core.cnature">
|
||||
</filter>
|
||||
name="%CDTLanguagesProperty.name">
|
||||
<enabledWhen>
|
||||
<adapt type="org.eclipse.core.resources.IProject">
|
||||
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
|
||||
</adapt>
|
||||
</enabledWhen>
|
||||
</page>
|
||||
</extension>
|
||||
<extension
|
||||
|
@ -1582,12 +1581,12 @@
|
|||
name="%CDTIndexer.nullindexer"
|
||||
id="org.eclipse.cdt.ui.nullindexerUI"/>
|
||||
<indexerUI
|
||||
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
|
||||
class="org.eclipse.cdt.ui.dialogs.FastIndexerBlock"
|
||||
id="org.eclipse.cdt.ui.fastIndexer"
|
||||
indexerID="org.eclipse.cdt.core.fastIndexer"
|
||||
name="%CDTIndexer.fastindexer"/>
|
||||
<indexerUI
|
||||
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
|
||||
class="org.eclipse.cdt.ui.dialogs.DOMSourceIndexerBlock"
|
||||
id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI"
|
||||
indexerID="org.eclipse.cdt.core.domsourceindexer"
|
||||
name="%CDTIndexer.domsourceindexer"/>
|
||||
|
|
|
@ -24,8 +24,6 @@ displaying mode.
|
|||
|
||||
In multi-tab page, tabs are displayed in order defined by
|
||||
their weights.
|
||||
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
@ -99,8 +97,6 @@ Ignored for single-tab pages.
|
|||
Usually pages are to be derived from
|
||||
org.eclipse.cdt.ui.newui.AbstractPage,
|
||||
but it is not obligatory.
|
||||
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java"/>
|
||||
|
@ -119,7 +115,6 @@ but it is not obligatory.
|
|||
<documentation>
|
||||
Abstract value to be used for sorting tabs inside of tab folder.
|
||||
Ignored for single-tab page.
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
|
@ -140,7 +135,7 @@ Ignored for single-tab page.
|
|||
<meta.section type="examples"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
<extension
|
||||
<extension
|
||||
point="org.eclipse.cdt.ui.cPropertyTab">
|
||||
<tab
|
||||
class="org.eclipse.cdt.managedbuilder.ui.newui.DiscoveryTab"
|
||||
|
@ -148,7 +143,7 @@ Ignored for single-tab page.
|
|||
name="Discovery options"
|
||||
weight="100"
|
||||
parent="org.eclipse.cdt.ui.newui.Page_PathAndSymb"/>
|
||||
</entension>
|
||||
</extension>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
@ -196,7 +191,6 @@ CPropertyVarsTab
|
|||
DiscoveryTab
|
||||
ToolChainEditTab
|
||||
ToolSettingsTab
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
# Contributors:
|
||||
# IBM Corporation - initial API and implementation
|
||||
# QNX Software System
|
||||
# Markus Schorn (Wind River Systems)
|
||||
###############################################################################
|
||||
|
||||
# ------- CView -----------------
|
||||
|
@ -47,7 +48,7 @@ BinaryParserBlock.desc=Set required binary parser for this project
|
|||
|
||||
BaseIndexerBlock.label=C/C++ Indexer
|
||||
BaseIndexerBlock.desc=C/C++ Indexer setting for this project.
|
||||
BaseIndexerBlock.comboLabel=Available indexers
|
||||
BaseIndexerBlock.comboLabel=Select Indexer
|
||||
|
||||
ReferenceBlock.label= Projects
|
||||
ReferenceBlock.desc= Referenced C/C++ Projects
|
||||
|
@ -328,5 +329,3 @@ IndexView.setFastIndexer.name = Use Fast Indexer
|
|||
IndexView.CountSymbols.name = Count Symbols
|
||||
IndexView.CountSymbols.title = Symbol Count
|
||||
IndexView.CountSymbols.message = The selected PDOMs contain {0} files, {1} macros; {2} symbols\r\n{3} references, {4} declarations, {5} definitions.
|
||||
|
||||
IndexerPreferencePage.applyToAllProjects = Apply indexer to all projects now
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2005, 2007 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
|
||||
|
@ -7,106 +7,65 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.preferences;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||
import org.eclipse.cdt.ui.dialogs.IndexerBlock;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||
import org.eclipse.cdt.ui.dialogs.IndexerBlock;
|
||||
|
||||
public class IndexerPreferencePage extends PreferencePage implements
|
||||
IWorkbenchPreferencePage, ICOptionContainer {
|
||||
|
||||
private IndexerBlock fOptionBlock;
|
||||
private Button applyIndexerToAllButton;
|
||||
|
||||
public IndexerPreferencePage(){
|
||||
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(PreferencesMessages.IndexerPrefs_description);
|
||||
fOptionBlock = new IndexerBlock();
|
||||
}
|
||||
|
||||
protected Control createContents(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, true);
|
||||
composite.setLayout(layout);
|
||||
composite.setLayout(new FillLayout());
|
||||
|
||||
fOptionBlock.createControl(composite);
|
||||
|
||||
applyIndexerToAllButton = new Button(composite, SWT.CHECK);
|
||||
applyIndexerToAllButton.setText(CUIPlugin.getResourceString("IndexerPreferencePage.applyToAllProjects")); //$NON-NLS-1$
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
public void init(IWorkbench workbench) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void updateContainer() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public Preferences getPreferences() {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private static class ApplyIndexer extends Job {
|
||||
private final String indexerId;
|
||||
public ApplyIndexer(String indexerId) {
|
||||
super("ApplyIndexer"); //$NON-NLS-1$
|
||||
setSystem(true);
|
||||
this.indexerId = indexerId;
|
||||
}
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
IPDOMManager manager = CCorePlugin.getPDOMManager();
|
||||
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
||||
for (int i = 0; i < projects.length; ++i) {
|
||||
manager.setIndexerId(projects[i], indexerId);
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean performOk() {
|
||||
try {
|
||||
fOptionBlock.performApply(null);
|
||||
if (applyIndexerToAllButton.getSelection()) {
|
||||
String indexerName = fOptionBlock.getSelectedIndexerID();
|
||||
String indexerId = fOptionBlock.getIndexerPageId(indexerName);
|
||||
new ApplyIndexer(indexerId).schedule();
|
||||
}
|
||||
fOptionBlock.performApply(new NullProgressMonitor());
|
||||
} catch (CoreException e) {}
|
||||
CUIPlugin.getDefault().savePluginPreferences();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performDefaults() {
|
||||
fOptionBlock.performDefaults();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.preferences;
|
||||
|
||||
|
@ -164,7 +165,6 @@ public final class PreferencesMessages extends NLS {
|
|||
public static String PathEntryVariablesBlock_addVariableButton;
|
||||
public static String PathEntryVariablesBlock_editVariableButton;
|
||||
public static String PathEntryVariablesBlock_removeVariableButton;
|
||||
public static String IndexerPrefs_description;
|
||||
public static String ProposalFilterPreferencesUtil_defaultFilterName;
|
||||
|
||||
public static String CEditorPreferencePage_typing_tabTitle;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
# Contributors:
|
||||
# IBM Corporation - initial API and implementation
|
||||
# Anton Leherbauer (Wind River Systems)
|
||||
# Markus Schorn (Wind River Systems)
|
||||
###############################################################################
|
||||
|
||||
CEditorPreferencePage_link=C/C++ Editor Preferences. Note that some preferences may be set on the <a href="org.eclipse.ui.preferencePages.GeneralTextEditor">Text Editors</a> preference page.
|
||||
|
@ -224,8 +225,6 @@ PathEntryVariablesBlock_editVariableButton = Edi&t...
|
|||
PathEntryVariablesBlock_removeVariableButton = &Remove
|
||||
|
||||
|
||||
#Indexer
|
||||
IndexerPrefs_description=Sets default Indexer Options for new Projects
|
||||
|
||||
# Language settings
|
||||
ProjectLanguagesPropertyPage_contentTypeColumn = Content Type
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 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 - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
|
||||
/**
|
||||
* @author Bogdan Gheorghe
|
||||
*/
|
||||
public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||
protected static final String INDEX_ALL_FILES = DialogsMessages.AbstractIndexerPage_indexAllFiles;
|
||||
protected static final String TRUE = String.valueOf(true);
|
||||
|
||||
protected AbstractIndexerPage() {
|
||||
super();
|
||||
}
|
||||
|
||||
final public IProject getCurrentProject() {
|
||||
ICOptionContainer container = getContainer();
|
||||
if (container != null) {
|
||||
return container.getProject();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the properties to initialize the controls of the page. Fill in defaults
|
||||
* for properties that are missing.
|
||||
* @since 4.0
|
||||
*/
|
||||
abstract public void setProperties(Properties properties);
|
||||
|
||||
/**
|
||||
* Return the properties according to the selections on the page.
|
||||
* @since 4.0
|
||||
*/
|
||||
abstract public Properties getProperties();
|
||||
|
||||
/**
|
||||
* {@link #getProperties()} will be called instead.
|
||||
*/
|
||||
final public void performApply(IProgressMonitor monitor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #setProperties(Properties)} will be called instead.
|
||||
*/
|
||||
final public void performDefaults() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* The framework disables and enables controls created by this page.
|
||||
* After controls are enabled {@link #updateEnablement()} is called to
|
||||
* allow for disabeling controls.
|
||||
* @since 4.0
|
||||
*/
|
||||
public void updateEnablement() {
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 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
|
||||
|
@ -7,170 +7,40 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corp. - Rational Software - initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
|
||||
public class DOMSourceIndexerBlock extends AbstractIndexerPage {
|
||||
private Button fAllFiles;
|
||||
|
||||
public final static String PREF_INDEX_MARKERS = CUIPlugin.PLUGIN_ID + ".indexmarkers"; //$NON-NLS-1$
|
||||
|
||||
private static final String ENABLE_PREPROCESSOR_PROBLEMS = CUIMessages.getString( "IndexerOptions.enablePreprocessor" ); //$NON-NLS-1$
|
||||
private static final String ENABLE_SEMANTIC_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableSemantic" ); //$NON-NLS-1$
|
||||
private static final String ENABLE_SYNTACTIC_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableSyntactic" ); //$NON-NLS-1$
|
||||
|
||||
private static final String INDEXER_PROBLEMS = CUIMessages.getString("IndexerOptions.problemReporting" ); //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
|
||||
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
|
||||
ICOptionContainer container = getContainer();
|
||||
IProject proj = null;
|
||||
// String indexMarkers = getIndexerProblemsValuesString();
|
||||
|
||||
if (container != null){
|
||||
proj = container.getProject();
|
||||
}
|
||||
else{
|
||||
proj = currentProject.getProject();
|
||||
}
|
||||
|
||||
if (proj != null) {
|
||||
ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(proj);
|
||||
if (cext.length > 0) {
|
||||
for (int i = 0; i < cext.length; i++) {
|
||||
// String id = cext[i].getID();
|
||||
// String orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
|
||||
// String indexProblems = getIndexerProblemsValuesString();
|
||||
// if (orig == null || !orig.equals(indexProblems)) {
|
||||
// cext[i].setExtensionData("indexmarkers", indexProblems); //$NON-NLS-1$
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (prefStore != null) {
|
||||
// prefStore.setValue(PREF_INDEX_MARKERS, indexMarkers);
|
||||
}
|
||||
}
|
||||
|
||||
//Project has just been created and its values have been store - don't need to request
|
||||
//an indexAll as one will come through the DeltaProcessor
|
||||
if (currentProject == null)
|
||||
return;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
||||
*/
|
||||
public void performDefaults() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
|
||||
Composite page = ControlFactory.createComposite(parent, 1);
|
||||
|
||||
Group problemsGroup = ControlFactory.createGroup(page,INDEXER_PROBLEMS,1);
|
||||
|
||||
GridData gd2 = (GridData) problemsGroup.getLayoutData();
|
||||
gd2.grabExcessHorizontalSpace = true;
|
||||
gd2.horizontalAlignment = GridData.FILL;
|
||||
|
||||
|
||||
ControlFactory.createCheckBox( problemsGroup, ENABLE_PREPROCESSOR_PROBLEMS );
|
||||
ControlFactory.createCheckBox( problemsGroup, ENABLE_SEMANTIC_PROBLEMS );
|
||||
ControlFactory.createCheckBox( problemsGroup, ENABLE_SYNTACTIC_PROBLEMS );
|
||||
|
||||
fAllFiles= ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
||||
setControl(page);
|
||||
|
||||
}
|
||||
|
||||
// public String getIndexerProblemsValuesString(){
|
||||
// int result = 0;
|
||||
// result |= preprocessorProblemsEnabled.getSelection() ? DOMSourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0;
|
||||
// if( syntacticProblemsEnabled != null )
|
||||
// result |= syntacticProblemsEnabled.getSelection() ? DOMSourceIndexer.SYNTACTIC_PROBLEMS_BIT : 0;
|
||||
// result |= semanticProblemsEnabled.getSelection() ? DOMSourceIndexer.SEMANTIC_PROBLEMS_BIT : 0;
|
||||
// Integer tempInt = new Integer(result);
|
||||
//
|
||||
// return tempInt.toString();
|
||||
// }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.index2.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
|
||||
*/
|
||||
public void initialize(ICProject project) {
|
||||
|
||||
try {
|
||||
loadPersistedValues(project.getProject());
|
||||
this.currentProject = project;
|
||||
} catch (CoreException e) {}
|
||||
|
||||
//Set the IProblem checkboxes
|
||||
// setIndexerProblemValues(oldIndexerProblemsValue);
|
||||
public Properties getProperties() {
|
||||
Properties props= new Properties();
|
||||
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllFiles.getSelection()));
|
||||
return props;
|
||||
}
|
||||
|
||||
public void loadPersistedValues(IProject project) throws CoreException {
|
||||
|
||||
ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(project);
|
||||
if (cext.length > 0) {
|
||||
for (int i = 0; i < cext.length; i++) {
|
||||
// String id = cext[i].getID();
|
||||
|
||||
String orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
|
||||
if (orig != null){
|
||||
// Integer tempInt = new Integer(orig);
|
||||
// oldIndexerProblemsValue = tempInt.intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
fAllFiles.setSelection(indexAllFiles);
|
||||
}
|
||||
|
||||
// public void setIndexerProblemValues( int value ){
|
||||
// preprocessorProblemsEnabled.setSelection( (value & DOMSourceIndexer.PREPROCESSOR_PROBLEMS_BIT) != 0 );
|
||||
// if( syntacticProblemsEnabled != null )
|
||||
// syntacticProblemsEnabled.setSelection( (value & DOMSourceIndexer.SYNTACTIC_PROBLEMS_BIT) != 0 );
|
||||
// semanticProblemsEnabled.setSelection( (value & DOMSourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0 );
|
||||
// }
|
||||
|
||||
public void loadPreferences() {
|
||||
String indexerId=prefStore.getString(PREF_INDEX_MARKERS);
|
||||
if (!indexerId.equals("")) { //$NON-NLS-1$
|
||||
// oldIndexerProblemsValue = (new Integer(indexerId)).intValue();
|
||||
// setIndexerProblemValues(oldIndexerProblemsValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePreferences() {
|
||||
prefStore.setToDefault(PREF_INDEX_MARKERS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class DialogsMessages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.dialogs.DialogsMessages"; //$NON-NLS-1$
|
||||
public static String AbstractIndexerPage_indexAllFiles;
|
||||
public static String PreferenceScopeBlock_enableProjectSettings;
|
||||
public static String PreferenceScopeBlock_preferenceLink;
|
||||
public static String PreferenceScopeBlock_storeWithProject;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, DialogsMessages.class);
|
||||
}
|
||||
|
||||
private DialogsMessages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
# Markus Schorn (Wind River Systems)
|
||||
###############################################################################
|
||||
PreferenceScopeBlock_enableProjectSettings=Enable project specific settings
|
||||
PreferenceScopeBlock_storeWithProject=Store settings with project
|
||||
PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
|
||||
AbstractIndexerPage_indexAllFiles=Index all files (files neither built nor included, also)
|
|
@ -0,0 +1,42 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
public class FastIndexerBlock extends AbstractIndexerPage {
|
||||
private Button fAllFiles;
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
Composite page = ControlFactory.createComposite(parent, 1);
|
||||
fAllFiles= ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
||||
setControl(page);
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
Properties props= new Properties();
|
||||
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllFiles.getSelection()));
|
||||
return props;
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
fAllFiles.setSelection(indexAllFiles);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
/**
|
||||
* Extension for the ICOptionContainer to be used with new project wizards.
|
||||
* This allows children to access the the project handle.
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ICOptionContainerExtension extends ICOptionContainer {
|
||||
/**
|
||||
* Returns the project to be created.
|
||||
* @since 4.0
|
||||
*/
|
||||
IProject getProjectHandle();
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 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
|
||||
|
@ -7,435 +7,390 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.ControlEnableState;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import com.ibm.icu.text.Collator;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
/**
|
||||
* @author Bogdan Gheorghe
|
||||
*/
|
||||
|
||||
/**
|
||||
* This <code>IndexerBlock2</code> is used in the <code>MakeProjectWizardOptionPage</code> and
|
||||
* This <code>IndexerBlock</code> is used in the <code>MakeProjectWizardOptionPage</code> and
|
||||
* the <code>NewManagedProjectOptionPage</code> to display the indexer options during the creation of
|
||||
* a new project.
|
||||
*/
|
||||
|
||||
public class IndexerBlock extends AbstractCOptionPage {
|
||||
private static final String NODE_INDEXERUI = "indexerUI"; //$NON-NLS-1$
|
||||
private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
|
||||
private static final String ATTRIB_NAME = "name"; //$NON-NLS-1$
|
||||
private static final String ATTRIB_INDEXERID = "indexerID"; //$NON-NLS-1$
|
||||
|
||||
private static final String PREF_PAGE_ID = "org.eclipse.cdt.ui.preferences.IndexerPreferencePage"; //$NON-NLS-1$
|
||||
|
||||
private static final String INDEXER_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.label" ); //$NON-NLS-1$
|
||||
private static final String INDEXER_DESCRIPTION = CUIPlugin.getResourceString("BaseIndexerBlock.desc"); //$NON-NLS-1$
|
||||
private static final String INDEXER_COMBO_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.comboLabel"); //$NON-NLS-1$
|
||||
|
||||
private Combo indexersComboBox;
|
||||
private HashMap indexerPageMap;
|
||||
private List indexerPageList;
|
||||
private String selectedIndexerId = null;
|
||||
private Composite parentComposite;
|
||||
private ICOptionPage currentPage;
|
||||
|
||||
String initialSelected;
|
||||
private PreferenceScopeBlock fPrefScopeBlock;
|
||||
private Combo fIndexersComboBox;
|
||||
private HashMap fIndexerConfigMap;
|
||||
private Composite fIndexerPageComposite;
|
||||
private AbstractIndexerPage fCurrentPage;
|
||||
private Properties fCurrentProperties;
|
||||
private ControlEnableState fEnableState;
|
||||
private Composite fPreferenceContent;
|
||||
|
||||
public IndexerBlock(){
|
||||
super(INDEXER_LABEL);
|
||||
setDescription(INDEXER_DESCRIPTION);
|
||||
initializeIndexerPageMap();
|
||||
}
|
||||
initializeIndexerConfigMap();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Create a profile page only on request
|
||||
*/
|
||||
protected static class IndexerPageConfiguration {
|
||||
private static class IndexerConfig {
|
||||
private AbstractIndexerPage fPage;
|
||||
private IConfigurationElement fElement;
|
||||
|
||||
ICOptionPage page;
|
||||
IConfigurationElement element;
|
||||
|
||||
public IndexerPageConfiguration(IConfigurationElement _element) {
|
||||
element = _element;
|
||||
public IndexerConfig(IConfigurationElement element) {
|
||||
fElement= element;
|
||||
}
|
||||
|
||||
public ICOptionPage getPage() throws CoreException {
|
||||
if (page == null) {
|
||||
page = (ICOptionPage) element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
public AbstractIndexerPage getPage() throws CoreException {
|
||||
if (fPage == null) {
|
||||
try {
|
||||
fPage= (AbstractIndexerPage) fElement.createExecutableExtension(ATTRIB_CLASS);
|
||||
}
|
||||
catch (Exception e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
if (fPage == null) {
|
||||
fPage= new NullIndexerBlock();
|
||||
}
|
||||
}
|
||||
return page;
|
||||
return fPage;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return element.getAttribute("name"); //$NON-NLS-1$
|
||||
return fElement.getAttribute(ATTRIB_NAME);
|
||||
}
|
||||
|
||||
public String getIndexerID(){
|
||||
return element.getAttribute("indexerID"); //$NON-NLS-1$
|
||||
return fElement.getAttribute(ATTRIB_INDEXERID);
|
||||
}
|
||||
}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
|
||||
Composite composite = ControlFactory.createComposite(parent, 1);
|
||||
Font font = parent.getFont();
|
||||
GridLayout layout= ((GridLayout)composite.getLayout());
|
||||
layout.marginHeight= 0;
|
||||
layout.marginWidth= 0;
|
||||
layout.verticalSpacing= 0;
|
||||
layout.horizontalSpacing= GridData.FILL_HORIZONTAL;
|
||||
composite.setLayoutData(null);
|
||||
composite.setFont(font);
|
||||
setControl(composite);
|
||||
|
||||
Composite scComp = ControlFactory.createComposite(composite, 1);
|
||||
((GridLayout)scComp.getLayout()).marginHeight = 0;
|
||||
((GridLayout)scComp.getLayout()).marginTop = 5;
|
||||
scComp.setFont(font);
|
||||
if (getProject() != null || getContainer() instanceof ICOptionContainerExtension) {
|
||||
fPrefScopeBlock= new PreferenceScopeBlock(PREF_PAGE_ID) {
|
||||
protected void onPreferenceScopeChange() {
|
||||
IndexerBlock.this.onPreferenceScopeChange();
|
||||
}
|
||||
};
|
||||
fPrefScopeBlock.createControl(composite);
|
||||
}
|
||||
|
||||
// Create a group for discovered indexer's UI
|
||||
if (createIndexerControls(scComp)) {
|
||||
// create a composite for discovery profile options
|
||||
Composite indexPageComposite = ControlFactory.createComposite(composite, 1);
|
||||
indexPageComposite.setFont(font);
|
||||
indexPageComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
|
||||
indexPageComposite.setLayout(new TabFolderLayout());
|
||||
// Must set the composite parent to super class.
|
||||
parentComposite = indexPageComposite;
|
||||
fPreferenceContent= ControlFactory.createComposite(composite, 1);
|
||||
layout= ((GridLayout)fPreferenceContent.getLayout());
|
||||
layout.marginHeight= 0;
|
||||
layout.marginWidth= 0;
|
||||
|
||||
setPage();
|
||||
Composite isc = ControlFactory.createComposite(fPreferenceContent, 1);
|
||||
GridLayout gridLayout = ((GridLayout)isc.getLayout());
|
||||
gridLayout.makeColumnsEqualWidth= false;
|
||||
gridLayout.marginHeight = 0;
|
||||
gridLayout.marginTop = 5;
|
||||
|
||||
}
|
||||
// add combo to select indexer
|
||||
Group group= ControlFactory.createGroup(isc,INDEXER_COMBO_LABEL, 1);
|
||||
fIndexersComboBox = ControlFactory.createSelectCombo(group,"", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fIndexersComboBox.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
onIndexerChange();
|
||||
}
|
||||
});
|
||||
|
||||
// add composite for pages
|
||||
fIndexerPageComposite= ControlFactory.createComposite(fPreferenceContent, 1);
|
||||
fIndexerPageComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
|
||||
fIndexerPageComposite.setLayout(new TabFolderLayout());
|
||||
|
||||
initializeScope();
|
||||
initializeIndexerCombo();
|
||||
onPreferenceScopeChange();
|
||||
parent.layout(true);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void setPage() {
|
||||
|
||||
String profileId = getCurrentIndexPageId();
|
||||
|
||||
//If no indexer has been selected, return
|
||||
if (profileId == null)
|
||||
return;
|
||||
|
||||
ICOptionPage page = getIndexerPage(profileId);
|
||||
if (page != null) {
|
||||
if (page.getControl() == null) {
|
||||
page.setContainer(getContainer());
|
||||
page.createControl(parentComposite);
|
||||
parentComposite.layout(true);
|
||||
}
|
||||
|
||||
if (currentPage != null){
|
||||
currentPage.setVisible(false);
|
||||
}
|
||||
|
||||
page.setVisible(true);
|
||||
}
|
||||
|
||||
setCurrentPage(page);
|
||||
|
||||
if (page instanceof AbstractIndexerPage){
|
||||
((AbstractIndexerPage) page).loadPreferences();
|
||||
private void enablePreferenceContent(boolean enable) {
|
||||
if (fEnableState != null) {
|
||||
fEnableState.restore();
|
||||
}
|
||||
if (enable) {
|
||||
fEnableState= null;
|
||||
}
|
||||
else {
|
||||
fEnableState= ControlEnableState.disable(fPreferenceContent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param page
|
||||
*/
|
||||
private void setCurrentPage(ICOptionPage page) {
|
||||
currentPage = page;
|
||||
private void initializeScope() {
|
||||
IProject proj= getProject();
|
||||
if (fPrefScopeBlock == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int scope= proj == null ? IndexerPreferences.SCOPE_INSTANCE : IndexerPreferences.getScope(proj);
|
||||
switch(scope) {
|
||||
case IndexerPreferences.SCOPE_PROJECT_PRIVATE:
|
||||
fPrefScopeBlock.setProjectLocalScope();
|
||||
break;
|
||||
case IndexerPreferences.SCOPE_PROJECT_SHARED:
|
||||
fPrefScopeBlock.setProjectScope();
|
||||
break;
|
||||
default:
|
||||
fPrefScopeBlock.setInstanceScope();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getCurrentIndexPageId() {
|
||||
String selectedIndexPageName = getSelectedIndexerID();
|
||||
private void initializeIndexerCombo() {
|
||||
String[] names= new String[fIndexerConfigMap.size()];
|
||||
int j= 0;
|
||||
for (Iterator i = fIndexerConfigMap.values().iterator(); i.hasNext();) {
|
||||
IndexerConfig config = (IndexerConfig) i.next();
|
||||
names[j++]= config.getName();
|
||||
}
|
||||
Arrays.sort(names, Collator.getInstance());
|
||||
fIndexersComboBox.setItems(names);
|
||||
}
|
||||
|
||||
if (selectedIndexPageName == null)
|
||||
return null;
|
||||
protected void onPreferenceScopeChange() {
|
||||
int scope= computeScope();
|
||||
if (fCurrentProperties == null || scope != IndexerPreferences.SCOPE_PROJECT_PRIVATE) {
|
||||
Properties props= IndexerPreferences.getProperties(getProject(), scope);
|
||||
|
||||
String indexerId= props.getProperty(IndexerPreferences.KEY_INDEXER_ID);
|
||||
if (getIndexerName(indexerId) == null) {
|
||||
if (fCurrentProperties != null) {
|
||||
props= fCurrentProperties;
|
||||
}
|
||||
else {
|
||||
props= IndexerPreferences.getProperties(getProject(), IndexerPreferences.SCOPE_INSTANCE);
|
||||
}
|
||||
}
|
||||
fCurrentProperties= props;
|
||||
}
|
||||
String indexerId= fCurrentProperties.getProperty(IndexerPreferences.KEY_INDEXER_ID);
|
||||
String indexerName = getIndexerName(indexerId);
|
||||
String[] indexerList = fIndexersComboBox.getItems();
|
||||
int selectedIndex = 0;
|
||||
for (int i=0; i<indexerList.length; i++){
|
||||
if (indexerList[i].equals(indexerName))
|
||||
selectedIndex = i;
|
||||
}
|
||||
fIndexersComboBox.select(selectedIndex);
|
||||
setPage();
|
||||
if (fPrefScopeBlock != null) {
|
||||
enablePreferenceContent(scope != IndexerPreferences.SCOPE_INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
String selectedIndexPageId = getIndexerPageId(selectedIndexPageName);
|
||||
|
||||
return selectedIndexPageId;
|
||||
protected void onIndexerChange() {
|
||||
if (fCurrentPage != null) {
|
||||
Properties props= fCurrentPage.getProperties();
|
||||
if (props != null) {
|
||||
fCurrentProperties.putAll(props);
|
||||
}
|
||||
}
|
||||
setPage();
|
||||
}
|
||||
|
||||
private boolean createIndexerControls(Composite parent) {
|
||||
Group group= ControlFactory.createGroup(parent,INDEXER_COMBO_LABEL,2);
|
||||
|
||||
// Add discovered indexers combo box
|
||||
indexersComboBox = ControlFactory.createSelectCombo(group,"", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
//Add combo box listener
|
||||
indexersComboBox.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
setPage();
|
||||
private int computeScope() {
|
||||
if (fPrefScopeBlock != null) {
|
||||
if (fPrefScopeBlock.isProjectLocalScope()) {
|
||||
return IndexerPreferences.SCOPE_PROJECT_PRIVATE;
|
||||
}
|
||||
});
|
||||
//Make sure that the combo box takes up two cells
|
||||
GridData gridData = (GridData) indexersComboBox.getLayoutData();
|
||||
gridData.verticalSpan=2;
|
||||
if (fPrefScopeBlock.isProjectScope()) {
|
||||
return IndexerPreferences.SCOPE_PROJECT_SHARED;
|
||||
}
|
||||
}
|
||||
return IndexerPreferences.SCOPE_INSTANCE;
|
||||
}
|
||||
|
||||
// fill the combobox and set the initial value
|
||||
for (Iterator items = getIndexerPageIdList().iterator(); items.hasNext();) {
|
||||
String profileId = (String)items.next();
|
||||
String pageName = getIndexerPageName(profileId);
|
||||
if (pageName != null) {
|
||||
indexersComboBox.add(pageName);
|
||||
private void setPage() {
|
||||
String indexerID= getSelectedIndexerID();
|
||||
AbstractIndexerPage page = getIndexerPage(indexerID);
|
||||
if (page != null) {
|
||||
if (page.getControl() == null) {
|
||||
page.setContainer(getContainer());
|
||||
page.createControl(fIndexerPageComposite);
|
||||
fIndexerPageComposite.layout(true);
|
||||
}
|
||||
}
|
||||
|
||||
//See what the preferred indexer is
|
||||
String indexerId = CCorePlugin.getPDOMManager().getDefaultIndexerId();
|
||||
String preferredIndexer = getIndexerPageName(indexerId);
|
||||
String[] indexerList = indexersComboBox.getItems();
|
||||
int selectedIndex = 0;
|
||||
for (int i=0; i<indexerList.length; i++){
|
||||
if (indexerList[i].equals(preferredIndexer))
|
||||
selectedIndex = i;
|
||||
if (fCurrentPage != null){
|
||||
fCurrentPage.setVisible(false);
|
||||
}
|
||||
|
||||
indexersComboBox.select(selectedIndex);
|
||||
if (page != null) {
|
||||
page.setProperties(fCurrentProperties);
|
||||
page.setVisible(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
fCurrentPage= page;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Adds all the contributed Indexer Pages to a map
|
||||
*/
|
||||
private void initializeIndexerPageMap() {
|
||||
indexerPageMap = new HashMap(5);
|
||||
indexerPageList = new ArrayList(5);
|
||||
|
||||
private void initializeIndexerConfigMap() {
|
||||
fIndexerConfigMap = new HashMap(5);
|
||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.getPluginId(), "IndexerPage"); //$NON-NLS-1$
|
||||
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
|
||||
for (int i = 0; i < infos.length; i++) {
|
||||
if (infos[i].getName().equals("indexerUI")) { //$NON-NLS-1$
|
||||
String id = infos[i].getAttribute("indexerID"); //$NON-NLS-1$
|
||||
indexerPageMap.put(id, new IndexerPageConfiguration(infos[i]));
|
||||
indexerPageList.add(id);
|
||||
if (infos[i].getName().equals(NODE_INDEXERUI)) {
|
||||
String id = infos[i].getAttribute(ATTRIB_INDEXERID);
|
||||
if (id != null) {
|
||||
IndexerConfig config= new IndexerConfig(infos[i]);
|
||||
if (config.getName() != null) {
|
||||
fIndexerConfigMap.put(id, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the contributed Indexer Pages as a list
|
||||
*/
|
||||
protected List getIndexerPageIdList() {
|
||||
return indexerPageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the page name for the given id
|
||||
*/
|
||||
protected String getIndexerPageName(String indexerPageId) {
|
||||
IndexerPageConfiguration configElement =
|
||||
(IndexerPageConfiguration) indexerPageMap.get(indexerPageId);
|
||||
private String getIndexerName(String indexerID) {
|
||||
IndexerConfig configElement= (IndexerConfig) fIndexerConfigMap.get(indexerID);
|
||||
if (configElement != null) {
|
||||
return configElement.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Returns the indexer page id for the give name
|
||||
* @param indexerPageName
|
||||
* @return String
|
||||
*/
|
||||
public String getIndexerPageId(String indexerPageName) {
|
||||
for (Iterator I = indexerPageMap.keySet().iterator(); I.hasNext();) {
|
||||
String indexerPageId = (String) I.next();
|
||||
String tempPageName = getIndexerPageName(indexerPageId);
|
||||
if (indexerPageName.equals(tempPageName)) {
|
||||
return indexerPageId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
private String getIndexerID(String indexerName) {
|
||||
for (Iterator i = fIndexerConfigMap.entrySet().iterator(); i.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
String id = (String) entry.getKey();
|
||||
IndexerConfig config = (IndexerConfig) entry.getValue();
|
||||
if (indexerName.equals(config.getName())) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ICOptionPage getIndexerPage(String indexerPageId) {
|
||||
IndexerPageConfiguration configElement =
|
||||
(IndexerPageConfiguration) indexerPageMap.get(indexerPageId);
|
||||
private AbstractIndexerPage getIndexerPage(String indexerID) {
|
||||
IndexerConfig configElement= (IndexerConfig) fIndexerConfigMap.get(indexerID);
|
||||
if (configElement != null) {
|
||||
try {
|
||||
return configElement.getPage();
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the indexer id for the given name
|
||||
*/
|
||||
protected String getIndexerIdName(String indexerPageId) {
|
||||
IndexerPageConfiguration configElement =
|
||||
(IndexerPageConfiguration) indexerPageMap.get(indexerPageId);
|
||||
if (configElement != null) {
|
||||
return configElement.getIndexerID();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||
//Get the currently selected indexer from the UI
|
||||
String indexerName = getSelectedIndexerID();
|
||||
//If no indexer has been selected, return
|
||||
if (indexerName == null)
|
||||
return;
|
||||
int scope= computeScope();
|
||||
IProject project= getProject();
|
||||
String indexerID = getSelectedIndexerID();
|
||||
if (indexerID == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Match up the selected indexer in the UI to a corresponding
|
||||
//contributed Indexer Page ID
|
||||
String indexerPageID = getIndexerPageId(indexerName);
|
||||
if (scope != IndexerPreferences.SCOPE_INSTANCE || project == null) {
|
||||
Properties props= new Properties();
|
||||
props.setProperty(IndexerPreferences.KEY_INDEXER_ID, indexerID);
|
||||
if (fCurrentPage != null) {
|
||||
Properties p1= fCurrentPage.getProperties();
|
||||
if (p1 != null) {
|
||||
props.putAll(p1);
|
||||
}
|
||||
}
|
||||
IndexerPreferences.setProperties(project, scope, props);
|
||||
}
|
||||
|
||||
if (indexerPageID == null)
|
||||
return;
|
||||
if (project != null) {
|
||||
IndexerPreferences.setScope(project, scope);
|
||||
}
|
||||
CCoreInternals.savePreferences(project);
|
||||
}
|
||||
|
||||
//Get the id of the indexer that goes along with this UI page - this gets persisted
|
||||
final String indexerID = getIndexerIdName(indexerPageID);
|
||||
//
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
monitor.beginTask(CUIMessages.getString("IndexerOptions.task.savingAttributes"), 2); //$NON-NLS-1$
|
||||
final String selected = indexerID;
|
||||
public void performDefaults() {
|
||||
fCurrentProperties= null;
|
||||
fPrefScopeBlock.setInstanceScope();
|
||||
onPreferenceScopeChange();
|
||||
|
||||
if (indexerID != null) {
|
||||
ICOptionContainer container = getContainer();
|
||||
final IProject project = (container != null)
|
||||
? container.getProject()
|
||||
: ((AbstractIndexerPage) currentPage).getCurrentProject();
|
||||
|
||||
if ( project != null) {
|
||||
ICProject cproject = CoreModel.getDefault().create(project);
|
||||
IPDOMManager manager = CCorePlugin.getPDOMManager();
|
||||
if (!indexerID.equals(manager.getIndexerId(cproject)))
|
||||
manager.setIndexerId(cproject, indexerID);
|
||||
if (currentPage != null && currentPage.getControl() != null) {
|
||||
currentPage.performApply(new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
} else {
|
||||
if (initialSelected == null || !selected.equals(initialSelected)) {
|
||||
|
||||
// First clean out the old indexer settings
|
||||
String oldId = CCorePlugin.getPDOMManager().getDefaultIndexerId();
|
||||
ICOptionPage tempPage = getIndexerPage(oldId);
|
||||
if (tempPage instanceof AbstractIndexerPage)
|
||||
((AbstractIndexerPage) tempPage).removePreferences();
|
||||
|
||||
CCorePlugin.getPDOMManager().setDefaultIndexerId(indexerID);
|
||||
}
|
||||
monitor.worked(1);
|
||||
// Give a chance to the contributions to save.
|
||||
ICOptionPage page = currentPage;
|
||||
if (page != null && page.getControl() != null) {
|
||||
page.performApply(new SubProgressMonitor(monitor, 1));
|
||||
}
|
||||
|
||||
}
|
||||
initialSelected = selected;
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists BasicIndexerBlock settings to disk and allows current indexer page to persist settings
|
||||
* This is needed since we need to pass in the project if we are trying to save changes made to the
|
||||
* property page.
|
||||
* @deprecated always returns false
|
||||
*/
|
||||
public void persistIndexerSettings(ICProject project, IProgressMonitor monitor) throws CoreException{
|
||||
if (currentPage instanceof AbstractIndexerPage)
|
||||
((AbstractIndexerPage)currentPage).setCurrentProject(project);
|
||||
|
||||
this.performApply(monitor);
|
||||
}
|
||||
|
||||
public void resetIndexerPageSettings(ICProject project){
|
||||
if (currentPage instanceof AbstractIndexerPage)
|
||||
((AbstractIndexerPage)currentPage).setCurrentProject(project);
|
||||
|
||||
this.performDefaults();
|
||||
}
|
||||
|
||||
public void performDefaults() {
|
||||
//Give a chance to the contributions to perform defaults.
|
||||
ICOptionPage page = currentPage;
|
||||
if (page != null && page.getControl() != null) {
|
||||
page.performDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isIndexEnabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setIndexerID(String indexerID, ICProject project) {
|
||||
//Get the corresponding text for the given indexer id
|
||||
selectedIndexerId = getIndexerPageName(indexerID);
|
||||
//Store the currently selected indexer id
|
||||
initialSelected = indexerID;
|
||||
|
||||
if (selectedIndexerId == null){
|
||||
CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.DEFAULT_INDEXER);
|
||||
selectedIndexerId = CCorePlugin.DEFAULT_INDEXER;
|
||||
}
|
||||
|
||||
//Set the appropriate indexer in the combo box
|
||||
indexersComboBox.setText(selectedIndexerId);
|
||||
//Load the appropriate page
|
||||
setPage();
|
||||
//Give the contributed page a chance to initialize
|
||||
if (currentPage instanceof AbstractIndexerPage){
|
||||
((AbstractIndexerPage) currentPage).initialize(project);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSelectedIndexerID(){
|
||||
String indexerID = null;
|
||||
|
||||
int selIndex = indexersComboBox.getSelectionIndex();
|
||||
|
||||
//If no indexer has been selected return
|
||||
if (selIndex != -1)
|
||||
indexerID = indexersComboBox.getItem(selIndex);
|
||||
|
||||
return indexerID;
|
||||
private String getSelectedIndexerID(){
|
||||
return getIndexerID(fIndexersComboBox.getText());
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
ICOptionContainer container = getContainer();
|
||||
if (container != null){
|
||||
if (container instanceof ICOptionContainerExtension) {
|
||||
try {
|
||||
return ((ICOptionContainerExtension) container).getProjectHandle();
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return container.getProject();
|
||||
} else {
|
||||
return ((AbstractIndexerPage)currentPage).getCurrentProject();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM Corp. - Rational Software - initial implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
@ -16,6 +17,7 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -23,21 +25,18 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.dialogs.PropertyPage;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
|
||||
public class IndexerOptionPropertyPage extends PropertyPage {
|
||||
public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionContainer {
|
||||
|
||||
private IndexerBlock optionPage;
|
||||
private String oldIndexerID;
|
||||
|
||||
public IndexerOptionPropertyPage(){
|
||||
super();
|
||||
optionPage = new IndexerBlock();
|
||||
optionPage.setContainer(this);
|
||||
}
|
||||
|
||||
protected Control createContents(Composite parent) {
|
||||
|
@ -46,44 +45,38 @@ public class IndexerOptionPropertyPage extends PropertyPage {
|
|||
|
||||
optionPage.createControl(composite);
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INDEXER_PROPERTIES);
|
||||
initialize();
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
protected void performDefaults() {
|
||||
ICProject tempProject = CoreModel.getDefault().create(getProject());
|
||||
optionPage.resetIndexerPageSettings(tempProject);
|
||||
}
|
||||
|
||||
private void initialize(){
|
||||
ICProject project = CoreModel.getDefault().create(getProject());
|
||||
try {
|
||||
oldIndexerID = CCorePlugin.getPDOMManager().getIndexerId(project);
|
||||
optionPage.setIndexerID(oldIndexerID, project);
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
optionPage.performDefaults();
|
||||
}
|
||||
|
||||
public boolean performOk() {
|
||||
ICProject tempProject = CoreModel.getDefault().create(getProject());
|
||||
try {
|
||||
optionPage.persistIndexerSettings(tempProject, new NullProgressMonitor());
|
||||
} catch (CoreException e) {}
|
||||
|
||||
optionPage.performApply(new NullProgressMonitor());
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IProject getProject(){
|
||||
IAdaptable tempElement = getElement();
|
||||
IProject project;
|
||||
if (tempElement instanceof IProject) {
|
||||
project = (IProject) tempElement;
|
||||
} else {
|
||||
project = (IProject)tempElement.getAdapter(IProject.class);
|
||||
IProject project= null;
|
||||
IAdaptable elem = getElement();
|
||||
if (elem instanceof IProject) {
|
||||
project= (IProject) elem;
|
||||
} else if (elem != null) {
|
||||
project= (IProject) elem.getAdapter(IProject.class);
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
public Preferences getPreferences() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void updateContainer() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 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
|
||||
|
@ -7,34 +7,30 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
|
||||
/**
|
||||
* @author Bogdan Gheorghe
|
||||
*/
|
||||
public class NullIndexerBlock extends AbstractIndexerPage {
|
||||
|
||||
public void initialize(ICProject currentProject) {}
|
||||
|
||||
public void performApply(IProgressMonitor monitor) throws CoreException {}
|
||||
|
||||
public void performDefaults() {}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NULL);
|
||||
setControl(comp);
|
||||
}
|
||||
|
||||
public void loadPreferences() {}
|
||||
|
||||
public void removePreferences() {}
|
||||
public Properties getProperties() {
|
||||
return new Properties();
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Link;
|
||||
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
|
||||
|
||||
abstract public class PreferenceScopeBlock {
|
||||
private Button fUseProjectSettings;
|
||||
private Button fStoreWithProject;
|
||||
private String fPrefPageID;
|
||||
private Link fLink;
|
||||
|
||||
public PreferenceScopeBlock(String linkedPrefPageID) {
|
||||
fPrefPageID= linkedPrefPageID;
|
||||
}
|
||||
|
||||
public void createControl(final Composite parent) {
|
||||
Composite group= ControlFactory.createComposite(parent,2);
|
||||
fUseProjectSettings= ControlFactory.createCheckBox(group, DialogsMessages.PreferenceScopeBlock_enableProjectSettings);
|
||||
|
||||
Composite two= ControlFactory.createComposite(group, 1);
|
||||
two.setLayout(new TabFolderLayout());
|
||||
fStoreWithProject= ControlFactory.createCheckBox(two, DialogsMessages.PreferenceScopeBlock_storeWithProject);
|
||||
|
||||
SelectionListener sl= new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateEnablement();
|
||||
onPreferenceScopeChange();
|
||||
}
|
||||
};
|
||||
fUseProjectSettings.addSelectionListener(sl);
|
||||
fStoreWithProject.addSelectionListener(sl);
|
||||
|
||||
fLink= new Link(two, SWT.NONE);
|
||||
fLink.setText(DialogsMessages.PreferenceScopeBlock_preferenceLink);
|
||||
fLink.setLayoutData(new GridData());
|
||||
sl= new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), fPrefPageID, null, null).open();
|
||||
onPreferenceScopeChange();
|
||||
}
|
||||
};
|
||||
fLink.addSelectionListener(sl);
|
||||
|
||||
Label horizontalLine= new Label(group, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
|
||||
horizontalLine.setFont(group.getFont());
|
||||
}
|
||||
|
||||
abstract protected void onPreferenceScopeChange();
|
||||
|
||||
private void updateEnablement() {
|
||||
if (fUseProjectSettings.getSelection()) {
|
||||
fLink.setVisible(false);
|
||||
fStoreWithProject.setVisible(true);
|
||||
}
|
||||
else {
|
||||
fStoreWithProject.setVisible(false);
|
||||
fLink.setVisible(true);
|
||||
}
|
||||
fUseProjectSettings.getParent().layout(true);
|
||||
}
|
||||
|
||||
public void setProjectLocalScope() {
|
||||
fUseProjectSettings.setSelection(true);
|
||||
fStoreWithProject.setSelection(false);
|
||||
updateEnablement();
|
||||
}
|
||||
|
||||
public void setProjectScope() {
|
||||
fUseProjectSettings.setSelection(true);
|
||||
fStoreWithProject.setSelection(true);
|
||||
updateEnablement();
|
||||
}
|
||||
|
||||
public void setInstanceScope() {
|
||||
fUseProjectSettings.setSelection(false);
|
||||
fStoreWithProject.setSelection(false);
|
||||
updateEnablement();
|
||||
}
|
||||
|
||||
public boolean isProjectLocalScope() {
|
||||
return fUseProjectSettings.getSelection() && !fStoreWithProject.getSelection();
|
||||
}
|
||||
|
||||
public boolean isProjectScope() {
|
||||
return fUseProjectSettings.getSelection() && fStoreWithProject.getSelection();
|
||||
}
|
||||
|
||||
public boolean isInstanceScope() {
|
||||
return !fUseProjectSettings.getSelection();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 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 - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.index;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
||||
/**
|
||||
* @author Bogdan Gheorghe
|
||||
*/
|
||||
public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||
|
||||
protected ICProject currentProject;
|
||||
protected IPreferenceStore prefStore=CUIPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
protected AbstractIndexerPage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by BaseIndexerBlock to give the indexer page a chance to load its state from store
|
||||
* @param currentProject - the project that this page is being created for
|
||||
*/
|
||||
abstract public void initialize(ICProject currentProject);
|
||||
/**
|
||||
* Called by the indexer block to give the indexer page an opportunity to
|
||||
* load any preferecnes previously set
|
||||
*/
|
||||
abstract public void loadPreferences();
|
||||
/**
|
||||
* Called on indexer preference changes to allow former indexer pages
|
||||
* to clean up the preferences store
|
||||
*/
|
||||
abstract public void removePreferences();
|
||||
|
||||
public IProject getCurrentProject() {
|
||||
return currentProject != null ? currentProject.getProject() : null;
|
||||
}
|
||||
|
||||
public void setCurrentProject(ICProject currentProject) {
|
||||
this.currentProject = currentProject;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.ui.newui;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2005 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
|
@ -134,7 +135,7 @@ public abstract class NewCProjectWizard extends BasicNewResourceWizard implement
|
|||
* Overwrite this method if you do not have a main page
|
||||
*/
|
||||
|
||||
protected IProject getProjectHandle() throws UnsupportedOperationException {
|
||||
public IProject getProjectHandle() throws UnsupportedOperationException {
|
||||
if (null == fMainPage)
|
||||
throw new UnsupportedOperationException();
|
||||
return fMainPage.getProjectHandle();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 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
|
||||
|
@ -7,11 +7,10 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
|
@ -19,7 +18,10 @@ import org.eclipse.jface.resource.ImageDescriptor;
|
|||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
public abstract class NewCProjectWizardOptionPage extends WizardPage implements ICOptionContainer {
|
||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainerExtension;
|
||||
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
|
||||
|
||||
public abstract class NewCProjectWizardOptionPage extends WizardPage implements ICOptionContainerExtension {
|
||||
|
||||
private TabFolderOptionBlock fOptionBlock;
|
||||
|
||||
|
@ -62,6 +64,14 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
|
||||
*/
|
||||
public abstract IProject getProject();
|
||||
public IProject getProject() {
|
||||
return ((NewCProjectWizard)getWizard()).getNewProject();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
|
||||
*/
|
||||
public IProject getProjectHandle() {
|
||||
return ((NewCProjectWizard)getWizard()).getProjectHandle();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue