Revision: 5475
          http://sourceforge.net/p/jump-pilot/code/5475
Author:   michaudm
Date:     2017-07-27 20:29:07 +0000 (Thu, 27 Jul 2017)
Log Message:
-----------
* AutoAssignAttributePlugIn : inverse options order (simple to more complex)
* Deprecate ReplaceValuePlugIn (redundant with the previous one, not undoable)

Modified Paths:
--------------
    core/trunk/ChangeLog
    
core/trunk/src/org/openjump/core/ui/plugin/tools/AutoAssignAttributePlugIn.java
    core/trunk/src/org/openjump/core/ui/plugin/tools/ReplaceValuePlugIn.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2017-07-26 21:18:55 UTC (rev 5474)
+++ core/trunk/ChangeLog        2017-07-27 20:29:07 UTC (rev 5475)
@@ -3,6 +3,10 @@
 # 2. make sure that lines break at 80 chars for constricted display situations
 #<-------------------------------- 80 chars 
---------------------------------->#
 
+2017-07-27 mmichaud <[email protected]>
+  * AutoAssignAttributePlugIn : inverse options order (simple to more complex)
+  * Deprecate ReplaceValuePlugIn (redundant with the previous one, not 
undoable)
+
 2017-07-26 mmichaud <[email protected]>
   * AutoAssignAttributePlugIn : accept boolean and long as target attributes
 

Modified: 
core/trunk/src/org/openjump/core/ui/plugin/tools/AutoAssignAttributePlugIn.java
===================================================================
--- 
core/trunk/src/org/openjump/core/ui/plugin/tools/AutoAssignAttributePlugIn.java 
    2017-07-26 21:18:55 UTC (rev 5474)
+++ 
core/trunk/src/org/openjump/core/ui/plugin/tools/AutoAssignAttributePlugIn.java 
    2017-07-27 20:29:07 UTC (rev 5475)
@@ -179,14 +179,13 @@
             Object item = targetAttributeComboBox.getModel().getElementAt(i);
             if (item.equals(targetAttribute)) 
targetAttributeComboBox.setSelectedIndex(i);
         }
-        
-        // Auto-increment options
+
+        // Set new value
         dialog.addSeparator();
-        final JRadioButton autoIncRB = 
dialog.addRadioButton(AUTOINC_CHECK_BOX, "MODE", autoIncrement, null);
-        dialog.addTextField(AUTOINC_PATTERN_BOX, pattern, 4, null, 
AUTOINC_DESCRIPTION_2);
-        dialog.addIntegerField(INC_VALUE_EDIT_BOX, 1, 4, "");
-        
-        // From other attribute option
+        final JRadioButton assignValueRB = 
dialog.addRadioButton(ASSIGN_VALUE_CHECK_BOX, "MODE", assignValue, null);
+        dialog.addTextField(ASSIGN_VALUE_TEXT_BOX, "", 15, null, "");
+
+        // Set value from another attribute
         dialog.addSeparator();
         final JRadioButton fromSourceRB = 
dialog.addRadioButton(FROM_SOURCE_CHECK_BOX, "MODE", assignFromSource, null);
         final JComboBox sourceAttributeComboBox = 
@@ -197,13 +196,17 @@
             Object item = sourceAttributeComboBox.getModel().getElementAt(i);
             if (item.equals(sourceAttribute)) 
sourceAttributeComboBox.setSelectedIndex(i);
         }
+        initEnableChecks(dialog);
 
-        initEnableChecks(dialog);
-        
+
+        // Auto-incremented value
         dialog.addSeparator();
-        final JRadioButton assignValueRB = 
dialog.addRadioButton(ASSIGN_VALUE_CHECK_BOX, "MODE", assignValue, null);
-        dialog.addTextField(ASSIGN_VALUE_TEXT_BOX, "", 15, null, "");
-        
+        final JRadioButton autoIncRB = 
dialog.addRadioButton(AUTOINC_CHECK_BOX, "MODE", autoIncrement, null);
+        dialog.addTextField(AUTOINC_PATTERN_BOX, pattern, 4, null, 
AUTOINC_DESCRIPTION_2);
+        dialog.addIntegerField(INC_VALUE_EDIT_BOX, 1, 4, "");
+
+        // Update controls
+
         updateControls(dialog);
 
         targetAttributeComboBox.addActionListener(new ActionListener() {

Modified: 
core/trunk/src/org/openjump/core/ui/plugin/tools/ReplaceValuePlugIn.java
===================================================================
--- core/trunk/src/org/openjump/core/ui/plugin/tools/ReplaceValuePlugIn.java    
2017-07-26 21:18:55 UTC (rev 5474)
+++ core/trunk/src/org/openjump/core/ui/plugin/tools/ReplaceValuePlugIn.java    
2017-07-27 20:29:07 UTC (rev 5475)
@@ -56,8 +56,9 @@
  * @version 25 juil. 06
  *
  * license Licence CeCILL http://www.cecill.info/
+ * @deprecated this plugin is not undoable - moreover, it is redundant with 
AutoAssignAttribute
  */
-
+@Deprecated
 public class ReplaceValuePlugIn extends AbstractPlugIn implements 
ThreadedPlugIn {
  
   //-- replace later with correct language
@@ -232,14 +233,24 @@
          for (Feature f : selectedFC) {
 
                  if (!byAttribute) {
-                         // remplacement par la valeur saisie
-                         if (type == AttributeType.DOUBLE) {
-                                 f.setAttribute(attrName, new Double (value));
-                         } else if (type == AttributeType.INTEGER)  {
-                                 f.setAttribute(attrName, new Integer (value));
-                         } else if (type == AttributeType.STRING) {
-                                 f.setAttribute(attrName, value);
-                         }
+                       try {
+                               // remplacement par la valeur saisie
+                               if (type != AttributeType.STRING && value == 
null || value.trim().isEmpty()) {
+                                       f.setAttribute(attrName, null);
+                               } else if (type == AttributeType.DOUBLE) {
+                                       f.setAttribute(attrName, new 
Double(value));
+                               } else if (type == AttributeType.INTEGER) {
+                                       f.setAttribute(attrName, new 
Integer(value));
+                               } else if (type == AttributeType.LONG) {
+                                       f.setAttribute(attrName, new 
Long(value));
+                               } else if (type == AttributeType.BOOLEAN) {
+                                       f.setAttribute(attrName, 
Boolean.parseBoolean(value));
+                               } else if (type == AttributeType.STRING) {
+                                       f.setAttribute(attrName, value);
+                               }
+                       } catch(NumberFormatException e) {
+                               f.setAttribute(attrName, null);
+                       }
                  }
          }
 
@@ -264,6 +275,10 @@
 
                          } else if (typeDest == AttributeType.STRING) {
                                  f.setAttribute(attrNameDest, attrValue);
+                         } else if (typeDest == AttributeType.LONG) {
+                                 f.setAttribute(attrNameDest, new 
Long(attrValue));
+                         } else if (typeDest == AttributeType.BOOLEAN) {
+                                 f.setAttribute(attrNameDest, 
Boolean.parseBoolean(attrValue));
                          }
                  }
          }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to