org.objectweb.jac.aspects.gui.swing
Class SwingDisplay

java.lang.Object
  extended byorg.objectweb.jac.aspects.gui.swing.SwingDisplay
All Implemented Interfaces:
CustomizedDisplay, Display

public class SwingDisplay
extends Object
implements CustomizedDisplay


Constructor Summary
SwingDisplay(ViewFactory factory)
           
 
Method Summary
 void addTimedoutDialog(DialogView dialog)
          Add a dialog to the list of timedout dialogs
 boolean addViewFor(Object substance)
           
 boolean addViewFor(Object substance, String viewType, Object[] viewParams)
           
 boolean addViewFor(Object substance, String viewType, Object[] viewParams, String title, String header, Object parent, boolean okButton, boolean cancelButton, boolean closeButton)
          Adds a view for a given Jac object.
 boolean addViewFor(Object substance, String title, String header, Object parent, boolean okButton, boolean cancelButton, boolean closeButton)
           
 void applicationStarted()
          Notifies the display that a new application has just started.
static Font boldifyFont(Font font)
           
static void boldifyFont(String resourceName)
           
 void close()
          Closes this display.
 void closeWindow(View window, boolean validate)
          Close a window.
 boolean fillParameters(AbstractMethodItem method, Object[] parameters)
          Called before interactively calling a method with parameters, so that the display can set some of them.
 void fullRefresh()
          Rebuilds all customized GUI windows.
 CustomizedView getCustomizedView(String customizedID)
          Returns a CustomizedView identified by its id
 Collection getCustomizedViews()
          Returns a collection of all CustomizedViews contained in the display.
 String getDisplayID()
          Gets the ID (a unique string identifier) of the current display.
 ViewFactory getFactory()
          Returns the ViewFactory of the display.
protected  void initFonts()
           
 void onInvocationReturn(Object substance, AbstractMethodItem method)
          Called after interactively calling a method with parameters.
 void openView(Object object)
          Shows the given object on the display by opening a new core view.
 void refresh()
          Refresh the display.
 void saveStreamToFile(Reader reader)
          show a save dialog and save the stream into the selected file
 void setDisplayID(String displayID)
          Sets the ID (a unique string identifier) of the current display.
 void show(Object object)
          Shows the given object on the display.
 void show(Object object, String viewType, Object[] viewParams)
          Shows a view of an object.
 void showCustomized(String id, Object object)
          Show a customized Gui.
 void showCustomized(String id, Object object, Map panels)
          Show a customized Gui.
 void showError(String message, String title)
          Show an error message to the user.
 boolean showInput(Object substance, AbstractMethodItem method, Object[] parameters)
          Asks the user to fill the parameters to prepare the invocation of the given method.
 void showMessage(String message, String title)
          Shows a message to the user.
 boolean showMessage(String message, String title, boolean okButton, boolean cancelButton, boolean closeButton)
          Displays a message to the user.
 boolean showModal(Object object, String viewType, Object[] viewParams, String title, String header, Object parent, boolean okButton, boolean cancelButton, boolean closeButton)
          Shows the given object on the display and waits for a user input.
 boolean showModal(Object object, String title, String header, Object parent, boolean okButton, boolean cancelButton, boolean closeButton)
          Shows the given object on the display and waits for a user input.
 Object showRefreshMessage(String message, String title)
          Shows a message to the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingDisplay

public SwingDisplay(ViewFactory factory)
Method Detail

initFonts

protected void initFonts()

boldifyFont

public static void boldifyFont(String resourceName)

boldifyFont

public static Font boldifyFont(Font font)

addTimedoutDialog

public void addTimedoutDialog(DialogView dialog)
Description copied from interface: CustomizedDisplay
Add a dialog to the list of timedout dialogs

Specified by:
addTimedoutDialog in interface CustomizedDisplay
Parameters:
dialog - the timedout dialog

closeWindow

public void closeWindow(View window,
                        boolean validate)
Description copied from interface: CustomizedDisplay
Close a window.

Specified by:
closeWindow in interface CustomizedDisplay
Parameters:
window - view window to close
validate - wether to validate values in editors

