import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
+import jalview.commands.EditCommand.Edit;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SearchResults;
import jalview.datamodel.Sequence;
import jalview.structure.SelectionSource;
import jalview.structure.SequenceListener;
import jalview.structure.StructureSelectionManager;
+import jalview.structure.VamsasSource;
+import jalview.util.Comparison;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
return features;
}
+ /**
+ * When all of a sequence of edits are complete, put the resulting edit list
+ * on the history stack (undo list), and reset flags for editing in progress.
+ */
void endEditing()
{
- if (editCommand != null && editCommand.getSize() > 0)
+ try
+ {
+ if (editCommand != null && editCommand.getSize() > 0)
+ {
+ ap.alignFrame.addHistoryItem(editCommand);
+ av.firePropertyChange("alignment", null, av.getAlignment()
+ .getSequences());
+ }
+ } finally
{
- ap.alignFrame.addHistoryItem(editCommand);
- av.firePropertyChange("alignment", null, av.getAlignment()
- .getSequences());
+ /*
+ * Tidy up come what may...
+ */
+ startseq = -1;
+ lastres = -1;
+ editingSeqs = false;
+ groupEditing = false;
+ keyboardNo1 = null;
+ keyboardNo2 = null;
+ editCommand = null;
}
-
- startseq = -1;
- lastres = -1;
- editingSeqs = false;
- groupEditing = false;
- keyboardNo1 = null;
- keyboardNo2 = null;
- editCommand = null;
}
void setCursorRow()
String lastMessage;
- @Override
public void mouseOverSequence(SequenceI sequence, int index, int pos)
{
String tmp = sequence.hashCode() + " " + index + " " + pos;
}
@Override
+ public VamsasSource getVamsasSource()
+ {
+ return this.ap == null ? null : this.ap.av;
+ }
public void updateColours(SequenceI seq, int index)
{
System.out.println("update the seqPanel colours");
}
}
- StringBuffer message = new StringBuffer();
+ StringBuilder message = new StringBuilder(64);
if (groupEditing)
{
message.append("Edit group:");
}
else
{
- editCommand.appendEdit(Action.INSERT_GAP, groupSeqs,
- startres, startres - lastres, av.getAlignment(), true);
+ appendEdit(Action.INSERT_GAP, groupSeqs, startres, startres
+ - lastres);
}
}
else
}
else
{
- editCommand.appendEdit(Action.DELETE_GAP, groupSeqs,
- startres, lastres - startres, av.getAlignment(), true);
+ appendEdit(Action.DELETE_GAP, groupSeqs, startres, lastres
+ - startres);
}
}
}
else
{
- editCommand.appendEdit(Action.INSERT_GAP, new SequenceI[]
- { seq }, lastres, startres - lastres, av.getAlignment(), true);
+ appendEdit(Action.INSERT_GAP, new SequenceI[]
+ { seq }, lastres, startres - lastres);
}
}
else
{
for (int j = lastres; j > startres; j--)
{
- if (!jalview.util.Comparison.isGap(seq.getCharAt(startres)))
+ if (!Comparison.isGap(seq.getCharAt(startres)))
{
endEditing();
break;
int max = 0;
for (int m = startres; m < lastres; m++)
{
- if (!jalview.util.Comparison.isGap(seq.getCharAt(m)))
+ if (!Comparison.isGap(seq.getCharAt(m)))
{
break;
}
if (max > 0)
{
- editCommand.appendEdit(Action.DELETE_GAP,
- new SequenceI[]
- { seq }, startres, max, av.getAlignment(), true);
+ appendEdit(Action.DELETE_GAP, new SequenceI[]
+ { seq }, startres, max);
}
}
}
}
else
{
- editCommand.appendEdit(Action.INSERT_NUC, new SequenceI[]
- { seq }, lastres, startres - lastres, av.getAlignment(), true);
+ appendEdit(Action.INSERT_NUC, new SequenceI[]
+ { seq }, lastres, startres - lastres);
}
}
}
}
}
- editCommand.appendEdit(Action.DELETE_GAP, seq, blankColumn, 1,
- av.getAlignment(), true);
+ appendEdit(Action.DELETE_GAP, seq, blankColumn, 1);
+
+ appendEdit(Action.INSERT_GAP, seq, j, 1);
+
+ }
+
+ /**
+ * Helper method to add and perform one edit action.
+ *
+ * @param action
+ * @param seq
+ * @param pos
+ * @param count
+ */
+ protected void appendEdit(Action action, SequenceI[] seq, int pos,
+ int count)
+ {
- editCommand.appendEdit(Action.INSERT_GAP, seq, j, 1,
- av.getAlignment(), true);
+ final Edit edit = new EditCommand().new Edit(action, seq, pos, count,
+ av.getAlignment().getGapCharacter());
+ editCommand.appendEdit(edit, av.getAlignment(),
+ true, null);
}
void deleteChar(int j, SequenceI[] seq, int fixedColumn)
{
- editCommand.appendEdit(Action.DELETE_GAP, seq, j, 1,
- av.getAlignment(), true);
+ appendEdit(Action.DELETE_GAP, seq, j, 1);
- editCommand.appendEdit(Action.INSERT_GAP, seq, fixedColumn, 1,
- av.getAlignment(), true);
+ appendEdit(Action.INSERT_GAP, seq, fixedColumn, 1);
}
/**