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

Fix for 166991, indexer preferences and project specific settings.

This commit is contained in:
Markus Schorn 2007-02-21 10:42:01 +00:00
parent 3e5e1b02ea
commit 5dfbff2013
46 changed files with 1325 additions and 918 deletions

View file

@ -72,7 +72,6 @@ public class AST2FileBasePluginTest extends TestCase {
className = aClassName; className = aClassName;
numProjects++; numProjects++;
} }
CCorePlugin.getPDOMManager().setIndexerId(cPrj, IPDOMManager.ID_NO_INDEXER);
} catch ( CoreException e ) { } catch ( CoreException e ) {
/*boo*/ /*boo*/
} }

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.TestScannerProvider; import org.eclipse.cdt.core.testplugin.TestScannerProvider;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.internal.core.CCoreInternals; 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.IFile;
import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
@ -79,11 +80,11 @@ public class IndexIncludeTest extends IndexTestBase {
public void testFastIndexer() throws Exception { public void testFastIndexer() throws Exception {
CCoreInternals.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_FAST_INDEXER); CCoreInternals.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_FAST_INDEXER);
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, false); IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
waitForIndexer(); waitForIndexer();
checkHeader(false); checkHeader(false);
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, true); IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
waitForIndexer(); waitForIndexer();
checkHeader(true); checkHeader(true);
@ -96,11 +97,11 @@ public class IndexIncludeTest extends IndexTestBase {
public void testFullIndexer() throws Exception { public void testFullIndexer() throws Exception {
CCoreInternals.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_FULL_INDEXER); CCoreInternals.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_FULL_INDEXER);
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, false); IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
waitForIndexer(); waitForIndexer();
checkHeader(false); checkHeader(false);
CCoreInternals.getPDOMManager().setIndexAllFiles(fProject, true); IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
waitForIndexer(); waitForIndexer();
checkHeader(true); checkHeader(true);

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.index.tests; 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.model.ICProject;
import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.TestScannerProvider; 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.cdt.utils.spawner.EnvironmentReader;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
@ -55,7 +56,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"}; TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
try { try {
CCoreInternals.getPDOMManager().setIndexAllFiles(cproject, true); IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
CCorePlugin.getPDOMManager().reindex(cproject); CCorePlugin.getPDOMManager().reindex(cproject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -72,11 +72,7 @@ abstract public class BaseTestFramework extends TestCase {
fileManager = new FileManager(); fileManager = new FileManager();
} }
} }
public void disableIndexing() throws CoreException {
CCorePlugin.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_NO_INDEXER);
}
public BaseTestFramework() public BaseTestFramework()
{ {
super(); super();

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.testplugin; package org.eclipse.cdt.core.testplugin;
import java.io.File; 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.ISourceRoot;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.CCoreInternals; 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.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
@ -94,7 +96,7 @@ public class CProjectHelper {
} }
newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project); newProject[0] = CCorePlugin.getDefault().getCoreModel().create(project);
if (indexerID != null) { 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); CCoreInternals.getPDOMManager().setIndexerId(newProject[0], indexerID);
} }
} }

View file

