Java Reference
In-Depth Information
adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new
ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new
RequirementsItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new
ReflectiveItemProviderAdapterFactory());
TransactionalEditingDomain domain =
TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
domain.setID("org.eclipse.requirements.EditingDomain");
// Add a listener to set the most recent command's affected objects
// to be the selection of the viewer with focus.
domain.getCommandStack()
.addCommandStackListener(new
CommandStackListener() {
public void commandStackChanged(final EventObject event) {
getContainer().getDisplay().asyncExec(new Runnable() {
public void run() {
firePropertyChange(IEditorPart.PROP_DIRTY);
// Try to select the affected objects.
Command mostRecentCommand = ((CommandStack)
event.getSource()).getMostRecentCommand();
if (mostRecentCommand != null) {
setSelectionToViewer(mostRecentCommand.getAffectedObjects());
}
if (propertySheetPage != null
&& !propertySheetPage.getControl().isDisposed()) {
propertySheetPage.refresh();
}
}
});
}
});
// Create the editing domain with a special command stack.
editingDomain =
(AdapterFactoryEditingDomain) domain
;
}
Open your
requirements.gmfgen
model and locate the
Editing
Domain ID
property in the
Editor
category of the
Gen Diagram
ModelEditPart
element part. Set the value of this property to the same ID we
previously set for the
TransactionalEditingDomain
, as seen in Figure 4-24.
Search WWH ::
Custom Search