X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=5ef256870ebb29804bfbcac19efb46e0d5949db8;hb=d9f0a24d9662a0b530fd79b51108dd074d03d6e0;hp=ef2401160f3cc8afb07f5823dbda24f77eb0ad20;hpb=1d0f5219658cdf6ad5e1a1cbe6e1bb8cd12e6d85;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index ef24011..5ef2568 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -79,7 +79,7 @@ public class AlignViewport extends AlignmentViewport private Rectangle explodedGeometry; - String viewName; + private String viewName; /* * Flag set true on the view that should 'gather' multiple views of the same @@ -304,6 +304,7 @@ public class AlignViewport extends AlignmentViewport { residueShading.setConsensus(hconsensus); } + setColourAppliesToAllGroups(true); } boolean validCharWidth; @@ -707,16 +708,20 @@ public class AlignViewport extends AlignmentViewport { if (AlignmentUtils.isMappable(toAdd, getAlignment())) { - if (openLinkedAlignment(toAdd, title)) - { - return; - } + openLinkedAlignment(toAdd, title); + return; } } + addDataToAlignment(toAdd); + } - /* - * No mappings, or offer declined - add sequences to this alignment - */ + /** + * adds sequences to this alignment + * + * @param toAdd + */ + void addDataToAlignment(AlignmentI toAdd) + { // TODO: JAL-407 regardless of above - identical sequences (based on ID and // provenance) should share the same dataset sequence @@ -751,30 +756,58 @@ public class AlignViewport extends AlignmentViewport * @param al * @param title */ - protected boolean openLinkedAlignment(AlignmentI al, String title) + protected void openLinkedAlignment(AlignmentI al, String title) { String[] options = new String[] { MessageManager.getString("action.no"), MessageManager.getString("label.split_window"), MessageManager.getString("label.new_window"), }; final String question = JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.open_split_window?")); - int response = JvOptionPane.showOptionDialog(Desktop.desktop, question, + final AlignViewport us = this; + + /* + * options No, Split Window, New Window correspond to + * dialog responses 0, 1, 2 (even though JOptionPane shows them + * in reverse order) + */ + JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop) + .setResponseHandler(0, new Runnable() + { + @Override + public void run() + { + addDataToAlignment(al); + } + }).setResponseHandler(1, new Runnable() + { + @Override + public void run() + { + us.openLinkedAlignmentAs(al, title, true); + } + }).setResponseHandler(2, new Runnable() + { + @Override + public void run() + { + us.openLinkedAlignmentAs(al, title, false); + } + }); + dialog.showDialog(question, MessageManager.getString("label.open_split_window"), JvOptionPane.DEFAULT_OPTION, JvOptionPane.PLAIN_MESSAGE, null, options, options[0]); + } - if (response != 1 && response != 2) + protected void openLinkedAlignmentAs(AlignmentI al, String title, + boolean newWindowOrSplitPane) { - return false; - } - final boolean openSplitPane = (response == 1); - final boolean openInNewWindow = (response == 2); - /* * Identify protein and dna alignments. Make a copy of this one if opening * in a new split pane. */ - AlignmentI thisAlignment = openSplitPane ? new Alignment(getAlignment()) + AlignmentI thisAlignment = newWindowOrSplitPane + ? new Alignment(getAlignment()) : getAlignment(); AlignmentI protein = al.isNucleotide() ? thisAlignment : al; final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment; @@ -795,7 +828,7 @@ public class AlignViewport extends AlignmentViewport AlignFrame newAlignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); newAlignFrame.setTitle(title); - newAlignFrame.statusBar.setText(MessageManager + newAlignFrame.setStatus(MessageManager .formatMessage("label.successfully_loaded_file", new Object[] { title })); @@ -806,7 +839,7 @@ public class AlignViewport extends AlignmentViewport // alignFrame.setFileName(file, format); // } - if (openInNewWindow) + if (!newWindowOrSplitPane) { Desktop.addInternalFrame(newAlignFrame, title, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); @@ -820,13 +853,11 @@ public class AlignViewport extends AlignmentViewport { } - if (openSplitPane) + if (newWindowOrSplitPane) { al.alignAs(thisAlignment); protein = openSplitFrame(newAlignFrame, thisAlignment); } - - return true; } /** @@ -1032,4 +1063,14 @@ public class AlignViewport extends AlignmentViewport } fr.setTransparency(featureSettings.getTransparency()); } + + public String getViewName() + { + return viewName; + } + + public void setViewName(String viewName) + { + this.viewName = viewName; + } }