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

Added Indexer Preference page that sets up the indexer to use for new projects

Removed Index Enabled checkboxes from Source + Dom indexers
Added import ctags file option under CTags Indexer
Fixed Apply/OK problem
This commit is contained in:
Bogdan Gheorghe 2005-04-27 19:18:13 +00:00
parent 308e1f4417
commit 6f38f94b90
18 changed files with 594 additions and 160 deletions

View file

@ -24,6 +24,8 @@ import org.eclipse.cdt.internal.core.index.IIndexerOutput;
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry; import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class CTagsFileReader { public class CTagsFileReader {
@ -78,15 +80,28 @@ public class CTagsFileReader {
(!currentFileName.equals(fileName))){ (!currentFileName.equals(fileName))){
currentFileName = fileName; currentFileName = fileName;
currentFile = (IFile) project.findMember(fileName); currentFile = (IFile) project.findMember(fileName);
indexer = new MiniIndexer(currentFile);
index.add(currentFile,indexer); if (currentFile == null){
//Didn't find file in project
IPath tempPath = new Path(filename);
tempPath = tempPath.removeLastSegments(1);
tempPath = tempPath.append(fileName);
currentFile = (IFile) project.findMember(tempPath);
}
if (currentFile != null){
indexer = new MiniIndexer(currentFile);
index.add(currentFile,indexer);
//encode new tag in current file
char[][] fullName = parser.getQualifiedName(tagEntry);
//encode name
String lineNumber = (String) tagEntry.tagExtensionField.get(CTagsConsoleParser.LINE);
indexer.addToOutput(fullName,(String)tagEntry.tagExtensionField.get(CTagsConsoleParser.KIND), Integer.parseInt(lineNumber));
}
} }
//encode new tag in current file
char[][] fullName = parser.getQualifiedName(tagEntry);
//encode name
String lineNumber = (String) tagEntry.tagExtensionField.get(CTagsConsoleParser.LINE);
indexer.addToOutput(fullName,(String)tagEntry.tagExtensionField.get(CTagsConsoleParser.KIND), Integer.parseInt(lineNumber));
} }
} catch (IOException e){} } catch (IOException e){}
} }

View file

