[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Managed Make Builder Customization
|
This patch contains implementation of interface for connection custom
option editors to Managed Make Builder Properties dialog (see Bug Report
# 64641).
To existing schema for optionCategory attribute added optional attribute
"class". This is a reference to class that implements custom editor. Can
be used in custom tool chain definition. As an example I attached new
option use case, where I replace standard options page for extra
libraries to a new one. A custom editor should sub-class
CustomBuildSettingsPage class.
Index: ManagedBuildTools.exsd
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.core/schema/ManagedBuildTools.exsd,v
retrieving revision 1.16
diff -u -r1.16 ManagedBuildTools.exsd
--- ManagedBuildTools.exsd 24 May 2004 23:23:36 -0000 1.16
+++ ManagedBuildTools.exsd 28 May 2004 20:32:33 -0000
@@ -561,6 +561,16 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
</complexType>
</element>
Index: BuildPropertyPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildPropertyPage.java,v
retrieving revision 1.17
diff -u -r1.17 BuildPropertyPage.java
--- BuildPropertyPage.java 19 May 2004 19:36:11 -0000 1.17
+++ BuildPropertyPage.java 28 May 2004 20:35:12 -0000
@@ -23,12 +23,14 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
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.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
@@ -107,7 +109,7 @@
private ITarget selectedTarget;
private IConfiguration [] configurations;
private IConfiguration selectedConfiguration;
- private BuildSettingsPage currentSettingsPage;
+ private IBuildSettingsPage currentSettingsPage;
private Map configToPageListMap;
private BuildToolsSettingsStore settingsStore;
private Map settingsStoreMap;
@@ -309,22 +311,22 @@
selectedCategory = category;
// Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
+ IBuildSettingsPage oldPage = currentSettingsPage;
currentSettingsPage = null;
// Create a new settings page if necessary
List pages = getPagesForConfig();
ListIterator iter = pages.listIterator();
while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
- if (page instanceof BuildOptionSettingsPage &&
- ((BuildOptionSettingsPage)page).isForCategory(category)) {
+ IBuildSettingsPage page = (IBuildSettingsPage) iter.next();
+ if (page instanceof IBuildOptionSettingsPage &&
+ ((IBuildOptionSettingsPage)page).isForCategory(category)) {
currentSettingsPage = page;
break;
}
}
if (currentSettingsPage == null) {
- currentSettingsPage = new BuildOptionSettingsPage(selectedConfiguration, category);
+ currentSettingsPage = createSettingsPage(selectedConfiguration, category);
pages.add(currentSettingsPage);
currentSettingsPage.setContainer(this);
if (currentSettingsPage.getControl() == null) {
@@ -345,8 +347,8 @@
// 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();
+ if(oldPage instanceof IBuildOptionSettingsPage) {
+ ((IBuildOptionSettingsPage)oldPage).storeSettings();
}
else if(oldPage instanceof BuildToolSettingsPage) {
((BuildToolSettingsPage)oldPage).storeSettings();
@@ -354,8 +356,8 @@
}
}
//update the field editors in the current page
- if(currentSettingsPage instanceof BuildOptionSettingsPage)
- ((BuildOptionSettingsPage)currentSettingsPage).updateFields();
+ if(currentSettingsPage instanceof IBuildOptionSettingsPage)
+ ((IBuildOptionSettingsPage)currentSettingsPage).updateFields();
if (oldPage != null)
oldPage.setVisible(false);
@@ -378,7 +380,7 @@
selectedTool = tool;
// Cache the current build setting page
- BuildSettingsPage oldPage = currentSettingsPage;
+ IBuildSettingsPage oldPage = currentSettingsPage;
currentSettingsPage = null;
// Create a new page if we need one
@@ -415,8 +417,8 @@
// 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();
+ if(oldPage instanceof IBuildOptionSettingsPage) {
+ ((IBuildOptionSettingsPage)oldPage).storeSettings();
}
else if(oldPage instanceof BuildToolSettingsPage) {
((BuildToolSettingsPage)oldPage).storeSettings();
@@ -877,7 +879,7 @@
}
ListIterator iter = pages.listIterator();
while (iter.hasNext()) {
- BuildSettingsPage page = (BuildSettingsPage) iter.next();
+ IBuildSettingsPage page = (IBuildSettingsPage) iter.next();
if (page == null) continue;
if (page instanceof BuildToolSettingsPage) {
// if the currentsettings page is not the tool settings page
@@ -886,8 +888,8 @@
if (!(currentSettingsPage instanceof BuildToolSettingsPage))
((BuildToolSettingsPage)page).updateAllOptionField();
((BuildToolSettingsPage)page).performOk();
- } else if (page instanceof BuildOptionSettingsPage) {
- ((BuildOptionSettingsPage)page).performOk();
+ } else if (page instanceof IBuildSettingsPage) {
+ ((IBuildSettingsPage)page).performOk();
}
}
@@ -914,6 +916,23 @@
int index = configSelector.indexOf(defaultConfig.getName());
configSelector.select(index == -1 ? 0 : index);
handleConfigSelection();
+ }
+
+ private IBuildSettingsPage createSettingsPage(IConfiguration configuration, IBuildObject buildObject) {
+ IBuildSettingsPage page = null;
+ if(buildObject instanceof ITool) {
+ page = new BuildToolSettingsPage(configuration,
+ (ITool)buildObject);
+ } else {
+ IOptionCategory category = (IOptionCategory)buildObject;
+ page = CustomBuildSettingsPage.
+ createCustomPage(configuration, category);
+ if(null == page) {
+ if(buildObject instanceof IOptionCategory)
+ page = new BuildOptionSettingsPage(configuration, category);
+ }
+ }
+ return page;
}
/**
Index: CustomBuildSettingsPage.java
===================================================================
RCS file: CustomBuildSettingsPage.java
diff -N CustomBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CustomBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,291 @@
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author AChapiro
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public abstract class CustomBuildSettingsPage extends DialogPage
+ implements
+ IBuildOptionSettingsPage, IPropertyChangeListener {
+
+
+ protected IConfiguration configuration;
+ protected IOptionCategory optionCategory;
+
+ protected IPreferencePageContainer container;
+
+ IOption[] options;
+ Object[] values;
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ * @return
+ */
+ public static CustomBuildSettingsPage createCustomPage(IConfiguration configuration, IOptionCategory optionCategory) {
+ CustomBuildSettingsPage page = null;
+
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(optionCategory);
+ if(element instanceof DefaultManagedConfigElement) {
+ if(null != element.getAttribute("class"))
+ try {
+ page = (CustomBuildSettingsPage)(((DefaultManagedConfigElement)element).getConfigurationElement().
+ createExecutableExtension("class"));
+ if(null != page) {
+ page.init(configuration, optionCategory);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return page;
+ }
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ */
+ private void init(IConfiguration configuration, IOptionCategory optionCategory) {
+ this.optionCategory = optionCategory;
+ this.configuration = configuration;
+ options = optionCategory.getOptions(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#updateFields()
+ */
+ public abstract void updateFields();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#storeSettings()
+ */
+ public void storeSettings() {
+ performOk();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#isForCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public boolean isForCategory(IOptionCategory optionCategory) {
+ if (optionCategory != null) {
+ return optionCategory.equals(this.optionCategory);
+ }
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#performOk()
+ */
+ public boolean performOk() {
+ // Write the preference store values back to the build model
+
+ boolean ok = false;
+
+ Object[] optionValues = getValues();
+
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+ assert (null != option);
+ String id = option.getId();
+ // Transfer value from dialog
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = ((Boolean)optionValues[i]).booleanValue();
+ getPreferenceStore().setValue(id, boolVal);
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ String strVal = (String)optionValues[i];
+ getPreferenceStore().setValue(id, strVal);
+ 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[] listVal = (String[])optionValues[i];
+ String listStr = BuildToolsSettingsStore.createList(listVal);
+ getPreferenceStore().setValue(id, listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
+ break;
+ default :
+ break;
+ }
+ }
+ return ok;
+ }
+
+ /**
+ * The field editor preference page implementation of this <code>IPreferencePage</code>
+ * (and <code>IPropertyChangeListener</code>) method intercepts <code>IS_VALID</code>
+ * events but passes other events on to its superclass.
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+/*
+ if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+ boolean newValue = ((Boolean) event.getNewValue()).booleanValue();
+ // If the new value is true then we must check all field editors.
+ // If it is false, then the page is invalid in any case.
+ if (newValue) {
+ checkState();
+ } else {
+ invalidFieldEditor = (FieldEditor) event.getSource();
+ setValid(newValue);
+ }
+ }
+*/
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setContainer(org.eclipse.jface.preference.IPreferencePageContainer)
+ */
+ public void setContainer(IPreferencePageContainer container) {
+ this.container = container;
+ }
+
+ /**
+ * @return
+ */
+ protected Object[] getValues() {
+ if(null == values) {
+ values = new Object[options.length];
+ for(int i = 0; i < options.length; ++i) {
+ // Transfer value from preference store to options
+ String id = options[i].getId();
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ values[i] = new Boolean(getPreferenceStore().getBoolean(id));
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ values[i] = getPreferenceStore().getString(id);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(id);
+ values[i] = BuildToolsSettingsStore
+ .parseString(listStr);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ return values;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ protected Object getValue(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ Object[] optionValues = getValues();
+ return optionValues[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ protected IOption getOption(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ return options[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param id
+ * @param value
+ */
+ protected void setValue(String id, Object value) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ assert (value instanceof Boolean);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ assert (value instanceof String);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ assert (value instanceof String[]);
+ break;
+ default :
+ break;
+ }
+ Object[] optionValues = getValues();
+ optionValues[i] = value;
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#computeSize()
+ */
+ public Point computeSize() {
+ if (getControl() != null) {
+ return getControl().getSize();
+ }
+ return new Point(0, 0);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public abstract void createControl(Composite parent);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (getControl() != null)
+ getControl().setVisible(visible);
+ }
+
+ /**
+ * @return
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ IPreferenceStore preferenceStore = container.getPreferenceStore();
+ assert (null != preferenceStore);
+ return preferenceStore;
+ }
+
+
+}
Index: IBuildOptionSettingsPage.java
===================================================================
RCS file: IBuildOptionSettingsPage.java
diff -N IBuildOptionSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildOptionSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+/*
+ * Created on May 14, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+
+/**
+ * @author AChapiro
+ *
+ * This is an extension of IBuildSettingsPage interface for option settings
+ * pages
+ */
+public interface IBuildOptionSettingsPage extends IBuildSettingsPage {
+
+ /**
+ * API calls this method to initialise UI
+ */
+ void updateFields();
+
+ /**
+ * API calls this method while storing data from this page
+ */
+ void storeSettings();
+
+ /**
+ * This method can be used for detecting category of options this
+ * page created for
+ * @param category
+ * @return true if this page connected to "category"
+ */
+ boolean isForCategory(IOptionCategory category);
+
+}
Index: IBuildSettingsPage.java
===================================================================
RCS file: IBuildSettingsPage.java
diff -N IBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * Created on May 13, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author AChapiro
+ * This interface works as adapter for different classes
+ * responsible for presentation of tools options
+ */
+public interface IBuildSettingsPage {
+
+ /**
+ * Method sets page container
+ * @param container
+ */
+ void setContainer(IPreferencePageContainer container);
+
+ /**
+ * Method returns control object for this page
+ * @return
+ */
+ Control getControl();
+
+ /**
+ * Method sets visibility status for this page
+ * @param visible
+ */
+ void setVisible(boolean visible);
+
+ /**
+ * API call this method during initialisation to create this method
+ * @param parent
+ */
+ void createControl(Composite parent);
+
+ /**
+ * Method computes size of this page
+ * @return
+ */
+ Point computeSize();
+
+ /**
+ * API call this method if OK button on property container was pressed
+ * @return
+ */
+ boolean performOk();
+}
Index: BuildSettingsPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java,v
retrieving revision 1.1
diff -u -r1.1 BuildSettingsPage.java
--- BuildSettingsPage.java 2 Mar 2004 15:27:47 -0000 1.1
+++ BuildSettingsPage.java 28 May 2004 20:36:20 -0000
@@ -15,7 +15,7 @@
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
-public class BuildSettingsPage extends FieldEditorPreferencePage {
+public class BuildSettingsPage extends FieldEditorPreferencePage implements IBuildSettingsPage {
protected IConfiguration configuration;
/**
Index: CustomBuildSettingsPage.java
===================================================================
RCS file: CustomBuildSettingsPage.java
diff -N CustomBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CustomBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,291 @@
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author AChapiro
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public abstract class CustomBuildSettingsPage extends DialogPage
+ implements
+ IBuildOptionSettingsPage, IPropertyChangeListener {
+
+
+ protected IConfiguration configuration;
+ protected IOptionCategory optionCategory;
+
+ protected IPreferencePageContainer container;
+
+ IOption[] options;
+ Object[] values;
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ * @return
+ */
+ public static CustomBuildSettingsPage createCustomPage(IConfiguration configuration, IOptionCategory optionCategory) {
+ CustomBuildSettingsPage page = null;
+
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(optionCategory);
+ if(element instanceof DefaultManagedConfigElement) {
+ if(null != element.getAttribute("class"))
+ try {
+ page = (CustomBuildSettingsPage)(((DefaultManagedConfigElement)element).getConfigurationElement().
+ createExecutableExtension("class"));
+ if(null != page) {
+ page.init(configuration, optionCategory);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return page;
+ }
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ */
+ private void init(IConfiguration configuration, IOptionCategory optionCategory) {
+ this.optionCategory = optionCategory;
+ this.configuration = configuration;
+ options = optionCategory.getOptions(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#updateFields()
+ */
+ public abstract void updateFields();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#storeSettings()
+ */
+ public void storeSettings() {
+ performOk();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#isForCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public boolean isForCategory(IOptionCategory optionCategory) {
+ if (optionCategory != null) {
+ return optionCategory.equals(this.optionCategory);
+ }
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#performOk()
+ */
+ public boolean performOk() {
+ // Write the preference store values back to the build model
+
+ boolean ok = false;
+
+ Object[] optionValues = getValues();
+
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+ assert (null != option);
+ String id = option.getId();
+ // Transfer value from dialog
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = ((Boolean)optionValues[i]).booleanValue();
+ getPreferenceStore().setValue(id, boolVal);
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ String strVal = (String)optionValues[i];
+ getPreferenceStore().setValue(id, strVal);
+ 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[] listVal = (String[])optionValues[i];
+ String listStr = BuildToolsSettingsStore.createList(listVal);
+ getPreferenceStore().setValue(id, listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
+ break;
+ default :
+ break;
+ }
+ }
+ return ok;
+ }
+
+ /**
+ * The field editor preference page implementation of this <code>IPreferencePage</code>
+ * (and <code>IPropertyChangeListener</code>) method intercepts <code>IS_VALID</code>
+ * events but passes other events on to its superclass.
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+/*
+ if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+ boolean newValue = ((Boolean) event.getNewValue()).booleanValue();
+ // If the new value is true then we must check all field editors.
+ // If it is false, then the page is invalid in any case.
+ if (newValue) {
+ checkState();
+ } else {
+ invalidFieldEditor = (FieldEditor) event.getSource();
+ setValid(newValue);
+ }
+ }
+*/
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setContainer(org.eclipse.jface.preference.IPreferencePageContainer)
+ */
+ public void setContainer(IPreferencePageContainer container) {
+ this.container = container;
+ }
+
+ /**
+ * @return
+ */
+ protected Object[] getValues() {
+ if(null == values) {
+ values = new Object[options.length];
+ for(int i = 0; i < options.length; ++i) {
+ // Transfer value from preference store to options
+ String id = options[i].getId();
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ values[i] = new Boolean(getPreferenceStore().getBoolean(id));
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ values[i] = getPreferenceStore().getString(id);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(id);
+ values[i] = BuildToolsSettingsStore
+ .parseString(listStr);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ return values;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ protected Object getValue(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ Object[] optionValues = getValues();
+ return optionValues[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ protected IOption getOption(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ return options[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param id
+ * @param value
+ */
+ protected void setValue(String id, Object value) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ assert (value instanceof Boolean);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ assert (value instanceof String);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ assert (value instanceof String[]);
+ break;
+ default :
+ break;
+ }
+ Object[] optionValues = getValues();
+ optionValues[i] = value;
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#computeSize()
+ */
+ public Point computeSize() {
+ if (getControl() != null) {
+ return getControl().getSize();
+ }
+ return new Point(0, 0);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public abstract void createControl(Composite parent);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (getControl() != null)
+ getControl().setVisible(visible);
+ }
+
+ /**
+ * @return
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ IPreferenceStore preferenceStore = container.getPreferenceStore();
+ assert (null != preferenceStore);
+ return preferenceStore;
+ }
+
+
+}
Index: IBuildOptionSettingsPage.java
===================================================================
RCS file: IBuildOptionSettingsPage.java
diff -N IBuildOptionSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildOptionSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+/*
+ * Created on May 14, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+
+/**
+ * @author AChapiro
+ *
+ * This is an extension of IBuildSettingsPage interface for option settings
+ * pages
+ */
+public interface IBuildOptionSettingsPage extends IBuildSettingsPage {
+
+ /**
+ * API calls this method to initialise UI
+ */
+ void updateFields();
+
+ /**
+ * API calls this method while storing data from this page
+ */
+ void storeSettings();
+
+ /**
+ * This method can be used for detecting category of options this
+ * page created for
+ * @param category
+ * @return true if this page connected to "category"
+ */
+ boolean isForCategory(IOptionCategory category);
+
+}
Index: IBuildSettingsPage.java
===================================================================
RCS file: IBuildSettingsPage.java
diff -N IBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * Created on May 13, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author AChapiro
+ * This interface works as adapter for different classes
+ * responsible for presentation of tools options
+ */
+public interface IBuildSettingsPage {
+
+ /**
+ * Method sets page container
+ * @param container
+ */
+ void setContainer(IPreferencePageContainer container);
+
+ /**
+ * Method returns control object for this page
+ * @return
+ */
+ Control getControl();
+
+ /**
+ * Method sets visibility status for this page
+ * @param visible
+ */
+ void setVisible(boolean visible);
+
+ /**
+ * API call this method during initialisation to create this method
+ * @param parent
+ */
+ void createControl(Composite parent);
+
+ /**
+ * Method computes size of this page
+ * @return
+ */
+ Point computeSize();
+
+ /**
+ * API call this method if OK button on property container was pressed
+ * @return
+ */
+ boolean performOk();
+}
Index: CustomBuildSettingsPage.java
===================================================================
RCS file: CustomBuildSettingsPage.java
diff -N CustomBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CustomBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,281 @@
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author AChapiro
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public abstract class CustomBuildSettingsPage extends DialogPage
+ implements
+ IBuildOptionSettingsPage, IPropertyChangeListener {
+
+
+ protected IConfiguration configuration;
+ protected IOptionCategory optionCategory;
+
+ protected IPreferencePageContainer container;
+
+ IOption[] options;
+ Object[] values;
+
+ /**
+ * This is a class factory for custom option editor
+ * @param configuration - configuration this page edits
+ * @param optionCategory - category this page represents
+ * @return
+ */
+ public static CustomBuildSettingsPage createCustomPage(IConfiguration configuration, IOptionCategory optionCategory) {
+ CustomBuildSettingsPage page = null;
+
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(optionCategory);
+ if(element instanceof DefaultManagedConfigElement) {
+ if(null != element.getAttribute("class"))
+ try {
+ page = (CustomBuildSettingsPage)(((DefaultManagedConfigElement)element).getConfigurationElement().
+ createExecutableExtension("class"));
+ if(null != page) {
+ page.init(configuration, optionCategory);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return page;
+ }
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ */
+ private void init(IConfiguration configuration, IOptionCategory optionCategory) {
+ this.optionCategory = optionCategory;
+ this.configuration = configuration;
+ options = optionCategory.getOptions(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#updateFields()
+ */
+ public abstract void updateFields();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#storeSettings()
+ */
+ public void storeSettings() {
+ performOk();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#isForCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public boolean isForCategory(IOptionCategory optionCategory) {
+ if (optionCategory != null) {
+ return optionCategory.equals(this.optionCategory);
+ }
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#performOk()
+ */
+ public boolean performOk() {
+ // Write the preference store values back to the build model
+
+ boolean ok = false;
+
+ Object[] optionValues = getValues();
+
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+ assert (null != option);
+ String id = option.getId();
+ // Transfer value from dialog
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = ((Boolean)optionValues[i]).booleanValue();
+ getPreferenceStore().setValue(id, boolVal);
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ String strVal = (String)optionValues[i];
+ getPreferenceStore().setValue(id, strVal);
+ 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[] listVal = (String[])optionValues[i];
+ String listStr = BuildToolsSettingsStore.createList(listVal);
+ getPreferenceStore().setValue(id, listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
+ break;
+ default :
+ break;
+ }
+ }
+ return ok;
+ }
+
+ /**
+ * This implementation does nothing; sub-class can change this behavior
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setContainer(org.eclipse.jface.preference.IPreferencePageContainer)
+ */
+ public void setContainer(IPreferencePageContainer container) {
+ this.container = container;
+ getPreferenceStore().addPropertyChangeListener(this);
+ }
+
+ /**
+ * @return array of values for each option object this page works with
+ */
+ protected Object[] getValues() {
+ if(null == values) {
+ values = new Object[options.length];
+ for(int i = 0; i < options.length; ++i) {
+ // Transfer value from preference store to options
+ String id = options[i].getId();
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ values[i] = new Boolean(getPreferenceStore().getBoolean(id));
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ values[i] = getPreferenceStore().getString(id);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(id);
+ values[i] = BuildToolsSettingsStore
+ .parseString(listStr);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ return values;
+ }
+
+ /**
+ * Find current option value
+ * @param id - option ID
+ * @return value of option
+ */
+ protected Object getValue(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ Object[] optionValues = getValues();
+ return optionValues[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get option object
+ * @param id - option ID
+ * @return IOption obect
+ */
+ protected IOption getOption(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ return options[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Modify option value
+ * @param id - option ID
+ * @param value - value to set to option
+ */
+ protected void setValue(String id, Object value) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ assert (value instanceof Boolean);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ assert (value instanceof String);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ assert (value instanceof String[]);
+ break;
+ default :
+ break;
+ }
+ Object[] optionValues = getValues();
+ optionValues[i] = value;
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#computeSize()
+ */
+ public Point computeSize() {
+ if (getControl() != null) {
+ return getControl().getSize();
+ }
+ return new Point(0, 0);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public abstract void createControl(Composite parent);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (getControl() != null)
+ getControl().setVisible(visible);
+ }
+
+ /**
+ * @return preference store object for the current project
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ IPreferenceStore preferenceStore = container.getPreferenceStore();
+ assert (null != preferenceStore);
+ return preferenceStore;
+ }
+
+
+}
Index: IBuildOptionSettingsPage.java
===================================================================
RCS file: IBuildOptionSettingsPage.java
diff -N IBuildOptionSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildOptionSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+/*
+ * Created on May 14, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+
+/**
+ * @author AChapiro
+ *
+ * This is an extension of IBuildSettingsPage interface for option settings
+ * pages
+ */
+public interface IBuildOptionSettingsPage extends IBuildSettingsPage {
+
+ /**
+ * API calls this method to initialise UI
+ */
+ void updateFields();
+
+ /**
+ * API calls this method while storing data from this page
+ */
+ void storeSettings();
+
+ /**
+ * This method can be used for detecting category of options this
+ * page created for
+ * @param category
+ * @return true if this page connected to "category"
+ */
+ boolean isForCategory(IOptionCategory category);
+
+}
Index: IBuildSettingsPage.java
===================================================================
RCS file: IBuildSettingsPage.java
diff -N IBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * Created on May 13, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author AChapiro
+ * This interface works as adapter for different classes
+ * responsible for presentation of tools options
+ */
+public interface IBuildSettingsPage {
+
+ /**
+ * Method sets page container
+ * @param container
+ */
+ void setContainer(IPreferencePageContainer container);
+
+ /**
+ * Method returns control object for this page
+ * @return
+ */
+ Control getControl();
+
+ /**
+ * Method sets visibility status for this page
+ * @param visible
+ */
+ void setVisible(boolean visible);
+
+ /**
+ * API call this method during initialisation to create this method
+ * @param parent
+ */
+ void createControl(Composite parent);
+
+ /**
+ * Method computes size of this page
+ * @return
+ */
+ Point computeSize();
+
+ /**
+ * API call this method if OK button on property container was pressed
+ * @return
+ */
+ boolean performOk();
+}
Index: CustomBuildSettingsPage.java
===================================================================
RCS file: CustomBuildSettingsPage.java
diff -N CustomBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CustomBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,281 @@
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author AChapiro
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public abstract class CustomBuildSettingsPage extends DialogPage
+ implements
+ IBuildOptionSettingsPage, IPropertyChangeListener {
+
+
+ protected IConfiguration configuration;
+ protected IOptionCategory optionCategory;
+
+ protected IPreferencePageContainer container;
+
+ IOption[] options;
+ Object[] values;
+
+ /**
+ * This is a class factory for custom option editor
+ * @param configuration - configuration this page edits
+ * @param optionCategory - category this page represents
+ * @return
+ */
+ public static CustomBuildSettingsPage createCustomPage(IConfiguration configuration, IOptionCategory optionCategory) {
+ CustomBuildSettingsPage page = null;
+
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(optionCategory);
+ if(element instanceof DefaultManagedConfigElement) {
+ if(null != element.getAttribute("class"))
+ try {
+ page = (CustomBuildSettingsPage)(((DefaultManagedConfigElement)element).getConfigurationElement().
+ createExecutableExtension("class"));
+ if(null != page) {
+ page.init(configuration, optionCategory);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return page;
+ }
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ */
+ private void init(IConfiguration configuration, IOptionCategory optionCategory) {
+ this.optionCategory = optionCategory;
+ this.configuration = configuration;
+ options = optionCategory.getOptions(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#updateFields()
+ */
+ public abstract void updateFields();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#storeSettings()
+ */
+ public void storeSettings() {
+ performOk();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#isForCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public boolean isForCategory(IOptionCategory optionCategory) {
+ if (optionCategory != null) {
+ return optionCategory.equals(this.optionCategory);
+ }
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#performOk()
+ */
+ public boolean performOk() {
+ // Write the preference store values back to the build model
+
+ boolean ok = false;
+
+ Object[] optionValues = getValues();
+
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+ assert (null != option);
+ String id = option.getId();
+ // Transfer value from dialog
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = ((Boolean)optionValues[i]).booleanValue();
+ getPreferenceStore().setValue(id, boolVal);
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ String strVal = (String)optionValues[i];
+ getPreferenceStore().setValue(id, strVal);
+ 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[] listVal = (String[])optionValues[i];
+ String listStr = BuildToolsSettingsStore.createList(listVal);
+ getPreferenceStore().setValue(id, listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
+ break;
+ default :
+ break;
+ }
+ }
+ return ok;
+ }
+
+ /**
+ * This implementation does nothing; sub-class can change this behavior
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setContainer(org.eclipse.jface.preference.IPreferencePageContainer)
+ */
+ public void setContainer(IPreferencePageContainer container) {
+ this.container = container;
+ getPreferenceStore().addPropertyChangeListener(this);
+ }
+
+ /**
+ * @return array of values for each option object this page works with
+ */
+ protected Object[] getValues() {
+ if(null == values) {
+ values = new Object[options.length];
+ for(int i = 0; i < options.length; ++i) {
+ // Transfer value from preference store to options
+ String id = options[i].getId();
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ values[i] = new Boolean(getPreferenceStore().getBoolean(id));
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ values[i] = getPreferenceStore().getString(id);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(id);
+ values[i] = BuildToolsSettingsStore
+ .parseString(listStr);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ return values;
+ }
+
+ /**
+ * Find current option value
+ * @param id - option ID
+ * @return value of option
+ */
+ protected Object getValue(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ Object[] optionValues = getValues();
+ return optionValues[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get option object
+ * @param id - option ID
+ * @return IOption obect
+ */
+ protected IOption getOption(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ return options[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Modify option value
+ * @param id - option ID
+ * @param value - value to set to option
+ */
+ protected void setValue(String id, Object value) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ assert (value instanceof Boolean);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ assert (value instanceof String);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ assert (value instanceof String[]);
+ break;
+ default :
+ break;
+ }
+ Object[] optionValues = getValues();
+ optionValues[i] = value;
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#computeSize()
+ */
+ public Point computeSize() {
+ if (getControl() != null) {
+ return getControl().getSize();
+ }
+ return new Point(0, 0);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public abstract void createControl(Composite parent);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (getControl() != null)
+ getControl().setVisible(visible);
+ }
+
+ /**
+ * @return preference store object for the current project
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ IPreferenceStore preferenceStore = container.getPreferenceStore();
+ assert (null != preferenceStore);
+ return preferenceStore;
+ }
+
+
+}
Index: IBuildOptionSettingsPage.java
===================================================================
RCS file: IBuildOptionSettingsPage.java
diff -N IBuildOptionSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildOptionSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+/*
+ * Created on May 14, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+
+/**
+ * @author AChapiro
+ *
+ * This is an extension of IBuildSettingsPage interface for option settings
+ * pages
+ */
+public interface IBuildOptionSettingsPage extends IBuildSettingsPage {
+
+ /**
+ * API calls this method to initialise UI
+ */
+ void updateFields();
+
+ /**
+ * API calls this method while storing data from this page
+ */
+ void storeSettings();
+
+ /**
+ * This method can be used for detecting category of options this
+ * page created for
+ * @param category
+ * @return true if this page connected to "category"
+ */
+ boolean isForCategory(IOptionCategory category);
+
+}
Index: IBuildSettingsPage.java
===================================================================
RCS file: IBuildSettingsPage.java
diff -N IBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * Created on May 13, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author AChapiro
+ * This interface works as adapter for different classes
+ * responsible for presentation of tools options
+ */
+public interface IBuildSettingsPage {
+
+ /**
+ * Method sets page container
+ * @param container
+ */
+ void setContainer(IPreferencePageContainer container);
+
+ /**
+ * Method returns control object for this page
+ * @return
+ */
+ Control getControl();
+
+ /**
+ * Method sets visibility status for this page
+ * @param visible
+ */
+ void setVisible(boolean visible);
+
+ /**
+ * API call this method during initialisation to create this method
+ * @param parent
+ */
+ void createControl(Composite parent);
+
+ /**
+ * Method computes size of this page
+ * @return
+ */
+ Point computeSize();
+
+ /**
+ * API call this method if OK button on property container was pressed
+ * @return
+ */
+ boolean performOk();
+}
Index: CustomBuildSettingsPage.java
===================================================================
RCS file: CustomBuildSettingsPage.java
diff -N CustomBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CustomBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,281 @@
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author AChapiro
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public abstract class CustomBuildSettingsPage extends DialogPage
+ implements
+ IBuildOptionSettingsPage, IPropertyChangeListener {
+
+
+ protected IConfiguration configuration;
+ protected IOptionCategory optionCategory;
+
+ protected IPreferencePageContainer container;
+
+ IOption[] options;
+ Object[] values;
+
+ /**
+ * This is a class factory for custom option editor
+ * @param configuration - configuration this page edits
+ * @param optionCategory - category this page represents
+ * @return
+ */
+ public static CustomBuildSettingsPage createCustomPage(IConfiguration configuration, IOptionCategory optionCategory) {
+ CustomBuildSettingsPage page = null;
+
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(optionCategory);
+ if(element instanceof DefaultManagedConfigElement) {
+ if(null != element.getAttribute("class"))
+ try {
+ page = (CustomBuildSettingsPage)(((DefaultManagedConfigElement)element).getConfigurationElement().
+ createExecutableExtension("class"));
+ if(null != page) {
+ page.init(configuration, optionCategory);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return page;
+ }
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ */
+ private void init(IConfiguration configuration, IOptionCategory optionCategory) {
+ this.optionCategory = optionCategory;
+ this.configuration = configuration;
+ options = optionCategory.getOptions(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#updateFields()
+ */
+ public abstract void updateFields();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#storeSettings()
+ */
+ public void storeSettings() {
+ performOk();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#isForCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public boolean isForCategory(IOptionCategory optionCategory) {
+ if (optionCategory != null) {
+ return optionCategory.equals(this.optionCategory);
+ }
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#performOk()
+ */
+ public boolean performOk() {
+ // Write the preference store values back to the build model
+
+ boolean ok = false;
+
+ Object[] optionValues = getValues();
+
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+ assert (null != option);
+ String id = option.getId();
+ // Transfer value from dialog
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = ((Boolean)optionValues[i]).booleanValue();
+ getPreferenceStore().setValue(id, boolVal);
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ String strVal = (String)optionValues[i];
+ getPreferenceStore().setValue(id, strVal);
+ 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[] listVal = (String[])optionValues[i];
+ String listStr = BuildToolsSettingsStore.createList(listVal);
+ getPreferenceStore().setValue(id, listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
+ break;
+ default :
+ break;
+ }
+ }
+ return ok;
+ }
+
+ /**
+ * This implementation does nothing; sub-class can change this behavior
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setContainer(org.eclipse.jface.preference.IPreferencePageContainer)
+ */
+ public void setContainer(IPreferencePageContainer container) {
+ this.container = container;
+ getPreferenceStore().addPropertyChangeListener(this);
+ }
+
+ /**
+ * @return array of values for each option object this page works with
+ */
+ protected Object[] getValues() {
+ if(null == values) {
+ values = new Object[options.length];
+ for(int i = 0; i < options.length; ++i) {
+ // Transfer value from preference store to options
+ String id = options[i].getId();
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ values[i] = new Boolean(getPreferenceStore().getBoolean(id));
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ values[i] = getPreferenceStore().getString(id);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(id);
+ values[i] = BuildToolsSettingsStore
+ .parseString(listStr);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ return values;
+ }
+
+ /**
+ * Find current option value
+ * @param id - option ID
+ * @return value of option
+ */
+ protected Object getValue(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ Object[] optionValues = getValues();
+ return optionValues[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get option object
+ * @param id - option ID
+ * @return IOption obect
+ */
+ protected IOption getOption(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ return options[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Modify option value
+ * @param id - option ID
+ * @param value - value to set to option
+ */
+ protected void setValue(String id, Object value) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ assert (value instanceof Boolean);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ assert (value instanceof String);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ assert (value instanceof String[]);
+ break;
+ default :
+ break;
+ }
+ Object[] optionValues = getValues();
+ optionValues[i] = value;
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#computeSize()
+ */
+ public Point computeSize() {
+ if (getControl() != null) {
+ return getControl().getSize();
+ }
+ return new Point(0, 0);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public abstract void createControl(Composite parent);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (getControl() != null)
+ getControl().setVisible(visible);
+ }
+
+ /**
+ * @return preference store object for the current project
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ IPreferenceStore preferenceStore = container.getPreferenceStore();
+ assert (null != preferenceStore);
+ return preferenceStore;
+ }
+
+
+}
Index: IBuildOptionSettingsPage.java
===================================================================
RCS file: IBuildOptionSettingsPage.java
diff -N IBuildOptionSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildOptionSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+/*
+ * Created on May 14, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+
+/**
+ * @author AChapiro
+ *
+ * This is an extension of IBuildSettingsPage interface for option settings
+ * pages
+ */
+public interface IBuildOptionSettingsPage extends IBuildSettingsPage {
+
+ /**
+ * API calls this method to initialise UI
+ */
+ void updateFields();
+
+ /**
+ * API calls this method while storing data from this page
+ */
+ void storeSettings();
+
+ /**
+ * This method can be used for detecting category of options this
+ * page created for
+ * @param category
+ * @return true if this page connected to "category"
+ */
+ boolean isForCategory(IOptionCategory category);
+
+}
Index: IBuildSettingsPage.java
===================================================================
RCS file: IBuildSettingsPage.java
diff -N IBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * Created on May 13, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author AChapiro
+ * This interface works as adapter for different classes
+ * responsible for presentation of tools options
+ */
+public interface IBuildSettingsPage {
+
+ /**
+ * Method sets page container
+ * @param container
+ */
+ void setContainer(IPreferencePageContainer container);
+
+ /**
+ * Method returns control object for this page
+ * @return
+ */
+ Control getControl();
+
+ /**
+ * Method sets visibility status for this page
+ * @param visible
+ */
+ void setVisible(boolean visible);
+
+ /**
+ * API call this method during initialisation to create this method
+ * @param parent
+ */
+ void createControl(Composite parent);
+
+ /**
+ * Method computes size of this page
+ * @return
+ */
+ Point computeSize();
+
+ /**
+ * API call this method if OK button on property container was pressed
+ * @return
+ */
+ boolean performOk();
+}
Index: BuildOptionSettingsPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java,v
retrieving revision 1.6
diff -u -r1.6 BuildOptionSettingsPage.java
--- BuildOptionSettingsPage.java 12 May 2004 14:33:12 -0000 1.6
+++ BuildOptionSettingsPage.java 28 May 2004 20:34:18 -0000
@@ -23,7 +23,7 @@
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.graphics.Point;
-public class BuildOptionSettingsPage extends BuildSettingsPage {
+public class BuildOptionSettingsPage extends BuildSettingsPage {
private ArrayList fieldsList = new ArrayList();
private IOptionCategory category;
@@ -131,6 +131,7 @@
// Transfer value from preference store to options
switch (option.getValueType()) {
case IOption.BOOLEAN :
+
boolean boolVal = getPreferenceStore().getBoolean(
option.getId());
ManagedBuildManager.setOption(configuration, option,
Index: CustomBuildSettingsPage.java
===================================================================
RCS file: CustomBuildSettingsPage.java
diff -N CustomBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CustomBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,291 @@
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author AChapiro
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public abstract class CustomBuildSettingsPage extends DialogPage
+ implements
+ IBuildOptionSettingsPage, IPropertyChangeListener {
+
+
+ protected IConfiguration configuration;
+ protected IOptionCategory optionCategory;
+
+ protected IPreferencePageContainer container;
+
+ IOption[] options;
+ Object[] values;
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ * @return
+ */
+ public static CustomBuildSettingsPage createCustomPage(IConfiguration configuration, IOptionCategory optionCategory) {
+ CustomBuildSettingsPage page = null;
+
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(optionCategory);
+ if(element instanceof DefaultManagedConfigElement) {
+ if(null != element.getAttribute("class"))
+ try {
+ page = (CustomBuildSettingsPage)(((DefaultManagedConfigElement)element).getConfigurationElement().
+ createExecutableExtension("class"));
+ if(null != page) {
+ page.init(configuration, optionCategory);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return page;
+ }
+
+ /**
+ * @param configuration
+ * @param optionCategory
+ */
+ private void init(IConfiguration configuration, IOptionCategory optionCategory) {
+ this.optionCategory = optionCategory;
+ this.configuration = configuration;
+ options = optionCategory.getOptions(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#updateFields()
+ */
+ public abstract void updateFields();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#storeSettings()
+ */
+ public void storeSettings() {
+ performOk();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#isForCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public boolean isForCategory(IOptionCategory optionCategory) {
+ if (optionCategory != null) {
+ return optionCategory.equals(this.optionCategory);
+ }
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#performOk()
+ */
+ public boolean performOk() {
+ // Write the preference store values back to the build model
+
+ boolean ok = false;
+
+ Object[] optionValues = getValues();
+
+ for (int i = 0; i < options.length; i++) {
+ IOption option = options[i];
+ assert (null != option);
+ String id = option.getId();
+ // Transfer value from dialog
+ switch (option.getValueType()) {
+ case IOption.BOOLEAN :
+ boolean boolVal = ((Boolean)optionValues[i]).booleanValue();
+ getPreferenceStore().setValue(id, boolVal);
+ ManagedBuildManager.setOption(configuration, option,
+ boolVal);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ String strVal = (String)optionValues[i];
+ getPreferenceStore().setValue(id, strVal);
+ 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[] listVal = (String[])optionValues[i];
+ String listStr = BuildToolsSettingsStore.createList(listVal);
+ getPreferenceStore().setValue(id, listStr);
+ ManagedBuildManager.setOption(configuration, option,
+ listVal);
+ break;
+ default :
+ break;
+ }
+ }
+ return ok;
+ }
+
+ /**
+ * The field editor preference page implementation of this <code>IPreferencePage</code>
+ * (and <code>IPropertyChangeListener</code>) method intercepts <code>IS_VALID</code>
+ * events but passes other events on to its superclass.
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+/*
+ if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+ boolean newValue = ((Boolean) event.getNewValue()).booleanValue();
+ // If the new value is true then we must check all field editors.
+ // If it is false, then the page is invalid in any case.
+ if (newValue) {
+ checkState();
+ } else {
+ invalidFieldEditor = (FieldEditor) event.getSource();
+ setValid(newValue);
+ }
+ }
+*/
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setContainer(org.eclipse.jface.preference.IPreferencePageContainer)
+ */
+ public void setContainer(IPreferencePageContainer container) {
+ this.container = container;
+ }
+
+ /**
+ * @return
+ */
+ protected Object[] getValues() {
+ if(null == values) {
+ values = new Object[options.length];
+ for(int i = 0; i < options.length; ++i) {
+ // Transfer value from preference store to options
+ String id = options[i].getId();
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ values[i] = new Boolean(getPreferenceStore().getBoolean(id));
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ values[i] = getPreferenceStore().getString(id);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ String listStr = getPreferenceStore().getString(id);
+ values[i] = BuildToolsSettingsStore
+ .parseString(listStr);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ return values;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ protected Object getValue(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ Object[] optionValues = getValues();
+ return optionValues[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ protected IOption getOption(String id) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ return options[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param id
+ * @param value
+ */
+ protected void setValue(String id, Object value) {
+ for(int i = 0; i < options.length; ++i) {
+ if(options[i].getId().equals(id)) {
+ switch (options[i].getValueType()) {
+ case IOption.BOOLEAN :
+ assert (value instanceof Boolean);
+ break;
+ case IOption.ENUMERATED :
+ case IOption.STRING :
+ assert (value instanceof String);
+ break;
+ case IOption.STRING_LIST :
+ case IOption.INCLUDE_PATH :
+ case IOption.PREPROCESSOR_SYMBOLS :
+ case IOption.LIBRARIES :
+ case IOption.OBJECTS :
+ assert (value instanceof String[]);
+ break;
+ default :
+ break;
+ }
+ Object[] optionValues = getValues();
+ optionValues[i] = value;
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#computeSize()
+ */
+ public Point computeSize() {
+ if (getControl() != null) {
+ return getControl().getSize();
+ }
+ return new Point(0, 0);
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public abstract void createControl(Composite parent);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.ui.properties.IBuildOptionSettingsPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (getControl() != null)
+ getControl().setVisible(visible);
+ }
+
+ /**
+ * @return
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ IPreferenceStore preferenceStore = container.getPreferenceStore();
+ assert (null != preferenceStore);
+ return preferenceStore;
+ }
+
+
+}
Index: IBuildOptionSettingsPage.java
===================================================================
RCS file: IBuildOptionSettingsPage.java
diff -N IBuildOptionSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildOptionSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+/*
+ * Created on May 14, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+
+/**
+ * @author AChapiro
+ *
+ * This is an extension of IBuildSettingsPage interface for option settings
+ * pages
+ */
+public interface IBuildOptionSettingsPage extends IBuildSettingsPage {
+
+ /**
+ * API calls this method to initialise UI
+ */
+ void updateFields();
+
+ /**
+ * API calls this method while storing data from this page
+ */
+ void storeSettings();
+
+ /**
+ * This method can be used for detecting category of options this
+ * page created for
+ * @param category
+ * @return true if this page connected to "category"
+ */
+ boolean isForCategory(IOptionCategory category);
+
+}
Index: IBuildSettingsPage.java
===================================================================
RCS file: IBuildSettingsPage.java
diff -N IBuildSettingsPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ IBuildSettingsPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * Created on May 13, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.cdt.managedbuilder.ui.properties;
+
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author AChapiro
+ * This interface works as adapter for different classes
+ * responsible for presentation of tools options
+ */
+public interface IBuildSettingsPage {
+
+ /**
+ * Method sets page container
+ * @param container
+ */
+ void setContainer(IPreferencePageContainer container);
+
+ /**
+ * Method returns control object for this page
+ * @return
+ */
+ Control getControl();
+
+ /**
+ * Method sets visibility status for this page
+ * @param visible
+ */
+ void setVisible(boolean visible);
+
+ /**
+ * API call this method during initialisation to create this method
+ * @param parent
+ */
+ void createControl(Composite parent);
+
+ /**
+ * Method computes size of this page
+ * @return
+ */
+ Point computeSize();
+
+ /**
+ * API call this method if OK button on property container was pressed
+ * @return
+ */
+ boolean performOk();
+}
Attachment:
com.qnx.tools.ide.qde.managedbuilder.ui.zip
Description: Zip compressed data