1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 12:35:22 +02:00

Commit for Leo Treggiari: fix for bugzilla 70577 and 71254

This commit is contained in:
Sean Evoy 2004-08-05 14:31:38 +00:00
parent 1d1df82897
commit 47cd4cbd24
6 changed files with 56 additions and 5 deletions

View file

@ -129,6 +129,13 @@ public interface IOption extends IBuildObject {
*/ */
public String getEnumCommand (String id); public String getEnumCommand (String id);
/**
* Answers the "name" associated with the enumeration id.
*
* @return
*/
public String getEnumName (String id);
/** /**
* @param name * @param name
* @return * @return

View file

@ -267,6 +267,23 @@ public class Option extends BuildObject implements IOption {
return cmd == null ? EMPTY_STRING : cmd; return cmd == null ? EMPTY_STRING : cmd;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumName(java.lang.String)
*/
public String getEnumName(String id) {
// Sanity
if (id == null) return EMPTY_STRING;
// First check for the command in ID->name map
String name = (String) getEnumNameMap().get(id);
if (name == null) {
// This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
// name of the enumeration.
name = id;
}
return name;
}
/* (non-Javadoc) /* (non-Javadoc)
* A memory-safe accessor to the map of enumerated option value IDs to the commands * A memory-safe accessor to the map of enumerated option value IDs to the commands
* that a tool understands. * that a tool understands.

View file

@ -286,12 +286,26 @@ public class OptionReference implements IOption {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String) * @see org.eclipse.cdt.core.build.managed.IOption#getEnumCommand(java.lang.String)
*/ */
public String getEnumCommand(String name) { public String getEnumCommand(String id) {
if (!resolved) { if (!resolved) {
resolveReferences(); resolveReferences();
} }
if (option != null) { if (option != null) {
return option.getEnumCommand(name); return option.getEnumCommand(id);
} else {
return new String();
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getEnumName(java.lang.String)
*/
public String getEnumName(String id) {
if (!resolved) {
resolveReferences();
}
if (option != null) {
return option.getEnumName(id);
} else { } else {
return new String(); return new String();
} }

View file

@ -68,9 +68,11 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
fieldsList.add(booleanField); fieldsList.add(booleanField);
break; break;
case IOption.ENUMERATED : case IOption.ENUMERATED :
String selId;
String sel; String sel;
try { try {
sel = opt.getSelectedEnum(); selId = opt.getSelectedEnum();
sel = opt.getEnumName(selId);
} catch (BuildException e) { } catch (BuildException e) {
// If we get this exception, then the option type is // If we get this exception, then the option type is
// wrong // wrong

View file

@ -184,8 +184,15 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
IOption option = options[k]; IOption option = options[k];
switch (option.getValueType()) { switch (option.getValueType()) {
case IOption.BOOLEAN : case IOption.BOOLEAN :
String boolCmd;
if (getPreferenceStore().getBoolean(option.getId())) { if (getPreferenceStore().getBoolean(option.getId())) {
buf.append(option.getCommand() + ITool.WHITE_SPACE); boolCmd = option.getCommand();
} else {
// Note: getCommandFalse is new with CDT 2.0
boolCmd = option.getCommandFalse();
}
if (boolCmd != null && boolCmd.length() > 0) {
buf.append(boolCmd + ITool.WHITE_SPACE);
} }
break; break;
case IOption.ENUMERATED : case IOption.ENUMERATED :
@ -199,10 +206,12 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
} }
break; break;
case IOption.STRING : case IOption.STRING :
String strCmd = option.getCommand();
String val = getPreferenceStore().getString(option.getId()); String val = getPreferenceStore().getString(option.getId());
// add this string option value to the list // add this string option value to the list
stringOptionsMap.put(option, val); stringOptionsMap.put(option, val);
if (val.length() > 0) { if (val.length() > 0) {
if (strCmd != null) buf.append(strCmd);
buf.append(val + ITool.WHITE_SPACE); buf.append(val + ITool.WHITE_SPACE);
} }
break; break;

View file

@ -232,7 +232,9 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
case IOption.ENUMERATED : case IOption.ENUMERATED :
try{ try{
value = opt.getSelectedEnum(); String selId;
selId = opt.getSelectedEnum();
value = opt.getEnumName(selId);
} catch (BuildException e) { } catch (BuildException e) {
break; break;
} }