org.netbeans.modules.bpel.model.impl
Class BpelModelImpl

java.lang.Object
  extended by org.netbeans.modules.xml.xam.AbstractModel<T>
      extended by org.netbeans.modules.xml.xam.dom.AbstractDocumentModel<BpelEntity>
          extended by org.netbeans.modules.bpel.model.impl.BpelModelImpl
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.UndoableEditListener, BpelModel, DocumentModel<BpelEntity>, Model<BpelEntity>, Referenceable

public class BpelModelImpl
extends AbstractDocumentModel<BpelEntity>
implements BpelModel


Nested Class Summary
protected  class BpelModelImpl.BpelModelUndoableEdit
           
protected  class BpelModelImpl.BpelModelUndoableEditSupport
           
 
Nested classes/interfaces inherited from class org.netbeans.modules.xml.xam.AbstractModel
AbstractModel.ModelUndoableEdit, AbstractModel.ModelUndoableEditSupport
 
Nested classes/interfaces inherited from interface org.netbeans.modules.xml.xam.Model
Model.State
 
Field Summary
 
Fields inherited from class org.netbeans.modules.xml.xam.dom.AbstractDocumentModel
access
 
Fields inherited from class org.netbeans.modules.xml.xam.AbstractModel
ues
 
Fields inherited from interface org.netbeans.modules.bpel.model.api.BpelModel
STATE
 
Fields inherited from interface org.netbeans.modules.xml.xam.Model
STATE_PROPERTY
 
Constructor Summary
BpelModelImpl(javax.swing.text.Document doc, Lookup lookup)
           
BpelModelImpl(ModelSource source)
           
 
Method Summary
 void addComponentListener(ComponentListener cl)
          Remove component event listener.
 void addEntityChangeListener(ChangeEventListener listener)
          Add change listener which will receive events for any element in the underlying model.
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Add property change listener which will receive events for any element in the underlying schema model.
 void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
          Adds undoable edit listener.
 void addUndoableRefactorListener(javax.swing.event.UndoableEditListener listener)
          Adds undoable refactoring edit listener.
 boolean canExtend(ExtensibleElements extensible, java.lang.Class<? extends ExtensionEntity> extensionType)
           
 BpelEntity createComponent(BpelEntity parent, org.w3c.dom.Element element)
          Create component to be added as child of given component.
 BpelEntity createRootComponent(org.w3c.dom.Element root)
           
 void endTransaction()
          This method stops the transaction and causes all events to be fired.
 BpelEntity findElement(int i)
          Finds Bpel element on the specified position.
(package private)  void fireChangeEvent(ChangeEvent event)
          This method should be visible only for model impl elements.
 void fireComponentChangedEvent(ComponentEvent evt)
           
 void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
           
 AnotherVersionBpelProcess getAnotherVersionProcess()
          Accessor to root bpel process element that has different version from currently supported.
 BpelBuilderImpl getBuilder()
           
(package private)  BpelChildEntitiesBuilder getChildBuilder()
           
protected  ComponentUpdater<BpelEntity> getComponentUpdater()
           
 BpelEntity getEntity(UniqueId id)
          Returns entity by its unique id.
(package private)  EntityFactoryRegistry getEntityRegistry()
           
(package private)  long getNextID()
           
 ProcessImpl getProcess()
           
 java.util.Set<javax.xml.namespace.QName> getQNames()
          Returns QName of elements used in model.
 BpelEntity getRootComponent()
          Returns model root component.
protected  java.lang.Object getSource()
           
<V> V
invoke(java.util.concurrent.Callable<V> action, java.lang.Object source)
          This method should be used for executing group of calls to model as atomic action.
 void invoke(java.lang.Runnable run)
          This method execute command run inside read lock on OM obtained.
(package private)  boolean isInEventsFiring()
           
 boolean isIntransaction()
           
 boolean isSupportedExpension(java.lang.String uri)
           
(package private)  void postInnerEventNotify(ChangeEvent event)
          This method will be called right after OM change was performed and we possibly need to change other elements in OM accordingly this change.
