ewe.ui
Class HtmlViewer

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.Container
              extended byewe.ui.Canvas
                  extended byewe.ui.Panel
                      extended byewe.ui.CellPanel
                          extended byewe.ui.FormBase
                              extended byewe.ui.Form
                                  extended byewe.ui.Editor
                                      extended byewe.ui.AppForm
                                          extended byewe.ui.HtmlViewer
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, FieldListener, HasProperties, ImageRefresher, IScroll, LayoutManager, ScrollClient, TimerProc, UIConstants
Direct Known Subclasses:
WebBrowser

public class HtmlViewer
extends AppForm

This is a useful Form that you can use to display HTML files. It consists of an HtmlDisplay along with optional controls.

The


Nested Class Summary
protected  class HtmlViewer.HtmlViewerDisplay
           
 
Field Summary
 boolean animatedImages
          Specifies if animated images should be allowed - true on some systems by default.
 TextCodec codec
          This is the codec that will be used to decode text.
static int DISPLAY_NO_OPEN
          A display option for the constructor.
static int DISPLAY_NO_STATUS_BAR
          A display option for the constructor.
static int DISPLAY_NO_TABS
          A display option for the constructor.
static int DISPLAY_NO_TOOL_BUTTONS
          A display option for the constructor.
 FontChooser fontChooser
           
 PropertyList htmlProperties
           
static String[] images
           
protected  Handle loading
           
 boolean showImages
          Specifies if images should be displayed - true by default.
 String status
           
protected  CardPanel statusCard
           
 
Fields inherited from class ewe.ui.AppForm
chosenMenuItem, data, isAutoExpandingTabs, menus, SHOW_EXIT_BUTTON, SHOW_NEW_BUTTON, SHOW_OPEN_BUTTON, SHOW_SAVE_AS_BUTTON, SHOW_SAVE_BUTTON, tabs, tools
 
Fields inherited from class ewe.ui.Editor
coroutineStackSize, currentEvent, DoDataTransfer, fieldListeners, fieldsWillNotBeAdded, myObject, objectClass, sampleObject, transfers
 
Fields inherited from class ewe.ui.Form
acceptsDroppedFiles, apply, back, buttons, BUTTONS_TO_SOFT_KEY_FIRST_BUTTON_SEPARATE, BUTTONS_TO_SOFT_KEY_MENU_ALWAYS, BUTTONS_TO_SOFT_KEY_USE_FIRST_SOFT_KEY, buttonsPanel, buttonsPerRow, cancel, deflt, dismantleOnClose, exitButtonDefined, exitSystemOnClose, exitValue, firstFocus, formFrame, globalIcon, handle, hasTopBar, keepFrame, moveable, no, noBorder, ok, pl, reset, resizable, resizeOnSIP, taskbarIcon, title, titleCancel, titleControls, titleOK, topControls, untitledTitle, windowFlagsToClear, windowFlagsToSet, windowIcon, windowTitle, yes
 
Fields inherited from class ewe.ui.FormBase
BACKB, CANCELB, close, cross, defaultShowOptions, DEFCANCELB, DEFOKB, EXIT_IDBACK, EXIT_IDCANCEL, EXIT_IDNO, EXIT_IDOK, EXIT_IDYES, IDBACK, IDCANCEL, IDNO, IDOK, IDYES, MBB, MBNONE, MBOK, MBOKCANCEL, MBYESNO, MBYESNOCANCEL, NOB, OKB, stop, tick, YESB
 
Fields inherited from class ewe.ui.CellPanel
autoSpan, equalHeights, equalWidths, layout, mySplitter, nextSplitter, quickRecalculate
 
Fields inherited from class ewe.ui.Panel
all, backgroundImage, calculated, childListeners, defaultAddToMeCellConstraints, defaultTags, grid, lastAdded, layoutManager, made, noInsets, stretchFirstColumn, stretchFirstRow, stretchLastColumn, stretchLastRow, titleGap
 