@ -15,6 +15,8 @@ import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer; import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
@ -35,6 +37,7 @@ import org.eclipse.core.runtime.Path;
class CTagsIndexAll extends CTagsIndexRequest { class CTagsIndexAll extends CTagsIndexRequest {
IProject project; IProject project;
static String ctagsFile = CCorePlugin.getDefault().getStateLocation().append("tempctags").toOSString(); //$NON-NLS-1$ static String ctagsFile = CCorePlugin.getDefault().getStateLocation().append("tempctags").toOSString(); //$NON-NLS-1$
private String ctagsFileToUse;
public CTagsIndexAll(IProject project, CTagsIndexer indexer) { public CTagsIndexAll(IProject project, CTagsIndexer indexer) {
super(project.getFullPath(), indexer); super(project.getFullPath(), indexer);
@ -75,21 +78,30 @@ class CTagsIndexAll extends CTagsIndexRequest {
project.deleteMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_ZERO); project.deleteMarkers(ICModelMarker.INDEXER_MARKER, true,IResource.DEPTH_ZERO);
} catch (CoreException e) {} } catch (CoreException e) {}
if (AbstractIndexer.TIMING)
startTime = System.currentTimeMillis();
//run CTags over project boolean success=false;
boolean success = runCTags();
if (AbstractIndexer.TIMING){ if (useInternalCTagsFile()){
cTagsEndTime = System.currentTimeMillis(); if (AbstractIndexer.TIMING)
System.out.println("CTags Run: " + (cTagsEndTime - startTime)); //$NON-NLS-1$ startTime = System.currentTimeMillis();
System.out.flush();
}
//run CTags over project
success = runCTags();
ctagsFileToUse=ctagsFile;
if (AbstractIndexer.TIMING){
cTagsEndTime = System.currentTimeMillis();
System.out.println("CTags Run: " + (cTagsEndTime - startTime)); //$NON-NLS-1$
System.out.flush();
}
} else {
success=getCTagsFileLocation();
}
if (success) { if (success) {
//Parse the CTag File //Parse the CTag File
CTagsFileReader reader = new CTagsFileReader(project,ctagsFile,indexer); CTagsFileReader reader = new CTagsFileReader(project,ctagsFileToUse,indexer);
reader.setIndex(index); reader.setIndex(index);
reader.parse(); reader.parse();
@ -170,4 +182,50 @@ class CTagsIndexAll extends CTagsIndexRequest {
return "indexing project " + this.project.getFullPath(); //$NON-NLS-1$ return "indexing project " + this.project.getFullPath(); //$NON-NLS-1$
} }
private boolean useInternalCTagsFile(){
try {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
if (cdesc == null)
return true;
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
if (cext.length > 0) {
for (int i = 0; i < cext.length; i++) {
String id = cext[i].getID();
String orig = cext[i].getExtensionData("ctagfiletype"); //$NON-NLS-1$
if (orig != null){
if (orig.equals(CTagsIndexer.CTAGS_INTERNAL))
return true;
else if (orig.equals(CTagsIndexer.CTAGS_EXTERNAL))
return false;
}
}
}
} catch (CoreException e) {}
return false;
}
private boolean getCTagsFileLocation() {
try {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
if (cdesc == null)
return false;
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
if (cext.length > 0) {
for (int i = 0; i < cext.length; i++) {
String id = cext[i].getID();
String orig = cext[i].getExtensionData("ctagfilelocation"); //$NON-NLS-1$
if (orig != null){
ctagsFileToUse=orig;
return true;
}
}
}
} catch (CoreException e) {}
return false;
}
} }

View file

@ -38,6 +38,10 @@ import org.eclipse.core.runtime.IPath;
*/ */
public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer { public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer {
public final static String CTAGS_INTERNAL = "ctags_internal"; //$NON-NLS-1$
public final static String CTAGS_EXTERNAL = "ctags_external"; //$NON-NLS-1$
public final static String CTAGS_LOCATION = "ctags_location"; //$NON-NLS-1$
private CIndexStorage indexStorage = null; private CIndexStorage indexStorage = null;
public ReadWriteMonitor storageMonitor = null; public ReadWriteMonitor storageMonitor = null;
private IndexManager indexManager = null; private IndexManager indexManager = null;

View file

@ -0,0 +1,84 @@
package org.eclipse.cdt.internal.core.index.nullindexer;
import java.io.IOException;
import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.index.ICDTIndexer;
import org.eclipse.cdt.core.index.IIndexStorage;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
import org.eclipse.cdt.internal.core.search.processing.IIndexJob;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.IPath;
public class NullIndexer extends AbstractCExtension implements ICDTIndexer {
public int getIndexerFeatures() {
// TODO Auto-generated method stub
return 0;
}
public void addRequest(IProject project, IResourceDelta delta, int kind) {
// TODO Auto-generated method stub
}
public void removeRequest(IProject project, IResourceDelta delta, int kind) {
// TODO Auto-generated method stub
}
public void indexJobFinishedNotification(IIndexJob job) {
// TODO Auto-generated method stub
}
public void shutdown() {
// TODO Auto-generated method stub
}
public void notifyIdle(long idlingTime) {
// TODO Auto-generated method stub
}
public void notifyIndexerChange(IProject project) {
// TODO Auto-generated method stub
}
public boolean isIndexEnabled(IProject project) {
// TODO Auto-generated method stub
return false;
}
public IIndexStorage getIndexStorage() {
// TODO Auto-generated method stub
return null;
}
public IIndex getIndex(IPath path, boolean reuseExistingFile,
boolean createIfMissing) {
// TODO Auto-generated method stub
return null;
}
public void indexerRemoved(IProject project) {
// TODO Auto-generated method stub
}
public void index(IFile document, IIndexerOutput output) throws IOException {
// TODO Auto-generated method stub
}
public boolean shouldIndex(IFile file) {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -218,7 +218,8 @@ public class SourceIndexer extends AbstractCExtension implements ICDTIndexer {
if( project == null || !project.exists() || !project.isOpen() ) if( project == null || !project.exists() || !project.isOpen() )
return false; return false;
Boolean indexValue = null; return true;
/*Boolean indexValue = null;
try { try {
indexValue = (Boolean) project.getSessionProperty(activationKey); indexValue = (Boolean) project.getSessionProperty(activationKey);
@ -248,7 +249,7 @@ public class SourceIndexer extends AbstractCExtension implements ICDTIndexer {
} catch (CoreException e) {} } catch (CoreException e) {}
return indexEnabled; return indexEnabled;*/
} }

View file

@ -69,3 +69,8 @@ cxxHeaderName=C++ Header File
asmSourceName=Assembly Source File asmSourceName=Assembly Source File
cdt_pathentry_var.description=CDT PathEntry Variable cdt_pathentry_var.description=CDT PathEntry Variable
CDTIndexer.originalsourceindexer=Original C/C++ Indexer
CDTIndexer.domsourceindexer=DOM AST C/C++ Indexer
CDTIndexer.ctagsindexer=CTags Indexer
CDTIndexer.nullindexer=No Indexer

View file

@ -529,7 +529,7 @@
<initializer class="org.eclipse.cdt.internal.core.CCorePreferenceInitializer"/> <initializer class="org.eclipse.cdt.internal.core.CCorePreferenceInitializer"/>
</extension> </extension>
<extension <extension
name="Original C/C++ Indexer" name="%CDTIndexer.originalsourceindexer"
id="originalsourceindexer" id="originalsourceindexer"
point="org.eclipse.cdt.core.CIndexer"> point="org.eclipse.cdt.core.CIndexer">
<cextension> <cextension>
@ -539,7 +539,7 @@
</cextension> </cextension>
</extension> </extension>
<extension <extension
name="DOM AST C/C++ Indexer" name="%CDTIndexer.domsourceindexer"
id="domsourceindexer" id="domsourceindexer"
point="org.eclipse.cdt.core.CIndexer"> point="org.eclipse.cdt.core.CIndexer">
<cextension> <cextension>
@ -562,11 +562,21 @@
</extension> </extension>
<extension <extension
id="ctagsindexer" id="ctagsindexer"
name="CTags Indexer" name="%CDTIndexer.ctagsindexer"
point="org.eclipse.cdt.core.CIndexer"> point="org.eclipse.cdt.core.CIndexer">
<cextension> <cextension>
<run <run
class="org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexer"> class="org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexer">
</run>
</cextension>
</extension>
<extension
id="nullindexer"
name="%CDTIndexer.nullindexer"
point="org.eclipse.cdt.core.CIndexer">
<cextension>
<run
class="org.eclipse.cdt.internal.core.index.nullindexer.NullIndexer">
</run> </run>
</cextension> </cextension>
</extension> </extension>

View file

@ -309,3 +309,12 @@ c.contextType.name = C
# completion # completion
completionContributors=Code Assist Completion Contributor completionContributors=Code Assist Completion Contributor
# Indexer Preference Name
indexerPrefName=Indexer
# indexer names
CDTIndexer.originalsourceindexer=Original C/C++ Indexer
CDTIndexer.domsourceindexer=DOM AST C/C++ Indexer
CDTIndexer.ctagsindexer=CTags Indexer
CDTIndexer.nullindexer=No Indexer

View file

@ -637,6 +637,11 @@
class="org.eclipse.cdt.internal.ui.preferences.PathEntryVariablePreferencePage" class="org.eclipse.cdt.internal.ui.preferences.PathEntryVariablePreferencePage"
id="org.eclipse.cdt.ui.preferences.PathEntryVariablePreferencePage"> id="org.eclipse.cdt.ui.preferences.PathEntryVariablePreferencePage">
</page> </page>
<page
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage"
id="org.eclipse.cdt.ui.preferences.IndexerPreferencePage"
name="%indexerPrefName"/>
<!--page <!--page
name="%WorkInProgress.name" name="%WorkInProgress.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
@ -1333,22 +1338,22 @@
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.SourceIndexerBlock" class="org.eclipse.cdt.ui.dialogs.SourceIndexerBlock"
indexerID="org.eclipse.cdt.core.originalsourceindexer" indexerID="org.eclipse.cdt.core.originalsourceindexer"
name="Original C/C++ Indexer" name="%CDTIndexer.originalsourceindexer"
id="org.eclipse.cdt.ui.originalSourceIndexerUI"/> id="org.eclipse.cdt.ui.originalSourceIndexerUI"/>
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock" class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
indexerID="org.eclipse.cdt.core.nullindexer" indexerID="org.eclipse.cdt.core.nullindexer"
name="No Indexer" name="%CDTIndexer.nullindexer"
id="org.eclipse.cdt.ui.nullindexerUI"/> id="org.eclipse.cdt.ui.nullindexerUI"/>
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.SourceIndexerBlock" class="org.eclipse.cdt.ui.dialogs.SourceIndexerBlock"
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="DOM AST C/C++ Indexer"/> name="%CDTIndexer.domsourceindexer"/>
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.CTagsIndexerBlock" class="org.eclipse.cdt.ui.dialogs.CTagsIndexerBlock"
indexerID="org.eclipse.cdt.core.ctagsindexer" indexerID="org.eclipse.cdt.core.ctagsindexer"
name="CTags Indexer" name="%CDTIndexer.ctagsindexer"
id="org.eclipse.cdt.ui.ctagsIndexerUI"/> id="org.eclipse.cdt.ui.ctagsIndexerUI"/>
</extension> </extension>
<extension <extension

View file

@ -57,7 +57,6 @@ AbstractErrorParserBlock.label.errorParsers=Error Parsers
ICElementPropertyConstants.catagory=Binary Info ICElementPropertyConstants.catagory=Binary Info
IndexerOptions.indexer = C/C++ Indexer
IndexerOptions.enableIndexing = Enable C/C++ &Indexing IndexerOptions.enableIndexing = Enable C/C++ &Indexing
IndexerOptions.problemReporting = C/C++ Index problem reporting IndexerOptions.problemReporting = C/C++ Index problem reporting
IndexerOptions.enablePreprocessor = Report &preprocessor problems IndexerOptions.enablePreprocessor = Report &preprocessor problems
@ -65,6 +64,12 @@ IndexerOptions.enableSemantic = Report &semantic problems
IndexerOptions.enableSyntactic = Report s&yntactic problems IndexerOptions.enableSyntactic = Report s&yntactic problems
IndexerOptiosn.task.savingAttributes = Saving Attributes IndexerOptiosn.task.savingAttributes = Saving Attributes
CTagsIndexerBlock.blockName=CTags File
CTagsIndexerBlock.radioButtonInternal=Use internal CTags file (default)
CTagsIndexerBlock.radioButtonExternal=Import existing CTags file
CTagsIndexerBlock.browseButton=Browse...
CTagsIndexerBlock.fileBrowser=Select CTags File
StatusBarUpdater.num_elements_selected={0} items selected StatusBarUpdater.num_elements_selected={0} items selected
CElementLabels.anonymous=(anon) CElementLabels.anonymous=(anon)

View file

@ -0,0 +1,63 @@
package org.eclipse.cdt.internal.ui.preferences;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.IndexerBlock;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
public class IndexerPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage, ICOptionContainer {
private IndexerBlock fOptionBlock;
public IndexerPreferencePage(){
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
setDescription(PreferencesMessages.getString("IndexerPrefs.description")); //$NON-NLS-1$
fOptionBlock = new IndexerBlock();
}
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
fOptionBlock.createControl(composite);
return composite;
}
public void init(IWorkbench workbench) {
// TODO Auto-generated method stub
}
public void updateContainer() {
// TODO Auto-generated method stub
}
public IProject getProject() {
// TODO Auto-generated method stub
return null;
}
public Preferences getPreferences() {
return null;
}
public boolean performOk() {
try {
fOptionBlock.performApply(null);
} catch (CoreException e) {}
CUIPlugin.getDefault().savePluginPreferences();
return true;
}
}

View file

@ -254,3 +254,5 @@ PathEntryVariableSelectionDialog.extendButton = &Extend...
PathEntryVariableSelectionDialog.ExtensionDialog.title = Variable Extension PathEntryVariableSelectionDialog.ExtensionDialog.title = Variable Extension
PathEntryVariableSelectionDialog.ExtensionDialog.description = Choose extension to {0} PathEntryVariableSelectionDialog.ExtensionDialog.description = Choose extension to {0}
#Indexer
IndexerPrefs.description=Sets default Indexer Options for new Projects

View file

@ -10,44 +10,237 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.ui.dialogs; package org.eclipse.cdt.ui.dialogs;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexer;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.internal.ui.util.SWTUtil;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.index.AbstractIndexerPage; 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.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.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
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.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
/** /**
* @author Bogdan Gheorghe * @author Bogdan Gheorghe
*/ */
public class CTagsIndexerBlock extends AbstractIndexerPage { public class CTagsIndexerBlock extends AbstractIndexerPage {
protected boolean internalTagsFile = true;
protected boolean externalTagsFile = false;
protected Button internalCTagsFile;
protected Button externalCTagsFile;
protected Button browseButton;
protected Text cTagsFile;
private String storedInternalExternal;
private String storedTagFile;
public final static String PREF_INTOREXT_CTAGS = CUIPlugin.PLUGIN_ID + ".intorextctags"; //$NON-NLS-1$
public final static String PREF_CTAGSLOCATION_CTAGS = CUIPlugin.PLUGIN_ID + ".ctagslocation"; //$NON-NLS-1$
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.ui.index.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject) * @see org.eclipse.cdt.ui.index.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
*/ */
public void initialize(IProject project) { public void initialize(IProject project) {
this.currentProject = project; this.currentProject = project;
} try {
loadPersistedValues(project);
/* (non-Javadoc) } catch (CoreException e) {}
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
*/
public void performApply(IProgressMonitor monitor) throws CoreException {
} }
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 internalExternalCTagsString = internalTagsFile ? CTagsIndexer.CTAGS_INTERNAL : CTagsIndexer.CTAGS_EXTERNAL;
String cTagsFileLocation = cTagsFile.getText();
//if external has been chosen, ensure that there is a cTagsFileLocation selected; otherwise default
//to internal file
if (internalExternalCTagsString.equals(CTagsIndexer.CTAGS_EXTERNAL) && cTagsFileLocation.equals("")) //$NON-NLS-1$
internalExternalCTagsString=CTagsIndexer.CTAGS_INTERNAL;
if (container != null){
proj = container.getProject();
}
else{
proj = currentProject;
}
if (proj != null) {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
if (cext.length > 0) {
for (int i = 0; i < cext.length; i++) {
String id = cext[i].getID();
String orig = cext[i].getExtensionData("ctagfiletype"); //$NON-NLS-1$
if (orig == null || !orig.equals(internalExternalCTagsString)) {
cext[i].setExtensionData("ctagfiletype", internalExternalCTagsString); //$NON-NLS-1$
}
orig = cext[i].getExtensionData("ctagfilelocation"); //$NON-NLS-1$
if (orig == null || !orig.equals(cTagsFileLocation)) {
cext[i].setExtensionData("ctagfilelocation", cTagsFileLocation); //$NON-NLS-1$
}
}
}
} else {
if (prefStore != null) {
prefStore.setValue(PREF_INTOREXT_CTAGS, internalExternalCTagsString);
prefStore.setValue(PREF_CTAGSLOCATION_CTAGS,cTagsFileLocation);
}
}
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
*/ */
public void performDefaults() { public void performDefaults() {
internalTagsFile=true;
externalTagsFile=false;
internalCTagsFile.setSelection(true);
externalCTagsFile.setSelection(false);
cTagsFile.setText(""); //$NON-NLS-1$
browseButton.setEnabled(false);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) * @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);
Group group = ControlFactory.createGroup(page, CUIMessages.getString("CTagsIndexerBlock.blockName"),3); //$NON-NLS-1$
GridData gd = (GridData) group.getLayoutData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
SelectionListener cListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
internalTagsFile = internalCTagsFile.getSelection();
externalTagsFile = externalCTagsFile.getSelection();
if (externalTagsFile){
setButtonState(CTagsIndexer.CTAGS_EXTERNAL);
}
if (internalTagsFile){
setButtonState(CTagsIndexer.CTAGS_INTERNAL);
}
}
};
internalCTagsFile = ControlFactory.createRadioButton(group,CUIMessages.getString("CTagsIndexerBlock.radioButtonInternal"),"Internal",cListener);//$NON-NLS-1$ //$NON-NLS-2$
((GridData)internalCTagsFile.getLayoutData()).horizontalSpan = 3;
((GridData)internalCTagsFile.getLayoutData()).grabExcessHorizontalSpace = true;
internalCTagsFile.setSelection(internalTagsFile);
externalCTagsFile = ControlFactory.createRadioButton(group,CUIMessages.getString("CTagsIndexerBlock.radioButtonExternal"),"External",cListener);//$NON-NLS-1$ //$NON-NLS-2$
((GridData)externalCTagsFile.getLayoutData()).horizontalSpan = 3;
((GridData)externalCTagsFile.getLayoutData()).grabExcessHorizontalSpace = true;
cTagsFile = ControlFactory.createTextField(group);
((GridData)cTagsFile.getLayoutData()).horizontalSpan = 2;
((GridData)cTagsFile.getLayoutData()).grabExcessHorizontalSpace = true;
browseButton = ControlFactory.createPushButton(group,CUIMessages.getString("CTagsIndexerBlock.browseButton")); //$NON-NLS-1$
((GridData)browseButton.getLayoutData()).widthHint = SWTUtil.getButtonWidthHint(browseButton);
browseButton.setEnabled(false);
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
handleBrowseButtonSelected();
}
private void handleBrowseButtonSelected() {
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
dialog.setText(CUIMessages.getString("CTagsIndexerBlock.fileBrowser")); //$NON-NLS-1$
String fileName = dialog.open();
if (fileName == null) {
return;
}
cTagsFile.setText(fileName);
}
});
setControl(page); setControl(page);
} }
public void loadPersistedValues(IProject project) throws CoreException {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
if (cext.length > 0) {
for (int i = 0; i < cext.length; i++) {
String id = cext[i].getID();
String orig = cext[i].getExtensionData("ctagfiletype"); //$NON-NLS-1$
if (orig != null){
storedInternalExternal=orig;
setButtonState(orig);
}
orig = cext[i].getExtensionData("ctagfilelocation"); //$NON-NLS-1$
if (orig != null){
storedTagFile=orig;
cTagsFile.setText(orig);
}
}
}
}
private void setButtonState(String orig){
if (orig.equals(CTagsIndexer.CTAGS_INTERNAL)){
internalTagsFile=true;
externalTagsFile=false;
internalCTagsFile.setSelection(true);
externalCTagsFile.setSelection(false);
browseButton.setEnabled(false);
} else if (orig.equals(CTagsIndexer.CTAGS_EXTERNAL)){
externalTagsFile=true;
internalTagsFile=false;
externalCTagsFile.setSelection(true);
internalCTagsFile.setSelection(false);
browseButton.setEnabled(true);
}
}
public void loadPreferences() {
String indexerId=prefStore.getString(PREF_INTOREXT_CTAGS);
if (!indexerId.equals("")) { //$NON-NLS-1$
setButtonState(indexerId);
}
indexerId=prefStore.getString(PREF_CTAGSLOCATION_CTAGS);
if (!indexerId.equals("")) { //$NON-NLS-1$
storedTagFile=indexerId;
cTagsFile.setText(indexerId);
}
}
public void removePreferences() {
prefStore.setToDefault(PREF_CTAGSLOCATION_CTAGS);
prefStore.setToDefault(PREF_INTOREXT_CTAGS);
}
} }

