JAL-2505 updates after conflicting merge of JAL-2504
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 22 May 2017 15:40:14 +0000 (16:40 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 22 May 2017 15:40:14 +0000 (16:40 +0100)
src/jalview/appletgui/FeatureRenderer.java
src/jalview/gui/FeatureRenderer.java

index 38ecf76..81b207f 100644 (file)
@@ -394,11 +394,14 @@ public class FeatureRenderer extends
     /*
      * only update default type and group if we used defaults
      */
-    String enteredType = name.getText().trim();
+    final String enteredType = name.getText().trim();
+    final String enteredGroup = group.getText().trim();
+    final String enteredDesc = description.getText().replace('\n', ' ');
+
     if (dialog.accept && useLastDefaults)
     {
       lastFeatureAdded = enteredType;
-      lastFeatureGroupAdded = group.getText().trim();
+      lastFeatureGroupAdded = enteredGroup;
     }
 
     if (!create)
@@ -406,26 +409,33 @@ public class FeatureRenderer extends
       SequenceFeature sf = features[featureIndex];
       if (dialog.accept)
       {
-        sf.type = enteredType;
-        sf.featureGroup = group.getText().trim();
-        if (sf.featureGroup != null && sf.featureGroup.length() < 1)
-        {
-          sf.featureGroup = null;
-        }
-        sf.description = description.getText().replace('\n', ' ');
         if (!colourPanel.isGcol)
         {
           // update colour - otherwise its already done.
           setColour(sf.type, new FeatureColour(colourPanel.getBackground()));
         }
+        int newBegin = sf.begin;
+        int newEnd = sf.end;
         try
         {
-          sf.begin = Integer.parseInt(start.getText());
-          sf.end = Integer.parseInt(end.getText());
+          newBegin = Integer.parseInt(start.getText());
+          newEnd = Integer.parseInt(end.getText());
         } catch (NumberFormatException ex)
         {
-          //
+          // 
         }
+
+        /*
+         * replace the feature by deleting it and adding a new one
+         * (to ensure integrity of SequenceFeatures data store)
+         */
+        sequences[0].deleteFeature(sf);
+        SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd,
+                enteredGroup);
+        newSf.setDescription(enteredDesc);
+        ffile.parseDescriptionHTML(newSf, false);
+        // amend features dialog only updates one sequence at a time
+        sequences[0].addSequenceFeature(newSf);
         boolean typeOrGroupChanged = (!featureType.equals(sf.type) || !featureGroup
                 .equals(sf.featureGroup));
 
@@ -451,12 +461,12 @@ public class FeatureRenderer extends
       {
         for (int i = 0; i < sequences.length; i++)
         {
-          features[i].type = enteredType;
-          features[i].featureGroup = group.getText().trim();
-          features[i].description = description.getText()
-                  .replace('\n', ' ');
-          sequences[i].addSequenceFeature(features[i]);
-          ffile.parseDescriptionHTML(features[i], false);
+          SequenceFeature sf = features[i];
+          SequenceFeature sf2 = new SequenceFeature(enteredType,
+                  enteredDesc, sf.getBegin(), sf.getEnd(), Float.NaN,
+                  enteredGroup);
+          ffile.parseDescriptionHTML(sf2, false);
+          sequences[i].addSequenceFeature(sf2);
         }
 
         Color newColour = colourPanel.getBackground();
index c0e3e73..c6610e1 100644 (file)
@@ -43,7 +43,6 @@ import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.util.Arrays;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.List;
 
 import javax.swing.JColorChooser;
@@ -449,24 +448,11 @@ public class FeatureRenderer extends
          * (to ensure integrity of SequenceFeatures data store)
          */
         sequences.get(0).deleteFeature(sf);
-        SequenceFeature newSf = new SequenceFeature(enteredType,
-                enteredDescription, newBegin, newEnd, sf.getScore(),
+        SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd,
                 enteredGroup);
-        // ensure any additional properties are copied
-        if (sf.otherDetails != null)
-        {
-          newSf.otherDetails = new HashMap<String, Object>(sf.otherDetails);
-        }
+        sf.setDescription(enteredDescription);
         ffile.parseDescriptionHTML(newSf, false);
-        // add any additional links not parsed from description
-        if (sf.links != null)
-        {
-          for (String link : sf.links)
-          {
-            newSf.addLink(link);
-          }
-        }
-        // amend features only gets one sequence to act on
+        // amend features dialog only updates one sequence at a time
         sequences.get(0).addSequenceFeature(newSf);
 
         if (refreshSettings)
@@ -486,8 +472,8 @@ public class FeatureRenderer extends
           SequenceFeature sf2 = new SequenceFeature(enteredType,
                   enteredDescription, sf.getBegin(), sf.getEnd(),
                   Float.NaN, enteredGroup);
-          sequences.get(i).addSequenceFeature(sf2);
           ffile.parseDescriptionHTML(sf2, false);
+          sequences.get(i).addSequenceFeature(sf2);
         }
 
         setColour(enteredType, fcol);