Fields inherited from class ewe.ui.Canvas
isFullScrollClient, origin, scrollPercent, virtualSize
 
Fields inherited from class ewe.ui.Container
closedFocus, cycleFocus, dontAutoScroll, dontFocusOnChildren
 
Fields inherited from class ewe.ui.Control
_debug, backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, DoPaintMethod, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, foreGround, haveNativePaint, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, MyClass, name, next, np, parent, penStatus, popupSound, popupSoundClip, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, standardBorder, standardEdge, startDragResolution, tags, tail, text, toolTip, width, x, y
 
Fields inherited from class ewe.ui.ControlBase
clipItems, clipObject, clipOwner, curPoint, currentPenEvent, debugControl, debugFlag, DidHoldDown, doubleBuffer, doubleClickTime, firstPress, globalDrawFlat, globalEditable, globalEnabled, globalPalmStyle, globalSmallControls, GotPenDown, PenIsOn, pressPoint, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed, useNativeTextInput
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.IScroll
Higher, Horizontal, Lower, OPTION_INDICATOR_ONLY, PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTo, Vertical
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Fields inherited from interface ewe.fx.ImageRefresher
KEEP_VISIBLE
 
Constructor Summary
HtmlViewer()
          Create the viewer with full tools.
HtmlViewer(HtmlDisplay display, int displayOptions)
          Create the viewer with a particular HtmlDisplay and using the specified display options.
HtmlViewer(int displayOptions)
          Create the viewer the specified display options.
 
Method Summary
 void action(String fieldName, Editor ed)
          This gets called by action(FieldTransfer ft,Editor ed) and by fieldChanged(FieldTransfer ft,Editor ed) if the field changed is a menu item.
protected  void addPropertiesTo(PropertyList pl)
           
 FormattedTextMaker cacheOpened(String name, FormattedTextMaker maker)
           
 void cancelLoading(boolean startingNewLoad)
          Use this to cancel a load/decode operation.
protected  HtmlDisplay createDisplay()
           
 Handle doOpen(String fileOrUrl)
          Open the file relative to the current document root, or as a new document/file.
protected  void endedLoad(Handle h)
           
 void fieldChanged(String fieldName, Editor ed)
          This gets called by fieldChanged(FieldTransfer ft,Editor ed).
 void filesDropped(String[] fileName)
          This is called when files are dropped on the Form and acceptsDroppedFiles is true.
 FormattedTextMaker findCached(String name)
           
 TextCodec getCodec()
           
 String getCurrentURL()
           
 void goBack()
          Go to previous document/location.
protected  boolean hotspotPressed(HotSpot hs, Point where)
           
static void main(String[] args)
           
protected  void newDocumentLoaded(String url)
           
protected  void noLoading()
           
 void open()
          Open a new file.
 void open(FormattedTextMaker maker)
           
 FormattedTextMaker open(String name)
           
 FormattedTextMaker open(String data, String fileName)
           
static HtmlViewer openAndDisplay(String url, int displayOptions, boolean execute)
           
protected  Handle openDocument(String url, PropertyList pl)
           
 void reload()
          Reload the current document.
 void removeCached(String name)
           
 void setDisplayFont(Font f)
          Set the display font.
 void setHtml(FormattedTextMaker html)
           
 Handle setHtml(Link link)
          Tell the viewer to load and display the Link.
 Handle setHtml(Object htmlText, String urlToDisplay, String bookmark)
          Set the Html text directly.
 FormattedTextMaker setHtml(String html, PropertyList props, Handle h)
           
 Handle setHtml(URL url)
          Tell the viewer to load and display the URL.
 void setupProperties()
          Setup the htmlProperties based on selected options.
protected  void startingLoad(Handle h)
           
protected  String toFullURL(String root, String document)
          This returns a String ONLY if the String is the name of a VALID URL resource.
 void update()
           
 
