Interface Document
- All Superinterfaces:
com.google.gwt.user.client.rpc.IsSerializable
,Item
,MetadataProvider
,PermissionsProvider<Document>
,PropertiesProvider
- All Known Subinterfaces:
SerializableDocument
- All Known Implementing Classes:
FilteredDocument
- The first dimension are the
Page
s. Pages are mere containers for data which can be displayed or manipulated. Each page consists of 1-nAbstractPageSegment
s, which occupy the document's layers for a page (see below). - The second dimension are the layers. Layers are virtual slots in the stack of data which represents a page. Layers are defined for the document as a whole, but pages are not required to have a page segment for each defined layer.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
An enum consisting of the default document states.static interface
This is a marker interface to be implemented by objects serving as state designators for documents. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The base resolution.static final String
A user property key for the name of the document to be presented to users such as in a window title bar etc..static final String
A user property key for the ID of an item in an archive with which the document is associated.static final String
A user property key for the name of the file from which the document originated.static final String
Property change key for the 'name' property.static final String
A property name prefix used for bridged property changes from pages.static final String
A property name prefix used for bridged property changes from user properties.static final String
Property change key for the 'state' property. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDocumentInterceptor
(DocumentInterceptor interceptor) Register aDocumentInterceptor
to this document instance.void
addDocumentListener
(DocumentListener listener) Register aDocumentListener
to this document instance.boolean
close()
Closes aDocument
.void
dispose()
Disposes of aDocument
performing necessary clean-up tasks.getName()
Gets the document's name.getPage
(int pageIndex) Convenience method: return the page at the given page index.getPage
(int pageIndex, boolean create) Return the page at the given page index.int
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.org.jadice.util.glazedlists.EventList<Page>
getPages()
Returns a list of pages in the document.getState()
boolean
Return whether or not thisDocument
has been disposed of.void
removeDocumentInterceptor
(DocumentInterceptor interceptor) Unregister aDocumentInterceptor
from this document.void
removeDocumentListener
(DocumentListener listener) Unregister aDocumentListener
from this document.void
Sets the document's name.boolean
setState
(Document.State state) Sets the current state of theDocument
.Methods inherited from interface com.levigo.jadice.document.metadata.MetadataProvider
getMetadata
Methods inherited from interface com.levigo.jadice.document.PermissionsProvider
getPermissions
Methods inherited from interface com.levigo.jadice.document.util.PropertiesProvider
getProperties
-
Field Details
-
PROPERTY_STATE
Property change key for the 'state' property.- See Also:
-
PROPERTY_NAME
Property change key for the 'name' property.- See Also:
-
PROPERTY_PREFIX_PAGE
A property name prefix used for bridged property changes from pages.- See Also:
-
PROPERTY_PREFIX_USER_PROPERTY
A property name prefix used for bridged property changes from user properties.- See Also:
-
PROPERTY_KEY_FILE_NAME
A user property key for the name of the file from which the document originated.- See Also:
-
PROPERTY_KEY_DISPLAY_NAME
A user property key for the name of the document to be presented to users such as in a window title bar etc..- See Also:
-
PROPERTY_KEY_DOCUMENT_ID
A user property key for the ID of an item in an archive with which the document is associated.- See Also:
-
BASE_RESOLUTION
static final int BASE_RESOLUTIONThe base resolution. All calculations are based on this resolution. The base resolution is currently a 7200'th of an inch.- See Also:
-
-
Method Details
-
addDocumentListener
Register aDocumentListener
to this document instance.- Parameters:
listener
- the listener to register- Throws:
IllegalArgumentException
- if parameter isnull
IllegalStateException
- if called on aDocument
which has been disposed of
-
addDocumentInterceptor
Register aDocumentInterceptor
to this document instance.- Parameters:
interceptor
- the interceptor to register- Throws:
IllegalArgumentException
- if parameter isnull
IllegalStateException
- if called on aDocument
which has been disposed of.
-
close
boolean close()Closes aDocument
. This includes performing a state transition toDocument.BasicState.CLOSED
and cleaning up resources. Both will only happen if all registeredDocumentInterceptor
s agree with the state change. In usual cases, this method should be preferred to callingdispose()
.- Returns:
- flag indicating whether the process passed successfully or not
- See Also:
-
dispose
void dispose()Disposes of a
Document
performing necessary clean-up tasks. DisposedDocument
s will haveDocument.BasicState.CLOSED
as theirDocument.State
. This method is not expected to ask registeredDocumentInterceptor
s for their consent about the state transition.DocumentListener
s may or may not be informed about the state change. In most cases,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. ADocument
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. -
isDisposed
boolean isDisposed() -
getName
String getName()Gets the document's name. -
getPage
Convenience method: return the page at the given page index. Equivalent to
. As an added convenience, callers need not lock the page list in order to be thread-safe.getPages()
.get(pageNumber)- Parameters:
pageIndex
- the 0-based index of the page to be returned.- Returns:
- a
Page
ornull
if the page doesn't exist.
-
getPage
Return the page at the given page index. Create it, if there is no page at this index at this point. As an added convenience, callers need not lock the page list in order to be thread-safe.- Parameters:
pageIndex
- the 0-based index of the page to be returned.create
- flag indicating if the page should be created if it doesn't exist.- Returns:
- a
Page
ornull
if the page doesn't exist andcreate
isfalse
. - Throws:
IndexOutOfBoundsException
- if pageIndex < 0IllegalStateException
- if called with parametercreate==true
on aDocument
which has been disposed of
-
getPageCount
int getPageCount()Convenience method: determine the number of pages in this document. Equivalent to
. As an added convenience, callers need not lock the page list in order to be thread-safe.getPages()
.size()- Returns:
- int the page number count
-
getPageIndex
Convenience method: determine the index of a page in this document. Equivalent to
. As an added convenience, callers need not lock the page list in order to be thread-safe.getPages()
.indexOf(page)- Parameters:
page
- to search for- Returns:
- int the page number of the given page in this document, or -1 if this document does not contain the page
- Throws:
NullPointerException
- if the page isnull
-
getPages
org.jadice.util.glazedlists.EventList<Page> getPages()Returns a list of pages in the document. Please note that, unless stated otherwise by implementors, this list is not thread-safe. Care must therefore be taken to manipulate the page list with appropriate locking as detailed in the documentation ofEventList
. As a convenience, a non-thread-safe page list may be wrapped usingGlazedLists.threadSafeList(EventList)
to obtain a thread-safe one.- Returns:
- List of pages
- Throws:
IllegalStateException
- if called on aDocument
which has been disposed of.
-
removeDocumentListener
Unregister aDocumentListener
from this document.- Parameters:
listener
- the listener to remove
-
removeDocumentInterceptor
Unregister aDocumentInterceptor
from this document.- Parameters:
interceptor
- the interceptor to remove
-
setName
Sets the document's name.- Parameters:
name
- The name to set- Throws:
IllegalStateException
- if called on aDocument
which has been disposed of.
-
getState
Document.State getState() -
setState
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.- Parameters:
state
- the new state- Returns:
- whether the state change was successful (
true
) or rejected (false
). - Throws:
IllegalStateException
- if called on aDocument
which has been disposed of.- See Also:
-