Package eu.bandm.tools.graficUtils
Class TextDialog
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
eu.bandm.tools.graficUtils.TextDialog
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,RootPaneContainer,WindowConstants
- Direct Known Subclasses:
DownloadDialog
Central class for incremental dialog with the user, with protocolling.
Text output is done in html, and input by clicking links.
The whole dialog history stays readable.
The instances are sub-classes which override the
react() method and
check the value of answer for the local url which has been clicked.
All transformation operate on the text form of the data.
Therefore every link must begin verbatim with »<a href=«.
The text lines of one particular interaction step can be added to the window
in multiple calls to appendText(String) and must be well-formed HTML.
Any link which starts with http:// or https:// does only try
a browser remote control and does not count as interaction.
All other href-values terminate the current interaction step and must be
decoded by the user.
Shortcuts by single numeric digit keypresses can be enabled, but are supported
only for a limited number of links (= »{code ...}« substrings),
see DIGITS.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialogNested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe url clicked by the user.static final DimensionDefault size of the swing pop-up window.static final Stringprotected final JEditorPaneevidentprotected booleanWhether the next call to appendText is the first in this step.protected final booleanprotected final Iconprotected KeyListenerAn answer is given by the of the user by pressing one of the shortcut keys.static final StringFor use by subclasses.protected HyperlinkListenerAn answer is given by the of the user by clicking one of the offered links.static final StringHTML tag to replace the "a"- tag to signal the non-selection of a link.(package private) static final Pattern(package private) static final Pattern(package private) static final Patternprotected intCounter of the input-output cycles.Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPEFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTextDialog(@Opt JFrame context, @Opt String windowtitle, boolean isModal, boolean hasShortcuts, PlafIcon.type t, @Opt Dimension size) Only real constructor, all others are just default argument wrappers.protectedTextDialog(JFrame context, String windowtitle, boolean isModal) protectedTextDialog(JFrame context, String windowtitle, boolean isModal, boolean hasShortcuts) protectedTextDialog(JFrame context, String windowtitle, boolean isModal, boolean hasShortcuts, PlafIcon.type t) protectedTextDialog(JFrame context, String windowtitle, boolean isModal, PlafIcon.type t) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendText(String text) Appends the text at the end of the buffer.protected voidappendTextLine(String text) Appends only short (additional) text without any interactive formatting.protected voiddoReact()protected voidfinished()protected voidreact()Callback function, must be overridden by the user.voidService access point to display and run this TextDialog.protected voidTry remote control of the system's browser.protected voidReplaces link appearances.static StringFor use by subclasses.static StringFor use by subclasses.Methods inherited from class javax.swing.JDialog
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, updateMethods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBackMethods inherited from class java.awt.Window
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, toFrontMethods inherited from class java.awt.Container
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, validateTreeMethods inherited from class java.awt.Component
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
-
Field Details
-
LF
For use by subclasses.- See Also:
-
defaultSize
Default size of the swing pop-up window. -
NON_SELECTED_LINK
HTML tag to replace the "a"- tag to signal the non-selection of a link.- See Also:
-
stepNum
protected int stepNumCounter of the input-output cycles. Numbers will be printed as small exponents before the output text. -
firstPara
protected boolean firstParaWhether the next call to appendText is the first in this step. -
answer
The url clicked by the user. Must be read and processed by the payload code. -
epane
evident -
icon
-
hasShortcuts
protected final boolean hasShortcuts -
shortcutlist
-
linklistener
An answer is given by the of the user by clicking one of the offered links. Consequences: The selected link is replaced by emphasized normal text; all others by stroke-out normal text. The variableansweris set and the call-backreact()is called. There the caller may perform the next step of the dialog by adding further HTML text (again with links for reaction) by callingappendText(String). All these steps are numbered visibly. We use the url value of the HTML source text, i.e. not parsed or verified, which is retrieved byHyperlinkEvent.getDescription(). -
DIGITS
- See Also:
-
keylistener
An answer is given by the of the user by pressing one of the shortcut keys. For the reaction seelinklistener. -
PATTERN_close_a
-
PATTERN_open_a
-
PATTERN_close_body
-
-
Constructor Details
-
TextDialog
-
TextDialog
-
TextDialog
-
TextDialog
protected TextDialog(JFrame context, String windowtitle, boolean isModal, boolean hasShortcuts, PlafIcon.type t) -
TextDialog
protected TextDialog(@Opt @Opt JFrame context, @Opt @Opt String windowtitle, boolean isModal, boolean hasShortcuts, PlafIcon.type t, @Opt @Opt Dimension size) Only real constructor, all others are just default argument wrappers.(Please not:
public JDialog(Window owner, String title) Creates a modeless dialog with the specified title and owner Window. ... Parameters: ... title - the String to display in the dialog's title bar or null if the dialog has no title
is THE ONLY PLACE where there is anything said about "title==null". We ASSUME that title is OPT String.)- Parameters:
context- the frame to which the dialog is relatedwindowtitle- the text in the window's title barisModal- whether the main frame cannot receive veents until this Dialog window is closed.hasShortcuts- whether the possible clicks can be activated by number nputt- the icon type which distinguisehs warnings, info, etc. (Icons for decorating or representing the window are a different this and can be set by explicitly invokingWindow.setIconImages(List), etc.)size- evident.
-
-
Method Details
-
wrapTT
For use by subclasses. Wrap into green bold teletype, for input/output examples. etc. -
wrapError
For use by subclasses. Wratp into red color for error messages. -
transformLinks
protected void transformLinks()Replaces link appearances. Is normally called immediately after a decisive click. Links are transformed as follows: (read square brackets for angle brackets) :[a href='xxx']yyy[/a] --> [b]yyy[/b] iff xxx==answer --> [strike]yyy[/strike] otherwise -
appendText
Appends the text at the end of the buffer. Technically the HTML must be decoded and the new text inserted befofePATTERN_close_body. If this is not the first step in the dialog process, but the first call in this step, then the step number is visibly represented. -
appendTextLine
Appends only short (additional) text without any interactive formatting. -
runDialog
public void runDialog()Service access point to display and run this TextDialog. -
doReact
protected void doReact() -
showURI
Try remote control of the system's browser. Here no message channel is available, but this method can be overridden by are more instrumented version. -
react
protected void react()Callback function, must be overridden by the user. It must execute the appropriate reactions, guided by the value ofanswer, which is (the raw source text of) the url selected by the user. Default behaviour is to close the dialog. -
finished
protected void finished()
-