aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Zotkin2013-03-01 14:06:57 (EST)
committerPaul Webster2013-03-01 14:06:57 (EST)
commite14cff6969683cb974f000ce377610b8b3a577c6 (patch)
tree60a9bd9da02c1f06e05a406cd32a3aea11767583
parent4ef1441f1d61e51bef4eecdd88f0ecb608a4b105 (diff)
downloadeclipse.platform.ui-e14cff6969683cb974f000ce377610b8b3a577c6.zip
eclipse.platform.ui-e14cff6969683cb974f000ce377610b8b3a577c6.tar.gz
eclipse.platform.ui-e14cff6969683cb974f000ce377610b8b3a577c6.tar.bz2
Bug 401611 - [Commands] request: convert parameter value back to Objectv20130301-190657I20130303-2000I20130302-1500I20130301-2000
-rw-r--r--bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/internal/HandlerServiceImpl.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/internal/HandlerServiceImpl.java b/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/internal/HandlerServiceImpl.java
index e8b565f..aa8d702 100644
--- a/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/internal/HandlerServiceImpl.java
+++ b/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/internal/HandlerServiceImpl.java
@@ -14,8 +14,12 @@ package org.eclipse.e4.core.commands.internal;
import java.util.Iterator;
import java.util.Map;
import javax.inject.Inject;
+import org.eclipse.core.commands.AbstractParameterValueConverter;
import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterType;
+import org.eclipse.core.commands.ParameterValueConversionException;
import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.e4.core.commands.EHandlerService;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
@@ -75,12 +79,41 @@ public class HandlerServiceImpl implements EHandlerService {
Iterator i = parms.entrySet().iterator();
while (i.hasNext()) {
Map.Entry entry = (Map.Entry) i.next();
- staticContext.set((String) entry.getKey(), entry.getValue());
+ String parameterId = (String) entry.getKey();
+ staticContext.set(
+ parameterId,
+ convertParameterValue(command.getCommand(), parameterId,
+ (String) entry.getValue()));
}
staticContext.set(PARM_MAP, parms);
staticContext.set(ParameterizedCommand.class, command);
}
+ /**
+ * Convert the parameter's value according to it's type.
+ *
+ * @param command
+ * @param parameterId
+ * @param value
+ * @return converted value
+ * @see org.eclipse.e4.ui.model.application.commands.MCommandParameter#getTypeId()
+ */
+ private Object convertParameterValue(Command command, String parameterId, String value) {
+ try {
+ ParameterType parameterType = command.getParameterType(parameterId);
+
+ if (parameterType != null) {
+ AbstractParameterValueConverter valueConverter = parameterType.getValueConverter();
+ if (valueConverter != null) {
+ return valueConverter.convertToObject(value);
+ }
+ }
+ } catch (NotDefinedException e) {
+ } catch (ParameterValueConversionException e) {
+ }
+ return value;
+ }
+
/*
* (non-Javadoc)
*