@ -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;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.pdom.dom.c;x-internal:=true, 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.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.fast;x-internal:=true,
org.eclipse.cdt.internal.core.pdom.indexer.full;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, org.eclipse.cdt.internal.core.pdom.indexer.nulli;x-internal:=true,

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.CCoreInternals; 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.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -770,6 +771,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
case IResourceChangeEvent.POST_CHANGE : case IResourceChangeEvent.POST_CHANGE :
try { try {
if (delta != null) { if (delta != null) {
checkForProjectRename(delta);
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta); ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
if (translatedDeltas.length > 0) { if (translatedDeltas.length > 0) {
for (int i = 0; i < translatedDeltas.length; i++) { 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) { private void deleting(IProject project, IResourceDelta delta) {
// stop the binary runner for this project // stop the binary runner for this project
removeBinaryRunner(project); removeBinaryRunner(project);

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,10 +8,13 @@
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom; package org.eclipse.cdt.core.dom;
import java.util.Properties;
import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -37,21 +40,21 @@ public interface IPDOMIndexer {
public String getID(); 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 * @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. * Clients are not allowed to call this method, it is called by the framework.
* @since 4.0 * @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. * Clients are not allowed to call this method, it is called by the framework.
* Used to check whether we need to reindex a project. * Used to check whether we need to reindex a project.
* @since 4.0 * @since 4.0
*/ */
public boolean isIndexAllFiles(boolean value); public boolean hasProperties(Properties props);
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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_JoinIndexerTask;
public static String PDOMManager_notifyJob_label; public static String PDOMManager_notifyJob_label;
public static String PDOMManager_notifyTask_message; public static String PDOMManager_notifyTask_message;
public static String PDOMManager_savePrefsJob;
public static String PDOMManager_StartJob_name; public static String PDOMManager_StartJob_name;
public static String WritablePDOM_error_unknownLinkage; public static String WritablePDOM_error_unknownLinkage;
static { static {

View file

@ -189,7 +189,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
protected void clear() throws CoreException { protected void clear() throws CoreException {
Database db = getDB(); Database db = getDB();
// Clear out the database // Clear out the database
db.clear(0); db.clear(1);
// Zero out the File Index and Linkages // Zero out the File Index and Linkages
db.putInt(FILE_INDEX, 0); db.putInt(FILE_INDEX, 0);
@ -535,7 +535,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
} }
public IIndexFragmentBinding adaptBinding(IIndexFragmentBinding binding) throws CoreException { public IIndexFragmentBinding adaptBinding(IIndexFragmentBinding binding) throws CoreException {
if (binding instanceof IBinding) { if (binding != null) {
return adaptBinding((IBinding) binding); return adaptBinding((IBinding) binding);
} }
return null; return null;

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,10 +18,9 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin; 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.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMIndexer; import org.eclipse.cdt.core.dom.IPDOMIndexer;
import org.eclipse.cdt.core.dom.IPDOMIndexerTask; 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.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener; 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.IWritableIndex;
import org.eclipse.cdt.internal.core.index.IWritableIndexManager; import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
import org.eclipse.cdt.internal.core.index.IndexChangeEvent; 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.index.IndexerStateEvent;
import org.eclipse.cdt.internal.core.pdom.PDOM.IListener; 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.dom.PDOMProjectIndexLocationConverter;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer; import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta; 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.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; 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.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job; 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.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; 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 * The PDOM Provider. This is likely temporary since I hope
@ -84,12 +77,21 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
return rule == this; return rule == this;
} }
} }
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 indexerProperty= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomIndexer"); //$NON-NLS-1$
private static final QualifiedName dbNameProperty= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomName"); //$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 NOTIFICATION_SCHEDULING_RULE = new PerInstanceSchedulingRule();
private static final ISchedulingRule INDEXER_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. * not allowed to hold a lock on fPDOMs.
*/ */
private Object fIndexerMutex= new Object(); private Object fIndexerMutex= new Object();
private IPreferenceChangeListener fPreferenceChangeListener= new IPreferenceChangeListener(){ private HashMap fPrefListeners= new HashMap();
public void preferenceChange(PreferenceChangeEvent event) {
onPreferenceChange(event);
}
};
/** /**
* Startup the PDOM. This mainly sets us up to handle model * 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$ return project.getElementName() + "." + System.currentTimeMillis() + ".pdom"; //$NON-NLS-1$//$NON-NLS-2$
} }
public String getDefaultIndexerId() { public String getDefaultIndexerId() {
IPreferencesService prefService = Platform.getPreferencesService(); return getIndexerId(null);
return prefService.getString(CCorePlugin.PLUGIN_ID, INDEXER_ID_KEY, }
CCorePlugin.DEFAULT_INDEXER, null);
} public void setDefaultIndexerId(String indexerId) {
setIndexerId(null, indexerId);
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 String getIndexerId(ICProject project) { public String getIndexerId(ICProject project) {
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID); IProject prj= project != null ? project.getProject() : null;
if (prefs == null) return IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, ID_NO_INDEXER);
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;
} }
public void setIndexerId(final ICProject project, String indexerId) { public void setIndexerId(final ICProject project, String indexerId) {
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID); IProject prj= project.getProject();
if (prefs == null) IndexerPreferences.set(prj, IndexerPreferences.KEY_INDEXER_ID, indexerId);
return; // TODO why would this be null? CCoreInternals.savePreferences(prj);
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);
} }
public IPDOMIndexer getIndexer(ICProject project) { public IPDOMIndexer getIndexer(ICProject project) {
return getIndexer(project, true); return getIndexer(project, true);
} }
public void onPreferenceChange(PreferenceChangeEvent event) { protected void onPreferenceChange(IProject project, PreferenceChangeEvent event) {
Object key= event.getKey(); if (project.exists() && project.isOpen()) {
if (key.equals(INDEXER_ID_KEY) || key.equals(INDEX_ALL_FILES)) { ICProject cproject= CoreModel.getDefault().create(project);
Preferences node = event.getNode(); if (cproject != null) {
if (CCorePlugin.PLUGIN_ID.equals(node.name())) { try {
node= node.parent(); changeIndexer(cproject);
IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(node.name()); }
if (project.exists() && project.isOpen()) { catch (Exception e) {
ICProject cproject= CoreModel.getDefault().create(project); CCorePlugin.log(e);
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 { private void changeIndexer(ICProject cproject) throws CoreException {
assert !Thread.holdsLock(fProjectToPDOM); assert !Thread.holdsLock(fProjectToPDOM);
IPDOMIndexer oldIndexer= null; IPDOMIndexer oldIndexer= null;
String newid= getIndexerId(cproject); IProject prj= cproject.getProject();
boolean allFiles= getIndexAllFiles(cproject);
String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, ID_NO_INDEXER);
Properties props= IndexerPreferences.getProperties(prj);
synchronized (fIndexerMutex) { synchronized (fIndexerMutex) {
oldIndexer= getIndexer(cproject, false); oldIndexer= getIndexer(cproject, false);
if (oldIndexer != null) { if (oldIndexer != null) {
if (oldIndexer.getID().equals(newid) && oldIndexer.isIndexAllFiles(allFiles)) { if (oldIndexer.getID().equals(newid) && oldIndexer.hasProperties(props)) {
return; return;
} }
} }
createIndexer(cproject, newid, allFiles, true); createIndexer(cproject, newid, props, true);
} }
if (oldIndexer != null) { if (oldIndexer != null) {
@ -367,14 +270,14 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
public IPDOMIndexer getIndexer(ICProject project, boolean create) { public IPDOMIndexer getIndexer(ICProject project, boolean create) {
assert !Thread.holdsLock(fProjectToPDOM); assert !Thread.holdsLock(fProjectToPDOM);
synchronized (fIndexerMutex) { synchronized (fIndexerMutex) {
IProject rproject = project.getProject(); IProject prj = project.getProject();
if (!rproject.isOpen()) { if (!prj.isOpen()) {
return null; return null;
} }
IPDOMIndexer indexer; IPDOMIndexer indexer;
try { try {
indexer = (IPDOMIndexer)rproject.getSessionProperty(indexerProperty); indexer = (IPDOMIndexer)prj.getSessionProperty(indexerProperty);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
return null; return null;
@ -386,7 +289,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
if (create) { if (create) {
try { try {
return createIndexer(project, getIndexerId(project), getIndexAllFiles(project), false); Properties props= IndexerPreferences.getProperties(prj);
return createIndexer(project, getIndexerId(project), props, false);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(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); assert Thread.holdsLock(fIndexerMutex);
PDOM pdom= (PDOM) getPDOM(project); PDOM pdom= (PDOM) getPDOM(project);
@ -411,7 +315,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
if ("run".equals(element.getName())) { //$NON-NLS-1$ if ("run".equals(element.getName())) { //$NON-NLS-1$
try { try {
indexer = (IPDOMIndexer)element.createExecutableExtension("class"); //$NON-NLS-1$ indexer = (IPDOMIndexer)element.createExecutableExtension("class"); //$NON-NLS-1$
indexer.setIndexAllFiles(allHeaders); indexer.setProperties(props);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
@ -496,17 +400,21 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
} }
private void registerPreferenceListener(ICProject project) { private void registerPreferenceListener(ICProject project) {
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID); IProject prj= project.getProject();
if (prefs != null) { PCL pcl= (PCL) fPrefListeners.get(prj);
prefs.addPreferenceChangeListener(fPreferenceChangeListener); if (pcl == null) {
} pcl= new PCL(prj);
fPrefListeners.put(prj, pcl);
}
IndexerPreferences.addChangeListener(prj, pcl);
} }
private void unregisterPreferenceListener(ICProject project) { private void unregisterPreferenceListener(ICProject project) {
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID); IProject prj= project.getProject();
if (prefs != null) { PCL pcl= (PCL) fPrefListeners.remove(prj);
prefs.removePreferenceChangeListener(fPreferenceChangeListener); if (pcl != null) {
} IndexerPreferences.removeChangeListener(prj, pcl);
}
} }
public void changeProject(ICProject project, ICElementDelta delta) throws CoreException { public void changeProject(ICProject project, ICElementDelta delta) throws CoreException {

View file

@ -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);
}
}
}
}

View file

@ -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);
}
}
}

View file

@ -95,6 +95,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
private static final Object NO_CONTEXT = new Object(); private static final Object NO_CONTEXT = new Object();
protected static final int MAX_ERRORS = 500; protected static final int MAX_ERRORS = 500;
private static final String TRUE = String.valueOf(true);
protected volatile int fTotalSourcesEstimate= 0; protected volatile int fTotalSourcesEstimate= 0;
protected volatile int fCompletedSources= 0; protected volatile int fCompletedSources= 0;
@ -283,7 +284,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
} }
protected boolean getIndexAllFiles() { protected boolean getIndexAllFiles() {
return getIndexer().getIndexAllFiles(); return TRUE.equals(getIndexer().getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
} }
protected ITranslationUnit findContext(IIndex index, IIndexFileLocation location) { protected ITranslationUnit findContext(IIndex index, IIndexFileLocation location) {

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,37 +13,25 @@
package org.eclipse.cdt.internal.core.pdom.indexer.fast; 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.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICElementDelta; 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.CCoreInternals;
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
* *
*/ */
public class PDOMFastIndexer implements IPDOMIndexer { public class PDOMFastIndexer extends AbstractPDOMIndexer {
// Must match extension id // Must match extension id
public static final String ID = IPDOMManager.ID_FAST_INDEXER; public static final String ID = IPDOMManager.ID_FAST_INDEXER;
protected ICProject project;
private boolean fIndexAllFiles;
public PDOMFastIndexer() { public PDOMFastIndexer() {
} }
public ICProject getProject() {
return project;
}
public void setProject(ICProject project) {
this.project = project;
}
public void handleDelta(ICElementDelta delta) throws CoreException { public void handleDelta(ICElementDelta delta) throws CoreException {
PDOMFastHandleDelta fhd= new PDOMFastHandleDelta(this, delta); PDOMFastHandleDelta fhd= new PDOMFastHandleDelta(this, delta);
if (fhd.estimateRemainingSources() > 0) { if (fhd.estimateRemainingSources() > 0) {
@ -58,16 +46,4 @@ public class PDOMFastIndexer implements IPDOMIndexer {
public String getID() { public String getID() {
return ID; return ID;
} }
public void setIndexAllFiles(boolean val) {
fIndexAllFiles= val;
}
public boolean getIndexAllFiles() {
return fIndexAllFiles;
}
public boolean isIndexAllFiles(boolean val) {
return fIndexAllFiles==val;
}
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,15 +7,15 @@
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer.full; 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.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICElementDelta; 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.CCoreInternals;
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
@ -25,21 +25,9 @@ import org.eclipse.core.runtime.CoreException;
* @author Doug Schaefer * @author Doug Schaefer
* *
*/ */
public class PDOMFullIndexer implements IPDOMIndexer { public class PDOMFullIndexer extends AbstractPDOMIndexer {
public static final String ID = IPDOMManager.ID_FULL_INDEXER; 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 { public void handleDelta(ICElementDelta delta) throws CoreException {
PDOMFullHandleDelta task = new PDOMFullHandleDelta(this, delta); PDOMFullHandleDelta task = new PDOMFullHandleDelta(this, delta);
if (task.estimateRemainingSources() > 0) { if (task.estimateRemainingSources() > 0) {
@ -54,16 +42,4 @@ public class PDOMFullIndexer implements IPDOMIndexer {
public String getID() { public String getID() {
return ID; return ID;
} }
public void setIndexAllFiles(boolean val) {
fIndexAllFiles= val;
}
public boolean getIndexAllFiles() {
return fIndexAllFiles;
}
public boolean isIndexAllFiles(boolean val) {
return fIndexAllFiles==val;
}
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.IPDOMIndexerTask;
import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICElementDelta; 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.CCoreInternals;
import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.index.IWritableIndexManager; 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.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -29,18 +29,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
* *
* The Null Indexer which does nothing. * 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; public static final String ID = IPDOMManager.ID_NO_INDEXER;
private ICProject project; public PDOMNullIndexer() {
fProperties.clear(); // don't accept any properties
public ICProject getProject() {
return project;
}
public void setProject(ICProject project) {
this.project = project;
} }
public void handleDelta(ICElementDelta delta) { public void handleDelta(ICElementDelta delta) {
@ -93,15 +87,4 @@ public class PDOMNullIndexer implements IPDOMIndexer {
public String getID() { public String getID() {
return ID; return ID;
} }
public boolean getIndexAllFiles() {
return false;
}
public void setIndexAllFiles(boolean value) {
}
public boolean isIndexAllFiles(boolean val) {
return true;
}
} }

View file

@ -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}'' WritablePDOM_error_unknownLinkage=AST specifies unknown linkage ''{0}''
PDOMManager_notifyJob_label=Notify Index Change Listeners PDOMManager_notifyJob_label=Notify Index Change Listeners
PDOMManager_JoinIndexerTask=Join Indexer PDOMManager_JoinIndexerTask=Join Indexer
PDOMManager_savePrefsJob=Save Project Preferences
PDOMManager_StartJob_name=Initialize Indexing PDOMManager_StartJob_name=Initialize Indexing
PDOMManager_notifyTask_message=Notify Listeners PDOMManager_notifyTask_message=Notify Listeners
PDOMManager_indexMonitorDetail={0}/{1} sources, {2} headers PDOMManager_indexMonitorDetail={0}/{1} sources, {2} headers

View file

@ -34,7 +34,6 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager; 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.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.WriteAccessException;

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.core.CCorePlugin;
import org.eclipse.cdt.internal.core.pdom.PDOMManager; 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 class CCoreInternals {
public static PDOMManager getPDOMManager() { public static PDOMManager getPDOMManager() {
return (PDOMManager) CCorePlugin.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);
}
} }

View file

@ -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 # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
# #
# Contributors: # Contributors:
# QNX Software Systems - Initial API and implementation # QNX Software Systems - Initial API and implementation
# Markus Schorn (Wind River Systems)
############################################################################### ###############################################################################
CBuilder.build_error= Build Error CBuilder.build_error= Build Error
CoreModel.BinaryRunner.Binary_Search_Thread=Searching for Binaries CoreModel.BinaryRunner.Binary_Search_Thread=Searching for Binaries
@ -75,6 +76,5 @@ indexer.notFound = Indexer not found
pdom.requestTooLarge=Request too large pdom.requestTooLarge=Request too large
pdom.indexer.name=C/C++ Indexer pdom.indexer.name=C/C++ Indexer
pdom.indexer.task=Indexing pdom.indexer.task=Indexing
pdom.indexer.filling=Counting files
pdom.indexer.message=file {0} of {1}: {2}
PDOMIndexerJob.updateMonitorJob=Update Monitor PDOMIndexerJob.updateMonitorJob=Update Monitor
CCoreInternals.savePreferencesJob=Save preferences

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Sergey Prigogin, Google * Sergey Prigogin, Google
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core; 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.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants; import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.internal.core.model.CModelManager; 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.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@ -54,8 +54,6 @@ public class CCorePreferenceInitializer extends AbstractPreferenceInitializer {
} }
// indexer defaults // indexer defaults
defaultPreferences.putBoolean(PDOMManager.INDEX_ALL_FILES, false); IndexerPreferences.initializeDefaultPreferences(defaultPreferences);
defaultPreferences.put(PDOMManager.INDEXER_ID_KEY, IPDOMManager.ID_FAST_INDEXER);
} }
} }

View file

@ -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));
}
}
}

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core; package org.eclipse.cdt.internal.core;
@ -1712,7 +1713,8 @@ public final class CharOperation {
// offsets inside pattern // offsets inside pattern
int pSegmentStart, pLength = pattern.length; int pSegmentStart, pLength = pattern.length;
if (freeLeadingDoubleStar = pattern[0] != pathSeparator){ freeLeadingDoubleStar= (pattern[0] != pathSeparator);
if (freeLeadingDoubleStar){
pSegmentStart = 0; pSegmentStart = 0;
} else { } else {
pSegmentStart = 1; pSegmentStart = 1;

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.core.testplugin.TestScannerProvider;
import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
@ -74,7 +75,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
public void _testInclusionAccrossProjects() throws Exception { public void _testInclusionAccrossProjects() throws Exception {
ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER); ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER);
try { try {
CCoreInternals.getPDOMManager().setIndexAllFiles(op, true); IndexerPreferences.set(op.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
CCoreInternals.getPDOMManager().reindex(op); CCoreInternals.getPDOMManager().reindex(op);
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {getProject(), op}); fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {getProject(), op});

View file

@ -47,7 +47,6 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.ui.actions, org.eclipse.cdt.ui.actions,
org.eclipse.cdt.ui.browser.typeinfo, org.eclipse.cdt.ui.browser.typeinfo,
org.eclipse.cdt.ui.dialogs, org.eclipse.cdt.ui.dialogs,
org.eclipse.cdt.ui.index,
org.eclipse.cdt.ui.text, org.eclipse.cdt.ui.text,
org.eclipse.cdt.ui.text.c.hover, org.eclipse.cdt.ui.text.c.hover,
org.eclipse.cdt.ui.text.contentassist, org.eclipse.cdt.ui.text.contentassist,

View file

@ -1495,15 +1495,14 @@
</enabledWhen> </enabledWhen>
</page> </page>
<page <page
adaptable="true"
class="org.eclipse.cdt.internal.ui.language.ProjectLanguageMappingPropertyPage" class="org.eclipse.cdt.internal.ui.language.ProjectLanguageMappingPropertyPage"
id="org.eclipse.cdt.ui.projectLanguageMappings" id="org.eclipse.cdt.ui.projectLanguageMappings"
name="%CDTLanguagesProperty.name" name="%CDTLanguagesProperty.name">
objectClass="org.eclipse.core.resources.IProject"> <enabledWhen>
<filter <adapt type="org.eclipse.core.resources.IProject">
name="nature" <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
value="org.eclipse.cdt.core.cnature"> </adapt>
</filter> </enabledWhen>
</page> </page>
</extension> </extension>
<extension <extension
@ -1582,12 +1581,12 @@
name="%CDTIndexer.nullindexer" name="%CDTIndexer.nullindexer"
id="org.eclipse.cdt.ui.nullindexerUI"/> id="org.eclipse.cdt.ui.nullindexerUI"/>
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock" class="org.eclipse.cdt.ui.dialogs.FastIndexerBlock"
id="org.eclipse.cdt.ui.fastIndexer" id="org.eclipse.cdt.ui.fastIndexer"
indexerID="org.eclipse.cdt.core.fastIndexer" indexerID="org.eclipse.cdt.core.fastIndexer"
name="%CDTIndexer.fastindexer"/> name="%CDTIndexer.fastindexer"/>
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock" class="org.eclipse.cdt.ui.dialogs.DOMSourceIndexerBlock"
id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI" id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI"
indexerID="org.eclipse.cdt.core.domsourceindexer" indexerID="org.eclipse.cdt.core.domsourceindexer"
name="%CDTIndexer.domsourceindexer"/> name="%CDTIndexer.domsourceindexer"/>

View file

@ -23,9 +23,7 @@ in multi-tab and single-tab mode. It&apos;s up to page to select
displaying mode. displaying mode.
In multi-tab page, tabs are displayed in order defined by In multi-tab page, tabs are displayed in order defined by
their weights. their weights.
</documentation> </documentation>
</annotation> </annotation>
@ -99,8 +97,6 @@ Ignored for single-tab pages.
Usually pages are to be derived from Usually pages are to be derived from
org.eclipse.cdt.ui.newui.AbstractPage, org.eclipse.cdt.ui.newui.AbstractPage,
but it is not obligatory. but it is not obligatory.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="java"/> <meta.attribute kind="java"/>
@ -119,7 +115,6 @@ but it is not obligatory.
<documentation> <documentation>
Abstract value to be used for sorting tabs inside of tab folder. Abstract value to be used for sorting tabs inside of tab folder.
Ignored for single-tab page. Ignored for single-tab page.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -140,7 +135,7 @@ Ignored for single-tab page.
<meta.section type="examples"/> <meta.section type="examples"/>
</appInfo> </appInfo>
<documentation> <documentation>
&lt;extension &lt;extension
point=&quot;org.eclipse.cdt.ui.cPropertyTab&quot;&gt; point=&quot;org.eclipse.cdt.ui.cPropertyTab&quot;&gt;
&lt;tab &lt;tab
class=&quot;org.eclipse.cdt.managedbuilder.ui.newui.DiscoveryTab&quot; class=&quot;org.eclipse.cdt.managedbuilder.ui.newui.DiscoveryTab&quot;
@ -148,7 +143,7 @@ Ignored for single-tab page.
name=&quot;Discovery options&quot; name=&quot;Discovery options&quot;
weight=&quot;100&quot; weight=&quot;100&quot;
parent=&quot;org.eclipse.cdt.ui.newui.Page_PathAndSymb&quot;/&gt; parent=&quot;org.eclipse.cdt.ui.newui.Page_PathAndSymb&quot;/&gt;
&lt;/entension&gt; &lt;/extension&gt;
</documentation> </documentation>
</annotation> </annotation>
@ -195,8 +190,7 @@ CBuildLocationOutputTab
CPropertyVarsTab CPropertyVarsTab
DiscoveryTab DiscoveryTab
ToolChainEditTab ToolChainEditTab
ToolSettingsTab ToolSettingsTab
</documentation> </documentation>
</annotation> </annotation>

View file

@ -8,6 +8,7 @@
# Contributors: # Contributors:
# IBM Corporation - initial API and implementation # IBM Corporation - initial API and implementation
# QNX Software System # QNX Software System
# Markus Schorn (Wind River Systems)
############################################################################### ###############################################################################
# ------- CView ----------------- # ------- CView -----------------
@ -47,7 +48,7 @@ BinaryParserBlock.desc=Set required binary parser for this project
BaseIndexerBlock.label=C/C++ Indexer BaseIndexerBlock.label=C/C++ Indexer
BaseIndexerBlock.desc=C/C++ Indexer setting for this project. BaseIndexerBlock.desc=C/C++ Indexer setting for this project.
BaseIndexerBlock.comboLabel=Available indexers BaseIndexerBlock.comboLabel=Select Indexer
ReferenceBlock.label= Projects ReferenceBlock.label= Projects
ReferenceBlock.desc= Referenced C/C++ Projects ReferenceBlock.desc= Referenced C/C++ Projects
@ -328,5 +329,3 @@ IndexView.setFastIndexer.name = Use Fast Indexer
IndexView.CountSymbols.name = Count Symbols IndexView.CountSymbols.name = Count Symbols
IndexView.CountSymbols.title = Symbol Count 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. 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

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,106 +7,65 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - initial API and implementation * QNX Software Systems - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences; 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.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Preferences; 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.jface.preference.PreferencePage;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage; 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 public class IndexerPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage, ICOptionContainer { IWorkbenchPreferencePage, ICOptionContainer {
private IndexerBlock fOptionBlock; private IndexerBlock fOptionBlock;
private Button applyIndexerToAllButton;
public IndexerPreferencePage(){ public IndexerPreferencePage(){
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
setDescription(PreferencesMessages.IndexerPrefs_description);
fOptionBlock = new IndexerBlock(); fOptionBlock = new IndexerBlock();
} }
protected Control createContents(Composite parent) { protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE); Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, true); composite.setLayout(new FillLayout());
composite.setLayout(layout);
fOptionBlock.createControl(composite); fOptionBlock.createControl(composite);
applyIndexerToAllButton = new Button(composite, SWT.CHECK);
applyIndexerToAllButton.setText(CUIPlugin.getResourceString("IndexerPreferencePage.applyToAllProjects")); //$NON-NLS-1$
return composite; return composite;
} }
public void init(IWorkbench workbench) { public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
} }
public void updateContainer() { public void updateContainer() {
// TODO Auto-generated method stub
} }
public IProject getProject() { public IProject getProject() {
// TODO Auto-generated method stub
return null; return null;
} }
public Preferences getPreferences() { 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() { public boolean performOk() {
try { try {
fOptionBlock.performApply(null); fOptionBlock.performApply(new NullProgressMonitor());
if (applyIndexerToAllButton.getSelection()) {
String indexerName = fOptionBlock.getSelectedIndexerID();
String indexerId = fOptionBlock.getIndexerPageId(indexerName);
new ApplyIndexer(indexerId).schedule();
}
} catch (CoreException e) {} } catch (CoreException e) {}
CUIPlugin.getDefault().savePluginPreferences();
return true; return true;
} }
public void performDefaults() {
fOptionBlock.performDefaults();
}
} }

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences; 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_addVariableButton;
public static String PathEntryVariablesBlock_editVariableButton; public static String PathEntryVariablesBlock_editVariableButton;
public static String PathEntryVariablesBlock_removeVariableButton; public static String PathEntryVariablesBlock_removeVariableButton;
public static String IndexerPrefs_description;
public static String ProposalFilterPreferencesUtil_defaultFilterName; public static String ProposalFilterPreferencesUtil_defaultFilterName;
public static String CEditorPreferencePage_typing_tabTitle; public static String CEditorPreferencePage_typing_tabTitle;

View file

@ -8,6 +8,7 @@
# Contributors: # Contributors:
# IBM Corporation - initial API and implementation # IBM Corporation - initial API and implementation
# Anton Leherbauer (Wind River Systems) # 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. 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 PathEntryVariablesBlock_removeVariableButton = &Remove
#Indexer
IndexerPrefs_description=Sets default Indexer Options for new Projects
# Language settings # Language settings
ProjectLanguagesPropertyPage_contentTypeColumn = Content Type ProjectLanguagesPropertyPage_contentTypeColumn = Content Type

View file

@ -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() {
}
}

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,170 +7,40 @@
* *
* Contributors: * Contributors:
* IBM Corp. - Rational Software - initial implementation * IBM Corp. - Rational Software - initial implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs; package org.eclipse.cdt.ui.dialogs;
import org.eclipse.core.resources.IProject; import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.swt.widgets.Button;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
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.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 { 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) { public void createControl(Composite parent) {
Composite page = ControlFactory.createComposite(parent, 1); Composite page = ControlFactory.createComposite(parent, 1);
fAllFiles= ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
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 );
setControl(page); setControl(page);
} }
// public String getIndexerProblemsValuesString(){ public Properties getProperties() {
// int result = 0; Properties props= new Properties();
// result |= preprocessorProblemsEnabled.getSelection() ? DOMSourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0; props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllFiles.getSelection()));
// if( syntacticProblemsEnabled != null ) return props;
// 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 void loadPersistedValues(IProject project) throws CoreException { public void setProperties(Properties properties) {
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
ICExtensionReference[] cext = CCorePlugin.getDefault().getBinaryParserExtensions(project); fAllFiles.setSelection(indexAllFiles);
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 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);
}
} }

View file

@ -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() {
}
}

View file

@ -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)

View file

@ -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);
}
}

View file

@ -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();
}

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,435 +7,390 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs; package org.eclipse.cdt.ui.dialogs;
import java.util.ArrayList; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; 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.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform; 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.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Group;
import org.eclipse.cdt.core.CCorePlugin; import com.ibm.icu.text.Collator;
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.CUIPlugin;
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout; 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 * @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 * the <code>NewManagedProjectOptionPage</code> to display the indexer options during the creation of
* a new project. * a new project.
*/ */
public class IndexerBlock extends AbstractCOptionPage { 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_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_DESCRIPTION = CUIPlugin.getResourceString("BaseIndexerBlock.desc"); //$NON-NLS-1$
private static final String INDEXER_COMBO_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.comboLabel"); //$NON-NLS-1$ private static final String INDEXER_COMBO_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.comboLabel"); //$NON-NLS-1$
private Combo indexersComboBox; private PreferenceScopeBlock fPrefScopeBlock;
private HashMap indexerPageMap; private Combo fIndexersComboBox;
private List indexerPageList; private HashMap fIndexerConfigMap;
private String selectedIndexerId = null; private Composite fIndexerPageComposite;
private Composite parentComposite; private AbstractIndexerPage fCurrentPage;
private ICOptionPage currentPage; private Properties fCurrentProperties;
private ControlEnableState fEnableState;
private Composite fPreferenceContent;
String initialSelected;
public IndexerBlock(){ public IndexerBlock(){
super(INDEXER_LABEL); super(INDEXER_LABEL);
setDescription(INDEXER_DESCRIPTION); setDescription(INDEXER_DESCRIPTION);
initializeIndexerPageMap(); initializeIndexerConfigMap();
} }
/** /**
* Create a profile page only on request * Create a profile page only on request
*/ */
protected static class IndexerPageConfiguration { private static class IndexerConfig {
private AbstractIndexerPage fPage;
private IConfigurationElement fElement;
ICOptionPage page; public IndexerConfig(IConfigurationElement element) {
IConfigurationElement element; fElement= element;
public IndexerPageConfiguration(IConfigurationElement _element) {
element = _element;
} }
public ICOptionPage getPage() throws CoreException { public AbstractIndexerPage getPage() throws CoreException {
if (page == null) { if (fPage == null) {
page = (ICOptionPage) element.createExecutableExtension("class"); //$NON-NLS-1$ 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() { public String getName() {
return element.getAttribute("name"); //$NON-NLS-1$ return fElement.getAttribute(ATTRIB_NAME);
} }
public String getIndexerID(){ public String getIndexerID(){
return element.getAttribute("indexerID"); //$NON-NLS-1$ return fElement.getAttribute(ATTRIB_INDEXERID);
} }
} }
public void createControl(Composite parent) { public void createControl(Composite parent) {
Composite composite = ControlFactory.createComposite(parent, 1); Composite composite = ControlFactory.createComposite(parent, 1);
Font font = parent.getFont();
GridLayout layout= ((GridLayout)composite.getLayout()); GridLayout layout= ((GridLayout)composite.getLayout());
layout.marginHeight= 0; layout.marginHeight= 0;
layout.marginWidth= 0; layout.marginWidth= 0;
layout.verticalSpacing= 0; layout.verticalSpacing= 0;
layout.horizontalSpacing= GridData.FILL_HORIZONTAL; layout.horizontalSpacing= GridData.FILL_HORIZONTAL;
composite.setLayoutData(null); composite.setLayoutData(null);
composite.setFont(font);
setControl(composite); setControl(composite);
Composite scComp = ControlFactory.createComposite(composite, 1); if (getProject() != null || getContainer() instanceof ICOptionContainerExtension) {
((GridLayout)scComp.getLayout()).marginHeight = 0; fPrefScopeBlock= new PreferenceScopeBlock(PREF_PAGE_ID) {
((GridLayout)scComp.getLayout()).marginTop = 5; protected void onPreferenceScopeChange() {
scComp.setFont(font); IndexerBlock.this.onPreferenceScopeChange();
}
// Create a group for discovered indexer's UI };
if (createIndexerControls(scComp)) { fPrefScopeBlock.createControl(composite);
// create a composite for discovery profile options }
Composite indexPageComposite = ControlFactory.createComposite(composite, 1);
indexPageComposite.setFont(font); fPreferenceContent= ControlFactory.createComposite(composite, 1);
indexPageComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); layout= ((GridLayout)fPreferenceContent.getLayout());
indexPageComposite.setLayout(new TabFolderLayout()); layout.marginHeight= 0;
// Must set the composite parent to super class. layout.marginWidth= 0;
parentComposite = indexPageComposite;
Composite isc = ControlFactory.createComposite(fPreferenceContent, 1);
setPage(); 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); parent.layout(true);
} }
/**
* private void enablePreferenceContent(boolean enable) {
*/ if (fEnableState != null) {
private void setPage() { fEnableState.restore();
}
String profileId = getCurrentIndexPageId(); if (enable) {
fEnableState= null;
//If no indexer has been selected, return }
if (profileId == null) else {
return; fEnableState= ControlEnableState.disable(fPreferenceContent);
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 initializeScope() {
* @param page IProject proj= getProject();
*/ if (fPrefScopeBlock == null) {
private void setCurrentPage(ICOptionPage page) { return;
currentPage = page; }
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() { private void initializeIndexerCombo() {
String selectedIndexPageName = getSelectedIndexerID(); String[] names= new String[fIndexerConfigMap.size()];
int j= 0;
if (selectedIndexPageName == null) for (Iterator i = fIndexerConfigMap.values().iterator(); i.hasNext();) {
return null; IndexerConfig config = (IndexerConfig) i.next();
names[j++]= config.getName();
String selectedIndexPageId = getIndexerPageId(selectedIndexPageName);
return selectedIndexPageId;
}
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();
}
});
//Make sure that the combo box takes up two cells
GridData gridData = (GridData) indexersComboBox.getLayoutData();
gridData.verticalSpan=2;
// 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);
}
} }
Arrays.sort(names, Collator.getInstance());
fIndexersComboBox.setItems(names);
}
//See what the preferred indexer is protected void onPreferenceScopeChange() {
String indexerId = CCorePlugin.getPDOMManager().getDefaultIndexerId(); int scope= computeScope();
String preferredIndexer = getIndexerPageName(indexerId); if (fCurrentProperties == null || scope != IndexerPreferences.SCOPE_PROJECT_PRIVATE) {
String[] indexerList = indexersComboBox.getItems(); 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; int selectedIndex = 0;
for (int i=0; i<indexerList.length; i++){ for (int i=0; i<indexerList.length; i++){
if (indexerList[i].equals(preferredIndexer)) if (indexerList[i].equals(indexerName))
selectedIndex = i; selectedIndex = i;
} }
fIndexersComboBox.select(selectedIndex);
indexersComboBox.select(selectedIndex); setPage();
if (fPrefScopeBlock != null) {
return true; enablePreferenceContent(scope != IndexerPreferences.SCOPE_INSTANCE);
}
}
protected void onIndexerChange() {
if (fCurrentPage != null) {
Properties props= fCurrentPage.getProperties();
if (props != null) {
fCurrentProperties.putAll(props);
}
}
setPage();
} }
/** private int computeScope() {
if (fPrefScopeBlock != null) {
if (fPrefScopeBlock.isProjectLocalScope()) {
return IndexerPreferences.SCOPE_PROJECT_PRIVATE;
}
if (fPrefScopeBlock.isProjectScope()) {
return IndexerPreferences.SCOPE_PROJECT_SHARED;
}
}
return IndexerPreferences.SCOPE_INSTANCE;
}
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);
}
}
if (fCurrentPage != null){
fCurrentPage.setVisible(false);
}
if (page != null) {
page.setProperties(fCurrentProperties);
page.setVisible(true);
}
fCurrentPage= page;
}
/**
* Adds all the contributed Indexer Pages to a map * Adds all the contributed Indexer Pages to a map
*/ */
private void initializeIndexerPageMap() { private void initializeIndexerConfigMap() {
indexerPageMap = new HashMap(5); fIndexerConfigMap = new HashMap(5);
indexerPageList = new ArrayList(5);
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.getPluginId(), "IndexerPage"); //$NON-NLS-1$ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.getPluginId(), "IndexerPage"); //$NON-NLS-1$
IConfigurationElement[] infos = extensionPoint.getConfigurationElements(); IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
for (int i = 0; i < infos.length; i++) { for (int i = 0; i < infos.length; i++) {
if (infos[i].getName().equals("indexerUI")) { //$NON-NLS-1$ if (infos[i].getName().equals(NODE_INDEXERUI)) {
String id = infos[i].getAttribute("indexerID"); //$NON-NLS-1$ String id = infos[i].getAttribute(ATTRIB_INDEXERID);
indexerPageMap.put(id, new IndexerPageConfiguration(infos[i])); if (id != null) {
indexerPageList.add(id); 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;
}
/** private String getIndexerName(String indexerID) {
* Returns the page name for the given id IndexerConfig configElement= (IndexerConfig) fIndexerConfigMap.get(indexerID);
*/
protected String getIndexerPageName(String indexerPageId) {
IndexerPageConfiguration configElement =
(IndexerPageConfiguration) indexerPageMap.get(indexerPageId);
if (configElement != null) { if (configElement != null) {
return configElement.getName(); return configElement.getName();
} }
return null; return null;
} }
/**
* Returns the indexer page id for the give name private String getIndexerID(String indexerName) {
* @param indexerPageName for (Iterator i = fIndexerConfigMap.entrySet().iterator(); i.hasNext();) {
* @return String Map.Entry entry = (Map.Entry) i.next();
*/ String id = (String) entry.getKey();
public String getIndexerPageId(String indexerPageName) { IndexerConfig config = (IndexerConfig) entry.getValue();
for (Iterator I = indexerPageMap.keySet().iterator(); I.hasNext();) { if (indexerName.equals(config.getName())) {
String indexerPageId = (String) I.next(); return id;
String tempPageName = getIndexerPageName(indexerPageId); }
if (indexerPageName.equals(tempPageName)) { }
return indexerPageId; return null;
}
}
return null;
} }
protected ICOptionPage getIndexerPage(String indexerPageId) { private AbstractIndexerPage getIndexerPage(String indexerID) {
IndexerPageConfiguration configElement = IndexerConfig configElement= (IndexerConfig) fIndexerConfigMap.get(indexerID);
(IndexerPageConfiguration) indexerPageMap.get(indexerPageId);
if (configElement != null) { if (configElement != null) {
try { try {
return configElement.getPage(); return configElement.getPage();
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().log(e);
} }
} }
return null; 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 { public void performApply(IProgressMonitor monitor) throws CoreException {
//Get the currently selected indexer from the UI int scope= computeScope();
String indexerName = getSelectedIndexerID(); IProject project= getProject();
//If no indexer has been selected, return String indexerID = getSelectedIndexerID();
if (indexerName == null) if (indexerID == null) {
return; return;
}
//Match up the selected indexer in the UI to a corresponding
//contributed Indexer Page ID if (scope != IndexerPreferences.SCOPE_INSTANCE || project == null) {
String indexerPageID = getIndexerPageId(indexerName); Properties props= new Properties();
props.setProperty(IndexerPreferences.KEY_INDEXER_ID, indexerID);
if (indexerPageID == null) if (fCurrentPage != null) {
return; Properties p1= fCurrentPage.getProperties();
if (p1 != null) {
//Get the id of the indexer that goes along with this UI page - this gets persisted props.putAll(p1);
final String indexerID = getIndexerIdName(indexerPageID); }
// }
if (monitor == null) { IndexerPreferences.setProperties(project, scope, props);
monitor = new NullProgressMonitor(); }
}
monitor.beginTask(CUIMessages.getString("IndexerOptions.task.savingAttributes"), 2); //$NON-NLS-1$ if (project != null) {
final String selected = indexerID; IndexerPreferences.setScope(project, scope);
}
if (indexerID != null) { CCoreInternals.savePreferences(project);
ICOptionContainer container = getContainer(); }
final IProject project = (container != null)
? container.getProject() public void performDefaults() {
: ((AbstractIndexerPage) currentPage).getCurrentProject(); fCurrentProperties= null;
fPrefScopeBlock.setInstanceScope();
if ( project != null) { onPreferenceScopeChange();
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 * @deprecated always returns false
* This is needed since we need to pass in the project if we are trying to save changes made to the
* property page.
*/ */
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() { public boolean isIndexEnabled() {
// TODO Auto-generated method stub
return false; return false;
} }
public void setIndexerID(String indexerID, ICProject project) { private String getSelectedIndexerID(){
//Get the corresponding text for the given indexer id return getIndexerID(fIndexersComboBox.getText());
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;
} }
public IProject getProject() { public IProject getProject() {
ICOptionContainer container = getContainer(); ICOptionContainer container = getContainer();
if (container != null){ if (container != null){
if (container instanceof ICOptionContainerExtension) {
try {
return ((ICOptionContainerExtension) container).getProjectHandle();
}
catch (Exception e) {
return null;
}
}
return container.getProject(); return container.getProject();
} else {
return ((AbstractIndexerPage)currentPage).getCurrentProject();
} }
return null;
} }
} }

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM Corp. - Rational Software - initial implementation * IBM Corp. - Rational Software - initial implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs; 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.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite; 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.PlatformUI;
import org.eclipse.ui.dialogs.PropertyPage; 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.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.ICHelpContextIds;
public class IndexerOptionPropertyPage extends PropertyPage { public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionContainer {
private IndexerBlock optionPage; private IndexerBlock optionPage;
private String oldIndexerID;
public IndexerOptionPropertyPage(){ public IndexerOptionPropertyPage(){
super(); super();
optionPage = new IndexerBlock(); optionPage = new IndexerBlock();
optionPage.setContainer(this);
} }
protected Control createContents(Composite parent) { protected Control createContents(Composite parent) {
@ -46,44 +45,38 @@ public class IndexerOptionPropertyPage extends PropertyPage {
optionPage.createControl(composite); optionPage.createControl(composite);
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INDEXER_PROPERTIES); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INDEXER_PROPERTIES);
initialize();
return composite; return composite;
} }
protected void performDefaults() { protected void performDefaults() {
ICProject tempProject = CoreModel.getDefault().create(getProject()); optionPage.performDefaults();
optionPage.resetIndexerPageSettings(tempProject);
} }
private void initialize(){ public boolean performOk() {
ICProject project = CoreModel.getDefault().create(getProject());
try { try {
oldIndexerID = CCorePlugin.getPDOMManager().getIndexerId(project); optionPage.performApply(new NullProgressMonitor());
optionPage.setIndexerID(oldIndexerID, project);
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().log(e); CUIPlugin.getDefault().log(e);
} }
}
public boolean performOk() {
ICProject tempProject = CoreModel.getDefault().create(getProject());
try {
optionPage.persistIndexerSettings(tempProject, new NullProgressMonitor());
} catch (CoreException e) {}
return true; return true;
} }
public IProject getProject(){ public IProject getProject(){
IAdaptable tempElement = getElement(); IProject project= null;
IProject project; IAdaptable elem = getElement();
if (tempElement instanceof IProject) { if (elem instanceof IProject) {
project = (IProject) tempElement; project= (IProject) elem;
} else { } else if (elem != null) {
project = (IProject)tempElement.getAdapter(IProject.class); project= (IProject) elem.getAdapter(IProject.class);
} }
return project; return project;
} }
public Preferences getPreferences() {
throw new UnsupportedOperationException();
}
public void updateContainer() {
}
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,34 +7,30 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.dialogs; package org.eclipse.cdt.ui.dialogs;
import org.eclipse.cdt.core.model.ICProject; import java.util.Properties;
import org.eclipse.cdt.ui.index.AbstractIndexerPage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
/** /**
* @author Bogdan Gheorghe * @author Bogdan Gheorghe
*/ */
public class NullIndexerBlock extends AbstractIndexerPage { 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) { public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NULL); Composite comp = new Composite(parent, SWT.NULL);
setControl(comp); setControl(comp);
} }
public void loadPreferences() {} public Properties getProperties() {
return new Properties();
public void removePreferences() {} }
public void setProperties(Properties properties) {
}
} }

View file

@ -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();
}
}

View file

@ -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;
}
}

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.ui.newui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.wizards; 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 * Overwrite this method if you do not have a main page
*/ */
protected IProject getProjectHandle() throws UnsupportedOperationException { public IProject getProjectHandle() throws UnsupportedOperationException {
if (null == fMainPage) if (null == fMainPage)
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
return fMainPage.getProjectHandle(); return fMainPage.getProjectHandle();

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,11 +7,10 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.wizards; 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.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences; 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.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Composite; 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; private TabFolderOptionBlock fOptionBlock;
@ -62,6 +64,14 @@ public abstract class NewCProjectWizardOptionPage extends WizardPage implements
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject() * @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();
}
} }