|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.jadice.swing.SwingUIDocument
public class SwingUIDocument
A UIDocument
for the use with Java AWT/Swing components. All calls to
DocumentListener
s and DocumentInterceptor
s registered with this document will
happen on the the event dispatch thread.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.levigo.jadice.document.Document |
---|
Document.BasicState, Document.State |
Field Summary |
---|
Fields inherited from interface com.levigo.jadice.document.Document |
---|
BASE_RESOLUTION, PROPERTY_KEY_DISPLAY_NAME, PROPERTY_KEY_DOCUMENT_ID, PROPERTY_KEY_FILE_NAME, PROPERTY_NAME, PROPERTY_PREFIX_PAGE, PROPERTY_PREFIX_USER_PROPERTY, PROPERTY_STATE |
Constructor Summary | |
---|---|
protected |
SwingUIDocument(Document doc)
|
Method Summary | |
---|---|
void |
addDocumentInterceptor(DocumentInterceptor interceptor)
Register a DocumentInterceptor to this document instance. |
void |
addDocumentListener(DocumentListener listener)
Register a DocumentListener to this document instance. |
void |
assertOwnership(Component owner)
Assert the given owner as the most recent UI component to own this document. |
boolean |
close()
Closes a Document . |
protected EventList<Page> |
createThreadProxyList(Document doc)
|
void |
dispose()
Disposes of a Document performing necessary clean-up tasks. |
protected void |
exceptionIfDisposed()
|
static UIDocument<Component> |
get(Document doc)
Return a UIDocument suitable for use with the Java AWT/Swing GUI toolkit based on the
given Document . |
Component |
getCurrentOwner()
Get the current owner, i.e. |
Metadata |
getMetadata()
Return the exposed meta-data or null if no meta-data is available. |
String |
getName()
Gets the document's name. |
Page |
getPage(int pageNumber)
Convenience method: return the page at the given page index. |
Page |
getPage(int pageNumber,
boolean create)
Return the page at the given page index. |
int |
getPageCount()
Convenience method: determine the number of pages in this document. |
int |
getPageIndex(Page page)
Convenience method: determine the index of a page in this document. |
EventList<Page> |
getPages()
Returns a list of pages in the document. |
Permissions<Document> |
getPermissions()
Provides an instance of Permissions . |
Map<String,Object> |
getProperties()
Return a map of user properties. |
Document |
getSourceDocument()
Return the source Document instance that this UIDocument is based on or
null . |
Document.State |
getState()
|
boolean |
isDisposed()
Return whether or not this Document has been disposed of. |
void |
removeDocumentInterceptor(DocumentInterceptor interceptor)
Unregister a DocumentInterceptor from this document. |
void |
removeDocumentListener(DocumentListener listener)
Unregister a DocumentListener from this document. |
void |
renounceOwnership(Component owner)
Renounce the ownership of this document by the given owner. |
void |
setName(String name)
Sets the document's name. |
boolean |
setState(Document.State docState)
Sets the current state of the Document . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected SwingUIDocument(Document doc)
Method Detail |
---|
public static UIDocument<Component> get(Document doc)
UIDocument
suitable for use with the Java AWT/Swing GUI toolkit based on the
given Document
. If the given document is already a SwingUIDocument, it is returned
unchanged. Otherwise a SwingUIDocument wrapper to the given document is returned. For a any
given document, only one wrapper is created. If a wrapper as already been created earlier, this
existing instance is returned from this call.
doc
- the document for which to return the SwingUIDocument wrapper.
IllegalStateException
- if called with a document that has been disposed of.protected EventList<Page> createThreadProxyList(Document doc)
public void addDocumentInterceptor(DocumentInterceptor interceptor)
Document
DocumentInterceptor
to this document instance.
addDocumentInterceptor
in interface Document
interceptor
- the interceptor to registerpublic void addDocumentListener(DocumentListener listener)
Document
DocumentListener
to this document instance.
addDocumentListener
in interface Document
listener
- Document.addDocumentListener(com.levigo.jadice.document.DocumentListener)
public void assertOwnership(Component owner)
UIDocument
UIDocument.renounceOwnership(Object)
) or another component asserts the ownership.
assertOwnership
in interface UIDocument<Component>
public boolean close()
Document
Document
. This includes performing a state transition to
Document.BasicState.CLOSED
and cleaning up resources. Both will only happen if all registered
DocumentInterceptor
s agree with the state change. In usual cases, this method should be
preferred to calling Document.dispose()
.
close
in interface Document
Document.close()
public void dispose()
Document
Disposes of a Document
performing necessary clean-up tasks. Disposed Document
s
will have Document.BasicState.CLOSED
as their Document.State
. This method is not expected
to ask registered DocumentInterceptor
s for their consent about the state transition.
DocumentListener
s may or may not be informed about the state change. In most cases,
Document.close()
should be used instead of this method.
Since cleaning up releases any resources held by this Document
, it will no longer be
practically useful afterwards. A Document
which has been disposed of will refuse
further changes on itself and may throw Exceptions if methods are called.
Before calling dispose it is for this reason important to make sure that the Document
to be disposed of is not registered with any other (GUI or non-GUI) component which might call
methods later on.
dispose
in interface Document
public boolean isDisposed()
Document
Document
has been disposed of. Disposed Document
s
will refuse further changes on themselves. Method calls on them may result in Exceptions being
thrown.
isDisposed
in interface Document
true
if this Document
has been disposed of and all of its
resources have been cleaned up. false
if this Document
has not yet
been disposed of and is therefore fully usable.Document.dispose()
public Component getCurrentOwner()
UIDocument
null
.
getCurrentOwner
in interface UIDocument<Component>
null
public String getName()
Document
getName
in interface Document
getName
in interface Item
Document.getName()
public Page getPage(int pageNumber)
Document
Document.getPages()
.get(pageNumber)
. As an added convenience, callers need not
lock the page list in order to be thread-safe.
getPage
in interface Document
pageNumber
- the 0-based index of the page to be returned.
Page
or null
if the page doesn't exist.Document.getPage(int)
public int getPageIndex(Page page)
Document
Document.getPages()
.indexOf(page)
. As an added convenience, callers need not lock
the page list in order to be thread-safe.
getPageIndex
in interface Document
page
- to search for
Document.getPageIndex(com.levigo.jadice.document.Page)
public Page getPage(int pageNumber, boolean create)
Document
getPage
in interface Document
pageNumber
- the 0-based index of the page to be returned.create
- flag indicating if the page should be created if it doesn't exist.
Page
or null
if the page doesn't exist and create
is
false
.Document.getPage(int, boolean)
public int getPageCount()
Document
Document.getPages()
.size()
. As an added convenience, callers need not lock the
page list in order to be thread-safe.
getPageCount
in interface Document
Document.getPageCount()
public EventList<Page> getPages()
Document
EventList
.
As a convenience, a non-thread-safe page list may be wrapped using
GlazedLists.threadSafeList(EventList)
to obtain a thread-safe one.
getPages
in interface Document
Document.getPages()
public Permissions<Document> getPermissions()
PermissionsProvider
Permissions
. Must never return null
.
getPermissions
in interface PermissionsProvider<Document>
Permissions
object.public Map<String,Object> getProperties()
PropertiesProvider
getProperties
in interface PropertiesProvider
public Document.State getState()
getState
in interface Document
Document.getState()
public void removeDocumentInterceptor(DocumentInterceptor interceptor)
Document
DocumentInterceptor
from this document.
removeDocumentInterceptor
in interface Document
interceptor
- the interceptor to removepublic void removeDocumentListener(DocumentListener listener)
Document
DocumentListener
from this document.
removeDocumentListener
in interface Document
listener
- the listener to removeDocument.removeDocumentListener(com.levigo.jadice.document.DocumentListener)
public void renounceOwnership(Component owner)
UIDocument
UIDocument.getCurrentOwner()
will return null
.
renounceOwnership
in interface UIDocument<Component>
public void setName(String name)
Document
setName
in interface Document
name
- The name to setDocument.setName(java.lang.String)
public boolean setState(Document.State docState)
Document
Sets the current state of the Document
.
The document Document.State
is not only a simple information about a document instance, but also
it provides the decision base of the enabled state for many document functionalities. If the
document state is not set or is set to a wrong state, these functionalities may become disabled
or fail to execute.
Registered interceptors may disapprove state changes. Therefore the requested state is not
necessarily the actual next state.
setState
in interface Document
docState
- the new state
true
) or rejected (
false
).Document.State
,
Document.BasicState
,
DocumentInterceptor
public Metadata getMetadata()
MetadataProvider
null
if no meta-data is available. An object being
a MetadataProvider is not required to provide a non-null
meta-data.
getMetadata
in interface MetadataProvider
null
protected void exceptionIfDisposed()
public Document getSourceDocument()
UIDocument
Document
instance that this UIDocument
is based on or
null
. If a UIDocument
has been created based on a existing
Document
instance the original instance can be obtained using this method. If the
UIDocument
is a standalone document, UIDocument.getSourceDocument()
will return itself
(using this
).
getSourceDocument
in interface UIDocument<Component>
Document
instance that this UIDocument
is based on or
null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |