true
if the settings page has been created for
+ * the option category specified in the argument.
+ *
* @param category
* @return
*/
@@ -87,14 +119,13 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
}
return false;
}
-
- /**
- * @see IPreferencePage#performOk()
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
public boolean performOk() {
// Write the field editor contents out to the preference store
boolean ok = super.performOk();
-
// Write the preference store values back to the build model
IOption[] options = category.getOptions(configuration);
for (int i = 0; i < options.length; i++) {
@@ -103,32 +134,57 @@ public class BuildOptionSettingsPage extends BuildSettingsPage {
// Transfer value from preference store to options
switch (option.getValueType()) {
case IOption.BOOLEAN :
- boolean boolVal = getPreferenceStore().getBoolean(option.getId());
- ManagedBuildManager.setOption(configuration, option, boolVal);
+ boolean boolVal = getPreferenceStore().getBoolean(
+ option.getId());
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
break;
case IOption.ENUMERATED :
- String enumVal = getPreferenceStore().getString(option.getId());
- ManagedBuildManager.setOption(configuration, option, enumVal);
+ String enumVal = getPreferenceStore().getString(
+ option.getId());
+ ManagedBuildManager.setOption(configuration, option,
+ enumVal);
break;
case IOption.STRING :
- String strVal = getPreferenceStore().getString(option.getId());
- ManagedBuildManager.setOption(configuration, option, strVal);
+ String strVal = getPreferenceStore().getString(
+ option.getId());
+ ManagedBuildManager
+ .setOption(configuration, option, strVal);
break;
case IOption.STRING_LIST :
case IOption.INCLUDE_PATH :
case IOption.PREPROCESSOR_SYMBOLS :
case IOption.LIBRARIES :
- case IOption.OBJECTS:
- String listStr = getPreferenceStore().getString(option.getId());
- String[] listVal = BuildToolsSettingsStore.parseString(listStr);
- ManagedBuildManager.setOption(configuration, option, listVal);
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(
+ option.getId());
+ String[] listVal = BuildToolsSettingsStore
+ .parseString(listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
break;
default :
break;
- }
+ }
}
-
return ok;
}
-
+
+ /**
+ * Update field editors in this page when the page is loaded.
+ */
+ public void updateFields() {
+ for (int i = 0; i < fieldsList.size(); i++) {
+ FieldEditor editor = (FieldEditor) fieldsList.get(i);
+ editor.loadDefault();
+ editor.load();
+ }
+ }
+
+ /**
+ * saves all field editors
+ */
+ public void storeSettings() {
+ super.performOk();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
index 7e3eee63f47..dff9bf690e9 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java
@@ -25,12 +25,14 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildSettingsPage;
+import org.eclipse.cdt.managedbuilder.ui.properties.BuildToolsSettingsStore;
+import org.eclipse.cdt.managedbuilder.ui.properties.ToolListContentProvider;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.preference.IPreferencePageContainer;
@@ -325,6 +327,23 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
children[i].setVisible(false);
}
currentSettingsPage.setVisible(true);
+
+ // save the last page build options.
+ // If the last page is tool page then parse all the options
+ // and put it in the appropriate preference store.
+ if (oldPage != null){
+ if(oldPage instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)oldPage).storeSettings();
+ }
+ else if(oldPage instanceof BuildToolSettingsPage) {
+ ((BuildToolSettingsPage)oldPage).storeSettings();
+ ((BuildToolSettingsPage)oldPage).parseAllOptions();
+ }
+ }
+ //update the field editors in the current page
+ if(currentSettingsPage instanceof BuildOptionSettingsPage)
+ ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
+
if (oldPage != null)
oldPage.setVisible(false);
@@ -376,6 +395,23 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
children[i].setVisible(false);
}
currentSettingsPage.setVisible(true);
+
+ // save the last page build options.
+ // If the last page is tool page then parse all the options
+ // and put it in the appropriate preference store.
+ if (oldPage != null){
+ if(oldPage instanceof BuildOptionSettingsPage) {
+ ((BuildOptionSettingsPage)oldPage).storeSettings();
+ }
+ else if(oldPage instanceof BuildToolSettingsPage) {
+ ((BuildToolSettingsPage)oldPage).storeSettings();
+ ((BuildToolSettingsPage)oldPage).parseAllOptions();
+ }
+ }
+ //update the field editor that displays all the build options
+ if(currentSettingsPage instanceof BuildToolSettingsPage)
+ ((BuildToolSettingsPage)currentSettingsPage).updateAllOptionField();
+
if (oldPage != null)
oldPage.setVisible(false);
@@ -395,7 +431,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
return names;
}
- /**
+ /* (non-Javadoc)
* @return
*/
protected Point getLastShellSize() {
@@ -440,10 +476,10 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
return null;
}
- /**
+ /* (non-Javadoc)
* @return
*/
- public IConfiguration getSelectedConfiguration() {
+ protected IConfiguration getSelectedConfiguration() {
return selectedConfiguration;
}
@@ -478,9 +514,9 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
Object primary = elements.length > 0 ? elements[0] : null;
if (primary != null && primary instanceof ITool) {
- // Check to see if there are any options.
+ // set the tool as primary selection in the tree hence it displays all the build options.
ITool tool = (ITool)primary;
- IOptionCategory top = tool.getTopOptionCategory();
+ /* IOptionCategory top = tool.getTopOptionCategory();
IOption[] topOpts = top.getOptions(selectedConfiguration);
if (topOpts != null && topOpts.length == 0) {
// Get the children categories and start looking
@@ -493,7 +529,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
break;
}
}
- }
+ }*/
}
if (primary != null) {
@@ -543,6 +579,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
configurations = selectedTarget.getConfigurations();
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
+ configSelector.add(ManagedBuilderUIPlugin.getResourceString(ALL_CONFS));
configSelector.select(0);
updateConfigs = true;
}
@@ -568,6 +605,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
configurations = selectedTarget.getConfigurations();
configSelector.removeAll();
configSelector.setItems(getConfigurationNames());
+ configSelector.add(ManagedBuilderUIPlugin.getResourceString(ALL_CONFS));
configSelector.select(configSelector.indexOf(name));
updateConfigs = true;
}
@@ -768,6 +806,11 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
while (iter.hasNext()) {
BuildSettingsPage page = (BuildSettingsPage) iter.next();
if (page instanceof BuildToolSettingsPage) {
+ // if the currentsettings page is not the tool settings page
+ // then update the all build options field editor based on the
+ // build options in other options settings page.
+ if (!(currentSettingsPage instanceof BuildToolSettingsPage))
+ ((BuildToolSettingsPage)page).updateAllOptionField();
((BuildToolSettingsPage)page).performOk();
} else if (page instanceof BuildOptionSettingsPage) {
((BuildOptionSettingsPage)page).performOk();
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
index 8d867b56169..17f3e8510c6 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolSettingsPage.java
@@ -10,49 +10,334 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* Contributors:
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolReference;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.graphics.Point;
public class BuildToolSettingsPage extends BuildSettingsPage {
// Field editor label
- private static final String COMMAND = "FieldEditors.tool.command"; //$NON-NLS-1$
-
+ private static final String COMMAND = "FieldEditors.tool.command"; //$NON-NLS-1$
+ // option names that stores additional options
+ private static final String COMPILER_FLAGS = ManagedBuilderUIPlugin.getResourceString("BuildToolSettingsPage.compilerflags"); //$NON-NLS-1$
+ private static final String LINKER_FLAGS = ManagedBuilderUIPlugin.getResourceString("BuildToolSettingsPage.linkerflags"); //$NON-NLS-1$
+ // all build options field editor label
+ private static final String ALL_OPTIONS = ManagedBuilderUIPlugin.getResourceString("BuildToolSettingsPage.alloptions"); //$NON-NLS-1$
+ // Whitespace character
+ private static final String WHITESPACE = " "; //$NON-NLS-1$
+ // field editor that displays all the build options for a particular tool
+ private MultiLineTextFieldEditor allOptionFieldEditor;
+ private static final String DEFAULT_SEPERATOR = ";"; //$NON-NLS-1$
// Tool the settings belong to
private ITool tool;
-
+ // all build options preference store id
+ private String allOptionsId = ""; //$NON-NLS-1$
+
BuildToolSettingsPage(IConfiguration configuration, ITool tool) {
// Cache the configuration and tool this page is for
super(configuration);
this.tool = tool;
+ allOptionsId = tool.getId() + ".allOptions"; //$NON-NLS-1$
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.preference.PreferencePage#computeSize()
*/
public Point computeSize() {
return super.computeSize();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
protected void createFieldEditors() {
// Load up the preference store
super.createFieldEditors();
-
// Add a string editor to edit the tool command
- StringFieldEditor stringField = new StringFieldEditor(tool.getId(), ManagedBuilderUIPlugin.getResourceString(COMMAND), getFieldEditorParent());
+ StringFieldEditor stringField = new StringFieldEditor(tool.getId(),
+ ManagedBuilderUIPlugin.getResourceString(COMMAND),
+ getFieldEditorParent());
stringField.setEmptyStringAllowed(false);
- addField(stringField);
+ addField(stringField);
+ // Add a field editor that displays over all build options
+ allOptionFieldEditor = new MultiLineTextFieldEditor(allOptionsId,
+ ALL_OPTIONS, getFieldEditorParent());
+ getPreferenceStore().setValue(allOptionsId, ""); //$NON-NLS-1$
+ addField(allOptionFieldEditor);
+ }
+
+ /**
+ * Update the field editor that displays all the build options
+ */
+ public void updateAllOptionField() {
+ try {
+ if (getToolFlags() != null) {
+ getPreferenceStore().setValue(allOptionsId, getToolFlags());
+ allOptionFieldEditor.load();
+ }
+ } catch (BuildException e) {
+ }
+ }
+
+ /**
+ * saves all field editors
+ */
+ public void storeSettings() {
+ super.performOk();
}
/**
- * Answers true
if the receiver manages settings for the argument
+ * Returns all the build options string
+ *
+ * @return @throws
+ * BuildException
+ */
+ private String getToolFlags() throws BuildException {
+ ITool[] tools = configuration.getTools();
+ for (int i = 0; i < tools.length; ++i) {
+ if (tools[i] instanceof ToolReference) {
+ if (((ToolReference) tools[i]).references(tool)) {
+ tool = tools[i];
+ break;
+ }
+ } else if (tools[i].equals(tool))
+ break;
+ }
+ StringBuffer buf = new StringBuffer();
+ // get the options for this tool
+ IOption[] options = tool.getOptions();
+ String listStr = ""; //$NON-NLS-1$
+ String[] listVal = null;
+ for (int k = 0; k < options.length; k++) {
+ IOption option = options[k];
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ if (getPreferenceStore().getBoolean(option.getId())) {
+ buf.append(option.getCommand() + ITool.WHITE_SPACE);
+ }
+ break;
+ case IOption.ENUMERATED :
+ String enumCommand = getPreferenceStore().getString(
+ option.getId());
+ if (enumCommand.indexOf(DEFAULT_SEPERATOR) != -1)
+ enumCommand = option.getSelectedEnum();
+ String enum = option.getEnumCommand(enumCommand);
+ if (enum.length() > 0) {
+ buf.append(enum + ITool.WHITE_SPACE);
+ }
+ break;
+ case IOption.STRING :
+ String val = getPreferenceStore().getString(option.getId());
+ if (val.length() > 0) {
+ buf.append(val + ITool.WHITE_SPACE);
+ }
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String cmd = option.getCommand();
+ listStr = getPreferenceStore().getString(option.getId());
+ listVal = BuildToolsSettingsStore.parseString(listStr);
+ for (int j = 0; j < listVal.length; j++) {
+ String temp = listVal[j];
+ if (cmd != null)
+ buf.append(cmd + temp + ITool.WHITE_SPACE);
+ else
+ buf.append(temp + ITool.WHITE_SPACE);
+ }
+ break;
+ default :
+ break;
+ }
+ }
+ return buf.toString().trim();
+ }
+
+ /**
+ * Creates single string from the string array with a separator
+ *
+ * @param items
+ * @return
+ */
+ private String createList(String[] items) {
+ StringBuffer path = new StringBuffer(""); //$NON-NLS-1$
+ for (int i = 0; i < items.length; i++) {
+ path.append(items[i]);
+ if (i < (items.length - 1)) {
+ path.append(DEFAULT_SEPERATOR);
+ }
+ }
+ return path.toString();
+ }
+
+ /**
+ * This method parses the string that is entered in the all build option
+ * field editor and stores the options to the corresponding option fields.
+ */
+ public void parseAllOptions() {
+ ITool[] tools = configuration.getTools();
+ for (int i = 0; i < tools.length; ++i) {
+ if (tools[i] instanceof ToolReference) {
+ if (((ToolReference) tools[i]).references(tool)) {
+ tool = tools[i];
+ break;
+ }
+ } else if (tools[i].equals(tool))
+ break;
+ }
+ // Get the all build options string from all options field
+ String alloptions = getPreferenceStore().getString(allOptionsId);
+ // list that holds the options for the option type other than
+ // boolean,string and enumerated
+ List optionsList = new ArrayList();
+ // additional options buffer
+ StringBuffer addnOptions = new StringBuffer();
+ // split all build options string
+ String[] optionsArr = alloptions.split(WHITESPACE);
+ for (int j = 0; j < optionsArr.length; j++) {
+ boolean optionValueExist = false;
+ // get the options for this tool
+ IOption[] options = tool.getOptions();
+ for (int k = 0; k < options.length; ++k) {
+ IOption opt = options[k];
+ String name = opt.getId();
+ // check whether the option value is already exist
+ // and also change the preference store based on
+ // the option value
+ switch (opt.getValueType()) {
+ case IOption.BOOLEAN :
+ if (opt.getCommand().equals(optionsArr[j])) {
+ getPreferenceStore().setValue(opt.getId(), true);
+ optionValueExist = true;
+ }
+ break;
+ case IOption.ENUMERATED :
+ String enum = ""; //$NON-NLS-1$
+ String[] enumValues = opt.getApplicableValues();
+ for (int i = 0; i < enumValues.length; i++) {
+ if (opt.getEnumCommand(enumValues[i]).equals(
+ optionsArr[j])) {
+ enum = enumValues[i];
+ optionValueExist = true;
+ }
+ }
+ if (!enum.equals("")) //$NON-NLS-1$
+ getPreferenceStore().setValue(opt.getId(), enum);
+ break;
+ case IOption.STRING :
+ String str = getPreferenceStore()
+ .getString(opt.getId());
+ if (alloptions.indexOf(str) == -1) {
+ getPreferenceStore().setValue(opt.getId(), ""); //$NON-NLS-1$
+ }
+ if (str.indexOf(optionsArr[j]) != -1) {
+ optionValueExist = true;
+ }
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ if (opt.getCommand() != null
+ && optionsArr[j].startsWith(opt.getCommand())
+ && !optionsList.contains(optionsArr[j])) {
+ optionsList.add(optionsArr[j]);
+ optionValueExist = true;
+ }
+ break;
+ case IOption.OBJECTS :
+ String userObjStr = getPreferenceStore().getString(
+ opt.getId());
+ String[] userObjs = BuildToolsSettingsStore
+ .parseString(userObjStr);
+ for (int m = 0; m < userObjs.length; m++) {
+ if (userObjs[m].equalsIgnoreCase(optionsArr[j]))
+ optionValueExist = true;
+ }
+ break;
+ default :
+ break;
+ }
+ }
+ // If the parsed string does not match with any previous option
+ // values then consider this option as a additional build option
+ if (!optionValueExist) {
+ addnOptions.append(optionsArr[j] + ITool.WHITE_SPACE);
+ }
+ }
+ // Now update the preference store with parsed options
+ // Get the options for this tool
+ IOption[] options = tool.getOptions();
+ for (int k = 0; k < options.length; ++k) {
+ IOption opt = options[k];
+ String name = opt.getId();
+ String listStr = ""; //$NON-NLS-1$
+ String[] listVal = null;
+ switch (opt.getValueType()) {
+ case IOption.BOOLEAN :
+ ArrayList optsList = new ArrayList(Arrays
+ .asList(optionsArr));
+ if (opt.getCommand() != null
+ && !optsList.contains(opt.getCommand()))
+ getPreferenceStore().setValue(opt.getId(), false);
+ break;
+ case IOption.STRING :
+ // put the additional options in the compiler flag or
+ // linker flag field
+ if (opt.getName().equals(COMPILER_FLAGS)
+ || opt.getName().equals(LINKER_FLAGS)) {
+ String newOptions = getPreferenceStore().getString(
+ opt.getId());
+ if (addnOptions.length() > 0) {
+ newOptions = newOptions + ITool.WHITE_SPACE
+ + addnOptions.toString().trim();
+ }
+ getPreferenceStore().setValue(opt.getId(), newOptions);
+ }
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ ArrayList newList = new ArrayList();
+ for (int i = 0; i < optionsList.size(); i++) {
+ if (opt.getCommand() != null
+ && ((String) optionsList.get(i)).startsWith(opt
+ .getCommand())) {
+ newList.add(((String) optionsList.get(i))
+ .substring(opt.getCommand().length()));
+ }
+ }
+ String[] strlist = new String[newList.size()];
+ newList.toArray(strlist);
+ newList.clear();
+ getPreferenceStore().setValue(opt.getId(),
+ BuildToolsSettingsStore.createList(strlist));
+ break;
+ default :
+ break;
+ }
+ }
+ }
+
+ /**
+ * Answers true
if the receiver manages settings for the
+ * argument
*
* @param tool
* @return
@@ -71,6 +356,61 @@ public class BuildToolSettingsPage extends BuildSettingsPage {
// Do the super-class thang
boolean result = super.performOk();
+ //parse and store all build options in the corresponding preference store
+ parseAllOptions();
+
+ // Write the preference store values back to the build model
+ ITool[] tools = configuration.getTools();
+ for (int i = 0; i < tools.length; ++i) {
+ if (tools[i] instanceof ToolReference) {
+ if (((ToolReference) tools[i]).references(tool)) {
+ tool = tools[i];
+ break;
+ }
+ } else if (tools[i].equals(tool)) {
+ break;
+ }
+ }
+ IOption[] options = tool.getOptions();
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+ // Transfer value from preference store to options
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = getPreferenceStore().getBoolean(
+ option.getId());
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
+ break;
+ case IOption.ENUMERATED :
+ String enumVal = getPreferenceStore().getString(
+ option.getId());
+ ManagedBuildManager.setOption(configuration, option,
+ enumVal);
+ break;
+ case IOption.STRING :
+ String strVal = getPreferenceStore().getString(
+ option.getId());
+ ManagedBuildManager
+ .setOption(configuration, option, strVal);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(
+ option.getId());
+ String[] listVal = BuildToolsSettingsStore
+ .parseString(listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
+ break;
+ default :
+ break;
+ }
+ }
+
// Get the actual value out of the field editor
String command = getPreferenceStore().getString(tool.getId());
if (command.length() == 0) {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java
index 5614952afb3..33fe8d77808 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildToolsSettingsStore.java
@@ -11,10 +11,8 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
* IBM Rational Software - Initial API and implementation
* **********************************************************************/
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import java.util.StringTokenizer;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -54,14 +52,14 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
public void addPropertyChangeListener(IPropertyChangeListener listener) {
listenerList.add(listener);
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String)
*/
public boolean contains(String name) {
@@ -87,7 +85,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
return path.toString();
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, java.lang.Object, java.lang.Object)
*/
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
@@ -103,7 +101,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
}
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String)
*/
public boolean getBoolean(String name) {
@@ -185,7 +183,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
return getDefaultLong(name);
}
- /* (non-javadoc)
+ /* (non-Javadoc)
* Answers the map containing the strings associated with each option
* ID.
*
@@ -223,8 +221,12 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
break;
case IOption.ENUMERATED :
- value = createList(opt.getApplicableValues());
- getSettingsMap().put(name, value);
+ try{
+ value = opt.getSelectedEnum();
+ } catch (BuildException e) {
+ break;
+ }
+ getSettingsMap().put(name, value);
break;
case IOption.STRING :
@@ -282,7 +284,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
}
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String)
*/
public String getString(String name) {
@@ -295,30 +297,33 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
return getDefaultString(name);
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String)
*/
public boolean isDefault(String name) {
return false;
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
*/
public boolean needsSaving() {
return dirtyFlag;
}
+ /**
+ * @param stringList
+ * @return
+ */
public static String[] parseString(String stringList) {
- StringTokenizer tokenizer = new StringTokenizer(stringList, BuildToolsSettingsStore.DEFAULT_SEPERATOR);
- ArrayList list = new ArrayList();
- while (tokenizer.hasMoreElements()) {
- list.add(tokenizer.nextElement());
+ if (stringList == null || stringList.length() == 0) {
+ return new String[0];
+ } else {
+ return stringList.split(BuildToolsSettingsStore.DEFAULT_SEPERATOR);
}
- return (String[]) list.toArray(new String[list.size()]);
}
- /**
+ /* (non-Javadoc)
*
*/
private void populateSettingsMap() {
@@ -335,7 +340,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
}
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, java.lang.String)
*/
public void putValue(String name, String value) {
@@ -347,19 +352,19 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
}
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
*/
public void removePropertyChangeListener(IPropertyChangeListener listener) {
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, double)
*/
public void setDefault(String name, double value) {
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, float)
*/
public void setDefault(String name, float value) {
@@ -424,7 +429,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
public void setValue(String name, long value) {
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, java.lang.String)
*/
public void setValue(String name, String value) {
@@ -437,7 +442,7 @@ public class BuildToolsSettingsStore implements IPreferenceStore {
}
}
- /**
+ /* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, boolean)
*/
public void setValue(String name, boolean value) {
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/MultiLineTextFieldEditor.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/MultiLineTextFieldEditor.java
new file mode 100644
index 00000000000..037d61c9667
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/MultiLineTextFieldEditor.java
@@ -0,0 +1,553 @@
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+/**********************************************************************
+ * Copyright (c) 2004 BitMethods Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * BitMethods Inc - Initial API and implementation
+ ***********************************************************************/
+
+import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * MultiLineTextFieldEditor.
+ * Field editor that is same as string field editor but
+ * will have the multi line text field for user input.
+ */
+public class MultiLineTextFieldEditor extends FieldEditor {
+
+ private static final String ERROR_MESSAGE = "Multiline.error.message"; //$NON-NLS-1$
+
+ /**
+ * Validation strategy constant (value 0
) indicating that
+ * the editor should perform validation after every key stroke.
+ *
+ * @see #setValidateStrategy
+ */
+ public static final int VALIDATE_ON_KEY_STROKE = 0;
+
+ /**
+ * Validation strategy constant (value 1
) indicating that
+ * the editor should perform validation only when the text widget
+ * loses focus.
+ *
+ * @see #setValidateStrategy
+ */
+ public static final int VALIDATE_ON_FOCUS_LOST = 1;
+
+ /**
+ * Text limit constant (value -1
) indicating unlimited
+ * text limit and width.
+ */
+ public static int UNLIMITED = -1;
+
+ /**
+ * Cached valid state.
+ */
+ private boolean isValid;
+
+ /**
+ * Old text value.
+ */
+ private String oldValue;
+ private String compTitle;
+ private Label title;
+
+ /**
+ * The text field, or null
if none.
+ */
+ private Text textField;
+
+ /**
+ * Width of text field in characters; initially unlimited.
+ */
+ private int widthInChars = UNLIMITED;
+
+ /**
+ * Text limit of text field in characters; initially unlimited.
+ */
+ private int textLimit = UNLIMITED;
+
+ /**
+ * The error message, or null
if none.
+ */
+ private String errorMessage;
+
+ /**
+ * Indicates whether the empty string is legal;
+ * true
by default.
+ */
+ private boolean emptyStringAllowed = true;
+
+ /**
+ * The validation strategy;
+ * VALIDATE_ON_KEY_STROKE
by default.
+ */
+ private int validateStrategy = VALIDATE_ON_KEY_STROKE;
+ /**
+ * Creates a new string field editor
+ */
+ protected MultiLineTextFieldEditor() {
+ }
+ /**
+ * Creates a string field editor.
+ * Use the method setTextLimit
to limit the text.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param width the width of the text input field in characters,
+ * or UNLIMITED
for no limit
+ * @param strategy either VALIDATE_ON_KEY_STROKE
to perform
+ * on the fly checking (the default), or VALIDATE_ON_FOCUS_LOST
to
+ * perform validation only after the text has been typed in
+ * @param parent the parent of the field editor's control
+ * @since 2.0
+ */
+ public MultiLineTextFieldEditor(
+ String name,
+ String labelText,
+ int width,
+ int strategy,
+ Composite parent) {
+ init(name, labelText);
+ widthInChars = width;
+ setValidateStrategy(strategy);
+ isValid = false;
+ errorMessage = ManagedBuilderUIPlugin.getResourceString(ERROR_MESSAGE);
+ createControl(parent);
+ }
+
+ /**
+ * Creates a string field editor.
+ * Use the method setTextLimit
to limit the text.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param width the width of the text input field in characters,
+ * or UNLIMITED
for no limit
+ * @param parent the parent of the field editor's control
+ */
+ public MultiLineTextFieldEditor(String name, String labelText, int width, Composite parent) {
+ this(name, labelText, width, VALIDATE_ON_KEY_STROKE, parent);
+ this.compTitle = labelText;
+ }
+ /**
+ * Creates a string field editor of unlimited width.
+ * Use the method setTextLimit
to limit the text.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param parent the parent of the field editor's control
+ */
+ public MultiLineTextFieldEditor(String name, String labelText, Composite parent) {
+ this(name, labelText, UNLIMITED, parent);
+ }
+
+ /**
+ * Adjusts the horizontal span of this field editor's basic controls
+ * + * Subclasses must implement this method to adjust the horizontal span + * of controls so they appear correct in the given number of columns. + *
+ *
+ * The number of columns will always be equal to or greater than the
+ * value returned by this editor's getNumberOfControls
method.
+ *
+ * @param numColumns the number of columns
+ */
+ protected void adjustForNumColumns(int numColumns) {
+ GridData gd = (GridData) textField.getLayoutData();
+ gd.horizontalSpan = numColumns - 1;
+ // We only grab excess space if we have to
+ // If another field editor has more columns then
+ // we assume it is setting the width.
+ gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1;
+ }
+ /**
+ * Checks whether the text input field contains a valid value or not.
+ *
+ * @return true
if the field value is valid,
+ * and false
if invalid
+ */
+ protected boolean checkState() {
+ boolean result = false;
+ if (emptyStringAllowed)
+ result = true;
+
+ if (textField == null)
+ result = false;
+
+ String txt = textField.getText();
+
+ if (txt == null)
+ result = false;
+
+ result = (txt.trim().length() > 0) || emptyStringAllowed;
+
+ // call hook for subclasses
+ result = result && doCheckState();
+
+ if (result)
+ clearErrorMessage();
+ else
+ showErrorMessage(errorMessage);
+
+ return result;
+ }
+ /**
+ * Hook for subclasses to do specific state checks.
+ *
+ * The default implementation of this framework method does
+ * nothing and returns true
. Subclasses should
+ * override this method to specific state checks.
+ *
true
if the field value is valid,
+ * and false
if invalid
+ */
+ protected boolean doCheckState() {
+ return true;
+ }
+ /**
+ * Fills this field editor's basic controls into the given parent.
+ *
+ * The string field implementation of this FieldEditor
+ * framework method contributes the text field. Subclasses may override
+ * but must call super.doFillIntoGrid
.
+ *
+ * Subclasses must implement this method to properly initialize + * the field editor. + *
+ */ + protected void doLoad() { + if (textField != null) { + String value = getPreferenceStore().getString(getPreferenceName()); + textField.setText(value); + oldValue = value; + } + } + + /** + * Initializes this field editor with the default preference value from + * the preference store. + *+ * Subclasses must implement this method to properly initialize + * the field editor. + *
+ */ + protected void doLoadDefault() { + if (textField != null) { + String value = + getPreferenceStore().getDefaultString(getPreferenceName()); + textField.setText(value); + } + valueChanged(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditor#doStore() + */ + protected void doStore() { + getPreferenceStore().setValue(getPreferenceName(), textField.getText()); + } + + /** + * Returns the error message that will be displayed when and if + * an error occurs. + * + * @return the error message, ornull
if none
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+ /**
+ * Returns the number of basic controls this field editor consists of.
+ *
+ * @return the number of controls
+ */
+ public int getNumberOfControls() {
+ return 2;
+ }
+ /**
+ * Returns the field editor's value.
+ *
+ * @return the current value
+ */
+ public String getStringValue() {
+ if (textField != null)
+ return textField.getText();
+ else
+ return getPreferenceStore().getString(getPreferenceName());
+ }
+
+ /**
+ * Returns this field editor's text control.
+ *
+ * @param parent the parent
+ * @return the text control, or null
if no
+ * text field is created yet
+ */
+ protected Text getTextControl() {
+ return textField;
+ }
+
+ /**
+ * Returns this field editor's text control.
+ * + * The control is created if it does not yet exist + *
+ * + * @param parent the parent + * @return the text control + */ + public Text getTextControl(Composite parent) { + if (textField == null) { + textField = + new Text( + parent, + SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); + textField.setFont(parent.getFont()); + switch (validateStrategy) { + case VALIDATE_ON_KEY_STROKE : + textField.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + valueChanged(); + } + }); + + textField.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + refreshValidState(); + } + public void focusLost(FocusEvent e) { + clearErrorMessage(); + } + }); + break; + case VALIDATE_ON_FOCUS_LOST : + textField.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + clearErrorMessage(); + } + }); + textField.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + refreshValidState(); + } + public void focusLost(FocusEvent e) { + valueChanged(); + clearErrorMessage(); + } + }); + break; + default : + Assert.isTrue(false, "Unknown validate strategy"); //$NON-NLS-1$ + } + textField.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + textField = null; + } + }); + if (textLimit > 0) { //Only set limits above 0 - see SWT spec + textField.setTextLimit(textLimit); + } + } else { + checkParent(textField, parent); + } + return textField; + } + + /** + * Returns whether an empty string is a valid value. + * + * @returntrue
if an empty string is a valid value, and
+ * false
if an empty string is invalid
+ * @see #setEmptyStringAllowed
+ */
+ public boolean isEmptyStringAllowed() {
+ return emptyStringAllowed;
+ }
+
+ /**
+ * Returns whether this field editor contains a valid value.
+ *
+ * The default implementation of this framework method
+ * returns true
. Subclasses wishing to perform
+ * validation should override both this method and
+ * refreshValidState
.
+ *
true
if the field value is valid,
+ * and false
if invalid
+ * @see #refreshValidState
+ */
+ public boolean isValid() {
+ return isValid;
+ }
+
+ /**
+ * Refreshes this field editor's valid state after a value change
+ * and fires an IS_VALID
property change event if
+ * warranted.
+ *
+ * The default implementation of this framework method does
+ * nothing. Subclasses wishing to perform validation should override
+ * both this method and isValid
.
+ *
true
if the empty string is allowed,
+ * and false
if it is considered invalid
+ */
+ public void setEmptyStringAllowed(boolean b) {
+ emptyStringAllowed = b;
+ }
+
+ /**
+ * Sets the error message that will be displayed when and if
+ * an error occurs.
+ *
+ * @param message the error message
+ */
+ public void setErrorMessage(String message) {
+ errorMessage = message;
+ }
+
+ /**
+ * Sets the focus to this field editor.
+ * + * The default implementation of this framework method + * does nothing. Subclasses may reimplement. + *
+ */ + public void setFocus() { + if (textField != null) { + textField.setFocus(); + } + } + + /** + * Sets this field editor's value. + * + * @param value the new value, ornull
meaning the empty string
+ */
+ public void setStringValue(String value) {
+ if (textField != null) {
+ if (value == null)
+ value = ""; //$NON-NLS-1$
+ oldValue = textField.getText();
+ if (!oldValue.equals(value)) {
+ textField.setText(value);
+ valueChanged();
+ }
+ }
+ }
+
+ /**
+ * Sets this text field's text limit.
+ *
+ * @param limit the limit on the number of character in the text
+ * input field, or UNLIMITED
for no limit
+ */
+ public void setTextLimit(int limit) {
+ textLimit = limit;
+ if (textField != null)
+ textField.setTextLimit(limit);
+ }
+
+ /**
+ * Sets the strategy for validating the text.
+ *
+ * Calling this method has no effect after createPartControl
+ * is called. Thus this method is really only useful for subclasses to call
+ * in their constructor. However, it has public visibility for backward
+ * compatibility.
+ *
VALIDATE_ON_KEY_STROKE
to perform
+ * on the fly checking (the default), or VALIDATE_ON_FOCUS_LOST
to
+ * perform validation only after the text has been typed in
+ */
+ public void setValidateStrategy(int value) {
+ Assert.isTrue(
+ value == VALIDATE_ON_FOCUS_LOST || value == VALIDATE_ON_KEY_STROKE);
+ validateStrategy = value;
+ }
+
+ /**
+ * Shows the error message set via setErrorMessage
.
+ */
+ public void showErrorMessage() {
+ showErrorMessage(errorMessage);
+ }
+
+ /**
+ * Informs this field editor's listener, if it has one, about a change
+ * to the value (VALUE
property) provided that the old and
+ * new values are different.
+ * + * This hook is not called when the text is initialized + * (or reset to the default value) from the preference store. + *
+ */ + protected void valueChanged() { + setPresentsDefaultValue(false); + boolean oldState = isValid; + refreshValidState(); + + if (isValid != oldState) + fireStateChanged(IS_VALID, oldState, isValid); + + String newValue = textField.getText(); + if (!newValue.equals(oldValue)) { + fireValueChanged(VALUE, oldValue, newValue); + oldValue = newValue; + } + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java index f2a73c07090..6ab7d18064e 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/NewConfigurationDialog.java @@ -1,5 +1,16 @@ package org.eclipse.cdt.managedbuilder.ui.properties; +/********************************************************************** + * Copyright (c) 2003,2004 IBM Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ + import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.ITarget; import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin; @@ -21,17 +32,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -/********************************************************************** - * Copyright (c) 2002,2003 Rational Software Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html - * - * Contributors: - * IBM Rational Software - Initial API and implementation -***********************************************************************/ - public class NewConfigurationDialog extends Dialog { // String constants private static final String PREFIX = "NewConfiguration"; //$NON-NLS-1$