Merge branch 'develop' into features/JAL-1152annotationSorting
authorJim Procter <jprocter@dundee.ac.uk>
Mon, 3 Nov 2014 16:13:35 +0000 (16:13 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 3 Nov 2014 16:13:35 +0000 (16:13 +0000)
.gitignore
src/jalview/appletgui/RedundancyPanel.java
src/jalview/commands/EditCommand.java
src/jalview/gui/RedundancyPanel.java

index 9841761..c47ff62 100644 (file)
@@ -3,4 +3,5 @@
 /classes
 .externalToolBuilders/Jalview Release indices [Builder].launch
 /.DS_Store
+.DS_Store
 /.com.apple.timemachine.supported
index 216f45d..1547862 100644 (file)
@@ -213,8 +213,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
       ap.alignFrame.addHistoryItem(cut);
 
       PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
-      // ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
-      // .getSequences());
+       ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences());
     }
 
   }
@@ -228,6 +227,7 @@ public class RedundancyPanel extends SliderPanel implements Runnable,
     {
       ap.av.historyList.removeElement(command);
       ap.alignFrame.updateEditMenuBar();
+      ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences());
     }
 
     ap.paintAlignment(true);
index 83ba536..5c698a8 100644 (file)
  */
 package jalview.commands;
 
-import java.util.*;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
 
-import jalview.datamodel.*;
+import java.util.Hashtable;
+import java.util.List;
 
 /**
  * 
@@ -215,28 +221,26 @@ public class EditCommand implements CommandI
 
   @Override
   final public void undoCommand(AlignmentI[] views)
-  {
-    int e = 0, eSize = edits.length;
-    for (e = eSize - 1; e > -1; e--)
-    {
-      switch (edits[e].command)
-      {
-      case INSERT_GAP:
-        deleteGap(edits[e]);
-        break;
-      case DELETE_GAP:
-        insertGap(edits[e]);
-        break;
-      case CUT:
-        paste(edits[e], views);
-        break;
-      case PASTE:
-        cut(edits[e], views);
-        break;
-      case REPLACE:
-        replace(edits[e]);
-        break;
-      }
+  { 
+    for(Edit e : edits){
+       switch (e.command)
+        {
+        case INSERT_GAP:
+          deleteGap(e);
+          break;
+        case DELETE_GAP:
+          insertGap(e);
+          break;
+        case CUT:
+          paste(e, views);
+          break;
+        case PASTE:
+          cut(e, views);
+          break;
+        case REPLACE:
+          replace(e);
+          break;
+        }
     }
   }
 
@@ -355,7 +359,10 @@ public class EditCommand implements CommandI
           List<SequenceI> sequences;
           synchronized (sequences = command.al.getSequences())
           {
-            sequences.add(command.alIndex[i], command.seqs[i]);
+            if (!(command.alIndex[i] < 0))
+            {
+              sequences.add(command.alIndex[i], command.seqs[i]);
+            }
           }
         }
         else
@@ -398,9 +405,13 @@ public class EditCommand implements CommandI
                       + command.number);
             }
             if (command.seqs[i].getStart() == start)
+            {
               newstart--;
+            }
             else
+            {
               newend++;
+            }
           }
         }
         command.string[i] = null;
@@ -704,10 +715,12 @@ public class EditCommand implements CommandI
       {
         temp = new Annotation[aSize + command.number];
         if (annotations[a].padGaps)
+        {
           for (int aa = 0; aa < temp.length; aa++)
           {
             temp[aa] = new Annotation(command.gapChar + "", null, ' ', 0);
           }
+        }
       }
       else
       {
@@ -786,8 +799,10 @@ public class EditCommand implements CommandI
           int copylen = Math.min(command.position,
                   annotations[a].annotations.length);
           if (copylen > 0)
+           {
             System.arraycopy(annotations[a].annotations, 0, temp, 0,
                     copylen); // command.position);
+          }
 
           Annotation[] deleted = new Annotation[command.number];
           if (copylen >= command.position)
index 1fcd875..0e55cf8 100755 (executable)
@@ -245,8 +245,7 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
       ap.alignFrame.addHistoryItem(cut);
 
       PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
-      // ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
-      // .getSequences());
+       ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences());
     }
 
   }
@@ -259,12 +258,17 @@ public class RedundancyPanel extends GSliderPanel implements Runnable
    */
   public void undoButton_actionPerformed(ActionEvent e)
   {
+    if(historyList == null || historyList.isEmpty()){
+        undoButton.setEnabled(false);
+       return;
+    }
+    
     CommandI command = (CommandI) historyList.pop();
-    command.undoCommand(af.getViewAlignments());
-
     if (ap.av.historyList.contains(command))
     {
+      command.undoCommand(af.getViewAlignments());
       ap.av.historyList.remove(command);
+      ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences());
       af.updateEditMenuBar();
     }