public abstract class AbstractModel<T extends Component<T>> extends Object implements Model<T>, UndoableEditListener
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractModel.ModelUndoableEdit |
protected class |
AbstractModel.ModelUndoableEditSupport |
Model.State
Modifier and Type | Field and Description |
---|---|
protected AbstractModel.ModelUndoableEditSupport |
ues |
STATE_PROPERTY
Constructor and Description |
---|
AbstractModel(ModelSource source) |
Modifier and Type | Method and Description |
---|---|
void |
addComponentListener(ComponentListener cl)
Removes component event listener.
|
void |
addPropertyChangeListener(PropertyChangeListener pcl)
Add property change listener which will receive events for any element
in the underlying schema model.
|
void |
addUndoableEditListener(UndoableEditListener uel)
Adds undoable edit listener.
|
void |
addUndoableRefactorListener(UndoableEditListener uel)
Adds undoable refactoring edit listener.
|
protected CompoundEdit |
createModelUndoableEdit() |
void |
endTransaction()
Ends the transaction and commits changes to the document.
|
protected void |
endTransaction(boolean quiet) |
protected void |
finishTransaction() |
void |
fireComponentChangedEvent(ComponentEvent evt) |
void |
firePropertyChangeEvent(PropertyChangeEvent event) |
abstract ModelAccess |
getAccess() |
ModelSource |
getModelSource() |
Model.State |
getState() |
boolean |
inSync()
Returns true if sync is being performed.
|
boolean |
inUndoRedo()
Indicates if the model in Undo/Redo stage.
|
boolean |
isAutoSyncActive() |
boolean |
isIntransaction()
Be very careful while using this method.
|
protected boolean |
needsSync()
This method is overridden by subclasses to determine if sync needs to be
performed.
|
protected void |
refresh()
Refresh the domain model component trees.
|
void |
removeComponentListener(ComponentListener cl)
Adds coarse-grained change listener for events on model components.
|
void |
removePropertyChangeListener(PropertyChangeListener pcl)
Remove property change listener.
|
void |
removeUndoableEditListener(UndoableEditListener uel)
Removes undoable edit listener.
|
void |
removeUndoableRefactorListener(UndoableEditListener uel)
Removes undoable refactoring edit listener.
|
void |
rollbackTransaction()
The method does nothing if the transaction hasn't been started or
started by another thread.
|
void |
setAutoSyncActive(boolean v) |
protected void |
setInSync(boolean v) |
protected void |
setInUndoRedo(boolean v) |
protected void |
setState(Model.State s) |
boolean |
startedFiringEvents()
Whether the model has started firing events.
|
boolean |
startTransaction()
This method will block until a transaction can be started.
|
void |
sync()
Makes the current memory model consistent with the underlying
representation, typically a swing document.
|
protected void |
syncCompleted()
This method is invoked when sync has completed.
|
protected void |
syncStarted()
This method is invoked when sync has started.
|
protected void |
transactionCompleted()
This method is invoked when a transaction has completed.
|
protected void |
transactionStarted()
This template method is invoked when a transaction is started.
|
void |
undoableEditHappened(UndoableEditEvent e) |
void |
validateWrite()
This method ensures that a transaction is currently in progress and
that the current thread is able to write.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addChildComponent, removeChildComponent
protected AbstractModel.ModelUndoableEditSupport ues
public AbstractModel(ModelSource source)
public abstract ModelAccess getAccess()
public void removePropertyChangeListener(PropertyChangeListener pcl)
Model
removePropertyChangeListener
in interface Model<T extends Component<T>>
public void addPropertyChangeListener(PropertyChangeListener pcl)
addPropertyChangeListener
in interface Model<T extends Component<T>>
public void firePropertyChangeEvent(PropertyChangeEvent event)
public void removeUndoableEditListener(UndoableEditListener uel)
Model
removeUndoableEditListener
in interface Model<T extends Component<T>>
public void addUndoableEditListener(UndoableEditListener uel)
Model
addUndoableEditListener
in interface Model<T extends Component<T>>
public void addUndoableRefactorListener(UndoableEditListener uel)
Model
addUndoableRefactorListener
in interface Model<T extends Component<T>>
public void removeUndoableRefactorListener(UndoableEditListener uel)
Model
removeUndoableRefactorListener
in interface Model<T extends Component<T>>
protected CompoundEdit createModelUndoableEdit()
public boolean inSync()
Model
protected void setInSync(boolean v)
public boolean inUndoRedo()
protected void setInUndoRedo(boolean v)
public Model.State getState()
protected void setState(Model.State s)
protected boolean needsSync()
protected void transactionStarted()
protected void transactionCompleted()
protected void syncStarted()
protected void syncCompleted()
public void sync() throws IOException
Model
protected void refresh()
public void removeComponentListener(ComponentListener cl)
Model
removeComponentListener
in interface Model<T extends Component<T>>
public void addComponentListener(ComponentListener cl)
Model
addComponentListener
in interface Model<T extends Component<T>>
public void fireComponentChangedEvent(ComponentEvent evt)
public boolean isIntransaction()
Model
isIntransaction
in interface Model<T extends Component<T>>
public void endTransaction() throws IllegalStateException
IllegalStateException
if it is not possible to
flush changes, because e.g. file is read-only, deleted or the document is changed
in an incompatible way during the transaction.endTransaction
in interface Model<T extends Component<T>>
IllegalStateException
- when the backing file/document is read-only or the document
changed in a way that prevent application of changes.protected void endTransaction(boolean quiet)
@CheckReturnValue public boolean startTransaction()
Model
Model.endTransaction()
has been invoked. A transaction must be
be acquired during a mutation, reading can be performed without
a transaction. Only a single transaction at a time is supported. Mutations
which occur based on events will not be reflected until the transaction
has completed.startTransaction
in interface Model<T extends Component<T>>
public void rollbackTransaction()
protected void finishTransaction()
public void validateWrite()
public boolean startedFiringEvents()
public void undoableEditHappened(UndoableEditEvent e)
undoableEditHappened
in interface UndoableEditListener
public ModelSource getModelSource()
getModelSource
in interface Model<T extends Component<T>>
public boolean isAutoSyncActive()
public void setAutoSyncActive(boolean v)