How to access enumeration literals defined in UML Profiles? [message #1730865] |
Fri, 29 April 2016 12:03 |
Rene Meis Messages: 19 Registered: June 2015 |
Junior Member |
|
|
Hi all,
I defined enumerations in UML profiles and also have stereotypes that use these enumerations as types of properties. Now I have the problem that I cannot assign an enumeration literal of the enumerations defined in the UML profile using the # notation.
Minimal example:
I have defined an enumeration Level in a profile with the literals easy, normal, and hard. I apply the profile to a UML model and run the following wizard on this model:
wizard EnumTest {
title : "Test Level Enum"
do {
(Model!AggregationKind#shared).println();
var enum = Model!Enumeration.all.selectOne(e|e.name = "Level").println();
enum.getOwnedLiterals().println();
(Model!Level#easy).println();
}
}
The result is (executed in Papyrus):
shared
Enumeration [name=Level, qualifiedName=Levels::Level, visibility=public, isLeaf=false, isAbstract=false, isFinalSpecialization=false, ]
OrderedSet {EnumerationLiteral [name=easy, qualifiedName=Levels::Level::easy, visibility=public, ], EnumerationLiteral [name=normal, qualifiedName=Levels::Level::normal, visibility=public, ], EnumerationLiteral [name=hard, qualifiedName=Levels::Level::hard, visibility=public, ]}
Cannot find enumeration literal Level#easy in model Model
at (/home/rene/Programme/Mars/workspaceVanilla/Wizard/test.ewl@7:3-7:19)
at (/home/rene/Programme/Mars/workspaceVanilla/Wizard/test.ewl@7:2-7:31)
at org.eclipse.epsilon.emc.emf.AbstractEmfModel.getEnumerationValue(AbstractEmfModel.java:159)
at org.eclipse.epsilon.eol.models.ModelRepository.getEnumerationValue(ModelRepository.java:130)
at org.eclipse.epsilon.eol.dom.EnumerationLiteralExpression.execute(EnumerationLiteralExpression.java:20)
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
at org.eclipse.epsilon.eol.dom.ExpressionInBrackets.execute(ExpressionInBrackets.java:19)
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
at org.eclipse.epsilon.eol.dom.OperationCallExpression.execute(OperationCallExpression.java:68)
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
at org.eclipse.epsilon.eol.dom.ExpressionStatement.execute(ExpressionStatement.java:19)
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
at org.eclipse.epsilon.eol.dom.StatementBlock.execute(StatementBlock.java:43)
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST(ExecutorFactory.java:109)
at org.eclipse.epsilon.eol.dom.ExecutableBlock.executeBlockOrExpressionAst(ExecutableBlock.java:74)
at org.eclipse.epsilon.eol.dom.ExecutableBlock.execute(ExecutableBlock.java:88)
at org.eclipse.epsilon.ewl.dom.Wizard.process(Wizard.java:57)
at org.eclipse.epsilon.ewl.execute.WizardInstance.process(WizardInstance.java:66)
at org.eclipse.epsilon.ewl.emf.ExecuteWizardInstanceCommand.execute(ExecuteWizardInstanceCommand.java:44)
at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFCommandOperation.java:119)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:516)
at org.eclipse.papyrus.commands.CheckedOperationHistory.execute(CheckedOperationHistory.java:184)
at org.eclipse.papyrus.commands.NotifyingWorkspaceCommandStack.doExecute(NotifyingWorkspaceCommandStack.java:261)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
at org.eclipse.papyrus.commands.NestingNotifyingWorkspaceCommandStack.execute(NestingNotifyingWorkspaceCommandStack.java:130)
at org.eclipse.epsilon.ewl.emf.AbstractContributeWizardsAction.execute(AbstractContributeWizardsAction.java:140)
at org.eclipse.epsilon.ewl.emf.AbstractContributeWizardsAction$1.widgetSelected(AbstractContributeWizardsAction.java:254)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1329)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3819)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3430)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
The result shows that the enumeration literal AggregationKind#shared can be accessed and that the enumeration Level is also known, but the # notation does not work as expected.
What am I doing wrong?
Thanks in advance,
Rene
|
|
|
|
|
|
|
|
|
Re: How to access enumeration literals defined in UML Profiles? [message #1732664 is a reply to message #1731555] |
Wed, 18 May 2016 22:22 |
|
Hi Rene,
Apologies for the slow response - this was a tricky one. It appears that you don't need the custom tool after all. Modifying your wizard as follows should do the trick.
wizard EnumTest {
title : "Test Level Enum"
do {
var ePackage = ProfileApplication.all.first().getAppliedDefinition();
Model.resource.resourceSet.packageRegistry.put(ePackage.nsURI, ePackage);
Game.all.println();
(Model!Level#easy).println();
}
}
Cheers,
Dimitris
|
|
|
|
Powered by
FUDForum. Page generated in 0.03195 seconds