1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-06 15:55:47 +02:00

Added code to load and store index enablement setting from a project's descriptor

This commit is contained in:
Bogdan Gheorghe 2004-05-05 17:01:19 +00:00
parent 3a6ffef8f8
commit 72799392c9
6 changed files with 55 additions and 10 deletions

View file

@ -1,3 +1,6 @@
2004-05-05 Bogdan Gheorghe
Added code to load and store index enablement setting from a project's descriptor
2004-05-03 Bogdan Gheorghe
Added index enablement checking to index manager

View file

@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.zip.CRC32;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICLogConstants;
import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.index.IIndex;
@ -42,6 +43,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class IndexManager extends JobManager implements IIndexConstants {
@ -77,6 +80,9 @@ public class IndexManager extends JobManager implements IIndexConstants {
public final static String ACTIVATION = "enable"; //$NON-NLS-1$
public final static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
public static final String INDEXER_ENABLED = "indexEnabled"; //$NON-NLS-1$
public static final String CDT_INDEXER = "cdt_indexer"; //$NON-NLS-1$
public static final String INDEXER_VALUE = "indexValue"; //$NON-NLS-1$
public synchronized void aboutToUpdateIndex(IPath path, Integer newIndexState) {
// newIndexState is either UPDATING_STATE or REBUILDING_STATE
@ -295,6 +301,18 @@ public class IndexManager extends JobManager implements IIndexConstants {
if (indexValue != null)
return indexValue.booleanValue();
try {
//Load value for project
indexValue = loadIndexerEnabledromCDescriptor(project);
if (indexValue != null){
project.setSessionProperty(IndexManager.activationKey, indexValue);
return indexValue.booleanValue();
}
} catch (CoreException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return false;
}
/**
@ -654,4 +672,21 @@ public class IndexManager extends JobManager implements IIndexConstants {
}
}
private Boolean loadIndexerEnabledromCDescriptor(IProject project) throws CoreException {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
Node child = descriptor.getProjectData(CDT_INDEXER).getFirstChild();
Boolean strBool = null;
while (child != null) {
if (child.getNodeName().equals(INDEXER_ENABLED))
strBool = Boolean.valueOf(((Element)child).getAttribute(INDEXER_VALUE));
child = child.getNextSibling();
}
return strBool;
}
}

View file

@ -1,3 +1,12 @@
2004-05-05 Bogdan Gheorghe
Moved the index enablement constants to IndexManager to allow the index manager
to load enablement settings if not done so by the property page
* src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
* src/org/eclipse/cdt/ui/dialogs/IndexerOptionDialogPage.java
* src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java
2004-05-05 Bogdan Gheorghe
Got rid of the old search context menus in CEditor, COutlineView, CView.

View file

@ -25,9 +25,7 @@ import org.eclipse.swt.widgets.Composite;
public class IndexerBlock extends AbstractCOptionPage {
private IndexerOptionDialogPage optionPage;
public static final String INDEXER_ENABLED = "indexEnabled"; //$NON-NLS-1$
public static final String CDT_INDEXER = "cdt_indexer"; //$NON-NLS-1$
public static final String INDEXER_VALUE = "indexValue"; //$NON-NLS-1$
private static final String INDEXER_LABEL = "IndexerBlock.label"; //$NON-NLS-1$
private static final String INDEXER_DESC = "IndexerBlock.desc"; //$NON-NLS-1$

View file

@ -88,7 +88,7 @@ public class IndexerOptionDialogPage extends DialogPage {
try {
newProject = project;
descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject);
rootElement = descriptor.getProjectData(IndexerBlock.CDT_INDEXER);
rootElement = descriptor.getProjectData(IndexManager.CDT_INDEXER);
// Clear out all current children
@ -119,10 +119,10 @@ public class IndexerOptionDialogPage extends DialogPage {
private static void saveIndexerEnabled (boolean indexerEnabled, Element rootElement, Document doc ) {
Element indexEnabled = doc.createElement(IndexerBlock.INDEXER_ENABLED);
Element indexEnabled = doc.createElement(IndexManager.INDEXER_ENABLED);
Boolean tempValue= new Boolean(indexerEnabled);
indexEnabled.setAttribute(IndexerBlock.INDEXER_VALUE,tempValue.toString());
indexEnabled.setAttribute(IndexManager.INDEXER_VALUE,tempValue.toString());
rootElement.appendChild(indexEnabled);
}

View file

@ -136,12 +136,12 @@ public class IndexerOptionPropertyPage extends PropertyPage {
private Boolean loadIndexerEnabledromCDescriptor(IProject project) throws CoreException {
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
Node child = descriptor.getProjectData(IndexerBlock.CDT_INDEXER).getFirstChild();
Node child = descriptor.getProjectData(IndexManager.CDT_INDEXER).getFirstChild();
Boolean strBool = null;
while (child != null) {
if (child.getNodeName().equals(IndexerBlock.INDEXER_ENABLED))
strBool = Boolean.valueOf(((Element)child).getAttribute(IndexerBlock.INDEXER_VALUE));
if (child.getNodeName().equals(IndexManager.INDEXER_ENABLED))
strBool = Boolean.valueOf(((Element)child).getAttribute(IndexManager.INDEXER_VALUE));
child = child.getNextSibling();