org.objectweb.jac.aspects.gui.web
Class AbstractView

java.lang.Object
  |
  +--org.objectweb.jac.aspects.gui.web.AbstractView
All Implemented Interfaces:
View, ViewIdentity
Direct Known Subclasses:
AbstractCollection, AbstractCompositeView, AbstractFieldEditor, AbstractFieldView, AbstractMenu, AbstractPage, CollectionItemView, CollectionSelector, Empty, Label, Method, StatusBar, ToolBar, Tree

public abstract class AbstractView
extends Object
implements View


Field Summary
protected  int column
           
protected  DisplayContext context
           
protected  String description
           
protected  Length height
           
protected  boolean isCellViewer
          row number, for TableCellViewer
protected  String label
           
protected  View parentView
           
protected  int row
           
protected  View table
           
protected  Length width
           
 
Constructor Summary
AbstractView()
           
AbstractView(ViewFactory factory, DisplayContext context)
           
 
Method Summary
 void close(boolean validate)
          Close this view.
protected  void closeForm(PrintWriter out)
           
 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.
protected  String eventURL(String event)
          Build the base URL for an event
protected  Composite eventURL(String text, String event, String params)
          Build an HTML element for an event.
protected  void genBody(PrintWriter out)
          Override this method to generate the body of an HTML page.
protected  void genEventAndActionButton(PrintWriter out, String event)
           
protected  void genPage(PrintWriter out)
          Generate an HTML page, with full headers
protected  void genStyleSheets(PrintWriter out, CustomizedView customized)
           
protected  String getBaseURL()
           
 String getCloseBorder()
           
 DisplayContext getContext()
           
 String getDescription()
          Get the value of description.
 ViewFactory getFactory()
          Gets the factory.
protected  String getId()
           
protected  String getId(View view)
           
 String getLabel()
          Gets the view's label (identifier).
 MethodItem getMessage()
          Get the value of message.
 String getOpenBorder()
           
 Object[] getParameters()
          The parameters that were used to compile the view.
 View getParentView()
          Get the value of parent.
 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.
protected  Element iconElement(String icon, String alt)
          Builds an tag for an icon
protected  Element iconElement(String icon, String alt, boolean showAlt)
          Builds an tag for an icon
 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
protected  boolean isInForm()
          Are we in a
element ?
protected  void openForm(PrintWriter out)
           
protected  void printAttributes(PrintWriter out)
           
 void setAttribute(String name, String value)
           
 void setColumn(int column)
           
 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 parent.
 void setRow(int row)
           
 void setSize(Length width, Length height)
          Sets the preferred size for this view.
 void setStyle(String style)
          Sets the view style.
 void setStyleSheet(String styleSheet)
           
 void setTable(View table)
           
 void setType(String type)
          Set the view type.
 void setViewBorder(Border v)
          Set the value of viewBorder.
protected  void showButton(PrintWriter out, String icon, String label, String event)
          Write HTML code for a button
protected  void showFormButtons(PrintWriter out)
           
protected  void showFormButtons(PrintWriter out, boolean dialog)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

label

protected String label

context

protected DisplayContext context

width

protected Length width

height

protected Length height

isCellViewer

protected boolean isCellViewer
row number, for TableCellViewer


row

protected int row

column

protected int column

table

protected View table

description

protected String description

parentView

protected View parentView
Constructor Detail

AbstractView

public AbstractView()

AbstractView

public AbstractView(ViewFactory factory,
                    DisplayContext context)
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.

getMessage

public MethodItem getMessage()
Get the value of message.

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

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)

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 parent.

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

setParentView

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

Specified by:
setParentView in interface View
Parameters:
v - Value to assign to parent.
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

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

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

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

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

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

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

isInForm

protected boolean isInForm()
Are we in a element ?


eventURL

protected Composite eventURL(String text,
                             String event,
                             String params)
Build an HTML element for an event. It takes into account if we are in a form, and if the browser is MS-IE.

Parameters:
text - text to display for the link
event - the name of the event
params - additional parameters for the link URL
Returns:
an HTML element

showButton

protected void showButton(PrintWriter out,
                          String icon,
                          String label,
                          String event)
Write HTML code for a button

Parameters:
out - where to write the HTML
icon - resource name of an icon
label - text of the button
event - the event linked to the button

getOpenBorder

public String getOpenBorder()

getCloseBorder

public String getCloseBorder()

getBaseURL

protected String getBaseURL()

eventURL

protected String eventURL(String event)
Build the base URL for an event

Parameters:
event - the name of the event

iconElement

protected Element iconElement(String icon,
                              String alt)
Builds an tag for an icon

Parameters:
icon - resource path of icon
alt - alt string for HTML tag

iconElement

protected Element iconElement(String icon,
                              String alt,
                              boolean showAlt)
Builds an tag for an icon

Parameters:
icon - resource path of icon
alt - alt string for HTML tag
showAlt - if true, return alt if icon is null

getId

protected String getId()

getId

protected String getId(View view)

setStyleSheet

public void setStyleSheet(String styleSheet)

genPage

protected void genPage(PrintWriter out)
                throws IOException
Generate an HTML page, with full headers

IOException
See Also:
genBody(PrintWriter)

genStyleSheets

protected void genStyleSheets(PrintWriter out,
                              CustomizedView customized)

genBody

protected void genBody(PrintWriter out)
                throws IOException
Override this method to generate the body of an HTML page.

IOException
See Also:
genPage(PrintWriter)

setTable

public void setTable(View table)

setRow

public void setRow(int row)

setColumn

public void setColumn(int column)

setAttribute

public void setAttribute(String name,
                         String value)

printAttributes

protected void printAttributes(PrintWriter out)

openForm

protected void openForm(PrintWriter out)

closeForm

protected void closeForm(PrintWriter out)

showFormButtons

protected void showFormButtons(PrintWriter out,
                               boolean dialog)

showFormButtons

protected void showFormButtons(PrintWriter out)

genEventAndActionButton

protected void genEventAndActionButton(PrintWriter out,
                                       String event)