mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
bug 290997: [Contribution] VS-style option tooltip display in Property Pages
patch from Miwako Tokugawa
This commit is contained in:
parent
bd8212e8aa
commit
9fa4bd5b07
9 changed files with 311 additions and 38 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.ui; singleton:=true
|
||||
Bundle-Version: 5.1.0.qualifier
|
||||
Bundle-Version: 5.2.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel Corporation and others.
|
||||
* Copyright (c) 2007, 2009 Intel Corporation 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - initial API and implementation
|
||||
* Miwako Tokugawa (Intel Corporation) - Fixed-location tooltip support
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.preferences;
|
||||
|
||||
|
@ -33,16 +34,19 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
private Button show_mng;
|
||||
private Button show_tool;
|
||||
private Button show_exp;
|
||||
private Button show_tipbox;
|
||||
|
||||
private Button b_0;
|
||||
private Button b_1;
|
||||
private Button b_2;
|
||||
private Button b_3;
|
||||
private Button b_4;
|
||||
|
||||
private Button s_0;
|
||||
private Button s_1;
|
||||
private Button s_2;
|
||||
|
||||
@Override
|
||||
public void createControls(Composite parent) {
|
||||
super.createControls(parent);
|
||||
usercomp.setLayout(new GridLayout(1, false));
|
||||
|
@ -63,6 +67,10 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
show_exp.setText(UIMessages.getString("PropertyPageDefsTab.10")); //$NON-NLS-1$
|
||||
show_exp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
show_tipbox = new Button(usercomp, SWT.CHECK);
|
||||
show_tipbox.setText(UIMessages.getString("PropertyPageDefsTab.16")); //$NON-NLS-1$
|
||||
show_tipbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
Group saveGrp = new Group(usercomp, SWT.NONE);
|
||||
saveGrp.setText(UIMessages.getString("PropertyPageDefsTab.11")); //$NON-NLS-1$
|
||||
saveGrp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
@ -101,6 +109,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
show_mng.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG));
|
||||
show_tool.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM));
|
||||
show_exp.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT));
|
||||
show_tipbox.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_TIPBOX));
|
||||
|
||||
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_DISC_NAMES)) {
|
||||
case CDTPrefUtil.DISC_NAMING_UNIQUE_OR_BOTH: b_0.setSelection(true); break;
|
||||
|
@ -116,11 +125,13 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performOK() {
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_DTREE, show_tree.getSelection());
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOMNG, !show_mng.getSelection());
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOTOOLM, !show_tool.getSelection());
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_EXPORT, show_exp.getSelection());
|
||||
CDTPrefUtil.setBool(CDTPrefUtil.KEY_TIPBOX, show_tipbox.getSelection());
|
||||
int x = 0;
|
||||
if (b_1.getSelection()) x = 1;
|
||||
else if (b_2.getSelection()) x = 2;
|
||||
|
@ -133,21 +144,27 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
|
|||
CDTPrefUtil.setInt(CDTPrefUtil.KEY_POSSAVE, x);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performDefaults() {
|
||||
show_tree.setSelection(false);
|
||||
show_mng.setSelection(true);
|
||||
show_tool.setSelection(true);
|
||||
show_exp.setSelection(false);
|
||||
show_tipbox.setSelection(false);
|
||||
b_0.setSelection(true);
|
||||
b_1.setSelection(false);
|
||||
b_2.setSelection(false);
|
||||
b_3.setSelection(false);
|
||||
b_4.setSelection(false);
|
||||
s_0.setSelection(true);
|
||||
s_1.setSelection(false);
|
||||
s_2.setSelection(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performApply(ICResourceDescription src, ICResourceDescription dst) { performOK(); }
|
||||
@Override
|
||||
protected void updateData(ICResourceDescription cfg) {} // Do nothing. Data is read once after creation
|
||||
@Override
|
||||
protected void updateButtons() {} // Do nothing. No buttons to update
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2007 Rational Software Corporation and others.
|
||||
* Copyright (c) 2004, 2009 Rational Software Corporation 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Intel corp. 2007 - modification for new CDT model.
|
||||
* Miwako Tokugawa (Intel Corporation) - Fixed-location tooltip support
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||
|
||||
|
@ -22,9 +23,10 @@ public abstract class AbstractToolSettingUI extends FieldEditorPreferencePage {
|
|||
protected AbstractCBuildPropertyTab buildPropPage;
|
||||
protected IResourceInfo fInfo;
|
||||
private boolean dirty = false;
|
||||
private boolean toolTipBoxNeeded = false;
|
||||
|
||||
/**
|
||||
* @param style
|
||||
*
|
||||
*/
|
||||
protected AbstractToolSettingUI(IResourceInfo info) {
|
||||
this(info, GRID);
|
||||
|
@ -41,6 +43,7 @@ public abstract class AbstractToolSettingUI extends FieldEditorPreferencePage {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
|
||||
*/
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
// Get the preference store for the build settings
|
||||
IPreferenceStore settings = getToolSettingsPrefStore();
|
||||
|
@ -48,15 +51,32 @@ public abstract class AbstractToolSettingUI extends FieldEditorPreferencePage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the tool settings preference store
|
||||
* @return the tool settings preference store
|
||||
*/
|
||||
protected ToolSettingsPrefStore getToolSettingsPrefStore() {
|
||||
return ToolSettingsPrefStore.getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flag indicating that tooltip box need to be displayed
|
||||
* @since 5.2
|
||||
*/
|
||||
protected void setToolTipBoxNeeded(boolean flag) {
|
||||
toolTipBoxNeeded = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this page needs to have a tool tip box.
|
||||
* @since 5.2
|
||||
*/
|
||||
protected boolean isToolTipBoxNeeded() {
|
||||
return toolTipBoxNeeded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called when the value of a dialog field changes
|
||||
*/
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
super.propertyChange(event);
|
||||
if (event.getProperty().equals(FieldEditor.VALUE)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2003, 2009 IBM Corporation 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* ARM Ltd. - basic tooltip support
|
||||
* Miwako Tokugawa (Intel Corporation) - Fixed-location tooltip support
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||
|
||||
|
@ -41,11 +42,17 @@ import org.eclipse.jface.preference.FileFieldEditor;
|
|||
import org.eclipse.jface.preference.StringFieldEditor;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.osgi.util.TextProcessor;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
||||
|
@ -59,12 +66,44 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
private int curr = -1;
|
||||
private Map<FieldEditor, Composite> fieldEditorsToParentMap =
|
||||
new HashMap<FieldEditor, Composite>();
|
||||
/** True if the user selected "Display tool option tips at a fixed location" in Preferences */
|
||||
private boolean displayFixedTip;
|
||||
/** type of mouse action the displayFixedTip responds to.
|
||||
** currently set to Enter rather than Hover since the former seems more responsive **/
|
||||
private final static int selectAction = SWT.MouseEnter;
|
||||
|
||||
private class TipInfo {
|
||||
private String name;
|
||||
private String tip;
|
||||
|
||||
public TipInfo(String name, String tip) {
|
||||
this.name = name;
|
||||
this.tip = tip;
|
||||
}
|
||||
protected String getName() {
|
||||
return name;
|
||||
}
|
||||
protected String getTip() {
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public BuildOptionSettingsUI(AbstractCBuildPropertyTab page,
|
||||
IResourceInfo info, IHoldsOptions optionHolder,
|
||||
IOptionCategory _category) {
|
||||
this(page, info, optionHolder, _category, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public BuildOptionSettingsUI(AbstractCBuildPropertyTab page,
|
||||
IResourceInfo info, IHoldsOptions optionHolder,
|
||||
IOptionCategory _category, boolean _displayFixedTip) {
|
||||
super(info);
|
||||
this.category = _category;
|
||||
this.displayFixedTip = _displayFixedTip;
|
||||
this.optionHolder = optionHolder;
|
||||
buildPropPage = page;
|
||||
if (info instanceof MultiItemsHolder) {
|
||||
|
@ -123,10 +162,14 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
|
||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#Editors()
|
||||
*/
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
// true if he user selected "Display tool option tips at a fixed location" in Preferences AND
|
||||
// and we are displaying the tool tip box on this page because one or more option has non-empty tool tip.
|
||||
boolean pageHasToolTipBox = isToolTipBoxNeeded();
|
||||
|
||||
// Get the preference store for the build settings
|
||||
super.createFieldEditors();
|
||||
// Iterate over the options in the category and create a field editor
|
||||
|
@ -138,7 +181,6 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
IHoldsOptions holder = (IHoldsOptions)options[index][0];
|
||||
if (holder == null) break; // The array may not be full
|
||||
IOption opt = (IOption)options[index][1];
|
||||
String optId = getToolSettingsPrefStore().getOptionId(opt);
|
||||
|
||||
// check to see if the option has an applicability calculator
|
||||
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
|
||||
|
@ -146,6 +188,15 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
|
||||
if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) {
|
||||
|
||||
String optId = getToolSettingsPrefStore().getOptionId(opt);
|
||||
String nameStr = TextProcessor.process(opt.getName());
|
||||
String tipStr = TextProcessor.process(opt.getToolTip());
|
||||
String contextId = opt.getContextId();
|
||||
|
||||
if (pageHasToolTipBox && (tipStr==null || tipStr.trim().length()==0)) {
|
||||
tipStr = Messages.getString("BuildOptionSettingsUI.0"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
try {
|
||||
// Figure out which type the option is and add a proper field
|
||||
// editor for it
|
||||
|
@ -160,11 +211,11 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
// browse button of the appropriate type.
|
||||
switch (opt.getBrowseType()) {
|
||||
case IOption.BROWSE_DIR: {
|
||||
stringField = new DirectoryFieldEditor(optId, TextProcessor.process(opt.getName()), fieldEditorParent);
|
||||
stringField = new DirectoryFieldEditor(optId, nameStr, fieldEditorParent);
|
||||
} break;
|
||||
|
||||
case IOption.BROWSE_FILE: {
|
||||
stringField = new FileFieldEditor(optId, TextProcessor.process(opt.getName()), fieldEditorParent) {
|
||||
stringField = new FileFieldEditor(optId, nameStr, fieldEditorParent) {
|
||||
/**
|
||||
* Do not perform validity check on the file name due to losing focus,
|
||||
* see http://bugs.eclipse.org/289448
|
||||
|
@ -178,7 +229,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
} break;
|
||||
|
||||
case IOption.BROWSE_NONE: {
|
||||
final StringFieldEditorM local = new StringFieldEditorM(optId, TextProcessor.process(opt.getName()), fieldEditorParent);
|
||||
final StringFieldEditorM local = new StringFieldEditorM(optId, nameStr, fieldEditorParent);
|
||||
stringField = local;
|
||||
local.getTextControl().addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
|
@ -191,22 +242,33 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
throw new BuildException(null);
|
||||
}
|
||||
}
|
||||
|
||||
stringField.getTextControl(fieldEditorParent).setToolTipText(TextProcessor.process(opt.getToolTip()));
|
||||
stringField.getLabelControl(fieldEditorParent).setToolTipText(TextProcessor.process(opt.getToolTip()));
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(stringField.getTextControl(fieldEditorParent), opt.getContextId());
|
||||
Label label = stringField.getLabelControl(fieldEditorParent);
|
||||
Text text = stringField.getTextControl(fieldEditorParent);
|
||||
if (pageHasToolTipBox) {
|
||||
label.setData(new TipInfo(nameStr,tipStr));
|
||||
label.addListener(selectAction, tipSetListener);
|
||||
text.setData(new TipInfo(nameStr,tipStr));
|
||||
text.addListener(selectAction, tipSetListener);
|
||||
} else {
|
||||
label.setToolTipText(tipStr);
|
||||
text.setToolTipText(tipStr);
|
||||
}
|
||||
if (!contextId.equals(AbstractPage.EMPTY_STR)) {
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(text, contextId);
|
||||
}
|
||||
fieldEditor = stringField;
|
||||
} break;
|
||||
|
||||
case IOption.BOOLEAN: {
|
||||
fieldEditor = new TriStateBooleanFieldEditor(
|
||||
optId,
|
||||
TextProcessor.process(opt.getName()),
|
||||
opt.getToolTip(),
|
||||
nameStr,
|
||||
tipStr,
|
||||
fieldEditorParent,
|
||||
opt.getContextId(),
|
||||
contextId,
|
||||
ohs,
|
||||
curr);
|
||||
// tipStr is handled in TriStateBooleanFieldEditor constructor
|
||||
} break;
|
||||
|
||||
case IOption.ENUMERATED: {
|
||||
|
@ -228,7 +290,19 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
String[] enumValidNames = new String[enumValidList.size()];
|
||||
enumValidList.copyInto(enumValidNames);
|
||||
|
||||
fieldEditor = new BuildOptionComboFieldEditor(optId, TextProcessor.process(opt.getName()), TextProcessor.process(opt.getToolTip()), opt.getContextId(), enumValidNames, sel, fieldEditorParent);
|
||||
// if (displayFixedTip==false), tooltip was already set in BuildOptionComboFieldEditor constructor.
|
||||
String tooltipHoverStr = displayFixedTip ? null : tipStr;
|
||||
fieldEditor = new BuildOptionComboFieldEditor(optId, nameStr,
|
||||
tooltipHoverStr, contextId, enumValidNames, sel, fieldEditorParent);
|
||||
|
||||
if (pageHasToolTipBox) {
|
||||
Combo combo = ((BuildOptionComboFieldEditor)fieldEditor).getComboControl();
|
||||
Label label = fieldEditor.getLabelControl(fieldEditorParent);
|
||||
combo.setData(new TipInfo(nameStr,tipStr));
|
||||
combo.addListener(selectAction, tipSetListener);
|
||||
label.setData(new TipInfo(nameStr,tipStr));
|
||||
label.addListener(selectAction, tipSetListener);
|
||||
}
|
||||
} break;
|
||||
|
||||
case IOption.INCLUDE_PATH:
|
||||
|
@ -245,8 +319,17 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
case IOption.UNDEF_INCLUDE_FILES:
|
||||
case IOption.UNDEF_LIBRARY_PATHS:
|
||||
case IOption.UNDEF_LIBRARY_FILES:
|
||||
case IOption.UNDEF_MACRO_FILES: {
|
||||
fieldEditor = new FileListControlFieldEditor(optId, TextProcessor.process(opt.getName()), TextProcessor.process(opt.getToolTip()), opt.getContextId(), fieldEditorParent, opt.getBrowseType());
|
||||
case IOption.UNDEF_MACRO_FILES:
|
||||
{
|
||||
// if (displayFixedTip==false), tooltip was already set in FileListControlFieldEditor constructor.
|
||||
String tooltipHoverStr = displayFixedTip ? null : tipStr;
|
||||
fieldEditor = new FileListControlFieldEditor(optId, nameStr,
|
||||
tooltipHoverStr, contextId, fieldEditorParent, opt.getBrowseType());
|
||||
if (pageHasToolTipBox) {
|
||||
Label label = fieldEditor.getLabelControl(fieldEditorParent);
|
||||
label.setData(new TipInfo(nameStr,tipStr));
|
||||
label.addListener(selectAction, tipSetListener);
|
||||
}
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
@ -456,6 +539,10 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean hasStr(String tipStr) {
|
||||
return (tipStr!=null && tipStr.trim().length()>0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
|
||||
*/
|
||||
|
@ -584,6 +671,35 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
updateFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the page needs to have the tool tip box.
|
||||
* @since 5.2
|
||||
*/
|
||||
protected boolean needToolTipBox(IHoldsOptions optionHolder, IOptionCategory category) {
|
||||
if (optionHolder instanceof ITool) { // option category page
|
||||
Object[][] options = category.getOptions(fInfo, optionHolder);
|
||||
for (int index = 0; index < options.length; ++index) {
|
||||
IHoldsOptions holder = (IHoldsOptions)options[index][0];
|
||||
if (holder == null) break; // The array may not be full
|
||||
IOption opt = (IOption)options[index][1];
|
||||
String tipStr = TextProcessor.process(opt.getToolTip());
|
||||
|
||||
// check to see if the option has an applicability calculator
|
||||
IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator();
|
||||
IBuildObject config = fInfo;
|
||||
|
||||
if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) {
|
||||
if (hasStr(tipStr)) {
|
||||
return true; // an option with a tip string was found.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// A tool option summary page does not list individual options
|
||||
// so never should have the box
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The items shown in an enumerated option may depend on other option values.
|
||||
* Whenever an option changes, check and update the valid enum values in
|
||||
|
@ -633,7 +749,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
enumValidList.copyInto(enumValidNames);
|
||||
|
||||
if ( selectNewEnum ) {
|
||||
// apparantly the currently selected enum value is not part anymore of the enum list
|
||||
// apparently the currently selected enum value is not part anymore of the enum list
|
||||
// select a new value.
|
||||
String selection = null;
|
||||
if ( selectDefault ) {
|
||||
|
@ -649,6 +765,16 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
fieldEditor.load();
|
||||
}
|
||||
|
||||
private final Listener tipSetListener = new Listener() {
|
||||
public void handleEvent(Event event) {
|
||||
Object data = event.widget.getData();
|
||||
if (data!=null && buildPropPage!=null) {
|
||||
TipInfo obj = (TipInfo)data;
|
||||
((ToolSettingsTab)buildPropPage).updateTipText(obj.getName(), obj.getTip());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -664,8 +790,15 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI {
|
|||
holders = ho;
|
||||
current = curr;
|
||||
button = getChangeControl(parent);
|
||||
if (displayFixedTip && isToolTipBoxNeeded()) {
|
||||
button.setData(new TipInfo(labelText,tooltip));
|
||||
button.addListener(selectAction, tipSetListener);
|
||||
} else {
|
||||
button.setToolTipText(tooltip);
|
||||
if (!contextId.equals(AbstractPage.EMPTY_STR)) PlatformUI.getWorkbench().getHelpSystem().setHelp(button, contextId);
|
||||
}
|
||||
if (!contextId.equals(AbstractPage.EMPTY_STR)) {
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(button, contextId);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2008 BitMethods Inc and others.
|
||||
* Copyright (c) 2004, 2009 BitMethods 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* BitMethods Inc - Initial API and implementation
|
||||
* ARM Ltd. - basic tooltip support
|
||||
* Miwako Tokugawa (Intel Corporation) - Fixed-location tooltip support
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||
|
||||
|
@ -147,8 +148,8 @@ public class FileListControlFieldEditor extends FieldEditor {
|
|||
topLayout = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = numColumns;
|
||||
layout.marginWidth = 7;
|
||||
layout.marginHeight = 5;
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
layout.makeColumnsEqualWidth = false;
|
||||
topLayout.setLayout(layout);
|
||||
GridData gddata = new GridData(GridData.FILL_HORIZONTAL);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
* Miwako Tokugawa (Intel Corporation) - Fixed-location tooltip support
|
||||
* QNX Software Systems - [269571] Apply button failure on tool changes
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||
|
@ -32,6 +33,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
|
|||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.MultiConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
||||
import org.eclipse.cdt.ui.newui.PageLayout;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jface.preference.IPreferencePageContainer;
|
||||
|
@ -46,8 +48,12 @@ import org.eclipse.jface.viewers.ViewerFilter;
|
|||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.custom.ScrolledComposite;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -61,7 +67,10 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
* Dialog widgets
|
||||
*/
|
||||
private TreeViewer optionList;
|
||||
private StyledText tipText;
|
||||
private StyleRange styleRange;
|
||||
private SashForm sashForm;
|
||||
private SashForm sashForm2;
|
||||
private Composite settingsPageContainer;
|
||||
private ScrolledComposite containerSC;
|
||||
|
||||
|
@ -77,6 +86,10 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
|
||||
private IResourceInfo fInfo;
|
||||
|
||||
private boolean displayFixedTip = CDTPrefUtil.getBool(CDTPrefUtil.KEY_TIPBOX);
|
||||
private int[] defaultWeights = new int[] {4, 1};
|
||||
private int[] hideTipBoxWeights = new int[] {1, 0};
|
||||
|
||||
@Override
|
||||
public void createControls(Composite par) {
|
||||
super.createControls(par);
|
||||
|
@ -94,9 +107,17 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
layout.numColumns = 2;
|
||||
layout.marginHeight = 5;
|
||||
sashForm.setLayout(layout);
|
||||
if (displayFixedTip==false) {
|
||||
createSelectionArea(sashForm);
|
||||
createEditArea(sashForm);
|
||||
|
||||
} else {
|
||||
createSelectionArea(sashForm);
|
||||
sashForm2 = new SashForm(sashForm, SWT.NONE);
|
||||
sashForm2.setOrientation(SWT.VERTICAL);
|
||||
createEditArea(sashForm2);
|
||||
createTipArea(sashForm2);
|
||||
sashForm2.setWeights(defaultWeights);
|
||||
}
|
||||
usercomp.addControlListener(new ControlAdapter() {
|
||||
@Override
|
||||
public void controlResized(ControlEvent e) {
|
||||
|
@ -108,7 +129,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
}
|
||||
|
||||
private void specificResize() {
|
||||
Point p1 = optionList.getTree().computeSize(-1, -1);
|
||||
Point p1 = optionList.getTree().computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
||||
Point p2 = optionList.getTree().getSize();
|
||||
Point p3 = usercomp.getSize();
|
||||
p1.x += calcExtra();
|
||||
|
@ -147,6 +168,33 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name - header of the tooltip help
|
||||
* @param tip - tooltip text
|
||||
* @since 5.2
|
||||
*/
|
||||
protected void updateTipText(String name, String tip) {
|
||||
if (tipText==null) {
|
||||
return;
|
||||
}
|
||||
tipText.setText(name+"\n\n"+tip); //$NON-NLS-1$
|
||||
styleRange.length = name.length();
|
||||
tipText.setStyleRange(styleRange);
|
||||
tipText.update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method resetTipText
|
||||
* @since 7.0
|
||||
*/
|
||||
private void resetTipText() {
|
||||
if (tipText==null) {
|
||||
return;
|
||||
}
|
||||
tipText.setText(Messages.getString("ToolSettingsTab.0")); //$NON-NLS-1$
|
||||
tipText.update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Method displayOptionsForCategory
|
||||
* @param category
|
||||
|
@ -176,9 +224,15 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
this,
|
||||
fInfo,
|
||||
optionHolder,
|
||||
category);
|
||||
category,
|
||||
displayFixedTip);
|
||||
boolean needToolTipBox = false;
|
||||
if (displayFixedTip==true) {
|
||||
needToolTipBox = ((BuildOptionSettingsUI)currentSettingsPage).needToolTipBox(optionHolder,category);
|
||||
}
|
||||
pages.add(currentSettingsPage);
|
||||
currentSettingsPage.setContainer(this);
|
||||
currentSettingsPage.setToolTipBoxNeeded(needToolTipBox);
|
||||
if (currentSettingsPage.getControl() == null) {
|
||||
currentSettingsPage.createControl(settingsPageContainer);
|
||||
}
|
||||
|
@ -191,11 +245,25 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
if (children[i] != currentControl)
|
||||
children[i].setVisible(false);
|
||||
}
|
||||
|
||||
if (displayFixedTip==true) {
|
||||
if (currentSettingsPage.isToolTipBoxNeeded()==false) {
|
||||
// eliminate the option tip box
|
||||
sashForm2.setWeights(hideTipBoxWeights);
|
||||
sashForm2.layout();
|
||||
} else {
|
||||
// display the option tip box
|
||||
sashForm2.setWeights(defaultWeights);
|
||||
sashForm2.layout();
|
||||
}
|
||||
}
|
||||
currentSettingsPage.setVisible(true);
|
||||
currentSettingsPage.updateFields();
|
||||
|
||||
if (oldPage != null && oldPage != currentSettingsPage)
|
||||
if (oldPage != null && oldPage != currentSettingsPage) {
|
||||
oldPage.setVisible(false);
|
||||
resetTipText();
|
||||
}
|
||||
|
||||
// Set the size of the scrolled area
|
||||
containerSC.setMinSize(currentSettingsPage.computeSize());
|
||||
|
@ -241,6 +309,12 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
children[i].setVisible(false);
|
||||
}
|
||||
|
||||
if (displayFixedTip==true) {
|
||||
// eliminate the tool tip area
|
||||
sashForm2.setWeights(hideTipBoxWeights);
|
||||
sashForm2.layout();
|
||||
}
|
||||
|
||||
// Make the current page visible
|
||||
currentSettingsPage.setVisible(true);
|
||||
|
||||
|
@ -258,11 +332,33 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
settingsPageContainer.layout();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Add the fixed-location tool tip box.
|
||||
*/
|
||||
private void createTipArea (Composite parent) {
|
||||
tipText = new StyledText(parent, SWT.V_SCROLL|SWT.BORDER | SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
|
||||
tipText.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
tipText.setText(Messages.getString("ToolSettingsTab.0")); //$NON-NLS-1$
|
||||
|
||||
styleRange = new StyleRange();
|
||||
styleRange.start = 0;
|
||||
FontData data = new FontData();
|
||||
data.setHeight(10);
|
||||
//data.setName("sans");
|
||||
data.setStyle(SWT.BOLD);
|
||||
Font font = new Font(parent.getDisplay(),data);
|
||||
styleRange.font = font;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Add the tabs relevant to the project to edit area tab folder.
|
||||
*/
|
||||
protected void createEditArea(Composite parent) {
|
||||
containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
int style = (SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
if (displayFixedTip) {
|
||||
style |= SWT.BORDER;
|
||||
}
|
||||
containerSC = new ScrolledComposite(parent, style);
|
||||
containerSC.setExpandHorizontal(true);
|
||||
containerSC.setExpandVertical(true);
|
||||
|
||||
|
@ -573,7 +669,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the "dirty" state
|
||||
* @return the "dirty" state
|
||||
*/
|
||||
public boolean isDirty() {
|
||||
// Check each settings page
|
||||
|
@ -593,12 +689,13 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the build macro provider to be used for macro resolution
|
||||
* @return the build macro provider to be used for macro resolution
|
||||
* In case the "Build Macros" tab is available, returns the BuildMacroProvider
|
||||
* supplied by that tab.
|
||||
* Unlike the default provider, that provider also contains
|
||||
* the user-modified macros that are not applied yet
|
||||
* If the "Build Macros" tab is not available, returns the default BuildMacroProvider
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public BuildMacroProvider obtainMacroProvider(){
|
||||
|
|
|
@ -103,6 +103,8 @@ PreferredToolchainsTab.0=Preferred toolchain will be selected by default in Wiza
|
|||
PreferredToolchainsTab.1=Make toolchain(s) preferred
|
||||
PreferredToolchainsTab.2=Make toolchain(s) not preferred
|
||||
PreferredToolchainsTab.3=Preferred toolchain(s):
|
||||
ToolSettingsTab.0=Hover over an option to display its tooltip
|
||||
BuildOptionSettingsUI.0=No tooltip is available for this option
|
||||
StdProjectTypeHandler.0=-- Other Toolchain --
|
||||
StdProjectTypeHandler.2=Default
|
||||
StdProjectTypeHandler.3=creation Make project: IBuilder is null
|
||||
|
|
|
@ -37,6 +37,8 @@ public class CDTPrefUtil {
|
|||
public static final String KEY_DTREE = "properties.data.hierarchy.enable"; //$NON-NLS-1$
|
||||
public static final String KEY_NOTOOLM = "properties.toolchain.modification.disable"; //$NON-NLS-1$
|
||||
public static final String KEY_EXPORT = "properties.export.page.enable"; //$NON-NLS-1$
|
||||
/** @since 5.2 */
|
||||
public static final String KEY_TIPBOX = "properties.option.tipbox.enable"; //$NON-NLS-1$
|
||||
// string keys
|
||||
public static final String KEY_PREFTC = "wizard.preferred.toolchains"; //$NON-NLS-1$
|
||||
public static final String KEY_CONFSET = "workingsets.selected.configs"; //$NON-NLS-1$
|
||||
|
|
|
@ -289,6 +289,7 @@ PropertyPageDefsTab.12=Save size and position
|
|||
PropertyPageDefsTab.13=Save size only
|
||||
PropertyPageDefsTab.14=Do not save at all
|
||||
PropertyPageDefsTab.15=Center dialogs on screen
|
||||
PropertyPageDefsTab.16=Display tool option tips at a fixed location
|
||||
PropertyPageDefsTab.4=Display "Tool Chain Editor" tab
|
||||
PropertyPageDefsTab.5=Discovery profiles naming rule
|
||||
PropertyPageDefsTab.6=Show disc. page names if they are unique. Else names + profile IDs.
|
||||
|
|
Loading…
Add table
Reference in a new issue