JAL-3032 variant of Sequence Details panel for JalviewJS
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 20 Aug 2018 10:52:01 +0000 (11:52 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 20 Aug 2018 10:52:01 +0000 (11:52 +0100)
src/jalview/gui/PopupMenu.java

index 8e2cda4..5a12a02 100644 (file)
@@ -25,6 +25,7 @@ import jalview.analysis.AlignmentAnnotationUtils;
 import jalview.analysis.AlignmentUtils;
 import jalview.analysis.Conservation;
 import jalview.bin.Cache;
+import jalview.bin.Jalview;
 import jalview.commands.ChangeCaseCommand;
 import jalview.commands.EditCommand;
 import jalview.commands.EditCommand.Action;
@@ -72,12 +73,14 @@ import java.util.TreeMap;
 import java.util.Vector;
 
 import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
 
 /**
  * DOCUMENT ME!
@@ -1633,8 +1636,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
 
   public void createSequenceDetailsReport(SequenceI[] sequences)
   {
-    CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
     StringBuilder contents = new StringBuilder(128);
+    contents.append("<html><body>");
     for (SequenceI seq : sequences)
     {
       contents.append("<p><h2>" + MessageManager.formatMessage(
@@ -1645,9 +1648,30 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
               contents, seq, true, true, ap.getSeqPanel().seqCanvas.fr);
       contents.append("</p>");
     }
-    cap.setText("<html>" + contents.toString() + "</html>");
+    contents.append("</body></html>");
+    String report = contents.toString();
+    
+    JInternalFrame frame;
+    if (Jalview.isJS())
+    {
+      JLabel textLabel = new JLabel();
+      textLabel.setText(report);
+      textLabel.setBackground(Color.WHITE);
+      JPanel pane = new JPanel(new BorderLayout());
+      ((JPanel) pane).setOpaque(true);
+      pane.setBackground(Color.WHITE);
+      ((JPanel) pane).add(textLabel, BorderLayout.NORTH);
+      frame = new JInternalFrame();
+      frame.getContentPane().add(new JScrollPane(pane));
+    }
+    else
+    {
+      CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
+      cap.setText(report);
+      frame = cap;
+    }
 
-    Desktop.addInternalFrame(cap,
+    Desktop.addInternalFrame(frame,
             MessageManager.formatMessage("label.sequence_details_for",
                     (sequences.length == 1 ? new Object[]
                     { sequences[0].getDisplayId(true) }
@@ -1655,7 +1679,6 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
                             { MessageManager
                                     .getString("label.selection") })),
             500, 400);
-
   }
 
   protected void showNonconserved_actionPerformed()