(package private)  void preInnerEventNotify(ChangeEvent event)
          This method will be called before OM change was performed and we possibly need to collect some information.
protected  void readLock()
           
protected  void readUnlock()
           
 void removeComponentListener(ComponentListener cl)
          Add coarse-grained change listener for events on model components.
 void removeEntityChangeListener(ChangeEventListener listener)
          Removes change listener from model.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
          Remove property change listener.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
          Removes undoable edit listener.
 void removeUndoableRefactorListener(javax.swing.event.UndoableEditListener listener)
          Removes undoable refactoring edit listener.
 void rollbackTransaction()
           
 boolean startTransaction()
          This method will block until a transaction can be started.
 void sync()
          make the current memory model consistent with the underlying representation, typically a swing document.
 void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
           
 void validateWrite()
          This method ensures that a transaction is currently in progress and that the current thread is able to write.
protected  void writeLock()
           
protected  void writeUnlock()
           
 
Methods inherited from class org.netbeans.modules.xml.xam.dom.AbstractDocumentModel
addChildComponent, areSameNodes, findComponent, findComponent, findComponent, findComponent, firePropertyChangedEvents, firePropertyChangedEvents, getAccess, getAccessProvider, getBaseDocument, getDocument, getElementNames, getQNameValuedAttributes, getXPathExpression, isDomainElement, needsSync, prepareChangeInfo, prepareSyncUnit, processSyncUnit, refresh, removeChildComponent, setIdentifyingAttributes, syncCompleted, syncStarted, toLocalName
 
Methods inherited from class org.netbeans.modules.xml.xam.AbstractModel
createModelUndoableEdit, endTransaction, finishTransaction, getModelSource, getState, inSync, inUndoRedo, isAutoSyncActive, setAutoSyncActive, setInSync, setInUndoRedo, setState, startedFiringEvents, transactionCompleted, transactionStarted
 
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, getModelSource, getState, inSync, removeChildComponent
 

Constructor Detail

BpelModelImpl

public BpelModelImpl(javax.swing.text.Document doc,
                     Lookup lookup)

BpelModelImpl

public BpelModelImpl(ModelSource source)
Method Detail

getProcess

public ProcessImpl getProcess()
Specified by:
getProcess in interface BpelModel
Returns:
reference to root of BPEL - process.

getBuilder

public BpelBuilderImpl getBuilder()
Specified by:
getBuilder in interface BpelModel
Returns:
builder for BPEL elements.

getEntity

public BpelEntity getEntity(UniqueId id)
Description copied from interface: BpelModel
Returns entity by its unique id.

Specified by:
getEntity in interface BpelModel
Parameters:
id - id of entity.
Returns:
entity by its id.

removePropertyChangeListener

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

Specified by:
removePropertyChangeListener in interface Model<BpelEntity>
Overrides:
removePropertyChangeListener in class AbstractModel<BpelEntity>

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Description copied from class: AbstractModel
Add property change listener which will receive events for any element in the underlying schema model.

Specified by:
addPropertyChangeListener in interface Model<BpelEntity>
Overrides:
addPropertyChangeListener in class AbstractModel<BpelEntity>

removeComponentListener

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

Specified by:
removeComponentListener in interface Model<BpelEntity>
Overrides:
removeComponentListener in class AbstractModel<BpelEntity>

addComponentListener

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

Specified by:
addComponentListener in interface Model<BpelEntity>
Overrides:
addComponentListener in class AbstractModel<BpelEntity>

addEntityChangeListener

public void addEntityChangeListener(ChangeEventListener listener)
Description copied from interface: BpelModel
Add change listener which will receive events for any element in the underlying model. Listener adds to model as weak reference. So one needs to care about keeping reference to listener somehere till it used and need to get events from model. If one will use anonymous class for adding then it will never get events. You should use method removePropertyChangeListener when listener is already not needed. For using this method you should keep reference to created listener. If you cannot use method removePropertyChangeListener then probably you will never get events from model because you don't keep reference to listener and it could be collected by GC in any time.

