SalesPoint v3.3 API

sale
Class FormSheet

java.lang.Object
  extended by sale.FormSheet
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DescriptiveFormSheet, LogOnForm, LogTableForm, MsgForm, SingleTableFormSheet, TextInputForm, TwoTableFormSheet, UserTableFormSheet

public class FormSheet
extends Object
implements Serializable

A FormSheet to be displayed in a FormSheetContainer.

FormSheets comprise a caption, a JComponent of arbitrary complexity, and a button bar. FormSheets will be displayed by FormSheetContainers, which define what the FormSheet finally looks like on the screen. Usually, the FormSheet's caption will become part of the FormSheetContainer's frame caption; the FormSheet's component will take up most of the client space of the FormSheetContainer's frame; and the button bar will be displayed at the bottom side of the FormSheetContainer's frame.

However, FormSheets are designed to make transparent the final display of the GUI, and, thus, you as an application developer do not need to worry about the final layout. All you need to know is what components you want to present and which buttons you want to put into the button bar. Buttons in the button bar are associated an Action that will be performed when the button is clicked. In the doAction() method of that Action, you will have access to the SalesPoint and SaleProcess in whose context the FormSheet is displayed, if any. There is also a special ActionListener, ActionActionListener, that you can use to associate any button in a FormSheet with an Action.

To actually display a FormSheet, you need a Display on which you can call Display.setFormSheet(sale.FormSheet) or Display.popUpFormSheet(sale.FormSheet).

Since:
v1.0
Author:
Steffen Zschaler
See Also:
Serialized Form

Nested Class Summary
static class FormSheet.FormButton
          A button in the FormSheet's button bar.
 
Field Summary
static int BTNID_CANCEL
          Button ID used for the standard Cancel button.
static int BTNID_OK
          Button ID used for the standard OK button.
protected  boolean m_fCancelled
          True if this FormSheet was canelled.
 
Constructor Summary
FormSheet(String sCaption, FormSheetContentCreator fscc, boolean fWaitResponse)
          Create a new FormSheet, using a content creator.
FormSheet(String sCaption, JComponent jcmpComponent)
          Create a new FormSheet.
FormSheet(String sCaption, JComponent jcmpComponent, boolean fWaitResponse)
          Create a new FormSheet.
 
Method Summary
 void addButton(FormSheet.FormButton fb)
          Add a button to the FormSheet's button bar.
 void addButton(String sCaption, int nID, Action aAction)
          Add a button to the FormSheet's button bar.
 void addContentCreator(FormSheetContentCreator fscc)
          Add a contents creator for this FormSheet.
 FormSheetContainer attach(FormSheetContainer fsc)
          Attach a FormSheetContainer to this FormSheet.
 SaleProcess attach(SaleProcess p)
          Attach a process to this FormSheet.
 SalesPoint attach(SalesPoint sp)
          Attach a SalesPoint to this FormSheet.
 Iterator<FormSheet.FormButton> buttonIterator()
          Return a fail-fast, readonly iterator iterating over the buttons in the button bar.
 Iterator<FormSheet.FormButton> buttonIterator(boolean fSorted)
          Return a readonly iterator iterating over the buttons in the button bar.
 void cancel()
          Hook method called whenever the standard "Cancel" button was clicked.
 void close()
          Close the FormSheet.
 FormSheetContainer detachDisplay()
          Detach the current FormSheetContainer from this FormSheet.
 SaleProcess detachProcess()
          Detach the current process from this FormSheet.
 SalesPoint detachSalesPoint()
          Detach the current SalesPoint from this FormSheet.
 void fillBtnPanel(JPanel jp)
          Called by the Framework to generate the button bar's representation.
 FormSheet.FormButton getButton(int nID)
          Get a button from the FormSheet's button bar.
 Object getButtonsLock()
          Get the monitor used to synchronize access to the FormSheet's button bar.
 String getCaption()
          Get the FormSheet's caption.
 JComponent getComponent()
          Get the component of this FormSheet.
 Object getComponentLock()
          Get the monitor to be used when accessing this FormSheet's component.
 FormSheetContainer getDisplay()
          Get the currently attached FormSheetContainer.
protected  Object getDisplayLock()
          Get the monitor used to synchronize access to the display.
 SaleProcess getProcess()
          Get the currently attached process.
 SalesPoint getSalesPoint()
          Get the currently attached SalesPoint.
 boolean isCancelled()
          Return whether the cancel button was used to close the FormSheet.
 void ok()
          Hook method called whenever the standard "OK" button was clicked.
 void removeAllButtons()
          Remove all buttons from the FormSheet's button bar.
 FormSheet.FormButton removeButton(int nID)
          Remove a button from the FormSheet's button bar.
 void setCaption(String sCaption)
          Set the caption for this FormSheet.
 JComponent setComponent(JComponent jcmpComponent)
          Set the component for this FormSheet.
 void setWaitResponse(boolean fWaitResponse)
          Set the waitResponse property of this FormSheet.
 String toString()
           
 boolean waitResponse()
          Return true if Display.setFormSheet(sale.FormSheet) should block until the FormSheet is closed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_fCancelled

