summaryrefslogtreecommitdiffstats
path: root/org.rtems.cdt.toolchain/src/org/rtems/cdt/toolchain/RtemsInstallBspDirectoryValueHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.rtems.cdt.toolchain/src/org/rtems/cdt/toolchain/RtemsInstallBspDirectoryValueHandler.java')
-rw-r--r--org.rtems.cdt.toolchain/src/org/rtems/cdt/toolchain/RtemsInstallBspDirectoryValueHandler.java101
1 files changed, 101 insertions, 0 deletions
diff --git a/org.rtems.cdt.toolchain/src/org/rtems/cdt/toolchain/RtemsInstallBspDirectoryValueHandler.java b/org.rtems.cdt.toolchain/src/org/rtems/cdt/toolchain/RtemsInstallBspDirectoryValueHandler.java
new file mode 100644
index 0000000..9be247e
--- /dev/null
+++ b/org.rtems.cdt.toolchain/src/org/rtems/cdt/toolchain/RtemsInstallBspDirectoryValueHandler.java
@@ -0,0 +1,101 @@
+package org.rtems.cdt.toolchain;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.core.runtime.IPath;
+
+public class RtemsInstallBspDirectoryValueHandler implements IManagedOptionValueHandler {
+ private IPath installedBspLibPath; // e.g., /opt/rtems_install/i386-rtems4.9/pc686/lib
+
+ public RtemsInstallBspDirectoryValueHandler() {
+ installedBspLibPath = RtemsEnvironmentVariableSupplier.getRtemsInstallBspLibDirectory();
+ }
+
+ /**
+ * Handles transfer between values between UI element and
+ * back-end in different circumstances.
+ *
+ * @param configuration build configuration of option
+ * (may be IConfiguration or IResourceConfiguration)
+ * @param holder contains the holder of the option
+ * @param option the option that is handled
+ * @param extraArgument extra argument for handler
+ * @param event event to be handled, one of the following:
+ * (EVENT_OPEN = 1, EVENT_CLOSE = 2,
+ * EVENT_SETDEFAULT = 3,
+ * EVENT_APPLY = 4, EVENT_LOAD = 5)
+ *
+ * @return True when the event was handled, false otherwise.
+ * This enables default event handling can take place.
+ */
+ public boolean handleValue(IBuildObject configuration, IHoldsOptions holder,
+ IOption option, String extraArgument, int event) {
+ if (event == EVENT_CLOSE) return false;
+
+ try {
+ String optionValue = (String) option.getValue();
+ if (optionValue==null || optionValue.trim().length()<=0) {
+ option.setValue(installedBspLibPath.toPortableString());
+ }
+ } catch (Exception e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks whether the value of an option is its default value.
+ *
+ * @param configuration build configuration of option
+ * (may be IConfiguration or IResourceConfiguration)
+ * @param holder contains the holder of the option
+ * @param option the option that is handled
+ * @param extraArgument extra argument for handler
+ *
+ * The additional options besides configuration are supplied to
+ * provide enough information for querying the default value from
+ * a potential data storage back-end.
+ *
+ * @return True if the options value is its default value and
+ * False otherwise. This enables that default event handling can
+ * take place.
+ */
+ public boolean isDefaultValue(IBuildObject configuration,
+ IHoldsOptions holder, IOption option, String extraArgument) {
+ if (installedBspLibPath==null) return false;
+
+ return installedBspLibPath.toPortableString().equals(option.getValue());
+ }
+
+ /**
+ * Checks whether an enumeration value of an option is currently a
+ * valid choice. The use-case for this method is the case, where
+ * the set of valid enumerations in the plugin.xml file changes.
+ * The UI will remove entries from selection lists if the value
+ * returns false.
+ *
+ * @param configuration build configuration of option
+ * (may be IConfiguration or IResourceConfiguration)
+ * @param holder contains the holder of the option
+ * @param option the option that is handled
+ * @param extraArgument extra argument for handler
+ * @param enumValue enumeration value that is to be checked
+ *
+ * The additional options besides configuration are supplied to
+ * provide enough information for querying information from a
+ * a potential data storage back-end.
+ *
+ * @return True if the enumeration value is valid and False
+ * otherwise.
+ */
+ public boolean isEnumValueAppropriate(IBuildObject configuration,
+ IHoldsOptions holder, IOption option, String extraArgument,
+ String enumValue) {
+ // By default return true for all the enum values.
+ return true;
+ }
+
+}