Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java2
-rw-r--r--codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java87
2 files changed, 49 insertions, 40 deletions
diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java
index bfed0b3497..d8c76b9bd6 100644
--- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java
+++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/GrepCheckerHelpLink.java
@@ -14,7 +14,7 @@ import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
/**
- * Example of codan problem details provider for flexlint integration
+ * Example of codan problem details provider for string search integration
*/
public class GrepCheckerHelpLink extends AbstractCodanProblemDetailsProvider {
@Override
diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java
index e6b5050996..d5cef632fa 100644
--- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java
+++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/ProfileChangeListener.java
@@ -7,8 +7,7 @@
*
* Contributors:
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
- *******************************************************************************/
-
+ *******************************************************************************/
package org.eclipse.cdt.codan.examples.uicontrib;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
@@ -32,87 +31,97 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChange
* Example of property change listener for changing error profiles
*/
public class ProfileChangeListener implements INodeChangeListener, IPreferenceChangeListener, IProblemProfileChangeListener {
-
- static ProfileChangeListener instance = new ProfileChangeListener();
-
- public static ProfileChangeListener getInstance(){
+ static ProfileChangeListener instance;
+
+ public static ProfileChangeListener getInstance() {
+ if (instance == null)
+ instance = new ProfileChangeListener();
return instance;
}
private IProject project;
+
private ProfileChangeListener(IProject project) {
this.project = project;
}
+
private ProfileChangeListener() {
CodanCorePlugin.getDefault().getStorePreferences().addNodeChangeListener(this);
CodanCorePlugin.getDefault().getStorePreferences().addPreferenceChangeListener(this);
- IWorkspace root = ResourcesPlugin.getWorkspace();
- IProject[] projects = root.getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
+ IWorkspace root = ResourcesPlugin.getWorkspace();
+ IProject[] projects = root.getRoot().getProjects();
+ for (int i = 0; i < projects.length; i++) {
IProject project = projects[i];
IEclipsePreferences prefs = CodanPreferencesLoader.getProjectNode(project);
if (prefs != null)
prefs.addPreferenceChangeListener(new ProfileChangeListener(project));
}
- // cannot do on plugin startup
- // CheckersRegistry.getInstance().getWorkspaceProfile().addProfileChangeListener(this);
+ // cannot do on plugin startup
+ // CheckersRegistry.getInstance().getWorkspaceProfile().addProfileChangeListener(this);
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
- */
public void preferenceChange(PreferenceChangeEvent event) {
if (event.getSource() instanceof IEclipsePreferences) {
- IEclipsePreferences ep = (IEclipsePreferences) event.getSource();
- if (project!=null) {
-
- if (GrepChecker.ID.equals(event.getKey())) {
- // severity or enablement has changed
- String val = (String) event.getNewValue();
- if (!val.startsWith("-")) {
- System.err.println("grep checker enabled!");
- }
+ //IEclipsePreferences ep = (IEclipsePreferences) event.getSource();
+ if (GrepChecker.ID.equals(event.getKey())) {
+ // severity or enablement has changed
+ String val = (String) event.getNewValue();
+ if (!val.startsWith("-")) {
+ System.err.print("grep checker enabled :)");
+ } else {
+ System.err.print("grep checker disabled :(");
}
-
+ System.err.println(" for "+((project==null)?"workspace":project.getName()));
}
}
-
-
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener
+ * #added(org.eclipse.core.runtime.preferences.IEclipsePreferences.
+ * NodeChangeEvent)
*/
public void added(NodeChangeEvent event) {
- System.err.println("node added "+event);
-
+ System.err.println("node added " + event);
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener
+ * #removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.
+ * NodeChangeEvent)
*/
public void removed(NodeChangeEvent event) {
- // TODO Auto-generated method stub
-
+ System.err.println("node removed " + event);
}
+
/**
*
*/
public void dispose() {
CodanCorePlugin.getDefault().getStorePreferences().removeNodeChangeListener(this);
CodanCorePlugin.getDefault().getStorePreferences().removePreferenceChangeListener(this);
-
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.codan.internal.core.CheckersRegistry.IProblemProfileChangeListener#profileChange(org.eclipse.cdt.codan.internal.core.CheckersRegistry.ProblemProfileChangeEvent)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.codan.internal.core.CheckersRegistry.
+ * IProblemProfileChangeListener
+ * #profileChange(org.eclipse.cdt.codan.internal
+ * .core.CheckersRegistry.ProblemProfileChangeEvent)
*/
public void profileChange(ProblemProfileChangeEvent event) {
if (event.getKey().equals(ProblemProfileChangeEvent.PROBLEM_KEY)) {
IResource resource = (IResource) event.getSource();
IProblemProfile profile = (IProblemProfile) event.getNewValue();
IProblem pp = profile.findProblem(GrepChecker.ID);
- System.err.println(pp.getName() + " enabled "+ pp.isEnabled());
+ System.err.println(pp.getName() + " enabled " + pp.isEnabled());
}
-
}
}

Back to the top