|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.lightdev.app.shtm.DocumentPane
public class DocumentPane
GUI representation of a document.
Swing already uses three types of classes to implement a model, view, controller (MVC) approach for a document:
JTextComponent - the view implementation
Document - the model implementation
EditorKit - the controller implementation
For a GUI representation of a document, additional parts are needed, such as a JScrollPane as well as listeners and fields to track the state of the document while it is represented on a GUI.
DocumentPane
wraps all those elements to implement a single
document centric external view to all elements.
If for instance an application wants to create a new document, it simply creates an instance of this class instead of having to implement own methods for instatiating each element (editor pane, scroll pane, etc.) separately.
Nested Class Summary | |
---|---|
class |
DocumentPane.DocumentPaneEvent
the event object definition for DocumentPaneEvents |
static interface |
DocumentPane.DocumentPaneListener
interface to be implemented for being notified of changes to the name of this document |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_STYLE_SHEET_NAME
default name for style sheet, when saved |
boolean |
saveSuccessful
indicator if a save operation was succesful |
java.lang.Thread |
saveThread
the save thread, if a save operation is in progress |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
DocumentPane()
construct a new DocumentPane . |
|
DocumentPane(java.net.URL docToLoad,
int newDocNo)
construct a new DocumentPane with either a new Document or an exisiting Document that is to be loaded into the DocumentPane upon construction. |
Method Summary | |
---|---|
void |
addDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
add a DocumentPaneListener to this Document |
void |
changedUpdate(javax.swing.event.DocumentEvent e)
listens to changes on the document to track whether or not the document needs to be saved. |
void |
createNewDocument()
create a new HTMLDocument and attach it to the editor |
void |
deleteTempDir()
remove the temporary storage created for this DocumentPane |
void |
fireActivated()
fire a DocumentPaneEvent to all registered DocumentPaneListeners |
void |
fireNameChanged()
fire a DocumentPaneEvent to all registered DocumentPaneListeners |
javax.swing.text.Document |
getDocument()
get the document of this DocumentPane |
java.lang.String |
getDocumentName()
get the name of the document of this pane. |
SHTMLEditorPane |
getEditor()
get the JEditorPane of this DocumentPane |
java.io.File |
getImageDir()
determine the directory this DocumentPane references image
files from |
java.net.URL |
getOldSource()
get the source, this document was having before its current sourceUrl was set. |
java.net.URL |
getSource()
get the source this document can be loaded from |
void |
insertUpdate(javax.swing.event.DocumentEvent e)
listens to inserts into the document to track whether or not the document needs to be saved. |
boolean |
isNewDoc()
indicates whether or not this document was newly created and not saved so far. |
void |
loadDocument(java.net.URL url)
load a document found at a certain URL. |
boolean |
needsSaving()
indicates whether or not the document needs to be saved. |
void |
removeAllListeners()
remove all listeners |
void |
removeDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
remove a DocumentPaneListener from this Document |
void |
removeUpdate(javax.swing.event.DocumentEvent e)
listens to removes from the document to track whether or not the document needs to be saved. |
void |
saveDocument()
saves the document to the file specified in the source of the DocumentPane and creates the associated style sheet. |
boolean |
saveInProgress()
indicates whether or not a save process is in progress |
void |
saveStyleSheet()
save the style sheet of this document to a CSS file. |
void |
setDocument(javax.swing.text.Document docToSet)
|
void |
setSource(java.net.URL source)
set the source this document is to be loaded from |
void |
stateChanged(javax.swing.event.ChangeEvent e)
|
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.lang.Thread saveThread
public boolean saveSuccessful
public static java.lang.String DEFAULT_STYLE_SHEET_NAME
Constructor Detail |
---|
public DocumentPane()
DocumentPane
.
A document still has to be either created or loaded after using this constructor, so it is better to use the constructor doing this right away instead.
public DocumentPane(java.net.URL docToLoad, int newDocNo)
docToLoad
- the document to be loaded. If this is null, a new
Document is created upon construction of the DocumentPanenewDocNo
- the number a new document shall have in the
title as long as it is not saved (such as in 'Untitled1'). If an
existing document shall be loaded, this number is ignoredMethod Detail |
---|
public SHTMLEditorPane getEditor()
JEditorPane
of this DocumentPane
public void createNewDocument()
public void setDocument(javax.swing.text.Document docToSet)
public void deleteTempDir()
DocumentPane
public void loadDocument(java.net.URL url)
url
- the URL to look for the documentpublic void saveDocument() throws DocNameMissingException
DocumentPane
and creates the associated style sheet.
The actual save process only is done, when there is a name to save
to. The class(es) calling this method have to make sure that a
name for new documents is requested from the user, for instance.
The desired name and location for the save need then to be set using method
setSource prior to a call to this method
DocNameMissingException
- to ensure the caller gets notified
that a save did not take place because of a missing name
and locationpublic java.io.File getImageDir()
DocumentPane
references image
files from
DocumentPane
are foundpublic boolean saveInProgress()
public void saveStyleSheet() throws java.io.IOException
With stage 8 this saves a style sheet by merging with an existing one with the same name/location. Styles in this style sheet overwrite styles in the existing style sheet.
java.io.IOException
public java.lang.String getDocumentName()
public boolean needsSaving()
public void setSource(java.net.URL source)
This is only to be used when it is made sure, that the document is saved at the location specified by 'source'.
the
- URL of the source this document is to be loaded frompublic java.net.URL getOldSource()
public java.net.URL getSource()
public boolean isNewDoc()
public javax.swing.text.Document getDocument()
DocumentPane
Document
of this DocumentPane
public void stateChanged(javax.swing.event.ChangeEvent e)
stateChanged
in interface javax.swing.event.ChangeListener
public void insertUpdate(javax.swing.event.DocumentEvent e)
insertUpdate
in interface javax.swing.event.DocumentListener
public void removeUpdate(javax.swing.event.DocumentEvent e)
removeUpdate
in interface javax.swing.event.DocumentListener
public void changedUpdate(javax.swing.event.DocumentEvent e)
changedUpdate
in interface javax.swing.event.DocumentListener
public void addDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
listener
- the listener object to addpublic void removeDocumentPaneListener(DocumentPane.DocumentPaneListener listener)
listener
- the listener object to removepublic void fireNameChanged()
public void fireActivated()
public void removeAllListeners()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |