mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
- added preference to disable check as you type
This commit is contained in:
parent
25406f96bc
commit
7fa181c4b6
9 changed files with 121 additions and 62 deletions
|
@ -10,37 +10,22 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.cxx.internal.model;
|
package org.eclipse.cdt.codan.core.cxx.internal.model;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.internal.core.CodanBuilder;
|
import org.eclipse.cdt.codan.internal.core.CodanBuilder;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Alena
|
* @author Alena
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
public class CxxCodanReconciler {
|
||||||
public class CxxCodanRenciler {
|
|
||||||
private CodanBuilder builder = new CodanBuilder();
|
private CodanBuilder builder = new CodanBuilder();
|
||||||
|
|
||||||
public void reconciledAst(IASTTranslationUnit ast, IProgressMonitor monitor) {
|
public void reconciledAst(IASTTranslationUnit ast, IResource resource,
|
||||||
|
IProgressMonitor monitor) {
|
||||||
if (ast == null)
|
if (ast == null)
|
||||||
return;
|
return;
|
||||||
String filePath = ast.getFilePath();
|
|
||||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
|
||||||
IWorkspaceRoot root = workspace.getRoot();
|
|
||||||
IFile[] resources;
|
|
||||||
URI uri = new File(filePath).toURI();
|
|
||||||
resources = root.findFilesForLocationURI(uri);
|
|
||||||
if (resources != null && resources.length > 0) {
|
|
||||||
IFile resource = resources[0];
|
|
||||||
builder.runInEditor(ast, resource, monitor);
|
builder.runInEditor(ast, resource, monitor);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
id="codanNature"
|
id="codanNature"
|
||||||
name="CDT Code Analysis Nature"
|
name="Code Analysis Nature"
|
||||||
point="org.eclipse.core.resources.natures">
|
point="org.eclipse.core.resources.natures">
|
||||||
<runtime>
|
<runtime>
|
||||||
<run
|
<run
|
||||||
|
|
|
@ -13,13 +13,14 @@ package org.eclipse.cdt.codan.core;
|
||||||
/**
|
/**
|
||||||
* Constant definitions for plug-in preferences
|
* Constant definitions for plug-in preferences
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
|
||||||
* part of a work in progress. There is no guarantee that this API will
|
* of a work in progress. There is no guarantee that this API will work or that
|
||||||
* work or that it will remain the same.
|
* it will remain the same.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class PreferenceConstants {
|
public class PreferenceConstants {
|
||||||
public static final String P_RUN_ON_BUILD = "booleanPreference"; //$NON-NLS-1$
|
public static final String P_RUN_ON_BUILD = "onBuild"; //$NON-NLS-1$
|
||||||
|
public static final String P_RUN_IN_EDITOR = "inEditor"; //$NON-NLS-1$
|
||||||
public static final String P_PROBLEMS = "problems"; //$NON-NLS-1$
|
public static final String P_PROBLEMS = "problems"; //$NON-NLS-1$
|
||||||
public static final String P_USE_PARENT = "useParentScope"; //$NON-NLS-1$
|
public static final String P_USE_PARENT = "useParentScope"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,12 @@ import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
|
||||||
import org.eclipse.cdt.codan.internal.core.model.ProblemProfile;
|
import org.eclipse.cdt.codan.internal.core.model.ProblemProfile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
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.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
private static final String NAME_ATTR = "name"; //$NON-NLS-1$
|
private static final String NAME_ATTR = "name"; //$NON-NLS-1$
|
||||||
|
@ -324,7 +323,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
wp = (IProblemProfile) getDefaultProfile().clone();
|
wp = (IProblemProfile) getDefaultProfile().clone();
|
||||||
// load default values
|
// load default values
|
||||||
CodanPreferencesLoader loader = new CodanPreferencesLoader(wp);
|
CodanPreferencesLoader loader = new CodanPreferencesLoader(wp);
|
||||||
loader.load(CodanCorePlugin.getDefault().getStorePreferences());
|
loader.load(loader.getWorkspaceNode());
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
wp = getDefaultProfile();
|
wp = getDefaultProfile();
|
||||||
}
|
}
|
||||||
|
@ -358,13 +357,12 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
// load default values
|
// load default values
|
||||||
CodanPreferencesLoader loader = new CodanPreferencesLoader(
|
CodanPreferencesLoader loader = new CodanPreferencesLoader(
|
||||||
prof);
|
prof);
|
||||||
IEclipsePreferences node = new ProjectScope(
|
Preferences projectNode = loader
|
||||||
(IProject) element)
|
.getProjectNode((IProject) element);
|
||||||
.getNode(CodanCorePlugin.PLUGIN_ID);
|
boolean useWorkspace = projectNode.getBoolean(
|
||||||
boolean useWorkspace = node.getBoolean(
|
|
||||||
PreferenceConstants.P_USE_PARENT, false);
|
PreferenceConstants.P_USE_PARENT, false);
|
||||||
if (!useWorkspace) {
|
if (!useWorkspace) {
|
||||||
loader.load(node);
|
loader.load(projectNode);
|
||||||
}
|
}
|
||||||
profiles.put(element, prof);
|
profiles.put(element, prof);
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
|
|
|
@ -10,11 +10,15 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.core;
|
package org.eclipse.cdt.codan.internal.core;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
||||||
import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
|
import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Alena
|
* @author Alena
|
||||||
|
@ -54,7 +58,8 @@ public class CodanPreferencesLoader {
|
||||||
*/
|
*/
|
||||||
public void setProperty(String id, String s) {
|
public void setProperty(String id, String s) {
|
||||||
IProblem prob = baseModel.findProblem(id);
|
IProblem prob = baseModel.findProblem(id);
|
||||||
if (!(prob instanceof CodanProblem)) return;
|
if (!(prob instanceof CodanProblem))
|
||||||
|
return;
|
||||||
String sevs = s;
|
String sevs = s;
|
||||||
boolean enabled = true;
|
boolean enabled = true;
|
||||||
if (sevs.startsWith("-")) { //$NON-NLS-1$
|
if (sevs.startsWith("-")) { //$NON-NLS-1$
|
||||||
|
@ -94,7 +99,8 @@ public class CodanPreferencesLoader {
|
||||||
*/
|
*/
|
||||||
public String getProperty(String id) {
|
public String getProperty(String id) {
|
||||||
IProblem prob = baseModel.findProblem(id);
|
IProblem prob = baseModel.findProblem(id);
|
||||||
if (!(prob instanceof CodanProblem)) return null;
|
if (!(prob instanceof CodanProblem))
|
||||||
|
return null;
|
||||||
String enabled = prob.isEnabled() ? "" : "-"; //$NON-NLS-1$ //$NON-NLS-2$
|
String enabled = prob.isEnabled() ? "" : "-"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
String severity = prob.getSeverity().toString();
|
String severity = prob.getSeverity().toString();
|
||||||
String res = enabled + severity;
|
String res = enabled + severity;
|
||||||
|
@ -104,7 +110,7 @@ public class CodanPreferencesLoader {
|
||||||
/**
|
/**
|
||||||
* @param storePreferences
|
* @param storePreferences
|
||||||
*/
|
*/
|
||||||
public void load(IEclipsePreferences storePreferences) {
|
public void load(Preferences storePreferences) {
|
||||||
IProblem[] probs = getProblems();
|
IProblem[] probs = getProblems();
|
||||||
for (int i = 0; i < probs.length; i++) {
|
for (int i = 0; i < probs.length; i++) {
|
||||||
String id = probs[i].getId();
|
String id = probs[i].getId();
|
||||||
|
@ -114,4 +120,22 @@ public class CodanPreferencesLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Preferences getProjectNode(IProject project) {
|
||||||
|
if (!project.exists())
|
||||||
|
return null;
|
||||||
|
Preferences prefNode = new ProjectScope(project)
|
||||||
|
.getNode(CodanCorePlugin.PLUGIN_ID);
|
||||||
|
if (prefNode == null)
|
||||||
|
return null;
|
||||||
|
return prefNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Preferences getWorkspaceNode() {
|
||||||
|
Preferences prefNode = new InstanceScope()
|
||||||
|
.getNode(CodanCorePlugin.PLUGIN_ID);
|
||||||
|
if (prefNode == null)
|
||||||
|
return null;
|
||||||
|
return prefNode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,22 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.ui.cxx;
|
package org.eclipse.cdt.codan.internal.ui.cxx;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanRenciler;
|
import java.io.File;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
||||||
|
import org.eclipse.cdt.codan.core.cxx.internal.model.CxxCodanReconciler;
|
||||||
|
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
|
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +33,7 @@ import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CodanCReconciler implements ICReconcilingListener {
|
public class CodanCReconciler implements ICReconcilingListener {
|
||||||
private CxxCodanRenciler reconsiler = new CxxCodanRenciler();
|
private CxxCodanReconciler reconsiler = new CxxCodanReconciler();
|
||||||
|
|
||||||
void install(ITextEditor editor) {
|
void install(ITextEditor editor) {
|
||||||
if (editor instanceof CEditor) {
|
if (editor instanceof CEditor) {
|
||||||
|
@ -66,7 +77,22 @@ public class CodanCReconciler implements ICReconcilingListener {
|
||||||
*/
|
*/
|
||||||
public void reconciled(IASTTranslationUnit ast, boolean force,
|
public void reconciled(IASTTranslationUnit ast, boolean force,
|
||||||
IProgressMonitor progressMonitor) {
|
IProgressMonitor progressMonitor) {
|
||||||
reconsiler.reconciledAst(ast, progressMonitor);
|
if (ast == null)
|
||||||
// System.err.println("ast reconsiled");
|
return;
|
||||||
|
String filePath = ast.getFilePath();
|
||||||
|
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
IWorkspaceRoot root = workspace.getRoot();
|
||||||
|
IFile[] resources;
|
||||||
|
URI uri = new File(filePath).toURI();
|
||||||
|
resources = root.findFilesForLocationURI(uri);
|
||||||
|
if (resources != null && resources.length > 0) {
|
||||||
|
IFile resource = resources[0];
|
||||||
|
IProject project = resource.getProject();
|
||||||
|
IPreferenceStore store = CodanUIActivator.getDefault()
|
||||||
|
.getPreferenceStore(project);
|
||||||
|
if (store.getBoolean(PreferenceConstants.P_RUN_IN_EDITOR)) {
|
||||||
|
reconsiler.reconciledAst(ast, resource, progressMonitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
package org.eclipse.cdt.codan.internal.ui;
|
package org.eclipse.cdt.codan.internal.ui;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +21,7 @@ public class CodanUIActivator extends AbstractUIPlugin {
|
||||||
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.ui";
|
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.ui";
|
||||||
// The shared instance
|
// The shared instance
|
||||||
private static CodanUIActivator plugin;
|
private static CodanUIActivator plugin;
|
||||||
|
private IPreferenceStore preferenceCoreStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor
|
* The constructor
|
||||||
|
@ -95,4 +103,22 @@ public class CodanUIActivator extends AbstractUIPlugin {
|
||||||
public static void log(String message) {
|
public static void log(String message) {
|
||||||
log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null));
|
log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IPreferenceStore getCorePreferenceStore() {
|
||||||
|
if (preferenceCoreStore == null) {
|
||||||
|
preferenceCoreStore = new ScopedPreferenceStore(
|
||||||
|
new InstanceScope(), CodanCorePlugin.PLUGIN_ID);
|
||||||
|
}
|
||||||
|
return preferenceCoreStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPreferenceStore getPreferenceStore(IProject project) {
|
||||||
|
ProjectScope ps = new ProjectScope(project);
|
||||||
|
ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, PLUGIN_ID);
|
||||||
|
scoped.setSearchContexts(new IScopeContext[] { ps, new InstanceScope() });
|
||||||
|
return scoped;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
package org.eclipse.cdt.codan.internal.ui.preferences;
|
package org.eclipse.cdt.codan.internal.ui.preferences;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
|
||||||
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
||||||
|
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
||||||
import org.eclipse.cdt.codan.internal.ui.actions.ToggleNatureAction;
|
import org.eclipse.cdt.codan.internal.ui.actions.ToggleNatureAction;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
|
||||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.ui.IWorkbenchPropertyPage;
|
import org.eclipse.ui.IWorkbenchPropertyPage;
|
||||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
|
||||||
|
|
||||||
public class BuildPropertyPage extends FieldEditorPreferencePage implements
|
public class BuildPropertyPage extends FieldEditorPreferencePage implements
|
||||||
IWorkbenchPropertyPage {
|
IWorkbenchPropertyPage {
|
||||||
|
@ -21,8 +18,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public BuildPropertyPage() {
|
public BuildPropertyPage() {
|
||||||
setPreferenceStore(org.eclipse.cdt.codan.internal.ui.CodanUIActivator.getDefault()
|
setPreferenceStore(CodanUIActivator.getDefault().getPreferenceStore());
|
||||||
.getPreferenceStore());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -35,7 +31,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
|
||||||
@Override
|
@Override
|
||||||
protected void createFieldEditors() {
|
protected void createFieldEditors() {
|
||||||
addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD,
|
addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD,
|
||||||
"&Run with Build", getFieldEditorParent()));
|
"&Run with build", getFieldEditorParent()));
|
||||||
|
addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_IN_EDITOR,
|
||||||
|
"Run as you &type (selected checkers)", getFieldEditorParent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,7 +68,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
|
||||||
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
|
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
|
||||||
*/
|
*/
|
||||||
public IAdaptable getElement() {
|
public IAdaptable getElement() {
|
||||||
return element;
|
if (element.getAdapter(IProject.class) != null)
|
||||||
|
return (IProject) element.getAdapter(IProject.class);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -82,14 +82,12 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
|
||||||
*/
|
*/
|
||||||
public void setElement(IAdaptable element) {
|
public void setElement(IAdaptable element) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
ProjectScope ps = new ProjectScope((IProject) getElement());
|
if (getElement() != null) {
|
||||||
ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps,
|
IPreferenceStore scoped = CodanUIActivator.getDefault()
|
||||||
CodanCorePlugin.PLUGIN_ID);
|
.getPreferenceStore(((IProject) getElement()));
|
||||||
scoped
|
|
||||||
.setSearchContexts(new IScopeContext[] { ps,
|
|
||||||
new InstanceScope() });
|
|
||||||
setPreferenceStore(scoped);
|
setPreferenceStore(scoped);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected String getPageId() {
|
protected String getPageId() {
|
||||||
return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage";
|
return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage";
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.codan.internal.ui.preferences;
|
package org.eclipse.cdt.codan.internal.ui.preferences;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
||||||
|
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
|
||||||
|
@ -18,16 +19,16 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
* Class used to initialize default preference values.
|
* Class used to initialize default preference values.
|
||||||
*/
|
*/
|
||||||
public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
|
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
|
||||||
|
* initializeDefaultPreferences()
|
||||||
*/
|
*/
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
IPreferenceStore store = org.eclipse.cdt.codan.internal.ui.CodanUIActivator
|
IPreferenceStore store = CodanUIActivator.getDefault()
|
||||||
.getDefault().getPreferenceStore();
|
.getPreferenceStore();
|
||||||
store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false);
|
store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false);
|
||||||
|
store.setDefault(PreferenceConstants.P_RUN_IN_EDITOR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue