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;
}
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;
}
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;
}
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();
}
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();
}
}
Aggregations