@Service(value=FormUtilities.class) public class FormUtilities extends Object
| Constructor and Description |
|---|
FormUtilities()
C'tor for this class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Activates the utility features.
|
void |
addWindow(Window w)
Adds window to the set of windows (must be visible or iconified).
|
void |
addWindowActionListener(ActionListener listener)
Adds a listener being notified whenever the state of the
current windows-list has changed.
|
protected FormEventQueue |
createEventQueue()
Creates a new event queue.
|
void |
doFireValueChanged(FormComponent c,
Object[] listeners)
Notifies all ValueListeners (usually only one!) that the field is
going to be displayed and thus needs the data what to display.
|
void |
doFireValueEntered(FormComponent c,
Object[] listeners)
Notifies all ValueListeners (usually only one!) that the field contents
should be moved to the actual data object.
|
void |
doValidate(FormComponent c)
Runs the validation if there is a binding and there
are validation annotations.
|
String |
dumpComponentHierarchy(Component comp,
MouseEvent me)
Creates a text-dump of the component hierarchy.
|
Point |
getAlignedLocation(Window window,
Point location)
Calculates the location of a window so that it
is completely visible on the screen, using a "free" spot.
|
long |
getAutoClose()
Gets the global autoclose feature for all newly created Windows.
|
FormComponentBinding |
getBinding(FormContainer container,
FormComponent component)
Gets the binding for a given component in the given container and
all its sub-containers.
|
FormComponentBinding |
getBinding(FormContainer container,
String bindingPath)
Gets the binding for a given binding path in the given container and
all its sub-containers.
|
FormBindingFactory |
getBindingFactory()
Gets the binding factory (singleton).
|
Point |
getCenteredLocation(Window window)
Calculates the location of a window so that it will be centered on the screen.
|
FormEventQueue |
getEventQueue()
Gets the eventqueue.
The method installs the FormEventQueue if not yet done. |
void |
getFormValue(Component c)
Recursively walk down and fireValueEntered().
|
String |
getHelpURL()
Gets the global help url prefix.
|
static FormUtilities |
getInstance()
The singleton.
|
Window |
getParentWindow(Component comp)
Determines the parent-window of a component.
Much the same as getTopLevelAncestor in JComponent, this does method not return Applets. |
String |
getPreferencesName(Class<?> clazz,
String compName)
Determines the Preferences-name for a class.
The name is built from the classname and a componentname. |
Point |
getPreferredLocation(Window window,
Window owner)
Calculates the position of a window on the screen so that
it is being display in an optimal manner.
|
Collection<FormContainer> |
getSubContainer(FormContainer container)
Gets all subcontainers.
|
Window |
getVisibleParentOrRelatedWindow(Component comp)
Gets the parent window of the given component.
|
Window[] |
getWindows()
Gets the current windows which are visible or iconified.
|
void |
hideErrorPopup()
Hides the currently displayed error popup, if any.
|
void |
installPreferredSizeMenu(Component comp,
String prefName)
Installs a menu for setting/retrieving the preferred sizes.
|
void |
invalidateParentInfo(Component c)
Recursively walk down and invalidate the parentInfo.
|
boolean |
isModalDialogShowing()
Checks whether a modal dialog is showing.
|
boolean |
isParentWindowModal(Component comp)
Determines whether parent window a modal dialog.
|
boolean |
isValueChanged(Component c,
boolean triggerValueChangedEnabledOnly)
Recursively walk down and check for value changed.
|
void |
loadPreferredSizes(Component comp,
String prefName,
boolean system)
Loads the preferences of a component.
Use it whenever there is no table in it (FormTable provide setting too) or some other scrolling regions need to be preset. |
void |
modalToFront()
Brings the current modal dialogs toFront.
|
void |
openHelpURL(Component comp)
Opens the online help for a given component.
|
boolean |
packParentWindow(Component comp)
Packs the window containing the given component.
|
void |
processWindowEvent(WindowEvent e)
Process a window event (from a FormDialog or FormFrame).
|
void |
removeWindow(Window w)
Removes a window from the set (i.e.
|
void |
removeWindowActionListener(ActionListener listener)
Removes a listener.
|
void |
requestFocusLater(Component c)
Requests focus by EventQueue.invokeLater().
|
void |
savePreferredSizes(Component comp,
String prefName,
boolean system)
Saves the preferences of a component.
Use it whenever there is no table in it (FormTable provide setting too) or some other scrolling regions need to be preset. |
void |
saveValue(Component c)
Recursively walk down and saveValue().
|
void |
setAutoClose(long ms)
Sets the global autoclose feature for all newly created Windows.
|
void |
setAutoUpdate(Component c,
boolean autoUpdate)
Recursively walk down and setAutoUpdate.
|
void |
setBackground(Component c,
Color background)
Recursively walk down and setBackground().
|
void |
setChangeable(Component c,
boolean changeable)
Recursively walk down and setChangeable().
|
void |
setDefaultCursor(Component comp)
Sets the default-cursor.
Determines the parent or related window and applies the cursor. |
void |
setDefaultFocusTraversalPolicy(Container container)
Sets the focus-policy for a container.
|
void |
setForeground(Component c,
Color foreground)
Recursively walk down and setForeground().
|
void |
setFormValue(Component c)
Recursively walk down and fireValueChanged().
|
void |
setFormValueKeepChanged(Component c)
Recursively walk down and fireValueChanged(),
but only fields that have *NOT* been changed by the user.
Nice to mask out unchanged fields. |
void |
setHelpURL(String aHelpURL)
Sets the global help url prefix.
|
void |
setUIVersionOfFormWindow(FormWindow formWindow)
Sets the initial uiversion of a
FormWindow. |
void |
setupDefaultBindings(JComponent comp)
Registers some default Keyboard Actions for Components.
|
void |
setWaitCursor(Component comp)
Sets the wait-cursor.
Determines the parent or related window and applies the cursor. |
void |
showErrorPopup(FormComponent formComponent,
String message)
Shows an error popup for a given component and message.
Any currently displayed error popup will be hidden first. |
void |
triggerValueChanged(Component c)
Recursively walk up and trigger value changed in FormContainers.
|
void |
updateUIofAllWindows()
Updates the UI of all registered windows
|
void |
updateUIofWindow(Window w)
Updates the UI of a given window.
|
void |
waitForEmptyEventQueue()
Waits for the event queue to become empty.
This method must not be invoked from the GUI thread! The method waits until the q is empty. |
public FormUtilities()
getInstance()public static FormUtilities getInstance()
public void activate()
public String dumpComponentHierarchy(Component comp, MouseEvent me)
comp - the deepest componentme - the optional mouse event (necessary for table headers only)protected FormEventQueue createEventQueue()
public FormEventQueue getEventQueue()
public FormBindingFactory getBindingFactory()
public void waitForEmptyEventQueue()
public void setAutoClose(long ms)
ms - timeout in milliseconds. Default is 0.public long getAutoClose()
public void modalToFront()
public void addWindow(Window w)
w - the window to addpublic void removeWindow(Window w)
w - the window to removepublic Window[] getWindows()
public boolean isModalDialogShowing()
public void setUIVersionOfFormWindow(FormWindow formWindow)
FormWindow.formWindow - the created windowpublic void updateUIofWindow(Window w)
w - the windowpublic void updateUIofAllWindows()
public void processWindowEvent(WindowEvent e)
e - the event to processpublic void addWindowActionListener(ActionListener listener)
listener - the action listenerpublic void removeWindowActionListener(ActionListener listener)
listener - the listener to be removedpublic void setDefaultFocusTraversalPolicy(Container container)
container - the container.public void setAutoUpdate(Component c, boolean autoUpdate)
c - the componentautoUpdate - the autoUpdate flagpublic void doFireValueChanged(FormComponent c, Object[] listeners)
c - the componentlisteners - the listener arraypublic void doFireValueEntered(FormComponent c, Object[] listeners)
c - the componentlisteners - the listener arraypublic void doValidate(FormComponent c)
c - the componentpublic void setFormValue(Component c)
c - the componentpublic void setFormValueKeepChanged(Component c)
c - the componentpublic void getFormValue(Component c)
c - the componentpublic void saveValue(Component c)
c - the componentpublic boolean isValueChanged(Component c, boolean triggerValueChangedEnabledOnly)
c - the componenttriggerValueChangedEnabledOnly - true if check only components with triggerValueChangedEnabledpublic void triggerValueChanged(Component c)
c - the componentpublic void setChangeable(Component c, boolean changeable)
c - the componentchangeable - true if changeablepublic void setBackground(Component c, Color background)
c - the componentbackground - the background colorpublic void setForeground(Component c, Color foreground)
c - the componentforeground - the foreground colorpublic Window getParentWindow(Component comp)
comp - the componentpublic Window getVisibleParentOrRelatedWindow(Component comp)
comp - the componentpublic boolean isParentWindowModal(Component comp)
comp - the componentpublic boolean packParentWindow(Component comp)
comp - the componentpublic void invalidateParentInfo(Component c)
c - the componentpublic Collection<FormContainer> getSubContainer(FormContainer container)
container - the parent containerpublic FormComponentBinding getBinding(FormContainer container, FormComponent component)
The method differs from Binder.getBinding(java.lang.String)
because the latter only finds bindings that were explicitly bound to the container.
This method, however, also finds bindings bound on sub containers.
container - the parent containercomponent - the componentpublic FormComponentBinding getBinding(FormContainer container, String bindingPath)
The method differs from Binder.getBinding(java.lang.String)
because the latter only finds bindings that were explicitly bound to the container.
This method, however, also finds bindings bound on sub containers.
container - the parent containerbindingPath - the opject's binding pathpublic void requestFocusLater(Component c)
c - the componentpublic void setWaitCursor(Component comp)
comp - the related componentpublic void setDefaultCursor(Component comp)
comp - the related componentpublic void hideErrorPopup()
IllegalStateException - if not invoked from within the dispatch threadpublic void showErrorPopup(FormComponent formComponent, String message)
formComponent - the componentmessage - the message, null to hideIllegalStateException - if not invoked from within the dispatch threadpublic Point getCenteredLocation(Window window)
window - the windowpublic Point getPreferredLocation(Window window, Window owner)
window - the window to be positioned on the screenowner - the window to which the window will be related topublic Point getAlignedLocation(Window window, Point location)
window - the current windowlocation - the desired (not necessarily current!) locationpublic void setupDefaultBindings(JComponent comp)
comp - the componentpublic void savePreferredSizes(Component comp, String prefName, boolean system)
comp - is the component (usually a panel, srolling area or window)prefName - is the preferences namesystem - is true if store to system-preferences, else store in userprefspublic void loadPreferredSizes(Component comp, String prefName, boolean system)
comp - is the component (usually a panel, srolling area or window)prefName - is the preferences namesystem - is true if load from system-preferences, else try userprefs firstpublic void installPreferredSizeMenu(Component comp, String prefName)
comp - is the componentprefName - is the preferences namepublic String getPreferencesName(Class<?> clazz, String compName)
clazz - the classcompName - the name of the componentpublic void setHelpURL(String aHelpURL)
aHelpURL - the prefixpublic String getHelpURL()
public void openHelpURL(Component comp)
comp - the componentTentackle - a domain driven enterprise framework