Specified by:
addEntityChangeListener in interface BpelModel
Parameters:
listener - listener for add.

removeEntityChangeListener

public void removeEntityChangeListener(ChangeEventListener listener)
Description copied from interface: BpelModel
Removes change listener from model.

Specified by:
removeEntityChangeListener in interface BpelModel
Parameters:
listener - listener for remove.

addUndoableEditListener

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

Specified by:
addUndoableEditListener in interface Model<BpelEntity>
Overrides:
addUndoableEditListener in class AbstractModel<BpelEntity>

removeUndoableEditListener

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

Specified by:
removeUndoableEditListener in interface Model<BpelEntity>
Overrides:
removeUndoableEditListener in class AbstractModel<BpelEntity>

addUndoableRefactorListener

public void addUndoableRefactorListener(javax.swing.event.UndoableEditListener listener)
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<BpelEntity>
Overrides:
addUndoableRefactorListener in class AbstractModel<BpelEntity>

removeUndoableRefactorListener

public void removeUndoableRefactorListener(javax.swing.event.UndoableEditListener listener)
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<BpelEntity>
Overrides:
removeUndoableRefactorListener in class AbstractModel<BpelEntity>

invoke

public <V> V invoke(java.util.concurrent.Callable<V> action,
                    java.lang.Object source)
         throws java.lang.Exception
Description copied from interface: BpelModel
This method should be used for executing group of calls to model as atomic action. Placing action in this method guarantee that model will not be affected via another threads in process of execution this action. Changes in model that represented by action will be executed synchronously. It means method will end only after all calls to model inside action would be executed. All model methods getXXX, setXX, addXX, etc. also atomic. If you need just get value or set new value in model you don't need to call this method. Each this action will be synchronized. You need to use this method when you need to perform many actions one depends from another. In this case value that you get in one action could be not valid for next action with model.

Specified by:
invoke in interface BpelModel
Type Parameters:
V - type for return value.
Parameters:
action - group of calls to model.
source - this is object that will be set as source for events that will be fired by model as result of this action. It could be used for distinguishing various consumers of model. Could be equall to null. If it equals to null then source of event will be set to Thread.currentThread(). One should not put "sync" method inside invoke() or in transaction that started with startTransaction(). Otherwise "sync" will no have any effect. OM consider starting transaction as starting mutation and in this case "sync" doesn't have sense.
Returns:
return value from action.
Throws:
java.lang.Exception - Exception exception that could be thrown by action

invoke

public void invoke(java.lang.Runnable run)
Description copied from interface: BpelModel
This method execute command run inside read lock on OM obtained. You should never try mutate OM inside this command run. Otherwise you will get InvalidaStateException.

Specified by:
invoke in interface BpelModel
Parameters:
run - command for execution

createRootComponent

public BpelEntity createRootComponent(org.w3c.dom.Element root)
Specified by:
createRootComponent in class AbstractDocumentModel<BpelEntity>

getRootComponent

public BpelEntity getRootComponent()
Description copied from interface: DocumentModel
Returns model root component.

Specified by:
getRootComponent in interface DocumentModel<BpelEntity>

validateWrite

public void validateWrite()
Description copied from class: AbstractModel
This method ensures that a transaction is currently in progress and that the current thread is able to write.

Overrides:
validateWrite in class AbstractModel<BpelEntity>

firePropertyChangeEvent

public void firePropertyChangeEvent(java.beans.PropertyChangeEvent event)
Overrides:
firePropertyChangeEvent in class AbstractModel<BpelEntity>

fireComponentChangedEvent

public void fireComponentChangedEvent(ComponentEvent evt)
Overrides:
fireComponentChangedEvent in class AbstractModel<BpelEntity>

sync

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

Specified by:
sync in interface Model<BpelEntity>
Overrides:
sync in class AbstractModel<BpelEntity>
Throws:
java.io.IOException

