}
}
- StringBuilder message = new StringBuilder(64);
- if (groupEditing)
+ /*
+ * initialise the edit command if there is not
+ * already one being extended
+ */
+ if (editCommand == null)
{
- message.append("Edit group:");
- if (editCommand == null)
+ if (groupEditing)
{
editCommand = new EditCommand(
MessageManager.getString("action.edit_group"));
}
- }
- else
- {
- message.append("Edit sequence: " + seq.getName());
- String label = seq.getName();
- if (label.length() > 10)
- {
- label = label.substring(0, 10);
- }
- if (editCommand == null)
+ else
{
+ String label = seq.getName();
+ if (label.length() > 10)
+ {
+ label = label.substring(0, 10);
+ }
editCommand = new EditCommand(MessageManager
.formatMessage("label.edit_params", new String[]
{ label }));
}
}
- if (insertGap)
- {
- message.append(" insert ");
- }
- else
- {
- message.append(" delete ");
- }
-
- message.append(Math.abs(startres - lastres) + " gaps.");
- ap.alignFrame.statusBar.setText(message.toString());
// Are we editing within a selection group?
if (groupEditing || (sg != null
if (groupEditing)
{
+ ap.alignFrame.statusBar.setText(" "); // defer this as difficult!
List<SequenceI> vseqs = sg.getSequences(av.getHiddenRepSequences());
int g, groupSize = vseqs.size();
SequenceI[] groupSeqs = new SequenceI[groupSize];
else
// ///Editing a single sequence///////////
{
+ String msg = getEditStatusMessage(insertGap, seq.getName());
+ ap.alignFrame.statusBar.setText(msg);
if (insertGap)
{
// dragging to the right
seqCanvas.repaint();
}
+ /**
+ * Constructs an informative status bar message while dragging to insert or
+ * delete gaps
+ *
+ * @param insert
+ * @param seqName
+ * @return
+ */
+ protected String getEditStatusMessage(boolean insert, String seqName)
+ {
+ /*
+ * add any inserts, and subtract any deletes, so far
+ */
+ int count = 0;
+ for (Edit cmd : editCommand.getEdits())
+ {
+ count += cmd.getAction() == Action.INSERT_GAP ? cmd.getNumber()
+ : -cmd.getNumber();
+ }
+
+ /*
+ * add the current action
+ */
+ count += insert ? 1 : -1;
+
+ if (count == 0)
+ {
+ /*
+ * inserts and deletes cancel out
+ */
+ return " ";
+ }
+ StringBuilder message = new StringBuilder(64);
+ if (groupEditing)
+ {
+ message.append("Edit group:");
+ }
+ else
+ {
+ message.append("Edit sequence: ").append(seqName);
+ }
+
+ message.append(count > 0 ? " insert " : " delete ");
+ count = Math.abs(count);
+ message.append(String.valueOf(count));
+ message.append(count > 1 ? " gaps" : " gap");
+ String msg = message.toString();
+ return msg;
+ }
+
void insertChar(int j, SequenceI[] seq, int fixedColumn)
{
int blankColumn = fixedColumn;