org.netbeans.modules.xml.xam/1 1.18.0 1

org.netbeans.modules.xml.xam
Class AbstractModel<T extends Component<T>>

java.lang.Object
  extended by org.netbeans.modules.xml.xam.AbstractModel<T>
All Implemented Interfaces:
EventListener, UndoableEditListener, Model<T>, Referenceable
Direct Known Subclasses:
AbstractDocumentModel

public abstract class AbstractModel<T extends Component<T>>
extends Object
implements Model<T>, UndoableEditListener


Nested Class Summary
protected  class AbstractModel.ModelUndoableEdit
           
protected  class AbstractModel.ModelUndoableEditSupport
           
 
Nested classes/interfaces inherited from interface org.netbeans.modules.xml.xam.Model
Model.State
 
Field Summary
protected  AbstractModel.ModelUndoableEditSupport ues
           
 
Fields inherited from interface org.netbeans.modules.xml.xam.Model
STATE_PROPERTY
 
Constructor Summary
AbstractModel(ModelSource source)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.netbeans.modules.xml.xam.Model
addChildComponent, removeChildComponent
 

Field Detail

ues

protected AbstractModel.ModelUndoableEditSupport ues
Constructor Detail

AbstractModel

public AbstractModel(ModelSource source)
Method Detail

getAccess

public abstract ModelAccess getAccess()

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
Description copied from interface: Model
Remove property change listener.

Specified by:
removePropertyChangeListener in interface Model<T extends Component<T>>

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
Add property change listener which will receive events for any element in the underlying schema model.

Specified by:
addPropertyChangeListener in interface Model<T extends Component<T>>

firePropertyChangeEvent

public void firePropertyChangeEvent(PropertyChangeEvent event)

removeUndoableEditListener

public void removeUndoableEditListener(UndoableEditListener uel)
Description copied from interface: Model
Removes undoable edit listener.

Specified by:
removeUndoableEditListener in interface Model<T extends Component<T>>

addUndoableEditListener

public void addUndoableEditListener(UndoableEditListener uel)
Description copied from interface: Model
Adds undoable edit listener.

Specified by:
addUndoableEditListener in interface Model<T extends Component<T>>

addUndoableRefactorListener

public void addUndoableRefactorListener(UndoableEditListener uel)
Description copied from interface: Model
Adds undoable refactoring edit listener. This is typically called by a refactoring manager before start refactoring changes. This will also save existing undoable edit listeners. Note, if these listeners are UndoManager instances, their queues will be cleared of existing edits.

Specified by:
addUndoableRefactorListener in interface Model<T extends Component<T>>

removeUndoableRefactorListener

public void removeUndoableRefactorListener(UndoableEditListener uel)
Description copied from interface: Model
Removes undoable refactoring edit listener. This will also restored the existing undoable edit listeners to the set before the start of refactoring. Note, if these listeners are UndoManager instances their queues are cleared of existing edits.

Specified by:
removeUndoableRefactorListener in interface Model<T extends Component<T>>

createModelUndoableEdit

protected CompoundEdit createModelUndoableEdit()

inSync

public boolean inSync()
Description copied from interface: Model
Returns true if sync is being performed.

Specified by:
inSync in interface Model<T extends Component<T>>

setInSync

protected void setInSync(boolean v)

inUndoRedo

public boolean inUndoRedo()
Indicates if the model in Undo/Redo stage.

Returns:

setInUndoRedo

protected void setInUndoRedo(boolean v)

getState

public Model.State getState()
Specified by:
getState in interface Model<T extends Component<T>>
Returns:
the last known state of the document. This method is affected by invocations of #sync().

setState

protected void setState(Model.State s)

needsSync

protected boolean needsSync()
This method is overridden by subclasses to determine if sync needs to be performed. The default implementation simply returns true.


transactionStarted

protected void transactionStarted()
This template method is invoked when a transaction is started. The default implementation does nothing.


transactionCompleted

protected void transactionCompleted()
This method is invoked when a transaction has completed. The default implementation does nothing.


syncStarted

protected void syncStarted()
This method is invoked when sync has started. The default implementation does nothing.


syncCompleted

protected void syncCompleted()
This method is invoked when sync has completed. The default implementation does nothing.


sync

public void sync()
          throws IOException
Description copied from interface: Model
Makes the current memory model consistent with the underlying representation, typically a swing document.

Specified by:
sync in interface Model<T extends Component<T>>
Throws:
IOException

refresh

protected void refresh()
Refresh the domain model component trees. Refresh actually means recreation of root component from XDM root. The old model's content is totally lost after the operation. Because the fresh model is created, the model's state should be VALID as the result of this call. Note: subclasses need to override to provide the actual refresh service. Note: direct links to model's components become invalid after this operation.


removeComponentListener

public void removeComponentListener(ComponentListener cl)
Description copied from interface: Model
Adds coarse-grained change listener for events on model components.

Specified by:
removeComponentListener in interface Model<T extends Component<T>>

addComponentListener

public void addComponentListener(ComponentListener cl)
Description copied from interface: Model
Removes component event listener.

Specified by:
addComponentListener in interface Model<T extends Component<T>>

fireComponentChangedEvent

public void fireComponentChangedEvent(ComponentEvent evt)

isIntransaction

public boolean isIntransaction()
Description copied from interface: Model
Be very careful while using this method. It returns only current state and doesn't inform if the transaction has been started by current thread. Only the thread, which owns the transaction can use it and do changes to the model.

Specified by:
isIntransaction in interface Model<T extends Component<T>>
Returns:
true if model is in middle of transformation tranasction.

endTransaction

public void endTransaction()
                    throws IllegalStateException
Ends the transaction and commits changes to the document. The operation may throw 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.

Specified by:
endTransaction in interface Model<T extends Component<T>>
Throws:
IllegalStateException - when the backing file/document is read-only or the document changed in a way that prevent application of changes.

endTransaction

protected void endTransaction(boolean quiet)

startTransaction

@CheckReturnValue
public boolean startTransaction()
Description copied from interface: Model
This method will block until a transaction can be started. A transaction in this context will fire events (such as property change) when 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.

Specified by:
startTransaction in interface Model<T extends Component<T>>
Returns:
true if transaction is acquired successfully, else false, for example if model has transitioned into invalid state.

rollbackTransaction

public void rollbackTransaction()
The method does nothing if the transaction hasn't been started or started by another thread.


finishTransaction

protected void finishTransaction()

validateWrite

public void validateWrite()
This method ensures that a transaction is currently in progress and that the current thread is able to write.


startedFiringEvents

public boolean startedFiringEvents()
Whether the model has started firing events. This is the indication of beginning of endTransaction call and any subsequent mutations are from handlers of main transaction events or some of their own events.


undoableEditHappened

public void undoableEditHappened(UndoableEditEvent e)
Specified by:
undoableEditHappened in interface UndoableEditListener

getModelSource

public ModelSource getModelSource()
Specified by:
getModelSource in interface Model<T extends Component<T>>
Returns:
the source of this model or null if this model does associate with any model source.

isAutoSyncActive

public boolean isAutoSyncActive()

setAutoSyncActive

public void setAutoSyncActive(boolean v)

org.netbeans.modules.xml.xam/1 1.18.0 1

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.