1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-09 11:33:20 +02:00

Bug # 207315 : context ID was ignored for IOption

This commit is contained in:
Oleg Krasilnikov 2007-11-07 07:23:21 +00:00
parent 2a3047e389
commit 055fe6f88f
6 changed files with 89 additions and 9 deletions

View file

@ -58,6 +58,7 @@ public interface IOption extends IBuildObject {
public static final String COMMAND = "command"; //$NON-NLS-1$ public static final String COMMAND = "command"; //$NON-NLS-1$
public static final String COMMAND_FALSE = "commandFalse"; //$NON-NLS-1$ public static final String COMMAND_FALSE = "commandFalse"; //$NON-NLS-1$
public static final String TOOL_TIP = "tip"; //$NON-NLS-1$ public static final String TOOL_TIP = "tip"; //$NON-NLS-1$
public static final String CONTEXT_ID = "contextId"; //$NON-NLS-1$
public static final String DEFAULT_VALUE = "defaultValue"; //$NON-NLS-1$ public static final String DEFAULT_VALUE = "defaultValue"; //$NON-NLS-1$
public static final String ENUM_VALUE = "enumeratedOptionValue"; //$NON-NLS-1$ public static final String ENUM_VALUE = "enumeratedOptionValue"; //$NON-NLS-1$
public static final String IS_DEFAULT = "isDefault"; //$NON-NLS-1$ public static final String IS_DEFAULT = "isDefault"; //$NON-NLS-1$
@ -241,6 +242,21 @@ public interface IOption extends IBuildObject {
*/ */
public void setToolTip(String tooltip); public void setToolTip(String tooltip);
/**
* Answers a <code>String</code> containing the contextId
* associated with the option
* @return String
*/
public String getContextId();
/**
* Sets a <code>String</code> containing the contextId
* associated with the option
*
* @param String
*/
public void setContextId(String id);
/** /**
* Answers the user-defined preprocessor symbols. * Answers the user-defined preprocessor symbols.
* *

View file

@ -61,6 +61,7 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
private String command; private String command;
private String commandFalse; private String commandFalse;
private String tip; private String tip;
private String contextId;
private List enumList; private List enumList;
private Map enumCommands; private Map enumCommands;
private Map enumNames; private Map enumNames;
@ -188,6 +189,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
if (option.tip != null) { if (option.tip != null) {
tip = new String(option.tip); tip = new String(option.tip);
} }
if (option.contextId != null) {
contextId = new String(option.contextId);
}
if (option.categoryId != null) { if (option.categoryId != null) {
categoryId = new String(option.categoryId); categoryId = new String(option.categoryId);
} }
@ -322,6 +326,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
// Get the tooltip for the option // Get the tooltip for the option
tip = element.getAttribute(TOOL_TIP); tip = element.getAttribute(TOOL_TIP);
// Get the contextID for the option
contextId = element.getAttribute(CONTEXT_ID);
// Options hold different types of values // Options hold different types of values
String valueTypeStr = element.getAttribute(VALUE_TYPE); String valueTypeStr = element.getAttribute(VALUE_TYPE);
if (valueTypeStr != null) { if (valueTypeStr != null) {
@ -442,6 +449,11 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
tip = element.getAttribute(TOOL_TIP); tip = element.getAttribute(TOOL_TIP);
} }
// Get the contextID for the option
if (element.getAttribute(CONTEXT_ID) != null) {
contextId = element.getAttribute(CONTEXT_ID);
}
// Options hold different types of values // Options hold different types of values
if (element.getAttribute(VALUE_TYPE) != null) { if (element.getAttribute(VALUE_TYPE) != null) {
String valueTypeStr = element.getAttribute(VALUE_TYPE); String valueTypeStr = element.getAttribute(VALUE_TYPE);
@ -689,6 +701,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
element.setAttribute(TOOL_TIP, tip); element.setAttribute(TOOL_TIP, tip);
} }
if (contextId != null) {
element.setAttribute(CONTEXT_ID, contextId);
}
/* /*
* Note: We store value & value-type as a pair, so we know what type of value we are * Note: We store value & value-type as a pair, so we know what type of value we are
* dealing with when we read it back in. * dealing with when we read it back in.
@ -1106,6 +1121,19 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
} }
return tip; return tip;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getContextId()
*/
public String getContextId() {
if (contextId == null) {
if (superClass != null) {
return superClass.getContextId();
} else {
return EMPTY_STRING;
}
}
return contextId;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getDefinedSymbols() * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefinedSymbols()
*/ */
@ -1589,7 +1617,7 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
} }
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#setToolTip(String) * @see org.eclipse.cdt.managedbuilder.core.IOption#setToolTip(String)
*/ */
@ -1604,6 +1632,20 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#setContextId(String)
*/
public void setContextId(String id) {
if (id == null && contextId == null) return;
if (id == null || contextId == null || !id.equals(contextId)) {
contextId = id;
if(!isExtensionElement()){
isDirty = true;
rebuildState = true;
}
}
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int) * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
*/ */
@ -1863,6 +1905,7 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
command == null && command == null &&
commandFalse == null && commandFalse == null &&
tip == null && tip == null &&
contextId == null &&
enumList == null && enumList == null &&
enumCommands == null && enumCommands == null &&
enumNames == null && enumNames == null &&

View file

@ -333,6 +333,13 @@ public class OptionReference implements IOption {
return option.getToolTip(); return option.getToolTip();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getContextID()
*/
public String getContextId() {
return option.getContextId();
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getDefinedSymbols() * @see org.eclipse.cdt.core.build.managed.IOption#getDefinedSymbols()
*/ */
@ -805,7 +812,13 @@ public class OptionReference implements IOption {
*/ */
public void setToolTip(String tooltip) { public void setToolTip(String tooltip) {
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#setContextId(String)
*/
public void setContextId(String contextId) {
}
public PluginVersionIdentifier getVersion() { public PluginVersionIdentifier getVersion() {
return option.getVersion(); return option.getVersion();
} }

View file

@ -20,6 +20,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.PlatformUI;
public class BuildOptionComboFieldEditor extends FieldEditor { public class BuildOptionComboFieldEditor extends FieldEditor {
@ -46,13 +47,15 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
* @param name * @param name
* @param label * @param label
* @param tooltip * @param tooltip
* @param contextId
* @param opts * @param opts
* @param sel * @param sel
* @param parent * @param parent
*/ */
public BuildOptionComboFieldEditor(String name, String label, String tooltip, String [] opts, String sel, Composite parent) { public BuildOptionComboFieldEditor(String name, String label, String tooltip, String contextId, String [] opts, String sel, Composite parent) {
this(name, label, opts, sel, parent); this(name, label, opts, sel, parent);
setToolTip(tooltip); setToolTip(tooltip);
if (!contextId.equals("")) PlatformUI.getWorkbench().getHelpSystem().setHelp(optionSelector, contextId); //$NON-NLS-1$
} }
/** /**

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.FieldEditor;
@ -38,6 +39,7 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
public class BuildOptionSettingsUI extends AbstractToolSettingUI { public class BuildOptionSettingsUI extends AbstractToolSettingUI {
private Map fieldsMap = new HashMap(); private Map fieldsMap = new HashMap();
@ -122,19 +124,20 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
stringField.getTextControl(fieldEditorParent).setToolTipText(opt.getToolTip()); stringField.getTextControl(fieldEditorParent).setToolTipText(opt.getToolTip());
stringField.getLabelControl(fieldEditorParent).setToolTipText(opt.getToolTip()); stringField.getLabelControl(fieldEditorParent).setToolTipText(opt.getToolTip());
PlatformUI.getWorkbench().getHelpSystem().setHelp(stringField.getTextControl(fieldEditorParent), opt.getContextId());
fieldEditor = stringField; fieldEditor = stringField;
} break; } break;
case IOption.BOOLEAN: { case IOption.BOOLEAN: {
class TooltipBooleanFieldEditor extends BooleanFieldEditor { class TooltipBooleanFieldEditor extends BooleanFieldEditor {
public TooltipBooleanFieldEditor(String name, String labelText, String tooltip, Composite parent) { public TooltipBooleanFieldEditor(String name, String labelText, String tooltip, Composite parent, String contextId) {
super(name, labelText, parent); super(name, labelText, parent);
getChangeControl(parent).setToolTipText(tooltip); getChangeControl(parent).setToolTipText(tooltip);
if (!contextId.equals(AbstractPage.EMPTY_STR)) PlatformUI.getWorkbench().getHelpSystem().setHelp(getChangeControl(parent), contextId);
} }
} }
fieldEditor = new TooltipBooleanFieldEditor(optId, opt.getName(), opt.getToolTip(), fieldEditorParent); fieldEditor = new TooltipBooleanFieldEditor(optId, opt.getName(), opt.getToolTip(), fieldEditorParent, opt.getContextId());
} break; } break;
case IOption.ENUMERATED: { case IOption.ENUMERATED: {
@ -156,7 +159,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
String[] enumValidNames = new String[enumValidList.size()]; String[] enumValidNames = new String[enumValidList.size()];
enumValidList.copyInto(enumValidNames); enumValidList.copyInto(enumValidNames);
fieldEditor = new BuildOptionComboFieldEditor(optId, opt.getName(), opt.getToolTip(), enumValidNames, sel, fieldEditorParent); fieldEditor = new BuildOptionComboFieldEditor(optId, opt.getName(), opt.getToolTip(), opt.getContextId(), enumValidNames, sel, fieldEditorParent);
} break; } break;
case IOption.INCLUDE_PATH: case IOption.INCLUDE_PATH:
@ -174,7 +177,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
case IOption.UNDEF_LIBRARY_PATHS: case IOption.UNDEF_LIBRARY_PATHS:
case IOption.UNDEF_LIBRARY_FILES: case IOption.UNDEF_LIBRARY_FILES:
case IOption.UNDEF_MACRO_FILES: { case IOption.UNDEF_MACRO_FILES: {
fieldEditor = new FileListControlFieldEditor(optId, opt.getName(), opt.getToolTip(), fieldEditorParent, opt.getBrowseType()); fieldEditor = new FileListControlFieldEditor(optId, opt.getName(), opt.getToolTip(), opt.getContextId(), fieldEditorParent, opt.getBrowseType());
} break; } break;
default: default:

View file

@ -32,7 +32,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.List;
import org.eclipse.ui.PlatformUI;
/** /**
* Field editor that uses FileListControl for user input. * Field editor that uses FileListControl for user input.
@ -79,11 +79,13 @@ public class FileListControlFieldEditor extends FieldEditor {
String name, String name,
String labelText, String labelText,
String tooltip, String tooltip,
String contextId,
Composite parent, Composite parent,
int type) { int type) {
this(name, labelText, parent, type); this(name, labelText, parent, type);
// can't use setToolTip(tooltip) as label not created yet // can't use setToolTip(tooltip) as label not created yet
getLabelControl(parent).setToolTipText(tooltip); getLabelControl(parent).setToolTipText(tooltip);
if (!contextId.equals("")) PlatformUI.getWorkbench().getHelpSystem().setHelp(list.getListControl(), contextId); //$NON-NLS-1$
} }
/** /**