Methods inherited from class ewe.ui.AppForm
addExpandingTool, addExpandingTool, addStandardFileMenu, addStandardFileMenu, addToolButton, addToolButton, getStandardFileCommands, setupStandardFileCommands, setupStandardFileCommands
 
Methods inherited from class ewe.ui.Editor
action, addExternalField, addExternalField, addField, addField, addField, canExit, dataChanged, dataChanged, dismantle, enableScrolling, fieldChanged, fieldEvent, findControlFor, findFields, findFieldTransfer, findFieldTransfer, findFieldTransfer, fireFieldChanged, fireFieldEvent, fireFieldEvent, formClosing, fromControls, fromControls, fromControls, fromControls, getData, getFileSaver, handleTransferError, make, modifyFields, onControlEvent, onDataChangeEvent, postEditorEvent, setData, setFields, setFileSaver, setObject, shown, toControls, toControls, toControls, toControls, transfer, transfer
 
Methods inherited from class ewe.ui.Form
_getSetField, addButton, addTabbedPanel, addToolbar, buttonsToMenu, buttonsToSoftKeyBar, buttonsToSoftKeyBar, cancelWait, checkButtons, close, closeAll, closeForTransfer, closeForTransfer, continueWait, createMenuItem, createMenuItem, createMenuItem, createWindow, defaultTitleTo, doButtons, doShowExec, exec, exec, exec, exec, exec, exec, exec, exec, exec, execute, execute, execute, exit, formShown, gatherButtons, getButton, getFirstFocus, getFormFrame, getProperties, getSoftKeyBarFor, getTopmostForm, handleAction, handleAction, hasExitButton, makeButtonForForm, makeButtonForForm, makeDefaultButton, makeDefaultButton, makeFrame, makeMenuItemForForm, makeMenuItemForForm, makeSoftKeys, makeSoftKeys, mb, menuItemSelected, modifyForSmartPhone, onEvent, onSoftKey, placeCancelOnLeft, removeSoftKeyBarFor, setOKCancel, setSoftKeyBarFor, setSoftKeyBarForAll, setTitle, setTopLevelTitle, setupFrame, show, show, show, show, show, show, showWait, stopFormHandle, toolsOnBottom, waitUntilClosed, waitUntilClosed, waitUntilClosed, waitUntilClosed, waitUntilPainted
 
Methods inherited from class ewe.ui.CellPanel
calculateSizes, makeLayoutGrid, relayout, relayoutMe, removeAll, reShow, resize, resizeTo
 
Methods inherited from class ewe.ui.Panel
add, addChildListener, addDirectly, addLast, addLast, addNext, addNext, addNext, doBackground, doBorder, endRow, getControlTag, getPreferredSize, getSubControls, isEmpty, layout, remove, removeChildListener, sendToChildListeners, setText
 
Methods inherited from class ewe.ui.Canvas
canGo, canScreenScroll, checkScrolls, doScroll, fixOrigin, getActual, getBuffer, getCurrent, getDisplayedSize, getMySize, getPercent, getScrollablePanel, getScrollClient, getVisible, getVisibleArea, needScrollBar, onScroll, onSetOrigin, reduceClip, scroll, scroll, scrollToVisible, setOrigin, updateScrollServer
 
Methods inherited from class ewe.ui.Container
_paintChildren, add, containerHasFocus, dismantle, doHotKey, findChild, focusFirst, focusFirst, focusOnContainer, focusOnData, getChildren, getChildrenBackwards, getNextKeyFocus, gotFocus, lostFocus, repaintDataNow, takeFocus, takePromptControl
 
Methods inherited from class ewe.ui.Control
acceptsData, activate, addListener, addTimer, amOnTopFrame, calculateTextSize, cancelCut, cancelHoldDown, canEdit, chainDataChange, change, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkPenTransparent, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createGraphics, dataAccepted, dataBeingRemoved, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, dataTransferCancelled, deactivate, defaultTo, doAction, doActionKey, doMenu, dontAcceptDrop, doPaint, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doPaintData, doShowMenu, dragged, exitEntry, fillBackground, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getBackground, getClipboardMenu, getClipObject, getControlBuffer, getControlBuffer, getDataRect, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFont, getFontMetrics, getFontMetrics, getForeground, getFrame, getFrameOrContainer, getGraphics, getImage, getLastSelected, getLocation, getMaximumSize, getMenu, getMinimumSize, getModifiers, getNext, getParent, getPasswordCharacter, getPosInFrame, getPosInParent, getPreferredSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getTag, getText, getToolTip, getWindow, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onKeyEvent, onLabelPenEvent, onPaint, onPenEvent, paintBackground, paintChildren, penClicked, penDoubleClicked, penHeld, penPressed, penReleased, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, postEvent, recalculatePreferredSize, redisplay, refresh, removeListener, removeTimer, repaint, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetRect, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, setTextSize, setToolTip, show, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, startDragging, stopDragging, takeData, takeFromClipboard, testDim, ticked, toClipboard, toField, toField, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryNext, tryStartMenu, updateData, willAcceptDrop, willShowFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 
Methods inherited from interface ewe.ui.ScrollClient
getServer, setServer
 

Field Detail

htmlProperties

public PropertyList htmlProperties

fontChooser

public FontChooser fontChooser

showImages

public boolean showImages
Specifies if images should be displayed - true by default.


animatedImages

public boolean animatedImages
Specifies if animated images should be allowed - true on some systems by default.


DISPLAY_NO_STATUS_BAR

public static final int DISPLAY_NO_STATUS_BAR
A display option for the constructor.

See Also:
Constant Field Values

DISPLAY_NO_TOOL_BUTTONS

public static final int DISPLAY_NO_TOOL_BUTTONS
A display option for the constructor.

See Also:
Constant Field Values

DISPLAY_NO_TABS

public static final int DISPLAY_NO_TABS
A display option for the constructor.

See Also:
Constant Field Values

DISPLAY_NO_OPEN

public static final int DISPLAY_NO_OPEN
A display option for the constructor.

See Also:
Constant Field Values

status

public String status

statusCard

protected CardPanel statusCard

codec

public TextCodec codec
This is the codec that will be used to decode text. If it is null then an AsciiCodec will be used.


loading

protected Handle loading

images

public static String[] images
Constructor Detail

HtmlViewer

public HtmlViewer()
Create the viewer with full tools.


HtmlViewer

public HtmlViewer(int displayOptions)
Create the viewer the specified display options.

Parameters:
displayOptions - This can be any of the : DISPLAY_XXX options ORed together.

HtmlViewer

public HtmlViewer(HtmlDisplay display,
                  int displayOptions)
Create the viewer with a particular HtmlDisplay and using the specified display options.

Parameters:
display - An HtmlDisplay to use (can be null).
displayOptions - This can be any of: DISPLAY_NO_STATUS_BAR, DISPLAY_NO_TOOL_BUTTONS, DISPLAY_NO_TABS OR'ed together.
Method Detail

getCodec

public TextCodec getCodec()

toFullURL

protected String toFullURL(String root,
                           String document)
This returns a String ONLY if the String is the name of a VALID URL resource. This could be a file name.

Parameters:
root - The current document root.
document - The document being referred to.
Returns:
the URL as a String if it is valid and can be retrieved by the Viewer.

openDocument

protected Handle openDocument(String url,
                              PropertyList pl)

hotspotPressed

protected boolean hotspotPressed(HotSpot hs,
                                 Point where)

noLoading

protected void noLoading()

startingLoad

protected void startingLoad(Handle h)

endedLoad

protected void endedLoad(Handle h)

getCurrentURL

public String getCurrentURL()