View file

@ -30,9 +30,9 @@ 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.NullProgressMonitor;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
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.graphics.Font;
@ -74,6 +74,8 @@ public class IndexerBlock extends AbstractCOptionPage {
String initialSelected; String initialSelected;
private IPreferenceStore prefStore=CUIPlugin.getDefault().getPreferenceStore();
public IndexerBlock(){ public IndexerBlock(){
super(INDEXER_LABEL); super(INDEXER_LABEL);
setDescription(INDEXER_DESCRIPTION); setDescription(INDEXER_DESCRIPTION);
@ -166,7 +168,12 @@ public class IndexerBlock extends AbstractCOptionPage {
page.setVisible(true); page.setVisible(true);
} }
setCurrentPage(page); setCurrentPage(page);
if (page instanceof AbstractIndexerPage){
((AbstractIndexerPage) page).loadPreferences();
}
} }
/** /**
@ -220,15 +227,27 @@ public class IndexerBlock extends AbstractCOptionPage {
} }
} }
//See what the preferred indexer is
String indexerId=prefStore.getString(CCorePlugin.PREF_INDEXER);
String preferredIndexer=null;
if (indexerId.equals("")) { //$NON-NLS-1$
preferredIndexer=getIndexerPageName("org.eclipse.cdt.core.nullindexer"); //$NON-NLS-1$
} else {
preferredIndexer=getIndexerPageName(indexerId);
}
String[] indexerList = indexersComboBox.getItems(); String[] indexerList = indexersComboBox.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("No Indexer")) //$NON-NLS-1$ if (indexerList[i].equals(preferredIndexer)) //$NON-NLS-1$
selectedIndex = i; selectedIndex = i;
} }
indexersComboBox.select(selectedIndex); indexersComboBox.select(selectedIndex);
String indexerPageID = getIndexerPageId(preferredIndexer);
initialSelected = getIndexerIdName(indexerPageID);
return true; return true;
} }
@ -359,19 +378,25 @@ public class IndexerBlock extends AbstractCOptionPage {
if (page != null && page.getControl() != null) { if (page != null && page.getControl() != null) {
page.performApply(new SubProgressMonitor(monitor, 1)); page.performApply(new SubProgressMonitor(monitor, 1));
} }
} }
}; };
CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(project, op, monitor); CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(project, op, monitor);
CCorePlugin.getDefault().getCoreModel().getIndexManager().indexerChangeNotification(project); //Only send out an index changed notification if the indexer has actually changed
if (initialSelected == null || !selected.equals(initialSelected)) {
CCorePlugin.getDefault().getCoreModel().getIndexManager().indexerChangeNotification(project);
}
} else { } else {
if (initialSelected == null || !selected.equals(initialSelected)) { if (initialSelected == null || !selected.equals(initialSelected)) {
if (container != null){
Preferences store = container.getPreferences(); if (prefStore != null) {
if (store != null) { //First clean out the old indexer settings
store.setValue(CCorePlugin.PREF_INDEXER, indexerID); String indexerId=prefStore.getString(CCorePlugin.PREF_INDEXER);
ICOptionPage tempPage = getIndexerPage(indexerId);
if (tempPage instanceof AbstractIndexerPage)
((AbstractIndexerPage) tempPage).removePreferences();
prefStore.setValue(CCorePlugin.PREF_INDEXER, indexerID);
} }
}
} }
monitor.worked(1); monitor.worked(1);
// Give a chance to the contributions to save. // Give a chance to the contributions to save.
@ -396,14 +421,21 @@ public class IndexerBlock extends AbstractCOptionPage {
((AbstractIndexerPage)currentPage).setCurrentProject(project); ((AbstractIndexerPage)currentPage).setCurrentProject(project);
this.performApply(monitor); this.performApply(monitor);
/*//Give the chosen indexer a chance to persist its values
if (currentPage != null){
currentPage.performApply(monitor);*/
} }
public void resetIndexerPageSettings(IProject project){
if (currentPage instanceof AbstractIndexerPage)
((AbstractIndexerPage)currentPage).setCurrentProject(project);
this.performDefaults();
}
public void performDefaults() { public void performDefaults() {
// TODO Auto-generated method stub //Give a chance to the contributions to perform defaults.
ICOptionPage page = currentPage;
if (page != null && page.getControl() != null) {
page.performDefaults();
}
} }
/** /**
@ -418,9 +450,11 @@ public class IndexerBlock extends AbstractCOptionPage {
* @param oldIndexerID * @param oldIndexerID
* @param project * @param project
*/ */
public void setIndexerID(String oldIndexerID, IProject project) { public void setIndexerID(String indexerID, IProject project) {
//Get the corresponding text for the given indexer id //Get the corresponding text for the given indexer id
selectedIndexerId = getIndexerPageName(oldIndexerID); selectedIndexerId = getIndexerPageName(indexerID);
//Store the currently selected indexer id
initialSelected = indexerID;
if (selectedIndexerId == null){ if (selectedIndexerId == null){
CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.DEFAULT_INDEXER_UNIQ_ID); CCorePlugin.getDefault().getPluginPreferences().setValue(CCorePlugin.PREF_INDEXER, CCorePlugin.DEFAULT_INDEXER_UNIQ_ID);
@ -449,4 +483,5 @@ public class IndexerBlock extends AbstractCOptionPage {
return indexerID; return indexerID;
} }
} }

View file

@ -59,8 +59,8 @@ public class IndexerOptionPropertyPage extends PropertyPage {
protected void performDefaults() { protected void performDefaults() {
initialize(); IProject tempProject = getProject();
super.performDefaults(); optionPage.resetIndexerPageSettings(tempProject);
} }
private void initialize(){ private void initialize(){
@ -81,24 +81,6 @@ public class IndexerOptionPropertyPage extends PropertyPage {
*/ */
public boolean performOk() { public boolean performOk() {
/* String newIndexerID = optionPage.getSelectedIndexerID();
boolean indexerIDChanged = false;
if (newIndexerID != null){
indexerIDChanged = !(oldIndexerID.equals(newIndexerID));
}
else if (oldIndexerID != null){
//newIndexerID is null, oldIndexerID wasn't null
indexerIDChanged = true;
}
if ( indexerIDChanged ){
//persist new values
IProject tempProject = getProject();
optionPage.persistIndexerValues(tempProject);
}*/
IProject tempProject = getProject(); IProject tempProject = getProject();
try { try {
optionPage.persistIndexerSettings(tempProject, new NullProgressMonitor()); optionPage.persistIndexerSettings(tempProject, new NullProgressMonitor());

View file

@ -34,4 +34,8 @@ public class NullIndexerBlock extends AbstractIndexerPage {
setControl(comp); setControl(comp);
} }
public void loadPreferences() {}
public void removePreferences() {}
} }

View file

@ -24,7 +24,6 @@ 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.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -33,22 +32,18 @@ import org.eclipse.swt.widgets.Group;
public class SourceIndexerBlock extends AbstractIndexerPage { public class SourceIndexerBlock extends AbstractIndexerPage {
public final static String PREF_INDEX_ENABLED = CUIPlugin.PLUGIN_ID + ".indexenabled"; //$NON-NLS-1$
public final static String PREF_INDEX_MARKERS = CUIPlugin.PLUGIN_ID + ".indexmarkers"; //$NON-NLS-1$ 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_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_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 ENABLE_SYNTACTIC_PROBLEMS = CUIMessages.getString( "IndexerOptions.enableSyntactic" ); //$NON-NLS-1$
private static final String ENABLE_INDEXING = CUIMessages.getString( "IndexerOptions.enableIndexing" ); //$NON-NLS-1$
private static final String INDEXER = CUIMessages.getString("IndexerOptions.indexer" ); //$NON-NLS-1$
private static final String INDEXER_PROBLEMS = CUIMessages.getString("IndexerOptions.problemReporting" ); //$NON-NLS-1$ private static final String INDEXER_PROBLEMS = CUIMessages.getString("IndexerOptions.problemReporting" ); //$NON-NLS-1$
private Button indexerEnabled;
private Button preprocessorProblemsEnabled; private Button preprocessorProblemsEnabled;
private Button syntacticProblemsEnabled; private Button syntacticProblemsEnabled;
private Button semanticProblemsEnabled; private Button semanticProblemsEnabled;
private boolean oldIndexerValue = false;
private int oldIndexerProblemsValue = 0; private int oldIndexerProblemsValue = 0;
/* (non-Javadoc) /* (non-Javadoc)
@ -63,7 +58,6 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$ monitor.beginTask(CUIMessages.getString("IndexerOptiosn.task.savingAttributes "), 1); //$NON-NLS-1$
ICOptionContainer container = getContainer(); ICOptionContainer container = getContainer();
IProject proj = null; IProject proj = null;
String indexEnabled = getIndexerEnabledString();
String indexMarkers = getIndexerProblemsValuesString(); String indexMarkers = getIndexerProblemsValuesString();
if (container != null){ if (container != null){
@ -77,31 +71,19 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false); ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(proj, false);
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID); ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
if (cext.length > 0) { if (cext.length > 0) {
//initializeIndexerId();
for (int i = 0; i < cext.length; i++) { for (int i = 0; i < cext.length; i++) {
String id = cext[i].getID(); String id = cext[i].getID();
//if (cext[i].getID().equals(parserID)) { String orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$ String indexProblems = getIndexerProblemsValuesString();
if (orig == null || !orig.equals(indexEnabled)) { if (orig == null || !orig.equals(indexProblems)) {
cext[i].setExtensionData("indexenabled", indexEnabled); //$NON-NLS-1$ cext[i].setExtensionData("indexmarkers", indexProblems); //$NON-NLS-1$
} }
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 { } else {
Preferences store = null; if (prefStore != null) {
if (container != null){ prefStore.setValue(PREF_INDEX_MARKERS, indexMarkers);
store = container.getPreferences();
}
if (store != null) {
store.setValue(PREF_INDEX_ENABLED, indexEnabled);
store.setValue(PREF_INDEX_MARKERS, indexMarkers);
} }
} }
@ -117,14 +99,6 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
if (indexer instanceof SourceIndexer) if (indexer instanceof SourceIndexer)
((SourceIndexer) indexer).removeIndexerProblems(currentProject); ((SourceIndexer) indexer).removeIndexerProblems(currentProject);
boolean indexProject = getIndexerValue();
if ((indexProject != oldIndexerValue)
&& (currentProject != null)
&& indexProject) {
if (indexer instanceof SourceIndexer)
((SourceIndexer) indexer).indexAll(currentProject);
}
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults() * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
@ -139,16 +113,6 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
Composite page = ControlFactory.createComposite(parent, 1); Composite page = ControlFactory.createComposite(parent, 1);
Group group = ControlFactory.createGroup(page,INDEXER,1);
GridData gd = (GridData) group.getLayoutData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
indexerEnabled = ControlFactory.createCheckBox(group, ENABLE_INDEXING );
Group problemsGroup = ControlFactory.createGroup(page,INDEXER_PROBLEMS,1); Group problemsGroup = ControlFactory.createGroup(page,INDEXER_PROBLEMS,1);
GridData gd2 = (GridData) problemsGroup.getLayoutData(); GridData gd2 = (GridData) problemsGroup.getLayoutData();
@ -158,16 +122,12 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
preprocessorProblemsEnabled = ControlFactory.createCheckBox( problemsGroup, ENABLE_PREPROCESSOR_PROBLEMS ); preprocessorProblemsEnabled = ControlFactory.createCheckBox( problemsGroup, ENABLE_PREPROCESSOR_PROBLEMS );
semanticProblemsEnabled = ControlFactory.createCheckBox( problemsGroup, ENABLE_SEMANTIC_PROBLEMS ); semanticProblemsEnabled = ControlFactory.createCheckBox( problemsGroup, ENABLE_SEMANTIC_PROBLEMS );
//uncomment when we want to report syntax problems
syntacticProblemsEnabled = ControlFactory.createCheckBox( problemsGroup, ENABLE_SYNTACTIC_PROBLEMS ); syntacticProblemsEnabled = ControlFactory.createCheckBox( problemsGroup, ENABLE_SYNTACTIC_PROBLEMS );
setControl(page); setControl(page);
} }
public boolean getIndexerValue(){
return indexerEnabled.getSelection();
}
public String getIndexerProblemsValuesString(){ public String getIndexerProblemsValuesString(){
int result = 0; int result = 0;
result |= preprocessorProblemsEnabled.getSelection() ? SourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0; result |= preprocessorProblemsEnabled.getSelection() ? SourceIndexer.PREPROCESSOR_PROBLEMS_BIT : 0;
@ -179,13 +139,6 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
return tempInt.toString(); return tempInt.toString();
} }
private String getIndexerEnabledString(){
if (indexerEnabled.getSelection())
return "true"; //$NON-NLS-1$
return "false"; //$NON-NLS-1$
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.ui.index2.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject) * @see org.eclipse.cdt.ui.index2.AbstractIndexerPage#initialize(org.eclipse.core.resources.IProject)
*/ */
@ -194,12 +147,7 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
try { try {
loadPersistedValues(project); loadPersistedValues(project);
this.currentProject = project; this.currentProject = project;
} catch (CoreException e) { } catch (CoreException e) {}
e.printStackTrace();
}
//Set the index enabled checkbox
setIndexerValue(oldIndexerValue);
//Set the IProblem checkboxes //Set the IProblem checkboxes
setIndexerProblemValues(oldIndexerProblemsValue); setIndexerProblemValues(oldIndexerProblemsValue);
@ -210,31 +158,19 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false); ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID); ICExtensionReference[] cext = cdesc.get(CCorePlugin.INDEXER_UNIQ_ID);
if (cext.length > 0) { if (cext.length > 0) {
//initializeIndexerId();
for (int i = 0; i < cext.length; i++) { for (int i = 0; i < cext.length; i++) {
String id = cext[i].getID(); String id = cext[i].getID();
//if (cext[i].getID().equals(parserID)) {
String orig = cext[i].getExtensionData("indexenabled"); //$NON-NLS-1$
if (orig != null){
Boolean tempBool = new Boolean(orig);
oldIndexerValue = tempBool.booleanValue();
}
orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$ String orig = cext[i].getExtensionData("indexmarkers"); //$NON-NLS-1$
if (orig != null){ if (orig != null){
Integer tempInt = new Integer(orig); Integer tempInt = new Integer(orig);
oldIndexerProblemsValue = tempInt.intValue(); oldIndexerProblemsValue = tempInt.intValue();
} }
//}
} }
} }
} }
public void setIndexerValue(boolean value){
indexerEnabled.setSelection(value);
}
public void setIndexerProblemValues( int value ){ public void setIndexerProblemValues( int value ){
preprocessorProblemsEnabled.setSelection( (value & SourceIndexer.PREPROCESSOR_PROBLEMS_BIT) != 0 ); preprocessorProblemsEnabled.setSelection( (value & SourceIndexer.PREPROCESSOR_PROBLEMS_BIT) != 0 );
if( syntacticProblemsEnabled != null ) if( syntacticProblemsEnabled != null )
@ -242,4 +178,16 @@ public class SourceIndexerBlock extends AbstractIndexerPage {
semanticProblemsEnabled.setSelection( (value & SourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0 ); semanticProblemsEnabled.setSelection( (value & SourceIndexer.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

@ -10,8 +10,10 @@
**********************************************************************/ **********************************************************************/
package org.eclipse.cdt.ui.index; package org.eclipse.cdt.ui.index;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.jface.preference.IPreferenceStore;
/** /**
* @author Bogdan Gheorghe * @author Bogdan Gheorghe
@ -19,6 +21,7 @@ import org.eclipse.core.resources.IProject;
public abstract class AbstractIndexerPage extends AbstractCOptionPage { public abstract class AbstractIndexerPage extends AbstractCOptionPage {
protected IProject currentProject; protected IProject currentProject;
protected IPreferenceStore prefStore=CUIPlugin.getDefault().getPreferenceStore();
protected AbstractIndexerPage() { protected AbstractIndexerPage() {
super(); super();
@ -29,8 +32,16 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
* @param currentProject - the project that this page is being created for * @param currentProject - the project that this page is being created for
*/ */
abstract public void initialize(IProject currentProject); abstract public void initialize(IProject 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() { public IProject getCurrentProject() {
return currentProject; return currentProject;