commands,
+ boolean getReply, String msg)
+ {
+ return executeCommand(getReply, msg,
+ commands.toArray(new StructureCommandI[commands.size()]));
+ }
+
+ /**
+ * Executes one or more structure viewer commands, optionally returning the
+ * reply, and optionally showing a status message while the command is being
+ * executed.
+ *
+ * If a reply is wanted, the execution is done synchronously (waits),
+ * otherwise it is done in a separate thread (doesn't wait).
+ *
+ * @param getReply
+ * @param msg
+ * @param cmds
+ * @return
+ */
+ protected List executeCommand(boolean getReply, String msg,
+ StructureCommandI... cmds)
+ {
+ JalviewStructureDisplayI theViewer = getViewer();
+ final long handle = msg == null ? 0 : theViewer.startProgressBar(msg);
+
+ if (getReply)
+ {
+ /*
+ * execute and wait for reply
+ */
+ List response = new ArrayList<>();
+ try
+ {
+ for (StructureCommandI cmd : cmds)
+ {
+ List replies = executeCommand(cmd, true);
+ if (replies != null)
+ {
+ response.addAll(replies);
+ }
+ }
+ return response;
+ } finally
+ {
+ if (msg != null)
+ {
+ theViewer.stopProgressBar(null, handle);
+ }
+ }
+ }
+
+ /*
+ * fire and forget
+ */
+ String threadName = msg == null ? "StructureCommand" : msg;
+ new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ for (StructureCommandI cmd : cmds)
+ {
+ executeCommand(cmd, false);
+ }
+ } finally
+ {
+ if (msg != null)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ theViewer.stopProgressBar(null, handle);
+ }
+ });
+ }
+ }
+ }
+ }, threadName).start();
+ return null;
+ }
+
+ /**
+ * Colours any structures associated with sequences in the given alignment as
+ * coloured in the alignment view, provided colourBySequence is enabled
+ */
+ public void colourBySequence(AlignmentViewPanel alignmentv)
+ {
+ if (!colourBySequence || !isLoadingFinished() || getSsm() == null)
+ {
+ return;
+ }
+ Map