ComponentListener
, ImageObserver
, MenuContainer
, Serializable
, EventListener
, Accessible
, RootPaneContainer
, WindowConstants
, IDocumentContainer
, ITemplateContainer
, ITemplatePanel
, IXHTMLPanel
, org.xhtmlrenderer.extend.UserInterface
, org.xhtmlrenderer.simple.extend.FormSubmissionListener
RequestWizard
public class TemplateWizard extends JDialog implements ITemplatePanel
This is an ITemplatePanel
with next/previous buttons by which
the user can walk through a list of pages. The pages that make up the
wizard are defined in the member pages
.
When you want to do something on a page change, use setHandler(nl.nikhef.jgridstart.gui.util.TemplateWizard.PageListener)
with
a TemplateWizard.PageListener
interface as argument. One can use setStep(int)
and
setStepRelative(int)
to change the current page.
To give the user an overview of the available steps in the wizard, there is
a variable wizard.contents.html
which can be inserted in each step
using the default template
substitutions. It can be
fixed to the viewport with css like position: fixed
.
updateWizardProperties(int)
generates this variable, which can be customized
by derived classes by overriding either that method, or getWizardContentsLine(int, int)
.
The default implementation of getWizardContentsLine(int, int) retrieves the HTML document title for each page to construct the overview of the available steps.
Modifier and Type | Class | Description |
---|---|---|
static interface |
TemplateWizard.PageListener |
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Container.AccessibleAWTContainer
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
JDialog.AccessibleJDialog
Window.AccessibleAWTWindow, Window.Type
Modifier and Type | Field | Description |
---|---|---|
protected JPanel |
btnLeft |
|
protected JPanel |
btnRight |
|
protected Action |
cancelAction |
"Cancel"/"Close" action
|
protected TemplateWizard.PageListener |
handler |
Listener for page changes
|
protected Action |
nextAction |
"Next" action
|
ArrayList<URL> |
pages |
wizard page templates for each step
|
protected TemplateButtonPanel |
pane |
actual dialog content with HTML and buttons
|
protected Action |
prevAction |
"Previous" action
|
protected int |
step |
currently active step (base 0), -1 for not initialized
|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
DEFAULT_MODALITY_TYPE
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
accessibleContext, rootPane, rootPaneCheckingEnabled
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
Constructor | Description |
---|---|
TemplateWizard() |
|
TemplateWizard(Dialog owner) |
|
TemplateWizard(Dialog owner,
Properties p) |
|
TemplateWizard(Frame owner) |
|
TemplateWizard(Frame owner,
Properties p) |
|
TemplateWizard(Properties p) |
Modifier and Type | Method | Description |
---|---|---|
void |
addMouseTrackingListener(org.xhtmlrenderer.swing.FSMouseListener l) |
|
void |
componentHidden(ComponentEvent e) |
|
void |
componentMoved(ComponentEvent e) |
|
void |
componentResized(ComponentEvent e) |
|
void |
componentShown(ComponentEvent e) |
|
Properties |
data() |
Return the properties.
|
Document |
getDocument() |
|
protected TemplateDocument |
getDocument(int i) |
return the TemplateDocument by index.
|
String |
getDocumentTitle() |
Returns the title as reported by the NamespaceHandler assigned to the SharedContext in this panel.
|
protected String |
getDocumentTitle(int step) |
Returns the title of a step
|
Component |
getFormComponent(String name) |
Return the Swing/AWT component for a form element by name.
|
Map<String,Component> |
getFormComponents() |
Return the list of Swing/AWT components.
|
List<?> |
getMouseTrackingListeners() |
|
org.xhtmlrenderer.layout.SharedContext |
getSharedContext() |
|
URL |
getURL() |
|
protected String |
getWizardContentsLine(int step,
int current) |
Returns the contents line for a page.
|
protected void |
initialize() |
Initialize and build the dialog
The background colour is set to the default control background colour as
specified by UIManager.
|
boolean |
isActive(Element e) |
|
boolean |
isFocus(Element e) |
|
boolean |
isHover(Element e) |
|
boolean |
print() |
print the contents of this pane.
|
boolean |
refresh() |
Refresh the contents so that all parsing is redone.
|
void |
reloadDocument(String URI) |
Reloads the document using the same base URL and namespace handler.
|
void |
reloadDocument(Document doc) |
Reloads the document using the same base URL and namespace handler.
|
void |
removeMouseTrackingListener(org.xhtmlrenderer.swing.FSMouseListener l) |
|
void |
replaceLinkListener(org.xhtmlrenderer.swing.LinkListener llnew) |
Replace the listener that is activated when a link is clicked.
|
protected Document |
retrieveDocument(URL url) |
|
void |
setBackground(Color c) |
|
void |
setData(Properties p) |
Set the properties to use for the template and form elements.
|
void |
setDocument(File file) |
Renders a Document read from an InputStream using a URL
as a base URL for relative paths.
|
void |
setDocument(InputStream stream,
String url) |
Renders a Document read from an InputStream using a URL
as a base URL for relative paths.
|
void |
setDocument(InputStream stream,
String url,
org.xhtmlrenderer.extend.NamespaceHandler nsh) |
|
void |
setDocument(String uri) |
Loads and renders a Document given a uri.
|
void |
setDocument(String url,
org.xhtmlrenderer.extend.NamespaceHandler nsh) |
|
void |
setDocument(TemplateDocument doc) |
Renders an ITemplateDocument instance.
|
void |
setDocument(TemplateDocument doc,
org.xhtmlrenderer.extend.NamespaceHandler nsh) |
|
void |
setDocument(Document doc) |
Renders an XML Document instance.
|
void |
setDocument(Document doc,
String url) |
Renders a Document using a URL as a base URL for relative
paths.
|
void |
setDocumentFromString(String content,
String url,
org.xhtmlrenderer.extend.NamespaceHandler nsh) |
|
void |
setFormSubmissionListener(org.xhtmlrenderer.simple.extend.FormSubmissionListener fsl) |
|
void |
setHandler(TemplateWizard.PageListener l) |
set the handler to be called when a page switch is done.
|
void |
setSharedContext(org.xhtmlrenderer.layout.SharedContext ctx) |
Sets the
RenderingContext attribute of the XHTMLPanel object. |
void |
setStep(int s) |
set the currently displayed page
|
void |
setStepRelative(int delta) |
go to another page by relative distance
|
void |
setSubmitAction(Action e) |
Set the action to perform on form submission.
|
void |
setVisible(boolean visible) |
Shows or hides the dialog.
|
void |
submit(String query) |
|
void |
updateWizardProperties(int step) |
Update the wizard properties for a step.
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBack
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
protected int step
protected TemplateButtonPanel pane
protected JPanel btnRight
protected JPanel btnLeft
protected Action nextAction
protected Action prevAction
protected Action cancelAction
protected TemplateWizard.PageListener handler
public TemplateWizard()
public TemplateWizard(Dialog owner)
public TemplateWizard(Frame owner)
public TemplateWizard(Properties p)
public TemplateWizard(Dialog owner, Properties p)
public TemplateWizard(Frame owner, Properties p)
protected TemplateDocument getDocument(int i)
The document is loaded on demand. Always use this method to access the document, or else it may not be loaded.
null
on failureprotected String getDocumentTitle(int step)
public void setStep(int s)
public void setStepRelative(int delta)
public void updateWizardProperties(int step)
This generaties the properties wizard.*
which can be
referenced in the template. The following variables are defined
by default:
wizard.contents.html
- list of pages (html)
Note that property wizard.contents.html.volatile
are
set to true
to avoid it being saved to disk for persistent
property stores (like jGridstart's CertificatePair).
Derived classes may add and/or override wizard properties. Please
make sure to set the wizard.foo.html.volatile
property
as well to avoid property clutter.
step
- step for which the contents is displayed; the default
implementation marks the currently displayed step.protected String getWizardContentsLine(int step, int current)
Default implementation returns a li item with an optional class
wizard-current
if it is the current page, or
wizard-future
if it is a step later than the current one.
step
- step to return contents for; index in pages
current
- the currently active steppublic void setVisible(boolean visible)
This also sets the current step to the first one if none is selected as of yet (only when there are pages defined).
setVisible
in class Dialog
protected void initialize()
public void setHandler(TemplateWizard.PageListener l)
protected Document retrieveDocument(URL url) throws SAXException, IOException, ParserConfigurationException
This version explicitly allows the use of default caches to enable
resource caching from URLs obtained with Class.getResource(java.lang.String)
.
public void setBackground(Color c)
setBackground
in class Dialog
public void addMouseTrackingListener(org.xhtmlrenderer.swing.FSMouseListener l)
addMouseTrackingListener
in interface IXHTMLPanel
public void componentHidden(ComponentEvent e)
componentHidden
in interface ComponentListener
public void componentMoved(ComponentEvent e)
componentMoved
in interface ComponentListener
public void componentResized(ComponentEvent e)
componentResized
in interface ComponentListener
public void componentShown(ComponentEvent e)
componentShown
in interface ComponentListener
public Properties data()
ITemplateContainer
Use this to retrieve data from form elements. The name of each element has a corresponding property key, and the value of the property is updated when the form element changes.
data
in interface ITemplateContainer
public Document getDocument()
getDocument
in interface IDocumentContainer
public String getDocumentTitle()
IDocumentContainer
getDocumentTitle
in interface IDocumentContainer
public List<?> getMouseTrackingListeners()
getMouseTrackingListeners
in interface IXHTMLPanel
public org.xhtmlrenderer.layout.SharedContext getSharedContext()
getSharedContext
in interface IXHTMLPanel
public URL getURL()
getURL
in interface IDocumentContainer
public boolean isActive(Element e)
isActive
in interface org.xhtmlrenderer.extend.UserInterface
public boolean isFocus(Element e)
isFocus
in interface org.xhtmlrenderer.extend.UserInterface
public boolean isHover(Element e)
isHover
in interface org.xhtmlrenderer.extend.UserInterface
public boolean print() throws PrinterException
IXHTMLPanel
A print dialog is shown first.
print
in interface IXHTMLPanel
PrinterException
public boolean refresh()
Note that the template may or may not be retrieved again from its source.
This happens automatically in ITemplateContainer.setData(java.util.Properties)
and ITemplateContainer.setDocument(nl.nikhef.xhtmlrenderer.swing.TemplateDocument)
.
Actually calls setStep(int)
so that the TemplateWizard.PageListener
and other hooks are properly updated.
refresh
in interface ITemplateContainer
true
public void reloadDocument(Document doc)
IDocumentContainer
reloadDocument
in interface IDocumentContainer
doc
- The document to reload.public void reloadDocument(String URI)
IDocumentContainer
reloadDocument
in interface IDocumentContainer
URI
- A URI for the Document to load, for example, file.toURL().toExternalForm().public void removeMouseTrackingListener(org.xhtmlrenderer.swing.FSMouseListener l)
removeMouseTrackingListener
in interface IXHTMLPanel
public void replaceLinkListener(org.xhtmlrenderer.swing.LinkListener llnew)
IXHTMLPanel
This is a convenience method that first removes all LinkListeners, and then adds the supplied one.
replaceLinkListener
in interface IXHTMLPanel
llnew
- New LinkListener to use for this panelpublic void setData(Properties p)
ITemplateContainer
Also reparses the document and updates the panel, if a template was set.
setData
in interface ITemplateContainer
p
- New properties to setpublic void setDocument(TemplateDocument doc)
ITemplateContainer
setDocument
in interface ITemplateContainer
doc
- template to show, this will be processed with the data
supplied by this container.public void setDocument(TemplateDocument doc, org.xhtmlrenderer.extend.NamespaceHandler nsh)
public void setDocument(Document doc, String url)
IDocumentContainer
setDocument
in interface IDocumentContainer
doc
- The new document valueurl
- The new document valuepublic void setDocument(Document doc)
IDocumentContainer
setDocument
in interface IDocumentContainer
doc
- The document to render.public void setDocument(File file) throws Exception
IDocumentContainer
setDocument
in interface IDocumentContainer
file
- The file to read the Document from. Relative paths
will be resolved based on the file's parent directory.Exception
public void setDocument(InputStream stream, String url, org.xhtmlrenderer.extend.NamespaceHandler nsh)
setDocument
in interface IDocumentContainer
public void setDocument(InputStream stream, String url) throws Exception
IDocumentContainer
setDocument
in interface IDocumentContainer
stream
- The stream to read the Document from.url
- The URL used to resolve relative path references.Exception
public void setDocument(String url, org.xhtmlrenderer.extend.NamespaceHandler nsh)
setDocument
in interface IDocumentContainer
public void setDocument(String uri)
IDocumentContainer
setDocument
in interface IDocumentContainer
public void setDocumentFromString(String content, String url, org.xhtmlrenderer.extend.NamespaceHandler nsh)
setDocumentFromString
in interface IDocumentContainer
public void setFormSubmissionListener(org.xhtmlrenderer.simple.extend.FormSubmissionListener fsl)
setFormSubmissionListener
in interface IXHTMLPanel
public void setSharedContext(org.xhtmlrenderer.layout.SharedContext ctx)
IXHTMLPanel
RenderingContext
attribute of the XHTMLPanel object. Generally
you should not use this unless you have a heavily customized context to
use. To modify just some rendering behavior, consider using
IXHTMLPanel.getSharedContext()
to retrieve the current context, and using
mutators to change its behavior.setSharedContext
in interface IXHTMLPanel
ctx
- A new RenderingContext to use for rendering.public void setSubmitAction(Action e)
ITemplateContainer
If this is set to null, the standard behaviour is done: posting data to the url supplied by the form.
setSubmitAction
in interface ITemplateContainer
public void submit(String query)
submit
in interface org.xhtmlrenderer.simple.extend.FormSubmissionListener
public Component getFormComponent(String name)
ITemplatePanel
Note that multiple radio buttons have the same name, so for these the
name is actually in the form name.value
.
getFormComponent
in interface ITemplatePanel
name
- like myfield
in >input type="text" name="myfield" /<
public Map<String,Component> getFormComponents()
ITemplatePanel
getFormComponents
in interface ITemplatePanel
ITemplatePanel.getFormComponent(java.lang.String)
Copyright © 2010-2018 Nikhef / Stichting FOM. All Rights Reserved.