JAL-3333 Replaced title text rendered in animated image with a titleText JLabel....
authorBen Soares <bsoares@dundee.ac.uk>
Fri, 28 Jun 2019 13:09:32 +0000 (14:09 +0100)
committerBen Soares <bsoares@dundee.ac.uk>
Fri, 28 Jun 2019 13:09:32 +0000 (14:09 +0100)
src/jalview/gui/WebserviceInfo.java
src/jalview/jbgui/GWebserviceInfo.java

index 2fc08e1..162d2b0 100644 (file)
@@ -26,7 +26,7 @@ import jalview.ws.WSClientI;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
-import java.awt.Font;
+import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.GridLayout;
@@ -39,7 +39,6 @@ import java.util.Vector;
 import javax.swing.JComponent;
 import javax.swing.JEditorPane;
 import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTabbedPane;
@@ -343,7 +342,9 @@ public class WebserviceInfo extends GWebserviceInfo
     }
 
     AnimatedPanel ap = new AnimatedPanel();
-    titlePanel.add(ap, BorderLayout.CENTER);
+    ap.setPreferredSize(new Dimension(60, 0));
+    titlePanel.add(ap, BorderLayout.LINE_START);
+    titlePanel.add(titleText, BorderLayout.CENTER);
 
     Thread thread = new Thread(ap);
     thread.start();