newDocumentLoaded

protected void newDocumentLoaded(String url)

setHtml

public Handle setHtml(URL url)
Tell the viewer to load and display the URL.

Parameters:
url - The url which can be an http:// url or a file name. It can also be relative to the current document.
Returns:
A Handle that can be used to monitor the progress of the display.

setHtml

public Handle setHtml(Link link)
Tell the viewer to load and display the Link. A Link can be a URL in text form or it can be a file name or an anchor ('#') to a bookmark in the current document.

Parameters:
link - The link which can be an "http://" url or a file name. It can also be relative to the current document.
Returns:
A Handle that can be used to monitor the progress of the display.

setHtml

public Handle setHtml(Object htmlText,
                      String urlToDisplay,
                      String bookmark)
Set the Html text directly.

Parameters:
htmlText - An object representing htmlText. This can be:
  • A ewe.net.URL holding the URL you want the browser to fetch.
  • A ewe.net.Link holding the URL or file that you want the browser to fetch.
  • A String holding the HTML text.
  • A ewe.util.ByteArray holding the text encoded HTML text.
  • A byte array (byte[]) holding the text encoded HTML.
  • A ewe.io.Streamable object from which the text can be read.
urlToDisplay - The URL to display for the data.
bookmark - An optional bookmark in the file to go to.
Returns:
A Handle that can be used to monitor the progress of the display.

setupProperties

public void setupProperties()
Setup the htmlProperties based on selected options.


cancelLoading

public void cancelLoading(boolean startingNewLoad)
Use this to cancel a load/decode operation. If you intend to immediately start another load using doOpen() then set startingNewLoad to true.


doOpen

public Handle doOpen(String fileOrUrl)
Open the file relative to the current document root, or as a new document/file.

Returns:
A Handle with which the progress of the load can be monitored.

createDisplay

protected HtmlDisplay createDisplay()

setHtml

public void setHtml(FormattedTextMaker html)

setHtml

public FormattedTextMaker setHtml(String html,
                                  PropertyList props,
                                  Handle h)

addPropertiesTo

protected void addPropertiesTo(PropertyList pl)

open

public FormattedTextMaker open(String data,
                               String fileName)

open

public void open(FormattedTextMaker maker)

findCached

public FormattedTextMaker findCached(String name)

cacheOpened

public FormattedTextMaker cacheOpened(String name,
                                      FormattedTextMaker maker)

removeCached

public void removeCached(String name)

open

public FormattedTextMaker open(String name)

action

public void action(String fieldName,
                   Editor ed)
Description copied from class: Editor
This gets called by action(FieldTransfer ft,Editor ed) and by fieldChanged(FieldTransfer ft,Editor ed) if the field changed is a menu item. By default it will look for a method called void _action(Editor ed) and if it finds it, it will be executed.

Overrides:
action in class Editor

goBack

public void goBack()
Go to previous document/location. Acts as if the go back button had been pressed.


open

public void open()
Open a new file. Acts as if the open button had been pressed.


reload

public void reload()
Reload the current document. Acts as if the reload button had been pressed.


fieldChanged

public void fieldChanged(String fieldName,
                         Editor ed)
Description copied from class: Editor
This gets called by fieldChanged(FieldTransfer ft,Editor ed). By default it will look for a method called void _changed(Editor ed) and if it finds it, it will be executed.

Overrides:
fieldChanged in class Editor

update

public void update()

filesDropped

public void filesDropped(String[] fileName)
Description copied from class: Form
This is called when files are dropped on the Form and acceptsDroppedFiles is true.

Overrides:
filesDropped in class Form
Parameters:
fileName - the list of fileNames dropped.

setDisplayFont

public void setDisplayFont(Font f)
Set the display font.


openAndDisplay

public static HtmlViewer openAndDisplay(String url,
                                        int displayOptions,
                                        boolean execute)

main

public static void main(String[] args)