protected boolean m_fCancelled
True if this FormSheet was canelled.


BTNID_OK

public static final int BTNID_OK
Button ID used for the standard OK button.

See Also:
Constant Field Values

BTNID_CANCEL

public static final int BTNID_CANCEL
Button ID used for the standard Cancel button.

See Also:
Constant Field Values
Constructor Detail

FormSheet

public FormSheet(String sCaption,
                 JComponent jcmpComponent)
Create a new FormSheet. Display.setFormSheet(sale.FormSheet) will block until this FormSheet is closed.

By default, a FormSheet has two standard buttons: "OK" and "Cancel".

Parameters:
sCaption - the caption of the FormSheet.
jcmpComponent - the component of the FormSheet.
See Also:
ok(), cancel()

FormSheet

public FormSheet(String sCaption,
                 JComponent jcmpComponent,
                 boolean fWaitResponse)
Create a new FormSheet.

By default, a FormSheet has two standard buttons: "OK" and "Cancel".

Parameters:
sCaption - the caption of the FormSheet.
jcmpComponent - the component of the FormSheet.
fWaitResponse - if true, Display.setFormSheet(sale.FormSheet) will block until this FormSheet is closed.
See Also:
ok(), cancel()

FormSheet

public FormSheet(String sCaption,
                 FormSheetContentCreator fscc,
                 boolean fWaitResponse)
Create a new FormSheet, using a content creator.

When the FormSheet is being serialized, only the content creator will be serialized. When the FormSheet gets deserialized, the content creator is called to restore the FormSheet's content.

Parameters:
sCaption - the FormSheet's caption
fscc - the FormSheetContentCreator that will create the FormSheet's contents
fWaitResponse - if true, Display.setFormSheet(sale.FormSheet) will block until this FormSheet is closed.
Method Detail

getComponentLock

public Object getComponentLock()
Get the monitor to be used when accessing this FormSheet's component.

FormSheetContainers can use this monitor when displaying the FormSheet, to make sure, they don't loose any changes about the component.

Override:
Never

getButtonsLock

public Object getButtonsLock()
Get the monitor used to synchronize access to the FormSheet's button bar.

FormSheetContainers can use this lock to make sure, they don't loose any button change events while making the FormSheet visible.

Override:
Never

getDisplayLock

protected Object getDisplayLock()
Get the monitor used to synchronize access to the display.

Subclasses of FormSheet can use this lock when defining further events that must be handled by the FormSheetContainer.

Override:
Never

addContentCreator

public final void addContentCreator(FormSheetContentCreator fscc)
Add a contents creator for this FormSheet.

When the contents creator is used to create the FormSheet's contents, all contents creators that have ever been added to the FormSheet will be called in the order in which they were added. This ensures, that you can subclass FormSheets that use contents creators properly, extending their contents by simply adding another contents creator.

In the first contents creator you can assume a null component, a "OK" as well as a "Cancel" button.

Parameters:
fscc - the new FormSheetContentCreator. Must not be null.
See Also:
ok(), cancel()
Override:
Never

setComponent

public JComponent setComponent(JComponent jcmpComponent)
Set the component for this FormSheet.

If the FormSheet is being displayed, an FormSheetContainer.onFormSheetComponentChanged(sale.FormSheet, javax.swing.JComponent) event is fired, so that the change can affect the display instantaneously.

Parameters:
jcmpComponent - the new component
Returns:
the previous component of this FormSheet, if any.
Override:
Never

getComponent

public JComponent getComponent()
Get the component of this FormSheet.

Override:
Never

setCaption

public void setCaption(String sCaption)
Set the caption for this FormSheet.

If the FormSheet is being displayed, an FormSheetContainer.onFormSheetCaptionChanged(sale.FormSheet, java.lang.String) event is fired, so that the change can affect the display instantaneously.

Parameters:
sCaption - the new caption.
Override:
Never

getCaption

public String getCaption()
Get the FormSheet's caption.

Override:
Never

isCancelled

public boolean isCancelled()
Return whether the cancel button was used to close the FormSheet.

Override:
Never

close

public void close()
Close the FormSheet. This will issue a call to FormSheetContainer.closeFormSheet(sale.FormSheet).

Override:
Never

waitResponse

public boolean waitResponse()
Return true if Display.setFormSheet(sale.FormSheet) should block until the FormSheet is closed.

Override:
Never Instead, set the waitResponse property by calling setWaitResponse(boolean) before making the FormSheet visible.

setWaitResponse

public void setWaitResponse(boolean fWaitResponse)
Set the waitResponse property of this FormSheet.

The waitResponse property decides whether or not Display.setFormSheet(sale.FormSheet) should block until the FormSheet is closed.

The new value of the waitResponse property will have no effect before the FormSheet is displayed the next time, by calling setFormSheet().

Parameters:
fWaitResponse - the new value for the waitResponse property. If true Display.setFormSheet(sale.FormSheet) should block until the FormSheet is closed.
Override:
Never

attach

public SalesPoint attach(SalesPoint sp)
Attach a SalesPoint to this FormSheet.

