Search in sources :

Example 11 with ComposedAdapterFactory

use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.

the class InteractionServices method changeParentForInteraction.

/**
 * Change the parent of an interaction with a selected one
 * @param interaction
 * @return
 */
public Interaction changeParentForInteraction(final Interaction interaction) {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    InteractionParentSelectionLabelProvider labelProvider = new InteractionParentSelectionLabelProvider(adapterFactory);
    InteractionParentSelectionContentProvider contentProvider = new InteractionParentSelectionContentProvider(adapterFactory);
    ElementTreeSelectionDialog dlg = new ElementTreeSelectionDialog(shell, labelProvider, contentProvider);
    dlg.setHelpAvailable(false);
    dlg.setValidator(new ISelectionStatusValidator() {

        public IStatus validate(Object[] selection) {
            Object selectedObject = selection[0];
            if (selectedObject instanceof EObject) {
                IPermissionAuthority authority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority((EObject) selectedObject);
                if (authority != null) {
                    LockStatus lockStatus = authority.getLockStatus((EObject) selectedObject);
                    if (LockStatus.LOCKED_BY_OTHER.equals(lockStatus)) {
                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "This element is locked by another user");
                    }
                }
            }
            return new Status(IStatus.OK, Activator.PLUGIN_ID, "");
        }
    });
    dlg.setTitle("Change interaction's parent");
    dlg.setMessage("Select the new parent for the interaction");
    Session session = SessionManager.INSTANCE.getSession(interaction);
    if (session == null) {
        return interaction;
    }
    dlg.setInput(session.getSemanticResources().toArray());
    dlg.setInitialSelection(interaction.eContainer());
    int btn = dlg.open();
    if (btn == Dialog.OK) {
        Object selectedElement = dlg.getFirstResult();
        if (selectedElement instanceof ObeoDSMObject && selectedElement != interaction.eContainer()) {
            // Change the parent
            ((ObeoDSMObject) selectedElement).getBehaviours().add(interaction);
        }
    }
    return interaction;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) LockStatus(org.eclipse.sirius.ecore.extender.business.api.permission.LockStatus) IPermissionAuthority(org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority) IStatus(org.eclipse.core.runtime.IStatus) LockStatus(org.eclipse.sirius.ecore.extender.business.api.permission.LockStatus) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) InteractionParentSelectionLabelProvider(org.obeonetwork.dsl.interaction.design.ui.extension.providers.InteractionParentSelectionLabelProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) Shell(org.eclipse.swt.widgets.Shell) InteractionParentSelectionContentProvider(org.obeonetwork.dsl.interaction.design.ui.extension.providers.InteractionParentSelectionContentProvider) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) EObject(org.eclipse.emf.ecore.EObject) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) EObject(org.eclipse.emf.ecore.EObject) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) Session(org.eclipse.sirius.business.api.session.Session)

Example 12 with ComposedAdapterFactory

use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.

the class UtilServices method getLabel.

public String getLabel(EObject object) {
    ComposedAdapterFactory composeable = new ComposedAdapterFactory();
    composeable.addAdapterFactory(dbEvolution);
    composeable.addAdapterFactory(compare);
    composeable.addAdapterFactory(database);
    composeable.addAdapterFactory(library);
    IItemLabelProvider provider = (IItemLabelProvider) composeable.adapt(object, IItemLabelProvider.class);
    if (provider != null) {
        return provider.getText(object);
    }
    return "";
}
Also used : IItemLabelProvider(org.eclipse.emf.edit.provider.IItemLabelProvider) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory)

Example 13 with ComposedAdapterFactory

use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.

the class EnvironmentEditor 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 EnvironmentItemProviderAdapterFactory());
    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) EnvironmentItemProviderAdapterFactory(org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory)

Example 14 with ComposedAdapterFactory

use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project gemoc-studio by eclipse.

the class FsmEditor 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 FsmItemProviderAdapterFactory());
    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 : 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) FsmItemProviderAdapterFactory(org.eclipse.gemoc.sample.legacyfsm.fsm.provider.FsmItemProviderAdapterFactory) 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)

Example 15 with ComposedAdapterFactory

use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project Malai by arnobl.

the class WidgetEditor 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 WidgetItemProviderAdapterFactory());
    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.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) ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) Command(org.eclipse.emf.common.command.Command) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) WidgetItemProviderAdapterFactory(org.malai.widget.provider.WidgetItemProviderAdapterFactory) EventObject(java.util.EventObject)

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