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:
parent
3a6ffef8f8
commit
72799392c9
6 changed files with 55 additions and 10 deletions
|
@ -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
|
2004-05-03 Bogdan Gheorghe
|
||||||
Added index enablement checking to index manager
|
Added index enablement checking to index manager
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.ICLogConstants;
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
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.IPath;
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
|
||||||
public class IndexManager extends JobManager implements IIndexConstants {
|
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 String ACTIVATION = "enable"; //$NON-NLS-1$
|
||||||
public final static QualifiedName activationKey = new QualifiedName(INDEX_MODEL_ID, ACTIVATION);
|
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) {
|
public synchronized void aboutToUpdateIndex(IPath path, Integer newIndexState) {
|
||||||
// newIndexState is either UPDATING_STATE or REBUILDING_STATE
|
// newIndexState is either UPDATING_STATE or REBUILDING_STATE
|
||||||
|
@ -295,6 +301,18 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
||||||
if (indexValue != null)
|
if (indexValue != null)
|
||||||
return indexValue.booleanValue();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -653,5 +671,22 @@ public class IndexManager extends JobManager implements IIndexConstants {
|
||||||
jobSet.remove(tempJob.resource.getLocation());
|
jobSet.remove(tempJob.resource.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
2004-05-05 Bogdan Gheorghe
|
||||||
Got rid of the old search context menus in CEditor, COutlineView, CView.
|
Got rid of the old search context menus in CEditor, COutlineView, CView.
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,7 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
public class IndexerBlock extends AbstractCOptionPage {
|
public class IndexerBlock extends AbstractCOptionPage {
|
||||||
|
|
||||||
private IndexerOptionDialogPage optionPage;
|
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_LABEL = "IndexerBlock.label"; //$NON-NLS-1$
|
||||||
private static final String INDEXER_DESC = "IndexerBlock.desc"; //$NON-NLS-1$
|
private static final String INDEXER_DESC = "IndexerBlock.desc"; //$NON-NLS-1$
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class IndexerOptionDialogPage extends DialogPage {
|
||||||
try {
|
try {
|
||||||
newProject = project;
|
newProject = project;
|
||||||
descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject);
|
descriptor = CCorePlugin.getDefault().getCProjectDescription(newProject);
|
||||||
rootElement = descriptor.getProjectData(IndexerBlock.CDT_INDEXER);
|
rootElement = descriptor.getProjectData(IndexManager.CDT_INDEXER);
|
||||||
|
|
||||||
|
|
||||||
// Clear out all current children
|
// Clear out all current children
|
||||||
|
@ -115,14 +115,14 @@ public class IndexerOptionDialogPage extends DialogPage {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void saveIndexerEnabled (boolean indexerEnabled, Element rootElement, Document doc ) {
|
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);
|
Boolean tempValue= new Boolean(indexerEnabled);
|
||||||
|
|
||||||
indexEnabled.setAttribute(IndexerBlock.INDEXER_VALUE,tempValue.toString());
|
indexEnabled.setAttribute(IndexManager.INDEXER_VALUE,tempValue.toString());
|
||||||
rootElement.appendChild(indexEnabled);
|
rootElement.appendChild(indexEnabled);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,12 +136,12 @@ public class IndexerOptionPropertyPage extends PropertyPage {
|
||||||
private Boolean loadIndexerEnabledromCDescriptor(IProject project) throws CoreException {
|
private Boolean loadIndexerEnabledromCDescriptor(IProject project) throws CoreException {
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
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;
|
Boolean strBool = null;
|
||||||
|
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
if (child.getNodeName().equals(IndexerBlock.INDEXER_ENABLED))
|
if (child.getNodeName().equals(IndexManager.INDEXER_ENABLED))
|
||||||
strBool = Boolean.valueOf(((Element)child).getAttribute(IndexerBlock.INDEXER_VALUE));
|
strBool = Boolean.valueOf(((Element)child).getAttribute(IndexManager.INDEXER_VALUE));
|
||||||
|
|
||||||
|
|
||||||
child = child.getNextSibling();
|
child = child.getNextSibling();
|
||||||
|
|
Loading…
Add table
Reference in a new issue