Revision: 19274
          http://sourceforge.net/p/gate/code/19274
Author:   markagreenwood
Date:     2016-05-05 12:45:36 +0000 (Thu, 05 May 2016)
Log Message:
-----------
make sure all the params are of the right object type before using them

Modified Paths:
--------------
    gate/trunk/src/main/gate/gui/DocumentExportMenu.java

Modified: gate/trunk/src/main/gate/gui/DocumentExportMenu.java
===================================================================
--- gate/trunk/src/main/gate/gui/DocumentExportMenu.java        2016-05-05 
08:57:14 UTC (rev 19273)
+++ gate/trunk/src/main/gate/gui/DocumentExportMenu.java        2016-05-05 
12:45:36 UTC (rev 19274)
@@ -23,6 +23,7 @@
 import gate.Resource;
 import gate.corpora.export.GateXMLExporter;
 import gate.creole.Parameter;
+import gate.creole.ParameterException;
 import gate.creole.ResourceData;
 import gate.event.CreoleEvent;
 import gate.event.CreoleListener;
@@ -514,6 +515,8 @@
     private ResourceParametersEditor parametersEditor;
 
     private boolean singleFile, userCanceled;
+    
+    private FeatureMap parameters;
 
     public DocumentExportDialog() {
       super(MainFrame.getInstance(), "Save As...", true);
@@ -643,8 +646,11 @@
     public synchronized boolean show(DocumentExporter de,
             List<List<Parameter>> params, boolean singleFile, String filePath) 
{
 
+      
+      
       this.singleFile = singleFile;
       this.de = de;
+      this.parameters = null;
 
       setTitle("Save as " + de.getFileType());
 
@@ -659,7 +665,30 @@
       dispose();
       if(userCanceled)
         return false;
-      else return true;
+      
+      //update the feature map to convert values to objects of the correct 
type.
+      
+      parameters = parametersEditor.getParameterValues();
+      
+      for (List<Parameter> disjunction : params) {
+        for (Parameter param : disjunction) {
+          if (!param.getTypeName().equals("java.lang.String") && 
parameters.containsKey(param.getName())) {
+            Object value = parameters.get(param.getName());
+            if (value instanceof String) {
+              try {
+                parameters.put(param.getName(), 
param.calculateValueFromString((String)value));
+              }
+              catch (ParameterException pe) {
+                pe.printStackTrace();
+                parameters = null;
+                return false;
+              }
+            }
+          }
+        }
+      }
+      
+      return true;
     }
 
     @Override
@@ -672,9 +701,7 @@
      * selected or the user pressed cancel
      */
     public FeatureMap getSelectedParameters() {
-      if(parametersEditor != null)
-        return parametersEditor.getParameterValues();
-      else return null;
+      return parameters;
     }
 
     /**

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to