use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project ecf by eclipse.
the class DiscoveryEditingDomainProvider method load.
public void load() {
// Create an adapter factory that yields item providers.
adapterFactory = new ComposedAdapterFactory();
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ModelItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
// Create the command stack that will notify this editor as commands are executed.
commandStack = new BasicCommandStack();
// Create the editing domain with a special command stack.
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap());
// Load the resource through the editing domain.
URI resourceURI = URI.createURI("service://");
try {
getEditingDomain().getResourceSet().getResource(resourceURI, true);
} catch (Exception e) {
getEditingDomain().getResourceSet().getResource(resourceURI, false);
}
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project ecf by eclipse.
the class DiscoveryView method createPartControl.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
* .Composite)
*/
public void createPartControl(Composite parent) {
ComposedAdapterFactory adapterFactory = DiscoveryEditingDomainProvider.eINSTANCE.getAdapterFactory();
// create the viewer
setSelectionViewer(new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL));
getSelectionViewer().setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
getSelectionViewer().setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
getSelectionViewer().setComparator(new ViewerComparator());
getSelectionViewer().setFilters(getViewerFilters());
getSelectionViewer().setUseHashlookup(true);
getSite().setSelectionProvider(getSelectionViewer());
// populate the viewer with the model if available
EList resources = DiscoveryEditingDomainProvider.eINSTANCE.getEditingDomain().getResourceSet().getResources();
if (resources != null) {
getSelectionViewer().setInput(resources.get(0));
getSelectionViewer().setSelection(new StructuredSelection(resources.get(0)), true);
}
new AdapterFactoryTreeEditor(getSelectionViewer().getTree(), adapterFactory);
getSelectionViewer().addPostSelectionChangedListener(new AdapterFactoryStatuslineProvider(adapterFactory, getViewSite().getActionBars().getStatusLineManager()));
drillDownAdapter = new DrillDownAdapter(getSelectionViewer());
createContextMenuFor(getSelectionViewer());
hookContextMenu();
contributeToActionBars();
// add collapse handler
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
collapseHandler = new CollapseAllHandler(getSelectionViewer());
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, collapseHandler);
// add DND support
Transfer[] supportedTransfers = { LocalSelectionTransfer.getTransfer() };
getSelectionViewer().addDragSupport(DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_MOVE, supportedTransfers, new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
LocalSelectionTransfer.getTransfer().setSelection(getSelectionViewer().getSelection());
}
});
// $NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.ecf.discovery.ui.ServiceView");
getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.
the class SoaEditor method initializeEditingDomain.
/**
* This sets up the editing domain for the model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected void initializeEditingDomain() {
// Create an adapter factory that yields item providers.
//
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new SoaItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new EnvironmentItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
// Create the command stack that will notify this editor as commands are executed.
//
BasicCommandStack commandStack = new BasicCommandStack();
// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
//
commandStack.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.getCurrentTab() != null) {
propertySheetPage.refresh();
}
}
});
}
});
// Create the editing domain with a special command stack.
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.
the class StateMachineEditor method initializeEditingDomain.
/**
* This sets up the editing domain for the model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected void initializeEditingDomain() {
// Create an adapter factory that yields item providers.
//
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new StateMachineItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new EnvironmentItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
// Create the command stack that will notify this editor as commands are executed.
//
BasicCommandStack commandStack = new BasicCommandStack();
// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
//
commandStack.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.getCurrentTab() != null) {
propertySheetPage.refresh();
}
}
});
}
});
// Create the editing domain with a special command stack.
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.
the class RequirementEditor method initializeEditingDomain.
/**
* This sets up the editing domain for the model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void initializeEditingDomain() {
// Create an adapter factory that yields item providers.
//
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new RequirementItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new TechnicalIDItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
// Create the command stack that will notify this editor as commands are executed.
//
BasicCommandStack commandStack = new BasicCommandStack();
// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
//
commandStack.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());
}
for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext(); ) {
PropertySheetPage propertySheetPage = i.next();
if (propertySheetPage.getControl().isDisposed()) {
i.remove();
} else {
propertySheetPage.refresh();
}
}
}
});
}
});
// Create the editing domain with a special command stack.
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
Aggregations