Search in sources :

Example 1 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject in project InformationSystem by ObeoNetwork.

the class TypesServices method getRootNamespaceContainersOrTypesDefinition.

public Collection<ObeoDSMObject> getRootNamespaceContainersOrTypesDefinition(Collection<StructuredType> types) {
    Collection<ObeoDSMObject> result = new ArrayList<ObeoDSMObject>();
    Collection<ObeoDSMObject> allContainers = new ArrayList<ObeoDSMObject>();
    collectAllContainers(types, allContainers);
    // we will keep only those whoose own parent is not in the list
    for (ObeoDSMObject container : allContainers) {
        if (container.eContainer() == null || !allContainers.contains(container.eContainer())) {
            result.add(container);
        }
    }
    return result;
}
Also used : ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) ArrayList(java.util.ArrayList)

Example 2 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject in project InformationSystem by ObeoNetwork.

the class StateMachineModelWizard method createInitialModel.

/**
 * Create a new model.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
protected EObject createInitialModel() {
    EClass eClass = (EClass) stateMachinePackage.getEClassifier(initialObjectCreationPage.getInitialObjectName());
    EObject rootObject = stateMachineFactory.create(eClass);
    if (rootObject instanceof ObeoDSMObject) {
        ((ObeoDSMObject) rootObject).setCreatedOn(new Date());
    }
    return rootObject;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EObject(org.eclipse.emf.ecore.EObject) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) Date(java.util.Date)

Example 3 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject 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 4 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject in project InformationSystem by ObeoNetwork.

the class InteractionParentSelectionContentProvider method getChildren.

@Override
public Object[] getChildren(Object object) {
    List<Object> result = new ArrayList<Object>();
    Object[] children = super.getChildren(object);
    for (Object child : children) {
        if (child instanceof ObeoDSMObject && !(child instanceof Behaviour)) {
            result.add(child);
        }
    }
    return result.toArray();
}
Also used : Behaviour(org.obeonetwork.dsl.environment.Behaviour) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) ArrayList(java.util.ArrayList) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject)

Example 5 with ObeoDSMObject

use of org.obeonetwork.dsl.environment.ObeoDSMObject in project InformationSystem by ObeoNetwork.

the class InteractionParentSelectionContentProvider method getElements.

@Override
public Object[] getElements(Object object) {
    if (object instanceof Object[]) {
        List<Object> elements = new ArrayList<Object>();
        for (Object input : (Object[]) object) {
            elements.addAll(Arrays.asList(getElements(input)));
        }
        return elements.toArray();
    } else {
        List<Object> result = new ArrayList<Object>();
        Object[] elements = super.getElements(object);
        for (Object element : elements) {
            if (element instanceof ObeoDSMObject && !(element instanceof Behaviour)) {
                result.add(element);
            }
        }
        return result.toArray();
    }
}
Also used : Behaviour(org.obeonetwork.dsl.environment.Behaviour) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) ArrayList(java.util.ArrayList) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject)

Aggregations

ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)20 EObject (org.eclipse.emf.ecore.EObject)10 ArrayList (java.util.ArrayList)7 Behaviour (org.obeonetwork.dsl.environment.Behaviour)4 Risk (fr.gouv.mindef.safran.graalextensions.Risk)3 Date (java.util.Date)3 EClass (org.eclipse.emf.ecore.EClass)3 MetaData (org.obeonetwork.dsl.environment.MetaData)3 MetaDataContainer (org.obeonetwork.dsl.environment.MetaDataContainer)3 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 Session (org.eclipse.sirius.business.api.session.Session)2 IPermissionAuthority (org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionAuthority)2 LockStatus (org.eclipse.sirius.ecore.extender.business.api.permission.LockStatus)2 Shell (org.eclipse.swt.widgets.Shell)2