Class WWindow
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WWindow
-
- All Implemented Interfaces:
Container
,WComponent
,WebComponent
,Serializable
public class WWindow extends AbstractWComponent implements Container
This component enables a pop up browser window with interactive wcomponent content. Be warned that pop up windows can cause workflow headaches as you can't control where the user goes. Eg. They may not close a pop up window before going back to the parent window. Later on they may choose to continue working in the pop up window, breaking the intended flow of the application.- Since:
- 1.0.0
- Author:
- Martin Shevchenko, Jonathan Austin
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WWindow.WindowModel
Holds the extrinsic state information of a window.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
Fields Modifier and Type Field Description static int
ACTIVE_STATE
This state is when the window is open and the initial render of the content is complete.static int
DISPLAY_STATE
The component is in this state when a request has been made to display the window.static int
INACTIVE_STATE
This is the "normal" state for the Window component when it's being processed as part of the parent window.static String
WWINDOW_REQUEST_PARAM_KEY
Request parameter key for a wwindow.-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WWindow()
Creates a new Window.WWindow(WComponent content)
Creates a new Window containing the specified content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterPaint(RenderContext renderContext)
Subclasses may override this method to output content after the component has been painted.void
display()
Signals that the pop up window should be opened in the given context.WComponent
getChildAt(int index)
Retrieves a child component by its index.int
getChildCount()
List<WComponent>
getChildren()
Retrieves a list of this Container's.protected WWindow.WindowModel
getComponentModel()
Returns the effective component model for this component.WComponent
getContent()
int
getHeight()
int
getIndexOfChild(WComponent childComponent)
Retrieves the index of the given child.int
getLeft()
protected WWindow.WindowModel
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.int
getState()
Retrieves the current state of the window.int
getStep()
Retrieves the current step counter.String
getTitle()
int
getTop()
String
getUrl()
Returns a dynamic URL that this wwindow component can be accessed from.int
getWidth()
void
handleRequest(Request request)
Override handleRequest in order to perform processing specific to this component.protected void
invokeLaters()
When the window is targetted, we need to run the "laters".boolean
isResizable()
boolean
isScrollable()
boolean
isShowLocation()
boolean
isShowMenuBar()
boolean
isShowStatus()
boolean
isShowToolbar()
protected boolean
isTargeted()
protected WWindow.WindowModel
newComponentModel()
Creates a new component model appropriate for this component.protected void
paintComponent(RenderContext renderContext)
Override paintComponent in order to paint the window or its content, depending on the window state.protected void
preparePaintComponent(Request request)
Override preparePaintComponent to clear the scratch map before the window content is being painted.void
setContent(WComponent content)
Set the WComponent that will handle the content for this pop up window.void
setHeight(int height)
Sets the window height.void
setLeft(int left)
Sets the x-coordinate of the window.void
setResizable(boolean resizable)
Sets whether the window is resizable.void
setScrollable(boolean scrollable)
Sets whether the window should have a scroll bar.void
setShowLocation(boolean showLocation)
Sets whether the browser location bar should be shown.void
setShowMenuBar(boolean showMenuBar)
Sets whether the browser menubar should be shown.void
setShowStatus(boolean showStatus)
Sets whether the browser status bar should be shown.void
setShowToolbar(boolean showToolbar)
Sets whether the browser toolbar should be shown.protected void
setState(int state)
Sets the current state of this component.void
setStep(int step)
Sets the current step counter.protected void
setTargeted(boolean targeted)
void
setTitle(String title)
Sets the window title.void
setTop(int top)
Sets the y-coordinate of the window.void
setWidth(int width)
Sets the window width.protected void
showWindow(RenderContext renderContext)
Emits the mark-up which pops up the window.String
toString()
Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Field Detail
-
WWINDOW_REQUEST_PARAM_KEY
public static final String WWINDOW_REQUEST_PARAM_KEY
Request parameter key for a wwindow.- See Also:
- Constant Field Values
-
INACTIVE_STATE
public static final int INACTIVE_STATE
This is the "normal" state for the Window component when it's being processed as part of the parent window.- See Also:
- Constant Field Values
-
DISPLAY_STATE
public static final int DISPLAY_STATE
The component is in this state when a request has been made to display the window. The necessary mark-up to open the window will be rendered in this mode.- See Also:
- Constant Field Values
-
ACTIVE_STATE
public static final int ACTIVE_STATE
This state is when the window is open and the initial render of the content is complete.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WWindow
public WWindow()
Creates a new Window.
-
WWindow
public WWindow(WComponent content)
Creates a new Window containing the specified content.- Parameters:
content
- the window content.
-
-
Method Detail
-
setContent
public void setContent(WComponent content)
Set the WComponent that will handle the content for this pop up window.- Parameters:
content
- the window content.
-
getContent
public WComponent getContent()
- Returns:
- the component which is the content for this window.
-
getTitle
public String getTitle()
- Returns:
- the window title.
-
setTitle
public void setTitle(String title)
Sets the window title.- Parameters:
title
- The title to set.
-
display
public void display()
Signals that the pop up window should be opened in the given context.
-
getHeight
public int getHeight()
- Returns:
- The height of the window. Default is 600px.
-
setHeight
public void setHeight(int height)
Sets the window height.- Parameters:
height
- The height of the window.
-
getWidth
public int getWidth()
- Returns:
- The width of the window. Default is 800px.
-
setWidth
public void setWidth(int width)
Sets the window width.- Parameters:
width
- The width of the window.
-
getTop
public int getTop()
- Returns:
- the y-coordinate of the window.
-
setTop
public void setTop(int top)
Sets the y-coordinate of the window.- Parameters:
top
- The y-coordinate of the window, or -1 for default.
-
getLeft
public int getLeft()
- Returns:
- the x-coordinate of the window.
-
setLeft
public void setLeft(int left)
Sets the x-coordinate of the window.- Parameters:
left
- The x-coordinate of the window, or -1 for default.
-
isShowMenuBar
public boolean isShowMenuBar()
- Returns:
- true the browser menubar should be shown.
-
setShowMenuBar
public void setShowMenuBar(boolean showMenuBar)
Sets whether the browser menubar should be shown. It is hidden by default.- Parameters:
showMenuBar
- The showMenuBar to set.
-
isShowToolbar
public boolean isShowToolbar()
- Returns:
- true if the browser toolbar should be shown.
-
setShowToolbar
public void setShowToolbar(boolean showToolbar)
Sets whether the browser toolbar should be shown. It is hidden by default.- Parameters:
showToolbar
- The showToolbar to set.
-
isShowLocation
public boolean isShowLocation()
- Returns:
- true if the browser location bar should be shown.
-
setShowLocation
public void setShowLocation(boolean showLocation)
Sets whether the browser location bar should be shown. It is hidden by default.- Parameters:
showLocation
- The showLocation to set.
-
isShowStatus
public boolean isShowStatus()
- Returns:
- true if the browser status bar should be shown.
-
setShowStatus
public void setShowStatus(boolean showStatus)
Sets whether the browser status bar should be shown. It is hidden by default.- Parameters:
showStatus
- The showStatus to set.
-
isResizable
public boolean isResizable()
- Returns:
- true if the window is resizable.
-
setResizable
public void setResizable(boolean resizable)
Sets whether the window is resizable.- Parameters:
resizable
- true if the window should be resizable, false if not.
-
isScrollable
public boolean isScrollable()
- Returns:
- true if the window is scrollable.
-
setScrollable
public void setScrollable(boolean scrollable)
Sets whether the window should have a scroll bar.- Parameters:
scrollable
- true if the window should have a scroll bar, false if not.
-
getState
public int getState()
Retrieves the current state of the window.- Returns:
- the current state of this window.
-
setState
protected void setState(int state)
Sets the current state of this component.- Parameters:
state
- the window state to set.
-
getUrl
public String getUrl()
Returns a dynamic URL that this wwindow component can be accessed from.- Returns:
- the URL to access this wwindow component.
-
handleRequest
public void handleRequest(Request request)
Override handleRequest in order to perform processing specific to this component.- Specified by:
handleRequest
in interfaceWComponent
- Overrides:
handleRequest
in classAbstractWComponent
- Parameters:
request
- the request being responded to.
-
invokeLaters
protected void invokeLaters()
When the window is targetted, we need to run the "laters". If we don't do this, they will not run because a targetted request bypasses the root component that would normally have run them.- Overrides:
invokeLaters
in classAbstractWComponent
-
preparePaintComponent
protected void preparePaintComponent(Request request)
Override preparePaintComponent to clear the scratch map before the window content is being painted.- Overrides:
preparePaintComponent
in classAbstractWComponent
- Parameters:
request
- the request being responded to.
-
paintComponent
protected void paintComponent(RenderContext renderContext)
Override paintComponent in order to paint the window or its content, depending on the window state.- Overrides:
paintComponent
in classAbstractWComponent
- Parameters:
renderContext
- the RenderContext to send the output to.
-
afterPaint
protected void afterPaint(RenderContext renderContext)
Description copied from class:AbstractWComponent
Subclasses may override this method to output content after the component has been painted. When overriding this method, it is good practice to call the superclass implementation before emitting any additional content.- Overrides:
afterPaint
in classAbstractWComponent
- Parameters:
renderContext
- the context to render to.
-
showWindow
protected void showWindow(RenderContext renderContext)
Emits the mark-up which pops up the window.- Parameters:
renderContext
- the RenderContext to send the output to.
-
isTargeted
protected boolean isTargeted()
- Returns:
- the current step counter.
-
setTargeted
protected void setTargeted(boolean targeted)
- Parameters:
targeted
- true if targeted
-
getStep
public int getStep()
Retrieves the current step counter. This method should only ever be used by internal code.- Returns:
- the current step counter.
-
setStep
public void setStep(int step)
Sets the current step counter. This method should only ever be used by internal code.- Parameters:
step
- the step to set.
-
getChildCount
public int getChildCount()
- Specified by:
getChildCount
in interfaceContainer
- Returns:
- the number of child components currently contained within this component.
-
getChildAt
public WComponent getChildAt(int index)
Retrieves a child component by its index.- Specified by:
getChildAt
in interfaceContainer
- Parameters:
index
- the index of the child component to be retrieved.- Returns:
- the child component at the given index.
-
getChildren
public List<WComponent> getChildren()
Retrieves a list of this Container's.- Specified by:
getChildren
in interfaceContainer
- Returns:
- an immutable list of this Container.
-
getIndexOfChild
public int getIndexOfChild(WComponent childComponent)
Retrieves the index of the given child.- Specified by:
getIndexOfChild
in interfaceContainer
- Parameters:
childComponent
- the child component to retrieve the index for.- Returns:
- the index of the given child component, or -1 if the component is not a child of this component.
-
toString
public String toString()
Description copied from class:AbstractWComponent
Creates a String representation of this component; usually for debugging purposes.- Overrides:
toString
in classAbstractWComponent
- Returns:
- a String representation of this component, for debugging purposes.
-
newComponentModel
protected WWindow.WindowModel newComponentModel()
Creates a new component model appropriate for this component.- Overrides:
newComponentModel
in classAbstractWComponent
- Returns:
- a new WindowModel.
-
getComponentModel
protected WWindow.WindowModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModel
in classAbstractWComponent
- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WWindow.WindowModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModel
in classAbstractWComponent
- Returns:
- the model for this component
-
-