Search in sources :

Example 31 with ComposedAdapterFactory

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);
    }
}
Also used : AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) HashMap(java.util.HashMap) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) URI(org.eclipse.emf.common.util.URI) IOException(java.io.IOException)

Example 32 with ComposedAdapterFactory

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);
}
Also used : AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) CollapseAllHandler(org.eclipse.ui.handlers.CollapseAllHandler) AdapterFactoryStatuslineProvider(org.eclipse.ecf.internal.discovery.ui.statusline.AdapterFactoryStatuslineProvider) EList(org.eclipse.emf.common.util.EList) IHandlerService(org.eclipse.ui.handlers.IHandlerService) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 33 with ComposedAdapterFactory

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>());
}
Also used : AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) CommandStack(org.eclipse.emf.common.command.CommandStack) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) EventObject(java.util.EventObject) SoaItemProviderAdapterFactory(org.obeonetwork.dsl.soa.provider.SoaItemProviderAdapterFactory) ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) Command(org.eclipse.emf.common.command.Command) EnvironmentItemProviderAdapterFactory(org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory)

Example 34 with ComposedAdapterFactory

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>());
}
Also used : AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) CommandStack(org.eclipse.emf.common.command.CommandStack) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) EventObject(java.util.EventObject) StateMachineItemProviderAdapterFactory(org.obeonetwork.dsl.statemachine.provider.StateMachineItemProviderAdapterFactory) ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) Command(org.eclipse.emf.common.command.Command) EnvironmentItemProviderAdapterFactory(org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory)

Example 35 with ComposedAdapterFactory

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>());
}
Also used : TechnicalIDItemProviderAdapterFactory(org.obeonetwork.dsl.technicalid.provider.TechnicalIDItemProviderAdapterFactory) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) CommandStack(org.eclipse.emf.common.command.CommandStack) PropertySheetPage(org.eclipse.ui.views.properties.PropertySheetPage) IPropertySheetPage(org.eclipse.ui.views.properties.IPropertySheetPage) ExtendedPropertySheetPage(org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) EventObject(java.util.EventObject) ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) Command(org.eclipse.emf.common.command.Command) RequirementItemProviderAdapterFactory(org.obeonetwork.dsl.requirement.provider.RequirementItemProviderAdapterFactory)

Aggregations

ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)40 ResourceItemProviderAdapterFactory (org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory)31 HashMap (java.util.HashMap)30 BasicCommandStack (org.eclipse.emf.common.command.BasicCommandStack)30 AdapterFactoryEditingDomain (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain)30 ReflectiveItemProviderAdapterFactory (org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory)30 EventObject (java.util.EventObject)29 LinkedHashMap (java.util.LinkedHashMap)29 Command (org.eclipse.emf.common.command.Command)29 CommandStack (org.eclipse.emf.common.command.CommandStack)29 CommandStackListener (org.eclipse.emf.common.command.CommandStackListener)29 ExtendedPropertySheetPage (org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage)15 IPropertySheetPage (org.eclipse.ui.views.properties.IPropertySheetPage)15 PropertySheetPage (org.eclipse.ui.views.properties.PropertySheetPage)15 EnvironmentItemProviderAdapterFactory (org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory)14 EcoreItemProviderAdapterFactory (org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory)8 TechnicalIDItemProviderAdapterFactory (org.obeonetwork.dsl.technicalid.provider.TechnicalIDItemProviderAdapterFactory)8 CinematicItemProviderAdapterFactory (org.obeonetwork.dsl.cinematic.provider.CinematicItemProviderAdapterFactory)6 FlowItemProviderAdapterFactory (org.obeonetwork.dsl.cinematic.flow.provider.FlowItemProviderAdapterFactory)5 ToolkitsItemProviderAdapterFactory (org.obeonetwork.dsl.cinematic.toolkits.provider.ToolkitsItemProviderAdapterFactory)5