ensure enfin service is started in background when desktop is displayed
[jalview.git] / src / jalview / gui / Desktop.java
index 7a972a1..5031f72 100755 (executable)
@@ -70,7 +70,84 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   public static boolean internalCopy = false;
 
   static int fileLoadingCount = 0;
-
+  class MyDesktopManager implements DesktopManager {
+         
+          private DesktopManager delegate;
+        
+          public MyDesktopManager(DesktopManager delegate) {
+             this.delegate = delegate;
+          }
+        
+          public void activateFrame(JInternalFrame f) {
+             try {
+                delegate.activateFrame(f);
+             } catch (NullPointerException npe) {
+                 Point p = getMousePosition();
+                 instance.showPasteMenu(p.x,p.y);
+             }
+          }
+
+       public void beginDraggingFrame(JComponent f) {
+               delegate.beginDraggingFrame(f);
+       }
+
+       public void beginResizingFrame(JComponent f, int direction) {
+               delegate.beginResizingFrame(f, direction);
+       }
+
+       public void closeFrame(JInternalFrame f) {
+               delegate.closeFrame(f);
+       }
+
+       public void deactivateFrame(JInternalFrame f) {
+               delegate.deactivateFrame(f);
+       }
+
+       public void deiconifyFrame(JInternalFrame f) {
+               delegate.deiconifyFrame(f);
+       }
+
+       public void dragFrame(JComponent f, int newX, int newY) {
+               delegate.dragFrame(f, newX, newY);
+       }
+
+       public void endDraggingFrame(JComponent f) {
+               delegate.endDraggingFrame(f);
+       }
+
+       public void endResizingFrame(JComponent f) {
+               delegate.endResizingFrame(f);
+       }
+
+       public void iconifyFrame(JInternalFrame f) {
+               delegate.iconifyFrame(f);
+       }
+
+       public void maximizeFrame(JInternalFrame f) {
+               delegate.maximizeFrame(f);
+       }
+
+       public void minimizeFrame(JInternalFrame f) {
+               delegate.minimizeFrame(f);
+       }
+
+       public void openFrame(JInternalFrame f) {
+               delegate.openFrame(f);
+       }
+
+       public void resizeFrame(JComponent f, int newX, int newY, int newWidth,
+                       int newHeight) {
+               delegate.resizeFrame(f, newX, newY, newWidth, newHeight);
+       }
+
+       public void setBoundsForFrame(JComponent f, int newX, int newY,
+                       int newWidth, int newHeight) {
+               delegate.setBoundsForFrame(f, newX, newY, newWidth, newHeight);
+       }
+        
+          // All other methods, simply delegate
+        
+       }
   /**
    * Creates a new Desktop object.
    */
@@ -100,8 +177,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
     // This line prevents Windows Look&Feel resizing all new windows to maximum
     // if previous window was maximised
-    desktop.setDesktopManager(new DefaultDesktopManager());
-
+    desktop.setDesktopManager(new MyDesktopManager(new DefaultDesktopManager()));
     Rectangle dims = getLastKnownDimensions("");
     if (dims != null)
     {
@@ -1886,4 +1962,17 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     return v_client;
 
   }
+
+  public void startServiceDiscovery()
+  {
+    discoverer.start();
+    
+    try {
+      new Thread(jalview.ws.EnfinEnvision2OneWay.getInstance()).start();
+    } catch (Exception e)
+    {
+      Cache.log.info("Exception when trying to launch Envision2 workflow discovery.",e);
+      Cache.log.info(e.getStackTrace());
+    }
+  }
 }