You will usually not call this method directly, it is called by the Framework.

Parameters:
sp - the SalesPoint to be attached.
Returns:
the previously attached SalesPoint, if any.
Override:
Never

detachSalesPoint

public SalesPoint detachSalesPoint()
Detach the current SalesPoint from this FormSheet.

You will usually not call this method directly, it is called by the Framework.

Returns:
the detached SalesPoint, if any.
Override:
Never

getSalesPoint

public SalesPoint getSalesPoint()
Get the currently attached SalesPoint.

Override:
Never

attach

public SaleProcess attach(SaleProcess p)
Attach a process to this FormSheet.

You will usually not call this method directly, it is called by the Framework.

Parameters:
p - the process to be attached.
Returns:
the previously attached process, if any.
Override:
Never

detachProcess

public SaleProcess detachProcess()
Detach the current process from this FormSheet.

You will usually not call this method directly, it is called by the Framework.

Returns:
the detached process, if any.
Override:
Never

getProcess

public SaleProcess getProcess()
Get the currently attached process.

Override:
Never

attach

public FormSheetContainer attach(FormSheetContainer fsc)
Attach a FormSheetContainer to this FormSheet.

You will usually not call this method directly, it is called by the Framework.

Parameters:
fsc - the FormSheetContainer to be attached.
Returns:
the previously attached FormSheetContainer, if any.
Override:
Never

detachDisplay

public FormSheetContainer detachDisplay()
Detach the current FormSheetContainer from this FormSheet.

You will usually not call this method directly, it is called by the Framework.

Returns:
the detached FormSheetContainer, if any.
Override:
Never

getDisplay

public FormSheetContainer getDisplay()
Get the currently attached FormSheetContainer.

Override:
Never

addButton

public void addButton(String sCaption,
                      int nID,
                      Action aAction)
Add a button to the FormSheet's button bar.

If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonAdded(sale.FormSheet, sale.FormSheet.FormButton) event is fired, so that the change can affect the display instantaneously.

Parameters:
sCaption - the caption of the button
nID - the ID of the button. This ID will later be used to identify the button and, therefore, must be unique for this FormSheet. If there is already a button in this FormSheet that has the same ID, a DuplicateButtonIDError will be thrown.
aAction - the action to be associated with the button.
Throws:
DuplicateButtonIDError - if a button with the same ID already exists.
Override:
Never

addButton

public void addButton(FormSheet.FormButton fb)
Add a button to the FormSheet's button bar.

If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonAdded(sale.FormSheet, sale.FormSheet.FormButton) event is fired, so that the change can affect the display instantaneously.

Parameters:
fb - the button to be added. The button's ID will later be used to identify it and, therefore, must be unique for this FormSheet. If there is already a button in this FormSheet that has the same ID, a DuplicateButtonIDError will be thrown.
Throws:
DuplicateButtonIDError - if a button with the same ID already exists.
Override:
Never

removeButton

public FormSheet.FormButton removeButton(int nID)
Remove a button from the FormSheet's button bar.

If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonRemoved(sale.FormSheet, sale.FormSheet.FormButton) event is fired, so that the change can affect the display instantaneously.

Parameters:
nID - the ID of the button to be removed. If the button does not exist, nothing happens.
Returns:
the removed button, if any.
Override:
Never

removeAllButtons

public void removeAllButtons()
Remove all buttons from the FormSheet's button bar.

If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonsCleared(sale.FormSheet) event is fired, so that the change can affect the display instantaneously.

Override:
Never

getButton

public FormSheet.FormButton getButton(int nID)
Get a button from the FormSheet's button bar.

Parameters:
nID - the ID of the button to be returned.
Override:
Never

buttonIterator

public Iterator<FormSheet.FormButton> buttonIterator()
Return a fail-fast, readonly iterator iterating over the buttons in the button bar.

The buttons will not be returned in the order in which they where added, but in a random order. To get them sorted in order of adding, see buttonIterator(boolean).

Override:
Never

buttonIterator

public Iterator<FormSheet.FormButton> buttonIterator(boolean fSorted)
Return a readonly iterator iterating over the buttons in the button bar.

Parameters:
fSorted - if true, the buttons will be returned in the order in which they were added to the FormSheet.
Override:
Never

fillBtnPanel

public void fillBtnPanel(JPanel jp)
Called by the Framework to generate the button bar's representation.

Parameters:
jp - the panel to be filled. The buttons will be added in the order in which they where added to the FormSheet.
Override:
Never

ok

public void ok()
Hook method called whenever the standard "OK" button was clicked.

Override:
Sometimes Override this method if you want to implement behavior that is to be executed when the standard "OK" button was pressed. The default implementation closes the FormSheet.

cancel

public void cancel()
Hook method called whenever the standard "Cancel" button was clicked.

See Also:
isCancelled()
Override:
Sometimes Override this method if you want to implement behavior that is to be executed when the standard "Cancel" button was pressed. The default implementation marks the FormSheet cancelled and closes it.

toString

public String toString()
Overrides:
toString in class Object

SalesPoint v3.3 API