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

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended byjavax.swing.JDialog
                      extended byorg.objectweb.jac.aspects.gui.swing.Dialog
All Implemented Interfaces:
Accessible, ActionListener, ContainerListener, DialogView, EventListener, ImageObserver, KeyListener, MenuContainer, RootPaneContainer, Serializable, View, ViewIdentity, WindowConstants, WindowView

public class Dialog
extends JDialog
implements ActionListener, KeyListener, ContainerListener, DialogView

This dialog is used to ask the parameters values when a method is called on a viewed JAC object.

Author:
Renaud Pawlak, Laurent Martelli
See Also:
View, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Dialog(View content, Object parent, String title, String description)
          Construct a dialog window.
 
Method Summary
 void actionPerformed(ActionEvent evt)
          Implements what is done when a button is pressed (may be either OK or CANCEL).
protected  void addKeyAndContainerListenerRecursively(Component c)
          Register as a KeyListener and ContainerListener on the component and its children recursively.
 void close(boolean validate)
          Close this view.
 void componentAdded(ContainerEvent event)
           
 void componentRemoved(ContainerEvent event)
           
 boolean equalsView(String type, Object[] parameters)
           
 boolean equalsView(ViewIdentity view)
          Tells if a view is the same as another one, ie it has the same type and parameters.
 View getContentView()
          Returns the content view of the window
 DisplayContext getContext()
           
 String getDescription()
          Get the value of description.
 ViewFactory getFactory()
          Gets the factory.
 String getLabel()
          Gets the view's label (identifier).
 MethodItem getMessage()
          Get the value of message.
 Object[] getParameters()
          The parameters that were used to compile the view.
 View getParentView()
          Get the value of parentView.
 View getRootView()
          Gets the ancestor view whose parent is null
 String getStyle()
          Gets the user-defined style for this view.
 String getType()
          Gets the view type.
 Border getViewBorder()
          Get the value of viewBorder.
 boolean isClosed()
          Tells if this view has been closed by the GUI or the user.
 boolean isDescendantOf(View ancestor)
          Tells wether this view has a given view in its ancestors
 void keyPressed(KeyEvent event)
           
 void keyReleased(KeyEvent event)
           
 void keyTyped(KeyEvent event)
           
protected  void removeKeyAndContainerListenerRecursively(Component c)
          Unregister as a KeyListener and ContainerListener on the component and its children recursively.
 void restoreContext()
          Restore context attributes memorized at creation time
 void setContext(DisplayContext context)
          Sets the display context for this view.
 void setDescription(String v)
          Set the value of description.
 void setFactory(ViewFactory factory)
          Sets the factory for this view (WEB, SWING or other supported factory).
 void setFocus(FieldItem field, Object option)
          Focus a field of an object's view.
 void setLabel(String label)
          Sets the label (the identifier) of the view.
 void setMessage(MethodItem v)
          Set the value of message.
 void setParameters(Object[] parameters)
          Sets the parameters that were used to construct the view.
 void setParentView(View v)
          Set the value of parentView.
 void setSize(Length width, Length height)
          Sets the preferred size for this view.
 void setStyle(String style)
          Sets the view style.
 void setType(String type)
          Set the view type.
 void setViewBorder(Border v)
          Set the value of viewBorder.
 boolean waitForClose()
          Waits until the dialog is closed or timeout iccurs.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dialog

public Dialog(View content,
              Object parent,
              String title,
              String description)
Construct a dialog window.

Parameters:
content - the content of the dialog
parent - the parent window of the dialog
description - a text describing the dialog to the user
Method Detail

getViewBorder

public Border getViewBorder()
Get the value of viewBorder.

Specified by:
getViewBorder in interface View
Returns:
value of viewBorder.

setViewBorder

public void setViewBorder(Border v)
Set the value of viewBorder.

Specified by:
setViewBorder in interface View
Parameters:
v - Value to assign to viewBorder.

setStyle

public void setStyle(String style)
Description copied from interface: View
Sets the view style. The style can be exploited in different maners depending on the GUI supports (e.g. with CSS for the WEB). Styles are user-defined.

Specified by:
setStyle in interface View

getStyle

public String getStyle()
Description copied from interface: View
Gets the user-defined style for this view.

Specified by:
getStyle in interface View
Returns:
the style, null if undefined

getMessage

public MethodItem getMessage()
Get the value of message.

Specified by:
getMessage in interface View
Returns:
value of message.

getDescription

public String getDescription()
Get the value of description.

Specified by:
getDescription in interface View
Returns:
value of description.

setDescription

public void setDescription(String v)
Set the value of description.

Specified by:
setDescription in interface View
Parameters:
v - Value to assign to description.
See Also:
View.setMessage(MethodItem)

getParentView

public View getParentView()
Get the value of parentView.

Specified by:
getParentView in interface View
Returns:
value of parentView.
See Also:
CompositeView

setParentView

public void setParentView(View v)
Set the value of parentView.

Specified by:
setParentView in interface View
Parameters:
v - Value to assign to parentView.
See Also:
CompositeView

getRootView

