debug dialog
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 25 Aug 2011 09:51:24 +0000 (10:51 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 25 Aug 2011 09:51:24 +0000 (10:51 +0100)
src/jalview/gui/RestServiceEditorPane.java
src/jalview/jbgui/GRestServiceEditorPane.java

index 4572f6f..581a44e 100644 (file)
@@ -25,6 +25,8 @@ import java.util.regex.Pattern;
 
 import javax.swing.*;
 import javax.swing.event.CaretEvent;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.text.GapContent;
@@ -56,14 +58,12 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
       @Override
       public void keyTyped(KeyEvent e)
       {
-        refreshCutnPaste(true);
       }
       
       @Override
       public void keyReleased(KeyEvent e)
       {
-        // TODO Auto-generated method stub
-        
+        refreshCutnPaste(true);        
       }
       
       @Override
@@ -73,35 +73,22 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
         
       }
     });
-    paste.addComponentListener(new ComponentListener()
+    panels.addChangeListener(new ChangeListener()
     {
-      
-      @Override
-      public void componentShown(ComponentEvent e)
-      {
-        updateServiceFromGui();
-        refreshCutnPaste(false);
-        
-      }
-      
-      @Override
-      public void componentResized(ComponentEvent e)
-      {        
-      }
-      
-      @Override
-      public void componentMoved(ComponentEvent e)
-      {
-        
-      }
-      
+      Object lastComp;
       @Override
-      public void componentHidden(ComponentEvent e)
+      public void stateChanged(ChangeEvent e)
       {
-        // TODO Auto-generated method stub
+        if (lastComp!=paste) {
+          updateServiceFromGui();
+          refreshCutnPaste(false);
+        } else {
+          refreshCutnPaste(true);
+        }
+        lastComp = panels.getSelectedComponent();
         
       }
-    });
+      });
   }
 
   public RestServiceEditorPane(RestServiceDescription toedit)
@@ -217,7 +204,6 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
       if (reparse)
       {
         String txt = urldesc.getText().trim();
-        StringBuffer warnings;
         if (txt.length() > 0)
         {
           RestServiceDescription rsd = null;
@@ -227,6 +213,7 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
             if (rsd.isValid())
             {
               parseWarnings.setVisible(false);
+              parseRes.setText("");
               initGuiWith(currentservice=rsd);
             }
             else
@@ -237,14 +224,16 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
             }
           } catch (Throwable e)
           {
+            e.printStackTrace();
             parseRes.setText("\nParsing failed. An unrecoverable exception was thrown:\n"
                     + e.toString());
             parseWarnings.setVisible(true);
           }
         }
+        paste.revalidate();
       }
     }
-
+    
   }
 
   public static void main(String[] args)
index 74b1463..69b9704 100644 (file)
@@ -80,7 +80,7 @@ public class GRestServiceEditorPane extends JPanel {
     inputs.setLayout(new MigLayout("","[grow 85,fill][]",""));
     paste = new JPanel();
     paste.setName("Cut'n'Paste");
-    paste.setLayout(new MigLayout());
+    paste.setLayout(new MigLayout("","[grow 100, fill]","[][grow 100,fill]"));
 
     panels = new JTabbedPane();
     panels.addTab(details.getName(), details);
@@ -280,21 +280,29 @@ public class GRestServiceEditorPane extends JPanel {
     // Parse flat-text to a service
 
     
-    urldesc = new JTextArea(2,40);
+    urldesc = new JTextArea(4,50);
     urldesc.setEditable(true);
+    urldesc.setWrapStyleWord(true);
     urldescVp = new JScrollPane();
     urldescVp.setViewportView(urldesc);
-    JvSwingUtils.mgAddtoLayout(paste,"Flat file representation of this rest service using the Really Simple Bioinformatics Service formalism", new JLabel("RSBS Encoded Service:"), urldescVp,"wrap");
-
-    parseRes = new JTextArea(5,40);
+    JPanel urldescPane = new JPanel();
+    urldescPane.setLayout(new MigLayout("","[grow 100, fill]", "[grow 100, fill]"));
+    urldescPane.setBorder(new TitledBorder("RSBS Encoded Service"));
+    urldescPane.add(urldescVp, "span");
+    paste.add(urldescPane,"span");
+    urldescPane.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Flat file representation of this rest service using the Really Simple Bioinformatics Service formalism"));
+    
+    parseRes = new JTextArea();
     parseResVp = new JScrollPane();
     parseResVp.setViewportView(parseRes);
-    parseWarnings = new JPanel(new MigLayout());
+    parseRes.setWrapStyleWord(true);
+    parseRes.setColumns(40);
+    parseWarnings = new JPanel(new MigLayout("","[grow 100, fill]", "[grow 100, fill]"));
     parseWarnings.setBorder(new TitledBorder("Parsing errors"));
     parseWarnings.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Results of parsing the RSBS representation")+"</html>");
-    parseWarnings.add(parseResVp, "wrap");
+    parseWarnings.add(parseResVp, "center");
     parseRes.setEditable(false);
-    
+    paste.add(parseWarnings, "span");
     setLayout(new BorderLayout());
     add(panels, BorderLayout.CENTER);
     okButton = JvSwingUtils.makeButton("OK", "", new ActionListener()