fullRefresh

public void fullRefresh()
Description copied from interface: Display
Rebuilds all customized GUI windows.

Specified by:
fullRefresh in interface Display

showCustomized

public void showCustomized(String id,
                           Object object,
                           Map panels)
Description copied from interface: Display
Show a customized Gui.

Specified by:
showCustomized in interface Display
Parameters:
id - the id of the customized GUI to show
object - the CustomizedGUI to show
panels - contents of panels ( panelID -> object)
See Also:
CustomizedGUI

showCustomized

public void showCustomized(String id,
                           Object object)
Description copied from interface: Display
Show a customized Gui.

Specified by:
showCustomized in interface Display
Parameters:
id - the id of the customized GUI to show
object - the CustomizedGUI to show
See Also:
CustomizedGUI

getCustomizedView

public CustomizedView getCustomizedView(String customizedID)
Description copied from interface: CustomizedDisplay
Returns a CustomizedView identified by its id

Specified by:
getCustomizedView in interface CustomizedDisplay
Parameters:
customizedID - the id of the CustomizedView
Returns:
the customized if exists, null otherwise

getCustomizedViews

public Collection getCustomizedViews()
Description copied from interface: CustomizedDisplay
Returns a collection of all CustomizedViews contained in the display.

Specified by:
getCustomizedViews in interface CustomizedDisplay
Returns:
all the customized of the display

getFactory

public ViewFactory getFactory()
Description copied from interface: CustomizedDisplay
Returns the ViewFactory of the display.

A view factory implements the creation methods for different visualisation supports (e.g. SWING, WEB, ...).

Specified by:
getFactory in interface CustomizedDisplay
Returns:
the factory that is used for this display

show

public void show(Object object)
Description copied from interface: Display
Shows the given object on the display.

The showed object is considered as a result.

On contrary to showModal, this method does not stop the client thread execution.

Specified by:
show in interface Display
Parameters:
object - the object to show

show

public void show(Object object,
                 String viewType,
                 Object[] viewParams)
Description copied from interface: Display
Shows a view of an object.

The showed object is considered as a result.

On contrary to showModal, this method does not stop the client thread execution.

Specified by:
show in interface Display
Parameters:
object - the object to show
viewType - the type of the view to display
viewParams - parameters to give the view constructor

showModal

public boolean showModal(Object object,
                         String viewType,
                         Object[] viewParams,
                         String title,
                         String header,
                         Object parent,
                         boolean okButton,
                         boolean cancelButton,
                         boolean closeButton)
Description copied from interface: Display
Shows the given object on the display and waits for a user input.

Specified by:
showModal in interface Display
Parameters:
object - the object to show
viewType - the type of view to build or the object
viewParams - parameters to give the view constructor
title - the window title if a window is opened
header - a header message
parent - the parent window
okButton - if true, a validation button is added
cancelButton - if true, a cancellation button is added
closeButton - if true, a closing button is added
Returns:
false if the user canceled
See Also:
Display.showModal(Object,String,String,Object,boolean,boolean,boolean)

showModal

public boolean showModal(Object object,
                         String title,
                         String header,
                         Object parent,
                         boolean okButton,
                         boolean cancelButton,
                         boolean closeButton)
Description copied from interface: Display
Shows the given object on the display and waits for a user input.

On contrary to show, this method stops the client thread execution and waits for a user input to continue (as an OK button click or a key pressing).

Specified by:
showModal in interface Display
Parameters:
object - the object to show
title - the window title if a window is opened
header - a header message
parent - the parent window
okButton - if true, a validation button is added
cancelButton - if true, a cancellation button is added
closeButton - if true, a closing button is added
Returns:
false if the user canceled
See Also:
Display.showModal(Object,String,Object[],String,String,Object,boolean,boolean,boolean)

openView

public void openView(Object object)
Description copied from interface: Display
Shows the given object on the display by opening a new core view.

On contrary to showModal, this method does not stop the client thread execution.

Specified by:
openView in interface Display
Parameters:
object - the object to show

showInput

