org.embl.ebi.escience.scuflui.shared
Class UIUtils

java.lang.Object
  extended by org.embl.ebi.escience.scuflui.shared.UIUtils

public class UIUtils
extends java.lang.Object

Contains utility methods to deal with opening windows and suchlike in a way that makes no assumptions about the existance of a JDesktop pane.

Author:
Tom Oinn

Nested Class Summary
static interface UIUtils.FrameCreator
          Implement this interface and set the DEFAULT_FRAME_CREATOR field to change the behaviour of the windowing system used by the Taverna Workbench
 
Field Summary
static UIUtils.FrameCreator DEFAULT_FRAME_CREATOR
           
 
Constructor Summary
UIUtils()
           
 
Method Summary
static void createFrame(javax.swing.JComponent rawComponent, int posX, int posY, int width, int height)
          As for the method above but allows a non-ScuflUIComponent JComponent.
static void createFrame(ScuflModel targetModel, UIComponentSPI targetComponent, int posX, int posY, int sizeX, int sizeY)
          Create a top level window using the configured default frame creator.
static java.awt.Component getActionEventParentWindow(java.awt.event.ActionEvent ae)
          Determines, if possible, the parent window of an ActionEvent.
static void launchBrowser(java.lang.String address)
          Launches the address in a browser.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FRAME_CREATOR

public static UIUtils.FrameCreator DEFAULT_FRAME_CREATOR
Constructor Detail

UIUtils

public UIUtils()
Method Detail

createFrame

public static void createFrame(ScuflModel targetModel,
                               UIComponentSPI targetComponent,
                               int posX,
                               int posY,
                               int sizeX,
                               int sizeY)
Create a top level window using the configured default frame creator. For platforms such as Mac OS X where the expected windowing behaviour is different from the default desktop pane the default frame creator can be overridden to produce whatever top level window is required - the Workbench class contains code to do this in the case of both OS X and other window systems where the desktop pane is not required.

This method will handle the appropriate logic to bind to and unbind from a model when given an implementation of the ScuflUIComponent interface. It's worth noting that, in addition to implementing this interface, any object passed in as the target component must also be a subclass of JComponent!


createFrame

public static void createFrame(javax.swing.JComponent rawComponent,
                               int posX,
                               int posY,
                               int width,
                               int height)
As for the method above but allows a non-ScuflUIComponent JComponent. Internally this component is wrapped up in a trivial ScuflUIComponent which entirely ignores the workflow model settings.


getActionEventParentWindow

public static java.awt.Component getActionEventParentWindow(java.awt.event.ActionEvent ae)
Determines, if possible, the parent window of an ActionEvent. Usually determined via the JPopupMenu invoker. This is useful for making JOptionPane dialogues modal when diplayed from menu item.

Parameters:
ae -
Returns:
Component, or null if it cannot be determined.

launchBrowser

public static void launchBrowser(java.lang.String address)
Launches the address in a browser. Currently very crude. On Linux will open in firefox and in Windows in IExplorer using an example taken from (http://www.javaworld.com/javaworld/javatips/jw-javatip66.html).
Ultimately this should be done using BasicService of javaws.jnlp e.g. BasicService.showDocument(address), but unable to do this at the moment due to licensing concerns with the sun jnlp jar (we are not able to host it in a Maven repository).

Parameters:
address - to launch