Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'codan/org.eclipse.cdt.codan.ui')
-rw-r--r--codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF3
-rw-r--r--codan/org.eclipse.cdt.codan.ui/plugin.xml4
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CheckerEnablementVerifier.java49
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java1
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties1
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java7
6 files changed, 63 insertions, 2 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
index 9517be08f7..d8980d5d46 100644
--- a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
+++ b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.cdt.ui,
org.eclipse.core.filesystem,
- org.eclipse.ui.console
+ org.eclipse.ui.console,
+ org.eclipse.ui.editors
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx",
diff --git a/codan/org.eclipse.cdt.codan.ui/plugin.xml b/codan/org.eclipse.cdt.codan.ui/plugin.xml
index 73de076654..9dbef631ff 100644
--- a/codan/org.eclipse.cdt.codan.ui/plugin.xml
+++ b/codan/org.eclipse.cdt.codan.ui/plugin.xml
@@ -238,4 +238,8 @@
</objectContribution>
</extension>
+ <extension
+ point="org.eclipse.cdt.codan.core.checkerEnablement">
+ <verifier class="org.eclipse.cdt.codan.internal.ui.CheckerEnablementVerifier" />
+ </extension>
</plugin>
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CheckerEnablementVerifier.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CheckerEnablementVerifier.java
new file mode 100644
index 0000000000..114456dc46
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CheckerEnablementVerifier.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alex Ruiz (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui;
+
+import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
+import org.eclipse.cdt.codan.core.model.IChecker;
+import org.eclipse.cdt.codan.internal.core.ICheckerEnablementVerifier;
+import org.eclipse.cdt.codan.ui.CodanEditorUtility;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.TextEditor;
+
+/**
+ * Default implementation of <code>{@link ICheckerEnablementVerifier}</code>.
+ */
+public class CheckerEnablementVerifier implements ICheckerEnablementVerifier {
+ @Override
+ public boolean isCheckerEnabled(IChecker checker, IResource resource, CheckerLaunchMode mode) {
+ if (mode != CheckerLaunchMode.RUN_ON_FILE_SAVE) {
+ return true;
+ }
+ for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
+ IWorkbenchPage page = window.getActivePage();
+ for (IEditorReference reference : page.getEditorReferences()) {
+ IEditorPart editor = reference.getEditor(false);
+ if (!CodanEditorUtility.isResourceOpenInEditor(resource, editor)) {
+ continue;
+ }
+ if (editor instanceof TextEditor) {
+ TextEditor textEditor = (TextEditor) editor;
+ return !textEditor.isDirty();
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
index 0ed0f2917c..cc8c5539b3 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
@@ -87,6 +87,7 @@ public class CodanUIMessages extends NLS {
public static String LaunchModesPropertyPage_RunOnDemand;
public static String LaunchModesPropertyPage_RunOnFullBuild;
public static String LaunchModesPropertyPage_RunOnIncrementalBuild;
+ public static String LaunchModesPropertyPage_RunOnFileSave;
static {
NLS.initializeMessages(CodanUIMessages.class.getName(), CodanUIMessages.class);
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties
index 2c02d8329c..414ab1e20e 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties
@@ -96,3 +96,4 @@ LaunchModesPropertyPage_RunAsYouType=Run as you type
LaunchModesPropertyPage_RunOnDemand=Run on demand
LaunchModesPropertyPage_RunOnFullBuild=Run on full build
LaunchModesPropertyPage_RunOnIncrementalBuild=Run on incremental build
+LaunchModesPropertyPage_RunOnFileSave=Run on file save or open
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java
index 380862d445..733f7c191c 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java
@@ -37,7 +37,11 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
super(GRID);
CheckersRegistry registry = CheckersRegistry.getInstance();
IChecker checker = registry.getCheckerForProblem(problem);
- runInEditor = (checker != null) ? Checkers.canCheckerRunAsYouType(checker) : false;
+ if (checker != null) {
+ runInEditor = Checkers.canCheckerRunAsYouType(checker);
+ } else {
+ runInEditor = false;
+ }
setPreferenceStore(prefStore);
editors = new ArrayList<FieldEditor>();
}
@@ -59,6 +63,7 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FULL_BUILD.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFullBuild, getFieldEditorParent()));
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_INC_BUILD.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnIncrementalBuild, getFieldEditorParent()));
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_DEMAND.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnDemand, getFieldEditorParent()));
+ addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FILE_SAVE.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFileSave, getFieldEditorParent()));
if (runInEditor) {
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_AS_YOU_TYPE.name(), CodanUIMessages.LaunchModesPropertyPage_RunAsYouType, getFieldEditorParent()));
}

Back to the top