1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

Apply patch for Option, tooltip support (bugzilla 113363)

This commit is contained in:
Leo Treggiari 2005-11-19 20:30:18 +00:00
parent dde1d9fe71
commit f024ed0dea
7 changed files with 278 additions and 125 deletions

View file

@ -1144,7 +1144,7 @@ Additional special types exist to flag options of special relevance to the build
<attribute name="tip" type="string">
<annotation>
<documentation>
Specifies a &quot;tip&quot; that can be displayed in hover help or on the property page. Not implemented in 2.0.
Specifies a &quot;tip&quot; that can be displayed in hover help or on the property page.
</documentation>
</annotation>
</attribute>

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
@ -45,6 +46,7 @@ public interface IOption extends IBuildObject {
public static final String CATEGORY = "category"; //$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 TOOL_TIP = "tip"; //$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 IS_DEFAULT = "isDefault"; //$NON-NLS-1$
@ -202,6 +204,21 @@ public interface IOption extends IBuildObject {
*/
public void setCommandFalse(String commandFalse);
/**
* Answers a <code>String</code> containing the tooltip
* associated with the option
* @return String
*/
public String getToolTip();
/**
* Sets a <code>String</code> containing the tooltip
* associated with the option
*
* @param String
*/
public void setToolTip(String tooltip);
/**
* Answers the user-defined preprocessor symbols.
*

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
@ -59,6 +60,7 @@ public class Option extends BuildObject implements IOption {
private String categoryId;
private String command;
private String commandFalse;
private String tip;
private List enumList;
private Map enumCommands;
private Map enumNames;
@ -181,6 +183,9 @@ public class Option extends BuildObject implements IOption {
if (option.commandFalse != null) {
commandFalse = new String(option.commandFalse);
}
if (option.tip != null) {
tip = new String(option.tip);
}
if (option.categoryId != null) {
categoryId = new String(option.categoryId);
}
@ -294,6 +299,9 @@ public class Option extends BuildObject implements IOption {
// Get the command defined for a Boolean option when the value is False
commandFalse = element.getAttribute(COMMAND_FALSE);
// Get the tooltip for the option
tip = element.getAttribute(TOOL_TIP);
// Options hold different types of values
String valueTypeStr = element.getAttribute(VALUE_TYPE);
if (valueTypeStr != null) {
@ -407,6 +415,11 @@ public class Option extends BuildObject implements IOption {
commandFalse = element.getAttribute(COMMAND_FALSE);
}
// Get the tooltip for the option
if (element.hasAttribute(TOOL_TIP)) {
tip = element.getAttribute(TOOL_TIP);
}
// Options hold different types of values
if (element.hasAttribute(VALUE_TYPE)) {
String valueTypeStr = element.getAttribute(VALUE_TYPE);
@ -623,6 +636,10 @@ public class Option extends BuildObject implements IOption {
element.setAttribute(COMMAND_FALSE, commandFalse);
}
if (tip != null) {
element.setAttribute(TOOL_TIP, tip);
}
/*
* 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.
@ -978,6 +995,19 @@ public class Option extends BuildObject implements IOption {
return commandFalse;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getToolTip()
*/
public String getToolTip() {
if (tip == null) {
if (superClass != null) {
return superClass.getToolTip();
} else {
return EMPTY_STRING;
}
}
return tip;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#getDefinedSymbols()
*/
@ -1339,6 +1369,17 @@ public class Option extends BuildObject implements IOption {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#setToolTip(String)
*/
public void setToolTip(String tooltip) {
if (tooltip == null && tip == null) return;
if (tooltip == null || tip == null || !tooltip.equals(tip)) {
tip = tooltip;
isDirty = true;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
*/
@ -1521,6 +1562,7 @@ public class Option extends BuildObject implements IOption {
categoryId == null &&
command == null &&
commandFalse == null &&
tip == null &&
enumList == null &&
enumCommands == null &&
enumNames == null &&

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
@ -294,6 +295,13 @@ public class OptionReference implements IOption {
return option.getCommandFalse();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getToolTip()
*/
public String getToolTip() {
return option.getToolTip();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#getDefinedSymbols()
*/
@ -750,6 +758,12 @@ public class OptionReference implements IOption {
public void setCommandFalse(String cmd) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IOption#setToolTip(String)
*/
public void setToolTip(String tooltip) {
}
public PluginVersionIdentifier getVersion() {
return option.getVersion();
}

View file

@ -7,11 +7,13 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@ -40,6 +42,50 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
createControl(parent);
}
/**
* @param name
* @param label
* @param tooltip
* @param opts
* @param sel
* @param parent
*/
public BuildOptionComboFieldEditor(String name, String label, String tooltip, String [] opts, String sel, Composite parent) {
this(name, label, opts, sel, parent);
setToolTip(tooltip);
}
/**
* Sets the field editor's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
*
* @param string the new tool tip text (or null)
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the field editor has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the field editor</li>
* </ul>
*/
public void setToolTip(String tooltip) {
optionSelector.setToolTipText(tooltip);
getLabelControl().setToolTipText(tooltip);
}
/**
* Returns the field editor's tool tip text, or null if it has
* not been set.
*
* @return the field editor's tool tip text
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the field editor has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the field editor</li>
* </ul>
*/
public String getToolTipText() {
return optionSelector.getToolTipText();
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
*/
@ -128,6 +174,27 @@ public class BuildOptionComboFieldEditor extends FieldEditor {
return 2;
}
/**
* Returns this field editor's text control.
*
* @return the text control, or <code>null</code> if no
* text field is created yet
*/
protected Combo getComboControl() {
return optionSelector;
}
/**
* Returns this field editor's text control.
*
* @return the text control, or <code>null</code> if no
* text field is created yet
*/
public Combo getComboControl(Composite parent) {
checkParent(optionSelector, parent);
return optionSelector;
}
/**
* Set whether or not the controls in the field editor
* are enabled.

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
@ -100,137 +101,98 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
} else {
config = clonedConfig;
}
if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) {
try {
// Figure out which type the option is and add a proper field
// editor for it
switch (opt.getValueType()) {
case IOption.STRING:
// fix for PR 63973
// Check browse type.
// If browsing is set, use a field editor that has a
// browse button of
// the appropriate type.
// Otherwise, use a regular text field.
switch (opt.getBrowseType()) {
case IOption.BROWSE_DIR:
Composite fieldEditorParent2 = getFieldEditorParent();
DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor(
prefName, opt.getName(), fieldEditorParent2);
try {
// Figure out which type the option is and add a proper field
// editor for it
Composite fieldEditorParent = getFieldEditorParent();
FieldEditor fieldEditor;
setFieldEditorEnablement(holder,
opt, applicabilityCalculator, dirFieldEditor, fieldEditorParent2);
addField(dirFieldEditor);
fieldsMap.put(prefName, dirFieldEditor);
fieldEditorsToParentMap.put(dirFieldEditor, fieldEditorParent2);
break;
case IOption.BROWSE_FILE:
Composite fieldEditorParent3 = getFieldEditorParent();
FileFieldEditor fileFieldEditor = new FileFieldEditor(
prefName, opt.getName(), fieldEditorParent3);
setFieldEditorEnablement(holder,
opt, applicabilityCalculator, fileFieldEditor, fieldEditorParent3);
addField(fileFieldEditor);
fieldsMap.put(prefName, fileFieldEditor);
fieldEditorsToParentMap.put(fileFieldEditor, fieldEditorParent3);
break;
case IOption.BROWSE_NONE:
Composite fieldEditorParent4 = getFieldEditorParent();
StringFieldEditor stringField = new StringFieldEditor(
prefName, opt.getName(), fieldEditorParent4);
setFieldEditorEnablement(holder,
opt, applicabilityCalculator, stringField, fieldEditorParent4);
addField(stringField);
fieldsMap.put(prefName, stringField);
fieldEditorsToParentMap.put(stringField, fieldEditorParent4);
break;
default:
// should not be possible
throw (new AssertionError());
}
// end fix for 63973
break;
case IOption.BOOLEAN:
Composite fieldEditorParent5 = getFieldEditorParent();
BooleanFieldEditor booleanField = new BooleanFieldEditor(
prefName, opt.getName(), fieldEditorParent5);
setFieldEditorEnablement(holder,
opt, applicabilityCalculator, booleanField, fieldEditorParent5);
addField(booleanField);
fieldsMap.put(prefName, booleanField);
fieldEditorsToParentMap.put(booleanField, fieldEditorParent5);
break;
case IOption.ENUMERATED:
String selId;
String sel;
try {
selId = opt.getSelectedEnum();
sel = opt.getEnumName(selId);
} catch (BuildException e) {
// If we get this exception, then the option type is
// wrong
break;
}
// Get all applicable values for this enumerated Option, But display
// only the enumerated values that are valid (static set of enumerated values defined
// in the plugin.xml file) in the UI Combobox. This refrains the user from selecting an
// invalid value and avoids issuing an error message.
String[] enumNames = opt.getApplicableValues();
Vector enumValidList = new Vector();
for (int i = 0; i < enumNames.length; ++i) {
if (opt.getValueHandler().isEnumValueAppropriate(config,
opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) {
enumValidList.add(enumNames[i]);
switch (opt.getValueType()) {
case IOption.STRING: {
StringFieldEditor stringField;
// If browsing is set, use a field editor that has a
// browse button of the appropriate type.
switch (opt.getBrowseType()) {
case IOption.BROWSE_DIR: {
stringField = new DirectoryFieldEditor(prefName, opt.getName(), fieldEditorParent);
} break;
case IOption.BROWSE_FILE: {
stringField = new FileFieldEditor(prefName, opt.getName(), fieldEditorParent);
} break;
case IOption.BROWSE_NONE: {
stringField = new StringFieldEditor(prefName, opt.getName(), fieldEditorParent);
} break;
default: {
throw new BuildException(null);
}
}
}
String[] enumValidNames = new String[enumValidList.size()];
enumValidList.copyInto(enumValidNames);
Composite fieldEditorParent6 = getFieldEditorParent();
BuildOptionComboFieldEditor comboField = new BuildOptionComboFieldEditor(
prefName, opt.getName(), enumValidNames, sel, fieldEditorParent6);
stringField.getTextControl(fieldEditorParent).setToolTipText(opt.getToolTip());
stringField.getLabelControl(fieldEditorParent).setToolTipText(opt.getToolTip());
fieldEditor = stringField;
} break;
case IOption.BOOLEAN: {
class TooltipBooleanFieldEditor extends BooleanFieldEditor {
public TooltipBooleanFieldEditor(String name, String labelText, String tooltip, Composite parent) {
super(name, labelText, parent);
getChangeControl(parent).setToolTipText(tooltip);
}
}
fieldEditor = new TooltipBooleanFieldEditor(prefName, opt.getName(), opt.getToolTip(), fieldEditorParent);
} break;
case IOption.ENUMERATED: {
String selId = opt.getSelectedEnum();
String sel = opt.getEnumName(selId);
setFieldEditorEnablement(holder,
opt, applicabilityCalculator, comboField, fieldEditorParent6);
addField(comboField);
fieldsMap.put(prefName, comboField);
fieldEditorsToParentMap.put(comboField, fieldEditorParent6);
break;
case IOption.INCLUDE_PATH:
case IOption.STRING_LIST:
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
case IOption.OBJECTS:
Composite fieldEditorParent7 = getFieldEditorParent();
FileListControlFieldEditor listField = new FileListControlFieldEditor(
prefName, opt.getName(), fieldEditorParent7, opt.getBrowseType());
setFieldEditorEnablement(holder,
opt, applicabilityCalculator, listField, fieldEditorParent7);
addField(listField);
fieldsMap.put(prefName, listField);
fieldEditorsToParentMap.put(listField, fieldEditorParent7);
break;
default:
break;
// Get all applicable values for this enumerated Option, But display
// only the enumerated values that are valid (static set of enumerated values defined
// in the plugin.xml file) in the UI Combobox. This refrains the user from selecting an
// invalid value and avoids issuing an error message.
String[] enumNames = opt.getApplicableValues();
Vector enumValidList = new Vector();
for (int i = 0; i < enumNames.length; ++i) {
if (opt.getValueHandler().isEnumValueAppropriate(config,
opt.getOptionHolder(), opt, opt.getValueHandlerExtraArgument(), enumNames[i])) {
enumValidList.add(enumNames[i]);
}
}
String[] enumValidNames = new String[enumValidList.size()];
enumValidList.copyInto(enumValidNames);
fieldEditor = new BuildOptionComboFieldEditor(prefName, opt.getName(), opt.getToolTip(), enumValidNames, sel, fieldEditorParent);
} break;
case IOption.INCLUDE_PATH:
case IOption.STRING_LIST:
case IOption.PREPROCESSOR_SYMBOLS:
case IOption.LIBRARIES:
case IOption.OBJECTS: {
fieldEditor = new FileListControlFieldEditor(prefName, opt.getName(), opt.getToolTip(), fieldEditorParent, opt.getBrowseType());
} break;
default:
throw new BuildException(null);
}
} catch (BuildException e) {
}
setFieldEditorEnablement(holder, opt, applicabilityCalculator, fieldEditor, fieldEditorParent);
addField(fieldEditor);
fieldsMap.put(prefName, fieldEditor);
fieldEditorsToParentMap.put(fieldEditor, fieldEditorParent);
} catch (BuildException e) {
}
}
}
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* BitMethods Inc - Initial API and implementation
* ARM Ltd. - basic tooltip support
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
@ -58,6 +59,56 @@ public class FileListControlFieldEditor extends FieldEditor {
list.setType(type);
}
/**
* Creates a file list control field editor.
* @param name the name of the preference this field editor works on
* @param labelText the label text of the field editor
* @param tooltip the tooltip text of the field editor
* @param parent the parent of the field editor's control
* @param type the browseType of the file list control
*/
public FileListControlFieldEditor(
String name,
String labelText,
String tooltip,
Composite parent,
int type) {
this(name, labelText, parent, type);
// can't use setToolTip(tooltip) as label not created yet
getLabelControl(parent).setToolTipText(tooltip);
}
/**
* Sets the field editor's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
*
* @param string the new tool tip text (or null)
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the field editor has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the field editor</li>
* </ul>
*/
public void setToolTip(String tooltip) {
// Currently just the label has the tooltip
getLabelControl().setToolTipText(tooltip);
}
/**
* Returns the field editor's tool tip text, or null if it has
* not been set.
*
* @return the field editor's tool tip text
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the field editor has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the field editor</li>
* </ul>
*/
public String getToolTipText() {
return getLabelControl().getToolTipText();
}
/**
* Creates a file list control field editor.
* @param name the name of the preference this field editor works on