public View getRootView()
Description copied from interface: View
Gets the ancestor view whose parent is null

Specified by:
getRootView in interface View

isDescendantOf

public boolean isDescendantOf(View ancestor)
Description copied from interface: View
Tells wether this view has a given view in its ancestors

Specified by:
isDescendantOf in interface View
Parameters:
ancestor - the ancestor

setMessage

public void setMessage(MethodItem v)
Set the value of message.

Specified by:
setMessage in interface View
Parameters:
v - Value to assign to message.
See Also:
View.setDescription(String)

setContext

public void setContext(DisplayContext context)
Description copied from interface: View
Sets the display context for this view.

The display context contains the factory that is used for this view.

Specified by:
setContext in interface View

getContext

public DisplayContext getContext()
Specified by:
getContext in interface View
Returns:
the DisplayContext of the view

setFactory

public void setFactory(ViewFactory factory)
Description copied from interface: View
Sets the factory for this view (WEB, SWING or other supported factory).

Specified by:
setFactory in interface View

getFactory

public ViewFactory getFactory()
Description copied from interface: View
Gets the factory.

Specified by:
getFactory in interface View

setLabel

public void setLabel(String label)
Description copied from interface: View
Sets the label (the identifier) of the view.

Specified by:
setLabel in interface View
Parameters:
label - a string that identifies the view

getLabel

public String getLabel()
Description copied from interface: View
Gets the view's label (identifier).

Specified by:
getLabel in interface View
Returns:
the view's label

setSize

public void setSize(Length width,
                    Length height)
Description copied from interface: View
Sets the preferred size for this view.

Specified by:
setSize in interface View
Parameters:
width - the preferred width. If null, the preferred width is not changed.
height - the preferred height. If null, the preferred height is not changed.

setType

public void setType(String type)
Description copied from interface: ViewIdentity
Set the view type.

Specified by:
setType in interface ViewIdentity

getType

public String getType()
Description copied from interface: ViewIdentity
Gets the view type.

Specified by:
getType in interface ViewIdentity
Returns:
view type string as declared in web.acc or swing.acc depending on the GUI target

setParameters

public void setParameters(Object[] parameters)
Description copied from interface: ViewIdentity
Sets the parameters that were used to construct the view.

Specified by:
setParameters in interface ViewIdentity

getParameters

public Object[] getParameters()
Description copied from interface: ViewIdentity
The parameters that were used to compile the view.

Specified by:
getParameters in interface ViewIdentity

equalsView

public boolean equalsView(ViewIdentity view)
Description copied from interface: ViewIdentity
Tells if a view is the same as another one, ie it has the same type and parameters.

Specified by:
equalsView in interface ViewIdentity

equalsView

public boolean equalsView(String type,
                          Object[] parameters)
Specified by:
equalsView in interface ViewIdentity

close

public void close(boolean validate)
Description copied from interface: View
Close this view. This should be upcalled when the view is closed in order to free resources or close other dependant views.

Specified by:
close in interface View
Parameters:
validate - wether to validate any value contained in editors.

isClosed

public boolean isClosed()
Description copied from interface: View
Tells if this view has been closed by the GUI or the user.

Specified by:
isClosed in interface View

setFocus

public void setFocus(FieldItem field,
                     Object option)
Description copied from interface: View
Focus a field of an object's view.

Specified by:
setFocus in interface View
Parameters:
field - the field to focus
option - an extra option

waitForClose

public boolean waitForClose()
Description copied from interface: DialogView
Waits until the dialog is closed or timeout iccurs.

Specified by:
waitForClose in interface DialogView
Returns:
true if the dialog was validated with the OK button by the user, false otherwise

getContentView

public View getContentView()
Description copied from interface: WindowView
Returns the content view of the window

Specified by:
getContentView in interface WindowView

restoreContext

public void restoreContext()
Description copied from interface: DialogView
Restore context attributes memorized at creation time

Specified by:
restoreContext in interface DialogView

actionPerformed

public void actionPerformed(ActionEvent evt)
Implements what is done when a button is pressed (may be either OK or CANCEL).

Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - tell what button was pressed

keyPressed

public void keyPressed(KeyEvent event)
Specified by:
keyPressed in interface KeyListener

keyTyped

public void keyTyped(KeyEvent event)
Specified by:
keyTyped in interface KeyListener

keyReleased

public void keyReleased(KeyEvent event)
Specified by:
keyReleased in interface KeyListener

componentAdded

public void componentAdded(ContainerEvent event)
Specified by:
componentAdded in interface ContainerListener

addKeyAndContainerListenerRecursively

protected void addKeyAndContainerListenerRecursively(Component c)
Register as a KeyListener and ContainerListener on the component and its children recursively.

Parameters:
c - the component

componentRemoved

public void componentRemoved(ContainerEvent event)
Specified by:
componentRemoved in interface ContainerListener

removeKeyAndContainerListenerRecursively

protected void removeKeyAndContainerListenerRecursively(Component c)
Unregister as a KeyListener and ContainerListener on the component and its children recursively.

Parameters:
c - the component