undoableEditHappened

public void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
Specified by:
undoableEditHappened in interface javax.swing.event.UndoableEditListener
Overrides:
undoableEditHappened in class AbstractModel<BpelEntity>

getQNames

public java.util.Set<javax.xml.namespace.QName> getQNames()
Description copied from class: AbstractDocumentModel
Returns QName of elements used in model. Domain model implementation needs to override this to be able to embed elements outside of the domain such as child elements of documentation in schema model.

Overrides:
getQNames in class AbstractDocumentModel<BpelEntity>
Returns:
full set of element QName's or null if there is no needs for distinction between domain and non-domain elements.

createComponent

public BpelEntity createComponent(BpelEntity parent,
                                  org.w3c.dom.Element element)
Description copied from interface: DocumentModel
Create component to be added as child of given component.

Specified by:
createComponent in interface DocumentModel<BpelEntity>

findElement

public BpelEntity findElement(int i)
Description copied from interface: BpelModel
Finds Bpel element on the specified position.

Specified by:
findElement in interface BpelModel
Parameters:
i - Position in NbDocument.
Returns:
Entity on the position if any.

isIntransaction

public boolean isIntransaction()
Specified by:
isIntransaction in interface Model<BpelEntity>
Overrides:
isIntransaction in class AbstractModel<BpelEntity>
Returns:
true if model is in middle of transformation tranasction.

startTransaction

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 #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<BpelEntity>
Overrides:
startTransaction in class AbstractModel<BpelEntity>
Returns:
true if transaction is acquired successfully, else false, for example if model has transitioned into invalid state.

endTransaction

public void endTransaction()
Description copied from interface: Model
This method stops the transaction and causes all events to be fired. After all events have been fired, the document representation will be modified to reflect the current value of the model (flush).

Specified by:
endTransaction in interface Model<BpelEntity>
Overrides:
endTransaction in class AbstractModel<BpelEntity>

rollbackTransaction

public void rollbackTransaction()
Overrides:
rollbackTransaction in class AbstractModel<BpelEntity>

isSupportedExpension

public boolean isSupportedExpension(java.lang.String uri)

getAnotherVersionProcess

public AnotherVersionBpelProcess getAnotherVersionProcess()
Description copied from interface: BpelModel
Accessor to root bpel process element that has different version from currently supported. Please note that this is only read-only element. You should not try to change it in any way. This method will return each time new instance of such root element. This method will return null if bpel process has correct namespace or not well formed ( in terms of XML ).

Specified by:
getAnotherVersionProcess in interface BpelModel
Returns:
OM root element that correspond to BPEL process with different version if any.

canExtend

public boolean canExtend(ExtensibleElements extensible,
                         java.lang.Class<? extends ExtensionEntity> extensionType)
Specified by:
canExtend in interface BpelModel

getComponentUpdater

protected ComponentUpdater<BpelEntity> getComponentUpdater()
Specified by:
getComponentUpdater in class AbstractDocumentModel<BpelEntity>

readLock

protected void readLock()

readUnlock

protected void readUnlock()

writeLock

protected void writeLock()

writeUnlock

protected void writeUnlock()

getSource

protected java.lang.Object getSource()

getEntityRegistry

EntityFactoryRegistry getEntityRegistry()

getNextID

long getNextID()

isInEventsFiring

final boolean isInEventsFiring()

preInnerEventNotify

final void preInnerEventNotify(ChangeEvent event)
                        throws VetoException
This method will be called before OM change was performed and we possibly need to collect some information.

Throws:
could - throw VetoException. It means that some visitor reject change.
VetoException

postInnerEventNotify

final void postInnerEventNotify(ChangeEvent event)
This method will be called right after OM change was performed and we possibly need to change other elements in OM accordingly this change.


fireChangeEvent

final void fireChangeEvent(ChangeEvent event)
This method should be visible only for model impl elements.

Parameters:
event - event for firing.

getChildBuilder

BpelChildEntitiesBuilder getChildBuilder()