JAL-1980 check for null alignment; JAL-1551 @Override's added
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 30 Nov 2015 09:31:51 +0000 (09:31 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 30 Nov 2015 09:31:51 +0000 (09:31 +0000)
src/jalview/gui/CutAndPasteTransfer.java

index ff3e0f2..8665320 100644 (file)
@@ -72,6 +72,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
   {
     SwingUtilities.invokeLater(new Runnable()
     {
+      @Override
       public void run()
       {
         textarea.requestFocus();
@@ -124,6 +125,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
     textarea.append(text);
   }
 
+  @Override
   public void save_actionPerformed(ActionEvent e)
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
@@ -160,6 +162,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void copyItem_actionPerformed(ActionEvent e)
   {
     textarea.getSelectedText();
@@ -173,6 +176,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void pasteMenu_actionPerformed(ActionEvent e)
   {
     Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -198,6 +202,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void ok_actionPerformed(ActionEvent e)
   {
     String text = getText();
@@ -247,7 +252,11 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
     {
       String title = MessageManager.formatMessage(
               "label.input_cut_paste_params", new String[] { format });
-      if (viewport != null)
+      /*
+       * if the view panel was closed its alignment is nulled
+       * and this is an orphaned cut and paste window
+       */
+      if (viewport != null && viewport.getAlignment() != null)
       {
         ((AlignViewport) viewport).addAlignment(al, title);
       }
@@ -319,6 +328,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void cancel_actionPerformed(ActionEvent e)
   {
     try
@@ -329,6 +339,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
     }
   }
 
+  @Override
   public void textarea_mousePressed(MouseEvent e)
   {
     if (SwingUtilities.isRightMouseButton(e))
@@ -339,6 +350,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
               MessageManager.getString("action.copy"));
       item.addActionListener(new ActionListener()
       {
+        @Override
         public void actionPerformed(ActionEvent e)
         {
           copyItem_actionPerformed(e);
@@ -348,6 +360,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
       item = new JMenuItem(MessageManager.getString("action.paste"));
       item.addActionListener(new ActionListener()
       {
+        @Override
         public void actionPerformed(ActionEvent e)
         {
           pasteMenu_actionPerformed(e);