public boolean showInput(Object substance,
                         AbstractMethodItem method,
                         Object[] parameters)
Description copied from interface: Display
Asks the user to fill the parameters to prepare the invocation of the given method.

This operation stops the client thread.

Specified by:
showInput in interface Display
Parameters:
substance - the object that contains the method (null if a constructor)
method - the method to fill the parameters o
parameters - the parameters values; as an input, they can be set by the client to fill default values for these parameters; as an output, they must be used by the client as the actual parameter values to call the given method
Returns:
false if the user canceled

getDisplayID

public String getDisplayID()
Description copied from interface: Display
Gets the ID (a unique string identifier) of the current display.

Specified by:
getDisplayID in interface Display
Returns:
a string

setDisplayID

public void setDisplayID(String displayID)
Description copied from interface: Display
Sets the ID (a unique string identifier) of the current display.

Specified by:
setDisplayID in interface Display
Parameters:
displayID - a string (should be unique)

showMessage

public boolean showMessage(String message,
                           String title,
                           boolean okButton,
                           boolean cancelButton,
                           boolean closeButton)
Description copied from interface: Display
Displays a message to the user.

Specified by:
showMessage in interface Display
Parameters:
title - the window title if a window is opened
message - a header message
okButton - if true, a validation button is added
cancelButton - if true, a cancellation button is added
closeButton - if true, a closing button is added
Returns:
false if the user canceled

showMessage

public void showMessage(String message,
                        String title)
Description copied from interface: Display
Shows a message to the user.

Specified by:
showMessage in interface Display
Parameters:
message - the title of the window
title - the message
See Also:
Display.showError(String,String)

showRefreshMessage

public Object showRefreshMessage(String message,
                                 String title)
Description copied from interface: Display
Shows a message to the user.

Specified by:
showRefreshMessage in interface Display
Parameters:
message - the title of the window
title - the message
Returns:
the auto-refreshed window
See Also:
Display.showError(String,String)

showError

public void showError(String message,
                      String title)
Description copied from interface: Display
Show an error message to the user.

Specified by:
showError in interface Display
Parameters:
message - the title of the window
title - the error message
See Also:
Display.showMessage(String,String)

refresh

public void refresh()
Description copied from interface: Display
Refresh the display.

This method is useful for some kind of displays when the refresh operation cannot be done automatically when the displayed objects states change (e.g. a web display).

Specified by:
refresh in interface Display
See Also:
WebDisplay

applicationStarted

public void applicationStarted()
Description copied from interface: Display
Notifies the display that a new application has just started.

At this step, all the root objects of the application have been created and it is time to open the main view if any.

Specified by:
applicationStarted in interface Display

close

public void close()
Description copied from interface: Display
Closes this display.

Specified by:
close in interface Display

saveStreamToFile

public void saveStreamToFile(Reader reader)
show a save dialog and save the stream into the selected file

Parameters:
reader - the stream to save

addViewFor

public boolean addViewFor(Object substance)

addViewFor

public boolean addViewFor(Object substance,
                          String viewType,
                          Object[] viewParams)

addViewFor

public boolean addViewFor(Object substance,
                          String title,
                          String header,
                          Object parent,
                          boolean okButton,
                          boolean cancelButton,
                          boolean closeButton)

addViewFor

public boolean addViewFor(Object substance,
                          String viewType,
                          Object[] viewParams,
                          String title,
                          String header,
                          Object parent,
                          boolean okButton,
                          boolean cancelButton,
                          boolean closeButton)
Adds a view for a given Jac object.

Parameters:
substance - the object to add a view for
Returns:
true if the OK button or the close button were clicked.

fillParameters

public boolean fillParameters(AbstractMethodItem method,
                              Object[] parameters)
Description copied from interface: Display
Called before interactively calling a method with parameters, so that the display can set some of them.

Specified by:
fillParameters in interface Display
Returns:
false if there some parameters are still unassigned

onInvocationReturn

public void onInvocationReturn(Object substance,
                               AbstractMethodItem method)
Description copied from interface: Display
Called after interactively calling a method with parameters.

Specified by:
onInvocationReturn in interface Display