1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

refactored per-problem launch mode: ui controls, internal structures, etc

This commit is contained in:
Alena Laskavaia 2011-02-28 04:43:38 +00:00
parent 3992f87dc4
commit 6179bd2262
15 changed files with 230 additions and 229 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009,2010 Alena Laskavaia * Copyright (c) 2009,2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,13 +13,13 @@ package org.eclipse.cdt.codan.core.model;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.codan.core.param.AbstractProblemPreference;
import org.eclipse.cdt.codan.core.param.BasicProblemPreference; import org.eclipse.cdt.codan.core.param.BasicProblemPreference;
import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference; import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType; import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType;
import org.eclipse.cdt.codan.core.param.ListProblemPreference; import org.eclipse.cdt.codan.core.param.ListProblemPreference;
import org.eclipse.cdt.codan.core.param.MapProblemPreference; import org.eclipse.cdt.codan.core.param.MapProblemPreference;
import org.eclipse.cdt.codan.core.param.RootProblemPreference;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -34,20 +34,18 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
* Checker that actually has parameter must override this * Checker that actually has parameter must override this
*/ */
public void initPreferences(IProblemWorkingCopy problem) { public void initPreferences(IProblemWorkingCopy problem) {
// by default add file scope preference getTopLevelPreference(problem); // initialize
addPreference(problem, new FileScopeProblemPreference(), null);
} }
/** /**
* Scope preference - special preference that all file checkers should have, * Scope preference - special preference that all file checkers should have,
* it allows user to include/exclude files for this specific problem. * it allows user to include/exclude files for this specific problem.
* *
* @param problem - problem for which scope preference is need * @param problem - problem for which scope preference is need
* @return scope problem preference, null if not defined * @return scope problem preference, null if not defined
*/ */
public FileScopeProblemPreference getScopePreference(IProblem problem) { public FileScopeProblemPreference getScopePreference(IProblem problem) {
FileScopeProblemPreference scope = (FileScopeProblemPreference) getTopLevelPreferenceMap(problem).getChildDescriptor( FileScopeProblemPreference scope = getTopLevelPreference(problem).getScopePreference();
FileScopeProblemPreference.KEY);
return scope; return scope;
} }
@ -57,7 +55,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
* be done within processResource method not in enabledInContext. * be done within processResource method not in enabledInContext.
* This test uses user "scope" preference for the all problems that this * This test uses user "scope" preference for the all problems that this
* checker can produce. * checker can produce.
* *
* @param res - resource to test on * @param res - resource to test on
* @return true if checker should report problems, fails otherwise. * @return true if checker should report problems, fails otherwise.
*/ */
@ -79,10 +77,10 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
* before printing of a problem. * before printing of a problem.
* This test uses user "scope" preference for the given problem. If scope is * This test uses user "scope" preference for the given problem. If scope is
* not defined preference it returns true. * not defined preference it returns true.
* *
* @param problem - problem to test for * @param problem - problem to test for
* @param resource - resource to test on * @param resource - resource to test on
* *
* @return true if problem should be report for given resource, fails * @return true if problem should be report for given resource, fails
* otherwise. * otherwise.
*/ */
@ -101,7 +99,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
/** /**
* Add a parameter * Add a parameter
* *
* @param problem * @param problem
* - problem that has parameter * - problem that has parameter
* @param key * @param key
@ -113,7 +111,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
* @return - parameter info object * @return - parameter info object
*/ */
public IProblemPreference addPreference(IProblemWorkingCopy problem, String key, String label, Object defaultValue) { public IProblemPreference addPreference(IProblemWorkingCopy problem, String key, String label, Object defaultValue) {
MapProblemPreference map = getTopLevelPreferenceMap(problem); MapProblemPreference map = getTopLevelPreference(problem);
BasicProblemPreference info = new BasicProblemPreference(key, label, PreferenceType.typeOf(defaultValue)); BasicProblemPreference info = new BasicProblemPreference(key, label, PreferenceType.typeOf(defaultValue));
map.addChildDescriptor(info); map.addChildDescriptor(info);
setDefaultPreferenceValue(problem, key, defaultValue); setDefaultPreferenceValue(problem, key, defaultValue);
@ -123,7 +121,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
/** /**
* Add preference of type list of strings, list is empty by * Add preference of type list of strings, list is empty by
* default * default
* *
* @param problem * @param problem
* - problem * - problem
* @param key * @param key
@ -133,10 +131,10 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
* @param itemLabel * @param itemLabel
* @return preference instance of of the list, can be used to add default * @return preference instance of of the list, can be used to add default
* values or set different element type * values or set different element type
* *
*/ */
public ListProblemPreference addListPreference(IProblemWorkingCopy problem, String key, String label, String itemLabel) { public ListProblemPreference addListPreference(IProblemWorkingCopy problem, String key, String label, String itemLabel) {
MapProblemPreference map = getTopLevelPreferenceMap(problem); MapProblemPreference map = getTopLevelPreference(problem);
ListProblemPreference list = new ListProblemPreference(key, label); ListProblemPreference list = new ListProblemPreference(key, label);
list.setChildDescriptor(new BasicProblemPreference(ListProblemPreference.COMMON_DESCRIPTOR_KEY, itemLabel, list.setChildDescriptor(new BasicProblemPreference(ListProblemPreference.COMMON_DESCRIPTOR_KEY, itemLabel,
PreferenceType.TYPE_STRING)); PreferenceType.TYPE_STRING));
@ -145,14 +143,14 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
/** /**
* Add preference for the given problem with default value * Add preference for the given problem with default value
* *
* @param problem * @param problem
* @param pref - preference * @param pref - preference
* @param defaultValue - default value of the preference * @param defaultValue - default value of the preference
* @return added preference * @return added preference
*/ */
public IProblemPreference addPreference(IProblemWorkingCopy problem, IProblemPreference pref, Object defaultValue) { public IProblemPreference addPreference(IProblemWorkingCopy problem, IProblemPreference pref, Object defaultValue) {
MapProblemPreference map = getTopLevelPreferenceMap(problem); MapProblemPreference map = getTopLevelPreference(problem);
String key = pref.getKey(); String key = pref.getKey();
pref = map.addChildDescriptor(pref); pref = map.addChildDescriptor(pref);
setDefaultPreferenceValue(problem, key, defaultValue); setDefaultPreferenceValue(problem, key, defaultValue);
@ -162,13 +160,13 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
/** /**
* Convenience method for setting default preference value for checker that * Convenience method for setting default preference value for checker that
* uses "map" as top level problem preference. * uses "map" as top level problem preference.
* *
* @param problem - problem for which to set default value for a prefence * @param problem - problem for which to set default value for a prefence
* @param key - preference key * @param key - preference key
* @param defaultValue - value of preference to be set * @param defaultValue - value of preference to be set
*/ */
protected void setDefaultPreferenceValue(IProblemWorkingCopy problem, String key, Object defaultValue) { protected void setDefaultPreferenceValue(IProblemWorkingCopy problem, String key, Object defaultValue) {
MapProblemPreference map = getTopLevelPreferenceMap(problem); MapProblemPreference map = getTopLevelPreference(problem);
if (map.getChildValue(key) == null) if (map.getChildValue(key) == null)
map.setChildValue(key, defaultValue); map.setChildValue(key, defaultValue);
} }
@ -179,14 +177,15 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
* If top level preference does not exist create a map preference with name * If top level preference does not exist create a map preference with name
* "params" * "params"
* and return it. * and return it.
* *
* @param problem * @param problem
* @return top level preference if it is a map * @return top level preference if it is a map
* @since 2.0
*/ */
protected MapProblemPreference getTopLevelPreferenceMap(IProblem problem) { public RootProblemPreference getTopLevelPreference(IProblem problem) {
MapProblemPreference map = (MapProblemPreference) problem.getPreference(); RootProblemPreference map = (RootProblemPreference) problem.getPreference();
if (map == null) { if (map == null) {
map = new MapProblemPreference(AbstractProblemPreference.PARAM, ""); //$NON-NLS-1$ map = new RootProblemPreference();
if (problem instanceof IProblemWorkingCopy) { if (problem instanceof IProblemWorkingCopy) {
((IProblemWorkingCopy) problem).setPreference(map); ((IProblemWorkingCopy) problem).setPreference(map);
} }
@ -197,7 +196,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
/** /**
* Returns value of the preference for the key in the top level * Returns value of the preference for the key in the top level
* preference map for the given problem * preference map for the given problem
* *
* @param problem - problem for which to get the preference * @param problem - problem for which to get the preference
* @param key - preference key * @param key - preference key
* @return value of the preference * @return value of the preference

View file

@ -11,10 +11,6 @@ package org.eclipse.cdt.codan.core.model;
* @since 2.0 * @since 2.0
*/ */
public enum CheckerLaunchMode { public enum CheckerLaunchMode {
/**
* use parent settings
*/
USE_PARENT,
/** /**
* checker run when full build is running * checker run when full build is running
*/ */

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Alena Laskavaia * Copyright (c) 2009, 2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -18,7 +18,7 @@ import java.io.StreamTokenizer;
/** /**
* Default implementation of problem preference. It keeps preference metadata * Default implementation of problem preference. It keeps preference metadata
* together with preference value. Some implementations may separate them. * together with preference value. Some implementations may separate them.
* *
*/ */
public abstract class AbstractProblemPreference implements IProblemPreference { public abstract class AbstractProblemPreference implements IProblemPreference {
/** /**
@ -49,7 +49,7 @@ public abstract class AbstractProblemPreference implements IProblemPreference {
/** /**
* Set preference key for itself * Set preference key for itself
* *
* @param key * @param key
*/ */
public void setKey(String key) { public void setKey(String key) {
@ -77,7 +77,7 @@ public abstract class AbstractProblemPreference implements IProblemPreference {
/** /**
* Sets a label for UI control * Sets a label for UI control
* *
* @param label * @param label
*/ */
public void setLabel(String label) { public void setLabel(String label) {
@ -88,7 +88,7 @@ public abstract class AbstractProblemPreference implements IProblemPreference {
/** /**
* Sets tooltip for ui control. Not supported now. * Sets tooltip for ui control. Not supported now.
* *
* @param tooltip * @param tooltip
*/ */
public void setToolTip(String tooltip) { public void setToolTip(String tooltip) {
@ -97,7 +97,7 @@ public abstract class AbstractProblemPreference implements IProblemPreference {
/** /**
* Sets uiinfo for ui control. Not supported now. * Sets uiinfo for ui control. Not supported now.
* *
* @param uiinfo * @param uiinfo
*/ */
public void setUiInfo(String uiinfo) { public void setUiInfo(String uiinfo) {
@ -196,4 +196,12 @@ public abstract class AbstractProblemPreference implements IProblemPreference {
String sval = tokenizer.sval; String sval = tokenizer.sval;
return sval; return sval;
} }
/**
* @return true when value if default (usually don't require storage in this case)
* @since 2.0
*/
public boolean isDefault(){
return false;
}
} }

View file

@ -28,7 +28,7 @@ import org.eclipse.core.runtime.Path;
/** /**
* Custom preference for resource scope * Custom preference for resource scope
* *
* @noextend This class is not intended to be extended by clients. * @noextend This class is not intended to be extended by clients.
* @since 1.0 * @since 1.0
*/ */
@ -63,7 +63,7 @@ public class FileScopeProblemPreference extends AbstractProblemPreference {
/** /**
* Get attribute. Possible keys are EXCUSION and INCLUSION * Get attribute. Possible keys are EXCUSION and INCLUSION
* *
* @param key * @param key
* @return class attribute for given key * @return class attribute for given key
*/ */
@ -77,7 +77,7 @@ public class FileScopeProblemPreference extends AbstractProblemPreference {
/** /**
* Set attribute to a value. Possible keys are EXCUSION and INCLUSION * Set attribute to a value. Possible keys are EXCUSION and INCLUSION
* *
* @param key * @param key
* @param value * @param value
*/ */
@ -124,6 +124,12 @@ public class FileScopeProblemPreference extends AbstractProblemPreference {
return resource; return resource;
} }
@Override
public boolean isDefault(){
if (inclusion.length==0 && exclusion.length==0)
return true;
return false;
}
public String exportValue() { public String exportValue() {
return exportPathList(INCLUSION, inclusion) + "," //$NON-NLS-1$ return exportPathList(INCLUSION, inclusion) + "," //$NON-NLS-1$
+ exportPathList(EXCLUSION, exclusion); + exportPathList(EXCLUSION, exclusion);
@ -209,7 +215,7 @@ public class FileScopeProblemPreference extends AbstractProblemPreference {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.codan.core.param.AbstractProblemPreference#clone() * @see org.eclipse.cdt.codan.core.param.AbstractProblemPreference#clone()
*/ */
@Override @Override
@ -224,7 +230,7 @@ public class FileScopeProblemPreference extends AbstractProblemPreference {
* exclusion/inclusion settings of this class). In inclusion list is defined * exclusion/inclusion settings of this class). In inclusion list is defined
* check first if it belongs to it, returns false if not. * check first if it belongs to it, returns false if not.
* Then checks if it belongs to exclusion list and return false if it is. * Then checks if it belongs to exclusion list and return false if it is.
* *
* @param path * @param path
* - resource path * - resource path
* @return true is given path is in scope * @return true is given path is in scope
@ -244,7 +250,7 @@ public class FileScopeProblemPreference extends AbstractProblemPreference {
/** /**
* Checks that given path matches on the paths provided as second argument * Checks that given path matches on the paths provided as second argument
* *
* @param resourcePath - resource path * @param resourcePath - resource path
* @param paths - array of path patterns, for pattern see * @param paths - array of path patterns, for pattern see
* {@link CharOperation#pathMatch} * {@link CharOperation#pathMatch}

View file

@ -10,6 +10,9 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.param; package org.eclipse.cdt.codan.core.param;
import java.io.IOException;
import java.io.StreamTokenizer;
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode; import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
/** /**
@ -17,7 +20,7 @@ import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
* *
* @since 2.0 * @since 2.0
*/ */
public class LaunchTypeProblemPreference extends MapProblemPreference { public class LaunchModeProblemPreference extends MapProblemPreference {
/** /**
* Propery key * Propery key
*/ */
@ -31,23 +34,34 @@ public class LaunchTypeProblemPreference extends MapProblemPreference {
/** /**
* constructor * constructor
*/ */
public LaunchTypeProblemPreference() { public LaunchModeProblemPreference() {
CheckerLaunchMode[] values = CheckerLaunchMode.values();
for (int i = 0; i < values.length; i++) {
CheckerLaunchMode checkerLaunchMode = values[i];
BasicProblemPreference desc = new BasicProblemPreference(checkerLaunchMode.name(), checkerLaunchMode.name(),
PreferenceType.TYPE_BOOLEAN);
IProblemPreference desc1 = addChildDescriptor(desc);
if (checkerLaunchMode == CheckerLaunchMode.USE_PARENT)
desc1.setValue(Boolean.TRUE);
}
} }
/** /**
* @return true if property is set to use parent mode * @return true if values has not been set
*/ */
public boolean isUsingParent() { @Override
return isRunningInMode(CheckerLaunchMode.USE_PARENT); public boolean isDefault(){
CheckerLaunchMode[] values = CheckerLaunchMode.values();
for (int i = 0; i < values.length; i++) {
CheckerLaunchMode checkerLaunchMode = values[i];
if (getChildDescriptor(checkerLaunchMode.name())!=null) return false;
}
return true;
}
/**
* @param checkerLaunchMode - launch mode
* @param value - value to set for the mode
* @return preference
*/
public IProblemPreference addLaunchMode(CheckerLaunchMode checkerLaunchMode, boolean value) {
BasicProblemPreference desc = new BasicProblemPreference(checkerLaunchMode.name(), checkerLaunchMode.name(),
PreferenceType.TYPE_BOOLEAN);
IProblemPreference desc1 = addChildDescriptor(desc);
desc1.setValue(value);
return desc1;
} }
/** /**
@ -55,12 +69,15 @@ public class LaunchTypeProblemPreference extends MapProblemPreference {
* @return true if this mode enabled for this preference * @return true if this mode enabled for this preference
*/ */
public boolean isRunningInMode(CheckerLaunchMode mode) { public boolean isRunningInMode(CheckerLaunchMode mode) {
if (getChildDescriptor(mode.name())==null) {
if (mode == CheckerLaunchMode.RUN_ON_INC_BUILD)
return isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD);
return true; // default is true
}
Object value = getChildValue(mode.name()); Object value = getChildValue(mode.name());
if (value instanceof Boolean) { if (value instanceof Boolean) {
return (Boolean) value; return (Boolean) value;
} }
if (mode == CheckerLaunchMode.USE_PARENT && value == null)
return true;
return false; return false;
} }
@ -69,7 +86,11 @@ public class LaunchTypeProblemPreference extends MapProblemPreference {
* @param value * @param value
*/ */
public void setRunningMode(CheckerLaunchMode mode, boolean value) { public void setRunningMode(CheckerLaunchMode mode, boolean value) {
setChildValue(mode.name(), value); if (getChildDescriptor(mode.name()) == null) {
addLaunchMode(mode, value);
} else {
setChildValue(mode.name(), value);
}
} }
/** /**
@ -79,6 +100,7 @@ public class LaunchTypeProblemPreference extends MapProblemPreference {
return isRunningInMode(CheckerLaunchMode.RUN_AS_YOU_TYPE) && isRunningInMode(CheckerLaunchMode.RUN_ON_DEMAND) return isRunningInMode(CheckerLaunchMode.RUN_AS_YOU_TYPE) && isRunningInMode(CheckerLaunchMode.RUN_ON_DEMAND)
&& isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD); && isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD);
} }
/** /**
* @return true if all modes are disabled * @return true if all modes are disabled
*/ */
@ -86,4 +108,20 @@ public class LaunchTypeProblemPreference extends MapProblemPreference {
return !isRunningInMode(CheckerLaunchMode.RUN_AS_YOU_TYPE) && !isRunningInMode(CheckerLaunchMode.RUN_ON_DEMAND) return !isRunningInMode(CheckerLaunchMode.RUN_AS_YOU_TYPE) && !isRunningInMode(CheckerLaunchMode.RUN_ON_DEMAND)
&& !isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD); && !isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD);
} }
@Override
protected IProblemPreference importChildValue(String key, StreamTokenizer tokenizer) throws IOException {
IProblemPreference desc = getChildDescriptor(key);
if (desc==null) {
CheckerLaunchMode mode = CheckerLaunchMode.valueOf(key);
if (mode==null)
throw new IllegalArgumentException(key);
desc = addLaunchMode(mode, true);
}
if (desc != null && desc instanceof AbstractProblemPreference) {
((AbstractProblemPreference) desc).importValue(tokenizer);
setChildValue(key, desc.getValue());
}
return desc;
}
} }

View file

@ -27,7 +27,7 @@ import org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences;
* "check setters". In this case you use this type. * "check setters". In this case you use this type.
* {@link AbstractCheckerWithProblemPreferences} class has map as default top * {@link AbstractCheckerWithProblemPreferences} class has map as default top
* level parameter preference. * level parameter preference.
* *
* @noextend This class is not intended to be extended by clients. * @noextend This class is not intended to be extended by clients.
*/ */
public class MapProblemPreference extends AbstractProblemPreference implements IProblemPreferenceCompositeValue, public class MapProblemPreference extends AbstractProblemPreference implements IProblemPreferenceCompositeValue,
@ -58,7 +58,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
/** /**
* Get parameter preference for element by key * Get parameter preference for element by key
* *
*/ */
public IProblemPreference getChildDescriptor(String key) { public IProblemPreference getChildDescriptor(String key) {
return hash.get(key); return hash.get(key);
@ -68,7 +68,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
* Adds or replaces child descriptor and value for the element with the key * Adds or replaces child descriptor and value for the element with the key
* equals to desc.getKey(). The desc object would be put in the map, some of * equals to desc.getKey(). The desc object would be put in the map, some of
* its field may be modified. * its field may be modified.
* *
* @param desc * @param desc
*/ */
public IProblemPreference addChildDescriptor(IProblemPreference desc) { public IProblemPreference addChildDescriptor(IProblemPreference desc) {
@ -130,6 +130,11 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
for (Iterator<String> iterator = hash.keySet().iterator(); iterator.hasNext();) { for (Iterator<String> iterator = hash.keySet().iterator(); iterator.hasNext();) {
String key = iterator.next(); String key = iterator.next();
IProblemPreference d = hash.get(key); IProblemPreference d = hash.get(key);
if (d instanceof AbstractProblemPreference) {
if (((AbstractProblemPreference) d).isDefault()) {
continue;
}
}
buf.append(key + "=>" + d.exportValue()); //$NON-NLS-1$ buf.append(key + "=>" + d.exportValue()); //$NON-NLS-1$
if (iterator.hasNext()) if (iterator.hasNext())
buf.append(","); //$NON-NLS-1$ buf.append(","); //$NON-NLS-1$
@ -160,6 +165,8 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
} }
while (true) { while (true) {
token = tokenizer.nextToken(); token = tokenizer.nextToken();
if (token == '}')
break;
String key = tokenizer.sval; String key = tokenizer.sval;
token = tokenizer.nextToken(); token = tokenizer.nextToken();
if (token != '=') if (token != '=')
@ -167,15 +174,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
token = tokenizer.nextToken(); token = tokenizer.nextToken();
if (token != '>') if (token != '>')
throw new IllegalArgumentException(String.valueOf((char) token)); throw new IllegalArgumentException(String.valueOf((char) token));
IProblemPreference desc = getChildDescriptor(key); importChildValue(key, tokenizer);
if (desc == null && LaunchTypeProblemPreference.KEY.equals(key)) {
desc = new LaunchTypeProblemPreference();
addChildDescriptor(desc);
}
if (desc != null && desc instanceof AbstractProblemPreference) {
((AbstractProblemPreference) desc).importValue(tokenizer);
setChildValue(key, desc.getValue());
}
token = tokenizer.nextToken(); token = tokenizer.nextToken();
if (token == '}') if (token == '}')
break; break;
@ -187,6 +186,22 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
} }
} }
/**
* @param key
* @param tokenizer
* @return
* @throws IOException
* @since 2.0
*/
protected IProblemPreference importChildValue(String key, StreamTokenizer tokenizer) throws IOException {
IProblemPreference desc = getChildDescriptor(key);
if (desc != null && desc instanceof AbstractProblemPreference) {
((AbstractProblemPreference) desc).importValue(tokenizer);
setChildValue(key, desc.getValue());
}
return desc;
}
/** /**
* Removes child descriptor by its key * Removes child descriptor by its key
*/ */
@ -233,7 +248,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
* this map would be removed. * this map would be removed.
* Preference descriptors for the keys must be set before calling this * Preference descriptors for the keys must be set before calling this
* method, unless value if instanceof {@link IProblemPreference}. * method, unless value if instanceof {@link IProblemPreference}.
* *
* @param value - must be Map<String,Object> * @param value - must be Map<String,Object>
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2009,2010 QNX Software Systems
* 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:
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.core.param;
/**
* Common problem preference root for most of the codan problems
*
* @noextend This class is not intended to be extended by clients.
* @since 2.0
*/
public class RootProblemPreference extends MapProblemPreference {
/**
* name of top level preference
*/
public static final String KEY = PARAM;
/**
* Default constructor
*/
public RootProblemPreference() {
super(KEY, ""); //$NON-NLS-1$
addChildDescriptor(new FileScopeProblemPreference());
addChildDescriptor(new LaunchModeProblemPreference());
}
/**
* @return scope preference
*/
public FileScopeProblemPreference getScopePreference() {
return (FileScopeProblemPreference) getChildDescriptor(
FileScopeProblemPreference.KEY);
}
/**
* @return launch mode
*/
public LaunchModeProblemPreference getLaunchModePreference() {
return (LaunchModeProblemPreference) getChildDescriptor(LaunchModeProblemPreference.KEY);
}
}

View file

@ -27,9 +27,8 @@ import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemCategory; import org.eclipse.cdt.codan.core.model.IProblemCategory;
import org.eclipse.cdt.codan.core.model.IProblemProfile; import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy; import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference;
import org.eclipse.cdt.codan.core.param.LaunchTypeProblemPreference; import org.eclipse.cdt.codan.core.param.RootProblemPreference;
import org.eclipse.cdt.codan.core.param.MapProblemPreference;
import org.eclipse.cdt.codan.internal.core.model.CodanProblem; import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory; 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;
@ -443,13 +442,11 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
if (problem == null) if (problem == null)
throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$ throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
if (checker instanceof AbstractCheckerWithProblemPreferences) { if (checker instanceof AbstractCheckerWithProblemPreferences) {
MapProblemPreference map = (MapProblemPreference) problem.getPreference(); RootProblemPreference root = ((AbstractCheckerWithProblemPreferences)checker).getTopLevelPreference(problem);
IProblemPreference pref1 = map.getChildDescriptor(LaunchTypeProblemPreference.KEY);
LaunchTypeProblemPreference pref = (LaunchTypeProblemPreference) pref1; LaunchModeProblemPreference pref = root.getLaunchModePreference();
if (pref == null || pref.isRunningInMode(CheckerLaunchMode.USE_PARENT)) { // XXX: how to set defaults
enabled = true;
break;
}
if (pref.isRunningInMode(mode)) { if (pref.isRunningInMode(mode)) {
enabled = true; enabled = true;
break; break;

View file

@ -72,7 +72,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
@ -90,6 +90,8 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable {
} }
public void setPreference(IProblemPreference value) { public void setPreference(IProblemPreference value) {
if (value==null)
throw new NullPointerException();
preference = value; preference = value;
} }
@ -99,7 +101,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.codan.core.model.IProblem#getMessagePattern() * @see org.eclipse.cdt.codan.core.model.IProblem#getMessagePattern()
*/ */
public String getMessagePattern() { public String getMessagePattern() {
@ -126,7 +128,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.codan.core.model.IProblem#getDescription() * @see org.eclipse.cdt.codan.core.model.IProblem#getDescription()
*/ */
public String getDescription() { public String getDescription() {
@ -135,7 +137,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.eclipse.cdt.codan.core.model.IProblemWorkingCopy#setDescription(java * org.eclipse.cdt.codan.core.model.IProblemWorkingCopy#setDescription(java
* .lang.String) * .lang.String)
@ -146,7 +148,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.codan.core.model.IProblem#getMarkerType() * @see org.eclipse.cdt.codan.core.model.IProblem#getMarkerType()
*/ */
public String getMarkerType() { public String getMarkerType() {
@ -155,7 +157,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable {
/** /**
* Sets the marker id for the problem. * Sets the marker id for the problem.
* *
* @param markerType * @param markerType
*/ */
public void setMarkerType(String markerType) { public void setMarkerType(String markerType) {

View file

@ -1,8 +1,12 @@
#Wed Feb 23 19:44:07 EST 2011 #Sun Feb 27 22:29:21 EST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.autoboxing=ignore

View file

@ -1,4 +1,4 @@
#Wed Feb 23 19:44:07 EST 2011 #Sun Feb 27 22:29:21 EST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Eclipse [built-in] - Alena formatter_profile=_Eclipse [built-in] - Alena
@ -18,7 +18,7 @@ sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=false sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false sp_cleanup.make_parameters_final=false

View file

@ -11,29 +11,15 @@
package org.eclipse.cdt.codan.internal.ui.preferences; package org.eclipse.cdt.codan.internal.ui.preferences;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode; import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.PreferenceStore; import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
public class LaunchModesPropertyPage extends FieldEditorPreferencePage { public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
private Button useParentSettingsButton;
private Button useLocalSettingsButton;
private Button configureButton;
private ArrayList<FieldEditor> editors; private ArrayList<FieldEditor> editors;
private Group useLocalGroup;
/** /**
* @param prefStore * @param prefStore
@ -59,11 +45,10 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
*/ */
@Override @Override
protected void createFieldEditors() { protected void createFieldEditors() {
createSelectionGroup(getFieldEditorParent()); addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FULL_BUILD.name(), "Run on full build", getFieldEditorParent()));
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FULL_BUILD.name(), "Run on full build", useLocalGroup)); addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_INC_BUILD.name(), "Run on incremental build", getFieldEditorParent()));
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_DEMAND.name(), "Run on demand", useLocalGroup)); addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_DEMAND.name(), "Run on demand", getFieldEditorParent()));
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_AS_YOU_TYPE.name(), "Run as you type", useLocalGroup)); addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_AS_YOU_TYPE.name(), "Run as you type", getFieldEditorParent()));
updateFieldEditors();
} }
/* /*
@ -79,56 +64,6 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
super.addField(editor); super.addField(editor);
} }
/**
* Creates and initializes a selection group with two choice buttons and one
* push button.
*
* @param parent
* - the parent composite
*/
private void createSelectionGroup(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
comp.setLayout(layout);
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite radioGroup = new Composite(comp, SWT.NONE);
radioGroup.setLayout(new GridLayout(2, false));
radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
useParentSettingsButton = createRadioButton(radioGroup, CodanUIMessages.OverlayPage_Use_Project_Settings);
configureButton = new Button(radioGroup, SWT.PUSH);
configureButton.setText("Configure...");
configureButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
configureProjectSettings();
}
});
useLocalSettingsButton = createRadioButton(radioGroup, "Use checker specific settings");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
useLocalSettingsButton.setLayoutData(gd);
// Set workspace/project radio buttons
try {
Boolean useParent = getPreferenceStore().getBoolean(CheckerLaunchMode.USE_PARENT.name());
if (useParent) {
useParentSettingsButton.setSelection(true);
} else {
useLocalSettingsButton.setSelection(true);
configureButton.setEnabled(false);
}
} catch (Exception e) {
useParentSettingsButton.setSelection(true);
}
useLocalGroup = new Group(radioGroup, SWT.NONE);
GridLayout layout2 = new GridLayout(2, false);
useLocalGroup.setLayout(layout2);
GridData gd2 = new GridData(GridData.FILL_BOTH);
gd2.horizontalSpan = 2;
useLocalGroup.setLayoutData(gd2);
}
/** /**
* *
*/ */
@ -136,52 +71,6 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/**
* Convenience method creating a radio button
*
* @param parent
* - the parent composite
* @param label
* - the button label
* @return - the new button
*/
private Button createRadioButton(Composite parent, String label) {
final Button button = new Button(parent, SWT.RADIO);
button.setText(label);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean useParent = button == useParentSettingsButton;
configureButton.setEnabled(useParent);
getPreferenceStore().setValue(CheckerLaunchMode.USE_PARENT.name(), useParent);
updateFieldEditors();
}
});
return button;
}
private void updateFieldEditors() {
// We iterate through all field editors
boolean enabled = useLocalSettingsButton.getSelection();
updateFieldEditors(enabled);
}
/**
* Enables or disables the field editors and buttons of this page Subclasses
* may override.
*
* @param enabled
* - true if enabled
*/
protected void updateFieldEditors(boolean enabled) {
Composite parent = useLocalGroup;
Iterator it = editors.iterator();
while (it.hasNext()) {
FieldEditor editor = (FieldEditor) it.next();
editor.setEnabled(enabled, parent);
}
}
@Override @Override
public boolean performOk() { public boolean performOk() {
boolean result = super.performOk(); boolean result = super.performOk();

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.codan.internal.ui.preferences;
import java.text.MessageFormat; import java.text.MessageFormat;
import org.eclipse.cdt.codan.core.PreferenceConstants; import org.eclipse.cdt.codan.core.PreferenceConstants;
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
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.IProblemCategory; import org.eclipse.cdt.codan.core.model.IProblemCategory;
@ -21,8 +20,8 @@ import org.eclipse.cdt.codan.core.model.IProblemElement;
import org.eclipse.cdt.codan.core.model.IProblemProfile; import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy; import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.param.LaunchTypeProblemPreference; import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference;
import org.eclipse.cdt.codan.core.param.MapProblemPreference; import org.eclipse.cdt.codan.core.param.RootProblemPreference;
import org.eclipse.cdt.codan.internal.core.CodanPreferencesLoader; import org.eclipse.cdt.codan.internal.core.CodanPreferencesLoader;
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages; import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
@ -91,16 +90,17 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
if (element instanceof IProblem) { if (element instanceof IProblem) {
IProblem p = (IProblem) element; IProblem p = (IProblem) element;
IProblemPreference preference = p.getPreference(); IProblemPreference preference = p.getPreference();
if (preference instanceof MapProblemPreference) { if (preference instanceof RootProblemPreference) {
LaunchTypeProblemPreference pref = (LaunchTypeProblemPreference) ((MapProblemPreference) preference) LaunchModeProblemPreference pref = ((RootProblemPreference) preference).getLaunchModePreference();
.getChildDescriptor(LaunchTypeProblemPreference.KEY); if (pref == null) {
if (pref == null || pref.isRunningInMode(CheckerLaunchMode.USE_PARENT)) {
return false; return false;
} }
boolean enabled = p.isEnabled(); boolean enabled = p.isEnabled();
boolean match = pref.isAllEnabled(); boolean match = pref.isAllEnabled();
if (enabled && match) return false; if (enabled && match)
if (!enabled && pref.isAllDisabled()) return false; return false;
if (!enabled && pref.isAllDisabled())
return false;
return true; return true;
} }
return false; return false;

View file

@ -14,8 +14,9 @@ import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
import org.eclipse.cdt.codan.core.model.IProblem; import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy; import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.param.LaunchTypeProblemPreference; import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference;
import org.eclipse.cdt.codan.core.param.MapProblemPreference; import org.eclipse.cdt.codan.core.param.MapProblemPreference;
import org.eclipse.cdt.codan.core.param.RootProblemPreference;
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages; import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.cdt.codan.internal.ui.preferences.LaunchModesPropertyPage; import org.eclipse.cdt.codan.internal.ui.preferences.LaunchModesPropertyPage;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -35,7 +36,7 @@ public class LaunchingTabComposite extends Composite {
private LaunchModesPropertyPage page; private LaunchModesPropertyPage page;
private IProblem problem; private IProblem problem;
private PreferenceStore prefStore; private PreferenceStore prefStore;
private LaunchTypeProblemPreference launchPref; private LaunchModeProblemPreference launchPref;
/** /**
* @param parent * @param parent
@ -51,18 +52,13 @@ public class LaunchingTabComposite extends Composite {
this.problem = problem; this.problem = problem;
this.prefStore = new PreferenceStore(); this.prefStore = new PreferenceStore();
IProblemPreference info = problem.getPreference(); IProblemPreference info = problem.getPreference();
if (info == null || (!(info instanceof MapProblemPreference))) { if (info == null || (!(info instanceof RootProblemPreference))) {
Label label = new Label(this, 0); Label label = new Label(this, 0);
label.setText(CodanUIMessages.ParametersComposite_None); label.setText(CodanUIMessages.ParametersComposite_None);
return; return;
} }
LaunchTypeProblemPreference launchModes = (LaunchTypeProblemPreference) ((MapProblemPreference) info) LaunchModeProblemPreference launchModes = ((RootProblemPreference) info).getLaunchModePreference();
.getChildDescriptor(LaunchTypeProblemPreference.KEY); launchPref = (LaunchModeProblemPreference) launchModes.clone();
if (launchModes == null) {
launchPref = new LaunchTypeProblemPreference();
} else {
launchPref = (LaunchTypeProblemPreference) launchModes.clone();
}
initPrefStore(); initPrefStore();
page = new LaunchModesPropertyPage(prefStore); page = new LaunchModesPropertyPage(prefStore);
page.noDefaultAndApplyButton(); page.noDefaultAndApplyButton();
@ -88,12 +84,14 @@ public class LaunchingTabComposite extends Composite {
* @param launchPref2 * @param launchPref2
* @param preferenceStore * @param preferenceStore
*/ */
private void saveToPref(LaunchTypeProblemPreference launchPref, IPreferenceStore preferenceStore) { private void saveToPref(LaunchModeProblemPreference launchPref, IPreferenceStore preferenceStore) {
CheckerLaunchMode[] values = CheckerLaunchMode.values(); CheckerLaunchMode[] values = CheckerLaunchMode.values();
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
CheckerLaunchMode checkerLaunchMode = values[i]; CheckerLaunchMode checkerLaunchMode = values[i];
if (!preferenceStore.isDefault(checkerLaunchMode.name())) { String name = checkerLaunchMode.name();
launchPref.setRunningMode(checkerLaunchMode, preferenceStore.getBoolean(checkerLaunchMode.name())); if (!preferenceStore.isDefault(name)) {
boolean value = preferenceStore.getBoolean(name);
launchPref.setRunningMode(checkerLaunchMode, value);
} }
} }
} }
@ -101,10 +99,10 @@ public class LaunchingTabComposite extends Composite {
private void initPrefStore() { private void initPrefStore() {
if (launchPref == null) if (launchPref == null)
return; return;
prefStore.setDefault(CheckerLaunchMode.USE_PARENT.name(), true);
CheckerLaunchMode[] values = CheckerLaunchMode.values(); CheckerLaunchMode[] values = CheckerLaunchMode.values();
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
CheckerLaunchMode checkerLaunchMode = values[i]; CheckerLaunchMode checkerLaunchMode = values[i];
prefStore.setDefault(checkerLaunchMode.name(), true);
prefStore.setValue(checkerLaunchMode.name(), launchPref.isRunningInMode(checkerLaunchMode)); prefStore.setValue(checkerLaunchMode.name(), launchPref.isRunningInMode(checkerLaunchMode));
} }
} }

View file

@ -18,7 +18,7 @@ import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference; import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.param.IProblemPreferenceCompositeDescriptor; import org.eclipse.cdt.codan.core.param.IProblemPreferenceCompositeDescriptor;
import org.eclipse.cdt.codan.core.param.LaunchTypeProblemPreference; import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference;
import org.eclipse.cdt.codan.core.param.ListProblemPreference; import org.eclipse.cdt.codan.core.param.ListProblemPreference;
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages; import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.dialogs.InputDialog;
@ -90,7 +90,7 @@ public class ParametersComposite extends Composite {
return; return;
if (info.getKey() == FileScopeProblemPreference.KEY) if (info.getKey() == FileScopeProblemPreference.KEY)
return; // skip the scope return; // skip the scope
if (info.getKey() == LaunchTypeProblemPreference.KEY) if (info.getKey() == LaunchModeProblemPreference.KEY)
return; // skip the launch return; // skip the launch
switch (info.getType()) { switch (info.getType()) {
case TYPE_STRING: { case TYPE_STRING: {