|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.salespointframework.core.FormSheet
public class FormSheet
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(org.salespointframework.core.FormSheet)
or Display.popUpFormSheet(org.salespointframework.core.FormSheet)
.
Nested Class Summary | |
---|---|
private class |
FormSheet.DnDDispatcher
this class manages drag'n drop events on this formsheet |
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. |
static int |
BUTTONBAR_BOTTOM
Place Buttonbar at bottom |
static int |
BUTTONBAR_LEFT
Place Buttonbar on left side |
static int |
BUTTONBAR_NONE
Don't display the Buttonbar |
static int |
BUTTONBAR_RIGHT
Place Buttonbar on right side |
static int |
BUTTONBAR_TOP
Place Buttonbar at top |
private int |
buttonbarPosition
Holds the location of the Buttonbar |
private static FormSheetContentCreator |
DEFAULT_CONTENT_CREATOR
The default FormSheetContentCreator, that creates the default OK and Cancel button. |
private java.lang.Object |
dragLock
drag component lock |
private java.util.List<DnDComponent> |
m_dndComponents
list of registered DnDComponent s |
private javax.swing.JComponent |
m_dragComponent
current component on drag layer |
private javax.swing.JPanel |
m_dragLayer
Holds the panel in the drag layer |
private java.awt.event.AWTEventListener |
m_dragMouseMotionListener
current mouse motion listener on drag layer |
protected boolean |
m_fCancelled
True if this FormSheet was canelled. |
private FormSheetContentCreator |
m_fsccContentCreator
The FormSheetContentCreator(s) that created the contents of this FormSheet. |
private FormSheetContainer |
m_fscDisplay
The FormSheetContainer displaying this FormSheet. |
private FormsheetCustomizationListener |
m_fsCustListener
Current FormsheetCustomizationListener |
private boolean |
m_fWaitResponse
Flag indicating whether Display.setFormSheet(org.salespointframework.core.FormSheet) should wait
for the FormSheet to be closed. |
private javax.swing.JComponent |
m_jcmpComponent
The FormSheet's component. |
private java.awt.Point |
m_lastMousePosition
Last mouse position on drag pane |
private javax.swing.JPanel |
m_modalLayer
Holds the panel in modal layer |
private FormSheet.DnDDispatcher |
m_mouseWatcher
Mouseposition watcher |
private java.util.Map<java.lang.Integer,FormSheet.FormButton> |
m_mpfbButtons
The buttons in this FormSheet's button bar. |
private int |
m_nLastAddIndex
The add index of the last button added. |
private java.lang.Object |
m_oButtonsLock
The monitor used to synchronize access to the FormSheet's buttons. |
private java.lang.Object |
m_oComponentLock
The monitor used to synchronize access to the FormSheet's component. |
private java.lang.Object |
m_oDisplayLock
The monitor used to synchronize access to the FormSheetContainer. |
private SaleProcess |
m_pAttached
The process attached to this FormSheet. |
private javax.swing.JPanel |
m_popupLayer
Holds the panel in popup layer |
private java.lang.String |
m_sCaption
The FormSheet's caption. |
private SalesPoint |
m_spAttached
The SalesPoint currently attached to this FormSheet. |
Constructor Summary | |
---|---|
FormSheet(java.lang.String sCaption,
FormSheetContentCreator fscc,
boolean fWaitResponse)
Create a new FormSheet, using a content creator. |
|
FormSheet(java.lang.String sCaption,
javax.swing.JComponent jcmpComponent)
Create a new FormSheet. |
|
FormSheet(java.lang.String sCaption,
javax.swing.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(java.lang.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. |
java.util.Iterator<FormSheet.FormButton> |
buttonIterator()
Return a fail-fast, readonly iterator iterating over the buttons in the button bar. |
java.util.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. |
void |
copyFormSheetDnDComponents(FormSheet fs)
registers all DnDComponent s from given FormSheet to this one |
private void |
createFromContentCreator()
Create the FormSheet's contents from the contents creator. |
javax.swing.JPanel |
customizeButtonbar(javax.swing.JPanel buttonbar)
Hook method called before buttons are added. |
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. |
javax.swing.JPanel |
fillBtnPanel(javax.swing.JPanel jp)
Called by the Framework to generate the button bar's representation. |
private java.awt.Point |
getBestDragComponentPosition(java.awt.Point p,
java.awt.Component host,
java.awt.Component cmp)
helper function for position calculation |
FormSheet.FormButton |
getButton(int nID)
Get a button from the FormSheet's button bar. |
int |
getButtonbarPosition()
|
java.lang.Object |
getButtonsLock()
Get the monitor used to synchronize access to the FormSheet's button bar. |
java.lang.String |
getCaption()
Get the FormSheet's caption. |
javax.swing.JComponent |
getComponent()
Get the component of this FormSheet. |
java.lang.Object |
getComponentLock()
Get the monitor to be used when accessing this FormSheet's component. |
FormSheetContainer |
getDisplay()
Get the currently attached FormSheetContainer. |
protected java.lang.Object |
getDisplayLock()
Get the monitor used to synchronize access to the display. |
javax.swing.JPanel |
getDragLayer()
Get the drag layer panel |
javax.swing.JPanel |
getModalLayer()
get the draglayer |
javax.swing.JPanel |
getPopupLayer()
get the popup layer |
SaleProcess |
getProcess()
Get the currently attached process. |
SalesPoint |
getSalesPoint()
Get the currently attached SalesPoint. |
javax.swing.JComponent |
getWrappedComponent()
Returns the wrapped component. |
boolean |
isCancelled()
Return whether the cancel button was used to close the FormSheet. |
boolean |
letFollowComponentOnDragLayer(javax.swing.JComponent cmp)
let the specified component follow the mouse cursor on drag layer |
void |
ok()
Hook method called whenever the standard "OK" button was clicked. |
void |
paintButtonBarBackground(java.awt.Graphics graphics,
javax.swing.JComponent c)
Paints button bar's background image |
private void |
paintWindowBackground(java.awt.Graphics graphics,
javax.swing.JComponent c)
paint the formsheet background |
boolean |
registerDnDComponent(DnDComponent dndcmp)
register a DnDComponent to FormSheet |
void |
removeAllButtons()
Remove all buttons from the FormSheet's button bar. |
void |
removeAllDndComponents()
removes all registered DnDComponent s from list of observes DnDComponent s but not from the FormSheet |
FormSheet.FormButton |
removeButton(int nID)
Remove a button from the FormSheet's button bar. |
void |
removeDnDComponent(DnDComponent dndcmp)
remove a DnDComponent from FormSheet |
void |
setButtonbarPosition(int position)
|
void |
setCaption(java.lang.String sCaption)
Set the caption for this FormSheet. |
javax.swing.JComponent |
setComponent(javax.swing.JComponent jcmpComponent)
Set the component for this FormSheet. |
void |
setFormsheetCustomizationListener(FormsheetCustomizationListener fscl)
Set the current FormsheetCustomizationListener |
void |
setWaitResponse(boolean fWaitResponse)
Set the waitResponse property of this FormSheet. |
void |
stopFollowComponentOnDragLayer()
stops the component follow the mouse on drag layer |
java.lang.String |
toString()
|
boolean |
waitResponse()
Return true if Display.setFormSheet(org.salespointframework.core.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 |
---|
private boolean m_fWaitResponse
Display.setFormSheet(org.salespointframework.core.FormSheet)
should wait
for the FormSheet to be closed.
private java.lang.String m_sCaption
private FormSheetContentCreator m_fsccContentCreator
private FormsheetCustomizationListener m_fsCustListener
private transient javax.swing.JComponent m_jcmpComponent
private transient java.lang.Object m_oComponentLock
private transient java.util.Map<java.lang.Integer,FormSheet.FormButton> m_mpfbButtons
private transient java.lang.Object m_oButtonsLock
private SalesPoint m_spAttached
private SaleProcess m_pAttached
private int buttonbarPosition
private javax.swing.JPanel m_dragLayer
private javax.swing.JPanel m_modalLayer
private javax.swing.JPanel m_popupLayer
private java.lang.Object dragLock
private FormSheet.DnDDispatcher m_mouseWatcher
private java.awt.Point m_lastMousePosition
private java.awt.event.AWTEventListener m_dragMouseMotionListener
private javax.swing.JComponent m_dragComponent
private java.util.List<DnDComponent> m_dndComponents
DnDComponent
s
private FormSheetContainer m_fscDisplay
private transient java.lang.Object m_oDisplayLock
private int m_nLastAddIndex
protected boolean m_fCancelled
public static final int BUTTONBAR_BOTTOM
public static final int BUTTONBAR_TOP
public static final int BUTTONBAR_LEFT
public static final int BUTTONBAR_RIGHT
public static final int BUTTONBAR_NONE
public static final int BTNID_OK
public static final int BTNID_CANCEL
private static final FormSheetContentCreator DEFAULT_CONTENT_CREATOR
Constructor Detail |
---|
public FormSheet(java.lang.String sCaption, javax.swing.JComponent jcmpComponent)
Display.setFormSheet(org.salespointframework.core.FormSheet)
will block until this FormSheet is closed.
By default, a FormSheet has two standard buttons: "OK" and "Cancel".
sCaption
- the caption of the FormSheet.jcmpComponent
- the component of the FormSheet.ok()
,
cancel()
public FormSheet(java.lang.String sCaption, javax.swing.JComponent jcmpComponent, boolean fWaitResponse)
By default, a FormSheet has two standard buttons: "OK" and "Cancel".
sCaption
- the caption of the FormSheet.jcmpComponent
- the component of the FormSheet.fWaitResponse
- if true, Display.setFormSheet(org.salespointframework.core.FormSheet)
will
block until this FormSheet is closed.ok()
,
cancel()
public FormSheet(java.lang.String sCaption, FormSheetContentCreator fscc, boolean fWaitResponse)
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.
sCaption
- the FormSheet's captionfscc
- the FormSheetContentCreator that will create the FormSheet's contentsfWaitResponse
- if true, Display.setFormSheet(org.salespointframework.core.FormSheet)
will
block until this FormSheet is closed.Method Detail |
---|
public java.lang.Object getComponentLock()
FormSheetContainers
can use this monitor when displaying the FormSheet, to
make sure, they don't loose any changes about the component.
public java.lang.Object getButtonsLock()
FormSheetContainers
can use this lock to make
sure, they don't loose any button change events while making the FormSheet visible.
protected java.lang.Object getDisplayLock()
Subclasses of FormSheet can use this lock when defining further events that
must be handled by the FormSheetContainer
.
private final void createFromContentCreator()
public final void addContentCreator(FormSheetContentCreator fscc)
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.
fscc
- the new FormSheetContentCreator. Must not be null
.ok()
,
cancel()
private void paintWindowBackground(java.awt.Graphics graphics, javax.swing.JComponent c)
graphics
- Graohics contextc
- public void stopFollowComponentOnDragLayer()
private java.awt.Point getBestDragComponentPosition(java.awt.Point p, java.awt.Component host, java.awt.Component cmp)
p
- host
- cmp
-
public boolean letFollowComponentOnDragLayer(javax.swing.JComponent cmp)
cmp
-
public javax.swing.JPanel getDragLayer()
public javax.swing.JPanel getModalLayer()
public javax.swing.JPanel getPopupLayer()
public boolean registerDnDComponent(DnDComponent dndcmp)
DnDComponent
to FormSheet
dndcmp
- component to register
public void removeDnDComponent(DnDComponent dndcmp)
DnDComponent
from FormSheet
dndcmp
- component to unregisterpublic void removeAllDndComponents()
DnDComponent
s from list of observes DnDComponent
s but not from the FormSheet
public void copyFormSheetDnDComponents(FormSheet fs)
DnDComponent
s from given FormSheet
to this one
fs
- public javax.swing.JComponent getWrappedComponent()
setComponent(JComponent)
public javax.swing.JComponent setComponent(javax.swing.JComponent jcmpComponent)
If the FormSheet is being displayed, an FormSheetContainer.onFormSheetComponentChanged(org.salespointframework.core.FormSheet, javax.swing.JComponent)
event is fired, so that the change can affect the display instantaneously.
jcmpComponent
- the new component
public javax.swing.JComponent getComponent()
getWrappedComponent()
instead.
public void setCaption(java.lang.String sCaption)
If the FormSheet is being displayed, an FormSheetContainer.onFormSheetCaptionChanged(org.salespointframework.core.FormSheet, java.lang.String)
event is
fired, so that the change can affect the display instantaneously.
sCaption
- the new caption.public java.lang.String getCaption()
public boolean isCancelled()
public void close()
FormSheetContainer.closeFormSheet(org.salespointframework.core.FormSheet)
.
public boolean waitResponse()
Display.setFormSheet(org.salespointframework.core.FormSheet)
should block until the FormSheet is closed.
public void setWaitResponse(boolean fWaitResponse)
waitResponse
property of this FormSheet.
The waitResponse
property decides whether or not Display.setFormSheet(org.salespointframework.core.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()
.
fWaitResponse
- the new value for the waitResponse
property. If true
Display.setFormSheet(org.salespointframework.core.FormSheet)
should block until the FormSheet is closed.public SalesPoint attach(SalesPoint sp)
You will usually not call this method directly, it is called by the Framework.
sp
- the SalesPoint to be attached.
public SalesPoint detachSalesPoint()
You will usually not call this method directly, it is called by the Framework.
public SalesPoint getSalesPoint()
public SaleProcess attach(SaleProcess p)
You will usually not call this method directly, it is called by the Framework.
p
- the process to be attached.
public SaleProcess detachProcess()
You will usually not call this method directly, it is called by the Framework.
public SaleProcess getProcess()
public FormSheetContainer attach(FormSheetContainer fsc)
You will usually not call this method directly, it is called by the Framework.
fsc
- the FormSheetContainer to be attached.
public FormSheetContainer detachDisplay()
You will usually not call this method directly, it is called by the Framework.
public FormSheetContainer getDisplay()
public void addButton(java.lang.String sCaption, int nID, Action aAction)
If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonAdded(org.salespointframework.core.FormSheet, org.salespointframework.core.FormSheet.FormButton)
event is
fired, so that the change can affect the display instantaneously.
sCaption
- the caption of the buttonnID
- 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.
DuplicateButtonIDError
- if a button with the same ID already exists.public void addButton(FormSheet.FormButton fb)
If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonAdded(org.salespointframework.core.FormSheet, org.salespointframework.core.FormSheet.FormButton)
event is
fired, so that the change can affect the display instantaneously.
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.
DuplicateButtonIDError
- if a button with the same ID already exists.public FormSheet.FormButton removeButton(int nID)
If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonRemoved(org.salespointframework.core.FormSheet, org.salespointframework.core.FormSheet.FormButton)
event is
fired, so that the change can affect the display instantaneously.
nID
- the ID of the button to be removed. If the button does not exist, nothing happens.
public void removeAllButtons()
If the FormSheet is being displayed, an FormSheetContainer.onFormSheetButtonsCleared(org.salespointframework.core.FormSheet)
event is
fired, so that the change can affect the display instantaneously.
public FormSheet.FormButton getButton(int nID)
nID
- the ID of the button to be returned.public java.util.Iterator<FormSheet.FormButton> buttonIterator()
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)
.
public java.util.Iterator<FormSheet.FormButton> buttonIterator(boolean fSorted)
fSorted
- if true, the buttons will be returned in the order in which they
were added to the FormSheet.public void setButtonbarPosition(int position)
public int getButtonbarPosition()
public javax.swing.JPanel fillBtnPanel(javax.swing.JPanel jp)
jp
- the panel to be filled. The buttons will be added in the order in which
they where added to the FormSheet.public void paintButtonBarBackground(java.awt.Graphics graphics, javax.swing.JComponent c)
g
- Graphics contextc
- target componentpublic javax.swing.JPanel customizeButtonbar(javax.swing.JPanel buttonbar)
setButtonbarPosition(int)
to set its position
don't manipulate any button inside here.
buttonbar
- public void setFormsheetCustomizationListener(FormsheetCustomizationListener fscl)
public void ok()
public void cancel()
isCancelled()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |