apply version 2.7 copyright
[jalview.git] / src / jalview / gui / RestServiceEditorPane.java
index 4f9c13e..dee5d7e 100644 (file)
@@ -1,3 +1,20 @@
+/*******************************************************************************
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
 package jalview.gui;
 
 import jalview.io.packed.DataProvider.JvDataType;
@@ -6,6 +23,7 @@ import jalview.ws.rest.InputType;
 import jalview.ws.rest.RestServiceDescription;
 
 import java.awt.BorderLayout;
+import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ComponentEvent;
@@ -22,6 +40,7 @@ import java.util.regex.Pattern;
 
 import javax.swing.JFrame;
 import javax.swing.JMenuItem;
+import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -64,6 +83,10 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
     });
     panels.addChangeListener(new ChangeListener()
     {
+
+      /**
+       * last panel selected - used to decide whether the service or the GUI has the latest info
+       */
       Object lastComp;
       @Override
       public void stateChanged(ChangeEvent e)
@@ -86,7 +109,7 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
 
   public RestServiceEditorPane(RestServiceDescription toedit)
   {
-    super();
+    this();
     oldservice = toedit;
     if (oldservice!=null)
     {    currentservice = new RestServiceDescription(toedit);
@@ -437,4 +460,47 @@ public class RestServiceEditorPane extends GRestServiceEditorPane
 
     }
   }
+  String finalService=null;
+  public void showDialog(String title)
+  {
+    if (oldservice!=null)
+    {
+      finalService = oldservice.toString();
+    }
+    JalviewDialog jvd = new JalviewDialog()
+    {
+      
+      @Override
+      protected void raiseClosed()
+      {
+        // TODO Auto-generated method stub
+        
+      }
+      
+      @Override
+      protected void okPressed()
+      {
+        updateServiceFromGui();
+        finalService = currentservice.toString();        
+      }
+      
+      @Override
+      protected void cancelPressed()
+      {
+        
+      }
+    };
+    JPanel pane = new JPanel(new BorderLayout()),okcancel=new JPanel(new FlowLayout());
+    pane.add(this,BorderLayout.CENTER);
+    okcancel.add(jvd.ok);
+    okcancel.add(jvd.cancel);
+    pane.add(okcancel, BorderLayout.SOUTH);
+    jvd.initDialogFrame(pane, true, true, title, 600,350);
+    jvd.waitForInput();
+  }
+
+  public String getEditedRestService()
+  {
+    return finalService;
+  }
 }