|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.scopemvc.controller.basic.ViewContext | +--org.scopemvc.controller.swing.SwingContext
Swing implementation of ViewContext
to
show views inside JFrames or JDialogs and show errors using JOptionPanes.
Also allows Views to take ownership of SMenuItems from their containing
Window.
ViewContext
Field Summary | |
static java.lang.String |
PROGRESS_START_DELAY_PROPERTY
The property in ScopeConfig for the delay before showing the wait cursor when startProgress once startProgress() has been called, value in milliseconds |
Constructor Summary | |
SwingContext()
Constructor for the SwingContext object |
Method Summary | |
boolean |
areAllViewsClosed()
Are there any Views left open? |
void |
exit()
Exit the application |
protected SMenuItem |
findMenuItem(SwingView inView,
java.lang.String inControlID)
Find the SMenuItem in the menu bar associated with the frame of the view. |
protected static SMenuItem |
findMenuItemInMenu(javax.swing.JMenu inMenu,
java.lang.String inControlID)
Find the SMenuItem in the menu. |
protected javax.swing.JRootPane |
findRootPaneFor(View inView)
Find the Rootpane that contains the SwingView or null if none can be found. |
protected java.awt.Window |
getDefaultParentWindow()
For dialogs to be opened, find the currently focussed window, or if none, the last opened window or if none, the shared null Frame. |
protected java.awt.Image |
getDefaultWindowIcon()
Get the default icon. |
protected javax.swing.JRootPane |
getFocussedRootPane()
Find the rootpane that currently contains the focussed component, or null if none. |
protected java.awt.Frame |
getSharedNullFrame()
Get the frame used as default parent for the views. |
protected java.awt.Container |
getTopmostContainer(SwingView inView)
Finds the topmost Container, stopping before any Window structure. |
void |
hideAllViews()
Hide all open Views. |
protected void |
hideRootPane(javax.swing.JRootPane inRootPane)
Hide the root pane and dispose of the parent window. |
void |
hideView(View inView)
Find the Window that is showing this View and then close it on Swing's event-handling thread. |
protected void |
hideWindow(java.awt.Window window)
Hide the window safely from the Swing event thread. |
void |
hookMenuItem(SwingView inView,
java.lang.String inControlID,
boolean inEnabled)
Hook a menu item to a view. |
protected boolean |
isFocusOwner(java.awt.Window inWindow)
Returns true if the window owns the focus. |
protected void |
setupWindow(javax.swing.JRootPane inRootPane,
SwingView inView,
boolean inCentreWindow)
Setup the window: insert the view in the window, setup the title and the menubar in the window and position the window on the screen. |
void |
showError(java.lang.String inErrorTitle,
java.lang.String inErrorMessage)
Show an error message in a JOptionPane |
void |
showMessage(java.lang.String inTitle,
java.lang.String inMessage)
Show a message in a JOptionPane |
void |
showView(View inView)
Show the view. |
protected void |
showViewInDialog(SwingView inView)
Make a dialog (modal or modeless determined by the display mode )
parented to either currently focussed window, or last shown, or null
shared frame. |
protected void |
showViewInPrimaryWindow(SwingView inView)
Show the view in a new frame |
void |
startProgress()
Start a progress indicator to notify the user that a long operation is running. |
void |
stopProgress()
Stop the progress indicator |
protected void |
unhookMenuItemImpl(java.lang.String inControlID,
SwingView inView)
Unhook a menu item from a view. |
Methods inherited from class org.scopemvc.controller.basic.ViewContext |
addProperty, clearProperties, clearThreadContext, getProperty, getViewContext, removeProperty, setGlobalContext, setThreadContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String PROGRESS_START_DELAY_PROPERTY
Constructor Detail |
public SwingContext()
Method Detail |
protected static SMenuItem findMenuItemInMenu(javax.swing.JMenu inMenu, java.lang.String inControlID)
inMenu
- A menuinControlID
- The control ID of the menu item to find
public void showView(View inView)
showView
in class ViewContext
inView
- The view to show. Must be a subclass of SwingViewpublic void hideView(View inView)
hideView
in class ViewContext
inView
- The view to hide. Must be a subclass of SwingViewpublic void hideAllViews()
public boolean areAllViewsClosed()
public void showError(java.lang.String inErrorTitle, java.lang.String inErrorMessage)
showError
in class ViewContext
inErrorTitle
- The title for the error messageinErrorMessage
- The error messagepublic void showMessage(java.lang.String inTitle, java.lang.String inMessage)
inTitle
- The title for the messageinMessage
- The messagepublic void exit()
exit
in class ViewContext
public void startProgress()
startProgress
in class ViewContext
public void stopProgress()
stopProgress
in class ViewContext
public void hookMenuItem(SwingView inView, java.lang.String inControlID, boolean inEnabled)
inView
- the view to hook the menu item to.inControlID
- The control ID used to identity the menu iteminEnabled
- Set to true to enable the menu itemprotected java.awt.Frame getSharedNullFrame()
protected java.awt.Image getDefaultWindowIcon()
ResourceLoader
protected javax.swing.JRootPane getFocussedRootPane()
protected boolean isFocusOwner(java.awt.Window inWindow)
Returns true if the window owns the focus.
Swing loses focus from the current component when a menu is pulled down so for a Window to have focus we say it needs to either contain the focus owner OR parent a Window (not a Dialog/Frame) that owns the focus.
inWindow
- The Window to test for focus
protected java.awt.Window getDefaultParentWindow()
protected java.awt.Container getTopmostContainer(SwingView inView)
inView
- The View to get the topmost Container from
protected void setupWindow(javax.swing.JRootPane inRootPane, SwingView inView, boolean inCentreWindow)
inRootPane
- The RootPane where to add the ViewinView
- The View to setupinCentreWindow
- If true, centre the window on the screen or on its
parent windowprotected javax.swing.JRootPane findRootPaneFor(View inView)
inView
- The View to get the RootPane from
protected void hideRootPane(javax.swing.JRootPane inRootPane)
inRootPane
- The RootPane to hideprotected void hideWindow(java.awt.Window window)
window
- The window to closeprotected void showViewInDialog(SwingView inView)
the display mode
)
parented to either currently focussed window, or last shown, or null
shared frame.
inView
- The View to showprotected void showViewInPrimaryWindow(SwingView inView)
inView
- The View to showprotected void unhookMenuItemImpl(java.lang.String inControlID, SwingView inView)
inView
- the view where the menu item was hooked to.inControlID
- The control ID used to identity the menu itemprotected SMenuItem findMenuItem(SwingView inView, java.lang.String inControlID)
inView
- A view contained in a frame containing a menubarinControlID
- The control ID of the menu item to find
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |