org.eclipse.graphiti.ui.editor

## Class DefaultUpdateBehavior

- java.lang.Object
- - org.eclipse.core.runtime.PlatformObject
  - - org.eclipse.graphiti.ui.editor.DefaultUpdateBehavior

All Implemented Interfaces:
  IOperationHistoryListener, IAdaptable, org.eclipse.emf.edit.domain.IEditingDomainProvider

    public class DefaultUpdateBehavior
    extends PlatformObject
    implements org.eclipse.emf.edit.domain.IEditingDomainProvider, IOperationHistoryListener

The default implementation for the `IDiagramContainerUI` behavior extension that controls update behavior of the editor and defines the EMF adapters that watch over model object modifications. Clients may subclass to change the behavior; use `IDiagramContainerUI#createUpdateBehavior()` to return the instance that shall be used.
Note that there is always a 1:1 relation with a `IDiagramContainerUI`.

Since:
  0.9

### Constructor Summary

Constructors
Constructor and Description
`DefaultUpdateBehavior(DiagramBehavior diagramBehavior)` Creates a new `DefaultUpdateBehavior` instance associated with the given `DiagramBehavior`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `dispose()` Disposes this `DefaultUpdateBehavior` and free all resources it holds.
`org.eclipse.emf.transaction.TransactionalEditingDomain` `getEditingDomain()` This returns the editing domain as required by the `IEditingDomainProvider` interface.
`void` `handleActivate()` Handles activation of the editor.
`void` `historyNotification(OperationHistoryEvent event)` Is called by the operation history of the `TransactionalEditingDomain` in case the history changes.
`void` `init()` Initializes listeners and adapters.
`void` `setAdapterActive(boolean active)` Sets the flag that indicates if the `updateAdapter` shall be active of not (`adapterActive`).
`void` `setEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)`
`void` `setResourceChanged(boolean resourceChanged)` Sets the flag that indicates if the underlying resource of the `Diagram` has been changed.
`void` `setResourceDeleted(boolean resourceDeleted)` Sets the flag that indicates if the underlying resource of the `Diagram` has been deleted.

### Methods inherited from class org.eclipse.core.runtime.PlatformObject

`getAdapter`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultUpdateBehavior

    public DefaultUpdateBehavior(DiagramBehavior diagramBehavior)

Creates a new `DefaultUpdateBehavior` instance associated with the given `DiagramBehavior`.

Parameters:
  `diagramEditor` - the part this model editor works on
Since:
  0.10

### Method Detail

#### setResourceDeleted

    public void setResourceDeleted(boolean resourceDeleted)

Sets the flag that indicates if the underlying resource of the `Diagram` has been deleted. Note that this flag should only be updated by the `updateAdapter`, see `adapterActive`, `isAdapterActive()` and `setAdapterActive(boolean)`.

Should not be called by external clients.

Parameters:
  `resourceDeleted` - the value to set the flag to, `true` indicates that the resource has been deleted.

#### setResourceChanged

    public void setResourceChanged(boolean resourceChanged)

Sets the flag that indicates if the underlying resource of the `Diagram` has been changed. Note that this flag should only be updated by the `updateAdapter`, see `adapterActive`, `isAdapterActive()` and `setAdapterActive(boolean)`.

Should not be called by external clients.

Parameters:
  `resourceChanged` - the value to set the flag to, `true` indicates that the resource has been changed.

#### handleActivate

    public void handleActivate()

Handles activation of the editor. In case of the underlying diagram resource being deleted (`resourceDeleted` is `true`) the editor will be closed after a call to `handleDirtyConflict()` that returns `true`. Also it will call `handleChangedResources()` in case the underlying diagram resource has changed (`resourceChanged` is `true`).

#### setAdapterActive

    public void setAdapterActive(boolean active)

Sets the flag that indicates if the `updateAdapter` shall be active of not (`adapterActive`).

Parameters:
  `active` - the new value for the flag

#### getEditingDomain

    public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()

This returns the editing domain as required by the `IEditingDomainProvider` interface.

Specified by:
  `getEditingDomain` in interface `org.eclipse.emf.edit.domain.IEditingDomainProvider`
Returns:
  The `TransactionalEditingDomain` that is used within this editor

#### init

    public void init()

Initializes listeners and adapters.

#### dispose

    public void dispose()

Disposes this `DefaultUpdateBehavior` and free all resources it holds. In case you only want to omit or influence the disposal of the `TransactionalEditingDomain`, you can also override `disposeEditingDomain()`.

#### historyNotification

    public void historyNotification(OperationHistoryEvent event)

Is called by the operation history of the `TransactionalEditingDomain` in case the history changes. Reacts on undo and redo events and updates the dirty state of the editor.

Specified by:
  `historyNotification` in interface `IOperationHistoryListener`
Parameters:
  `event` - the `OperationHistoryEvent` to react upon

#### setEditingDomain

    public void setEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)

Since:
  0.10