@@ -351,7 +352,8 @@ public class WebserviceInfo extends GWebserviceInfo
     frame.addInternalFrameListener(
             new javax.swing.event.InternalFrameAdapter()
             {
-              public void internalFrameClosed(
+              @Override
+                       public void internalFrameClosed(
                       javax.swing.event.InternalFrameEvent evt)
               {
                 // System.out.println("Shutting down webservice client");
@@ -375,6 +377,36 @@ public class WebserviceInfo extends GWebserviceInfo
   public void setStatus(int status)
   {
     currentStatus = status;
+
+    String message = null;
+    switch (currentStatus)
+    {
+    case STATE_QUEUING:
+      message = MessageManager.getString("label.state_queueing");
+      break;
+
+    case STATE_RUNNING:
+      message = MessageManager.getString("label.state_running");
+      break;
+
+    case STATE_STOPPED_OK:
+      message = MessageManager.getString("label.state_completed");
+      break;
+
+    case STATE_CANCELLED_OK:
+      message = MessageManager.getString("label.state_job_cancelled");
+      break;
+
+    case STATE_STOPPED_ERROR:
+      message = MessageManager.getString("label.state_job_error");
+      break;
+
+    case STATE_STOPPED_SERVERERROR:
+      message = MessageManager.getString("label.server_error_try_later");
+      break;
+    }
+    titleText.setText(title + (message == null ? "" : " - " + message));
+    titleText.repaint();
   }
 
   /**
@@ -676,7 +708,8 @@ public class WebserviceInfo extends GWebserviceInfo
    * @param e
    *          DOCUMENT ME!
    */
-  protected void cancel_actionPerformed(ActionEvent e)
+  @Override
+protected void cancel_actionPerformed(ActionEvent e)
   {
     if (!serviceIsCancellable)
     {
@@ -707,7 +740,8 @@ public class WebserviceInfo extends GWebserviceInfo
   {
     javax.swing.SwingUtilities.invokeLater(new Runnable()
     {
-      public void run()
+      @Override
+       public void run()
       {
         JvOptionPane.showInternalMessageDialog(Desktop.desktop, message,
                 title, JvOptionPane.WARNING_MESSAGE);
@@ -756,7 +790,8 @@ public class WebserviceInfo extends GWebserviceInfo
 
     BufferedImage offscreen;
 
-    public void run()
+    @Override
+       public void run()
     {
       startTime = System.currentTimeMillis();
 
@@ -800,62 +835,6 @@ public class WebserviceInfo extends GWebserviceInfo
       g.setColor(Color.white);
       g.fillRect(0, 0, getWidth(), getHeight());
 
-      g.setFont(new Font("Arial", Font.BOLD, 12));
-      g.setColor(Color.black);
-
-      switch (currentStatus)
-      {
-      case STATE_QUEUING:
-        g.drawString(
-                title.concat(" - ").concat(
-                        MessageManager.getString("label.state_queueing")),
-                60, 30);
-
-        break;
-
-      case STATE_RUNNING:
-        g.drawString(
-                title.concat(" - ").concat(
-                        MessageManager.getString("label.state_running")),
-                60, 30);
-
-        break;
-
-      case STATE_STOPPED_OK:
-        g.drawString(
-                title.concat(" - ").concat(
-                        MessageManager.getString("label.state_completed")),
-                60, 30);
-
-        break;
-
-      case STATE_CANCELLED_OK:
-        g.drawString(
-                title.concat(" - ")
-                        .concat(MessageManager
-                                .getString("label.state_job_cancelled")),
-                60, 30);
-
-        break;
-
-      case STATE_STOPPED_ERROR:
-        g.drawString(
-                title.concat(" - ").concat(
-                        MessageManager.getString("label.state_job_error")),
-                60, 30);
-
-        break;
-
-      case STATE_STOPPED_SERVERERROR:
-        g.drawString(
-                title.concat(" - ")
-                        .concat(MessageManager
-                                .getString("label.server_error_try_later")),
-                60, 30);
-
-        break;
-      }
-
       if (image != null)
       {
         int x = image.getWidth(this) / 2, y = image.getHeight(this) / 2;
@@ -865,7 +844,8 @@ public class WebserviceInfo extends GWebserviceInfo
       }
     }
 
-    public void paintComponent(Graphics g1)
+    @Override
+       public void paintComponent(Graphics g1)
     {
       drawPanel();
 
@@ -880,7 +860,8 @@ public class WebserviceInfo extends GWebserviceInfo
     renderAsHtml = b;
   }
 
-  public void hyperlinkUpdate(HyperlinkEvent e)
+  @Override
+public void hyperlinkUpdate(HyperlinkEvent e)
   {
     Desktop.hyperlinkUpdate(e);
   }
index ba84411..cddbb3b 100755 (executable)
@@ -25,6 +25,7 @@ import jalview.util.MessageManager;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
+import java.awt.Font;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.GridLayout;
@@ -61,6 +62,8 @@ public class GWebserviceInfo extends JPanel
 
   protected JPanel buttonPanel = new JPanel();
 
+  public JLabel titleText = new JLabel();
+
   public JButton cancel = new JButton();
 
   public JButton showResultsNewFrame = new JButton();
@@ -95,7 +98,7 @@ public class GWebserviceInfo extends JPanel
    */
   private void jbInit() throws Exception
   {
-    infoText.setFont(new java.awt.Font("Verdana", 0, 10));
+    infoText.setFont(new Font("Verdana", 0, 10));
     infoText.setBorder(null);
     infoText.setEditable(false);
     infoText.setText("");
@@ -106,13 +109,17 @@ public class GWebserviceInfo extends JPanel
     titlePanel.setBackground(Color.white);
     titlePanel.setPreferredSize(new Dimension(0, 60));
     titlePanel.setLayout(borderLayout3);
+    titleText.setFont(new Font("Arial", Font.BOLD, 12));
+    titleText.setBorder(null);
+    titleText.setText("");
     jScrollPane1.setBorder(null);
     jScrollPane1.setPreferredSize(new Dimension(400, 70));
-    cancel.setFont(new java.awt.Font("Verdana", 0, 11));
+    cancel.setFont(new Font("Verdana", 0, 11));
     cancel.setText(MessageManager.getString("action.cancel"));
     cancel.addActionListener(new java.awt.event.ActionListener()
     {
-      public void actionPerformed(ActionEvent e)
+      @Override
+       public void actionPerformed(ActionEvent e)
       {
         cancel_actionPerformed(e);
       }