Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Simplify diagram creation
Simplify diagram creation [message #1403342] Wed, 23 July 2014 06:20 Go to next message
Richard Meyer is currently offline Richard MeyerFriend
Messages: 40
Registered: June 2012
Member
Hi,

I have successfully created a Sirius diagram editor and deployed to our RCP. Till now, to create a new diagram, the user has to do the following steps:
- create a Modeling Project
- create the EMF model file
- select the viewpoint
- create a new representation

Is there a way to simplify the creation of a diagram for the end user (New-> DiagramXY)?

Is the creation of a diagram only possible in a "Modeling Project"?

Thanks in advance.
Re: Simplify diagram creation [message #1403355 is a reply to message #1403342] Wed, 23 July 2014 08:00 Go to previous messageGo to next message
Alex Lagarde is currently offline Alex LagardeFriend
Messages: 193
Registered: May 2010
Senior Member

Hi Richard,

You do not have to be in a Modeling Project to be able to select
Viewpoints and Create Diagrams. You just need a "Representation File"
(.aird), as this is this file that holds the Viewpoint Selection and
stores the created representations.

The Modeling Project is just a convenience to create the aird file and
automatically associate any model created in this project to this aird
file. We cannot go much further in easing representation creation as we
do not know which models, viewpoints and representations should be created.

Regarding your question to "simply the creation of a diagram", if you
already know which kind of model should be created and which kind of
Viewpoint activated, you could decide to write your own Wizard that
would do these steps automatically.

Here are some APIs that may interest you in this context:
- Create a representation file
SessionManager.INSTANCE.getSession(myAirdURI, myProgressMonitor)

- Select a Viewpoint
Have a look at "ViewpointSelection", this class provides utility methods
to add a ViewpointSelection page to your own Wizards. If you do not want
to leave the end-user make the choice, you can use the
ChangeViewpointSelectionCommand

- Create a representation
DialectManager.INSTANCE.createRepresentation()

- Open an editor
DialectUIManager.INSTANCE.openEditor()


I also may take a look at what is done in the Ecore Tools Project Wizard
(far more complex operations but same idea)
http://git.eclipse.org/c/ecoretools/org.eclipse.ecoretools.git/tree/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/wizard/EcoreModelerWizard.java

Please let me know if I was not clear or if you have further question.

Regards,
Alex

Le 23/07/2014 08:20, Richard Meyer a écrit :
> Hi,
>
> I have successfully created a Sirius diagram editor and deployed to our
> RCP. Till now, to create a new diagram, the user has to do the following
> steps: - create a Modeling Project - create the EMF model file
> - select the viewpoint
> - create a new representation
>
> Is there a way to simplify the creation of a diagram for the end user
> (New-> DiagramXY)?



>
> Is the creation of a diagram only possible in a "Modeling Project"?
>
> Thanks in advance.
>
Re: Simplify diagram creation [message #1405051 is a reply to message #1403342] Wed, 06 August 2014 13:02 Go to previous messageGo to next message
Richard Meyer is currently offline Richard MeyerFriend
Messages: 40
Registered: June 2012
Member
Hy Alex,

many thanks for your quick response.
Unfortunately I have some problems with the implementation.
I think the first problem is that the viewpoint is not added:
//create viewpoint
IFile airdFile = project.getFile("representations.aird");
if(!airdFile.exists())
    throw new Exception("could not found file:" + airdFile.getLocationURI());
Session session = SessionManager.INSTANCE.getSession(URI.createURI(airdFile.getLocationURI().toASCIIString()), monitor);
                	
                                		
//adding the resource to Sirius session
AddSemanticResourceCommand addCommandToSession = new AddSemanticResourceCommand(session, fileURI, monitor );
session.getTransactionalEditingDomain().getCommandStack().execute(addCommandToSession);
                		
//find and add viewpoint
Set<Viewpoint> viewpoints = ViewpointSelection.getViewpoints(FILE_EXTENSION);
if(viewpoints.isEmpty())
      throw new Exception("Could not found viewpoint for file extension " + FILE_EXTENSION);
                		
ViewpointSelection.Callback callback = new ViewpointSelectionCallbackWithConfimation();
                		 
@SuppressWarnings("restriction")
RecordingCommand command = new ChangeViewpointSelectionCommand(
                				session,
                				callback,
                				viewpoints, new HashSet<Viewpoint>(), monitor);
                		
session.getTransactionalEditingDomain().getCommandStack().execute(command);


In the .aird file I can see that the resource file is successfully added, but the viewpoint is still missing.
If I debug the project I can see that ViewpointSelection.getViewpoints(FILE_EXTENSION); method returns the correct viewpoint.

Any help would be greatly appreciated.
Richard
Re: Simplify diagram creation [message #1405935 is a reply to message #1405051] Fri, 08 August 2014 14:40 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 702
Registered: July 2009
Senior Member
Le 06/08/2014 15:02, Richard Meyer a écrit :
> //find and add viewpoint
> Set<Viewpoint> viewpoints =
> ViewpointSelection.getViewpoints(FILE_EXTENSION);
> if(viewpoints.isEmpty())
> throw new Exception("Could not found viewpoint for file extension
> " + FILE_EXTENSION);
>
> ViewpointSelection.Callback callback = new
> ViewpointSelectionCallbackWithConfimation();
> @SuppressWarnings("restriction")
> RecordingCommand command = new ChangeViewpointSelectionCommand(
> session,
> callback,
> viewpoints, new HashSet<Viewpoint>(),
> monitor);
>
> session.getTransactionalEditingDomain().getCommandStack().execute(command);
>
>
> In the .aird file I can see that the resource file is successfully
> added, but the viewpoint is still missing. If I debug the project I can
> see that ViewpointSelection.getViewpoints(FILE_EXTENSION); method
> returns the correct viewpoint.

I'm not sure this is the cause of your problem, but the instances of
Viewpoint you get from ViewpointSelection.getViewpoints(FILE_EXTENSION)
are the ones loaded in the global ViewpointRegistry (the central
registry which knows about all the viewpoints installed in the system).

Each individual Session is isolated into its own ResourceSet, so it must
have its own copy of the Viewpoints it uses loaded in its context. You
can use

SiriusResourceHelper.getCorrespondingViewpoint(session, viewpoint);

to transform the instances you get from ViewpointSelection into
equivalent instances loaded in the Session's own ResourceSet
(SiriusResourceHelper will take care of loading the .odesign needed in
the session if they are not already).

Try passing the "transformed" Viewpoint instances to
ChangeViewpointSelectionCommand.

--
Pierre-Charles David - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Simplify diagram creation [message #1409972 is a reply to message #1403342] Tue, 19 August 2014 13:00 Go to previous messageGo to next message
Richard Meyer is currently offline Richard MeyerFriend
Messages: 40
Registered: June 2012
Member
Hy Pierre,

many thanks for your help.
With your hint the code now is working.
Only one thing...
rootObject = session.getSemanticResources().iterator().next().getContents().get(0);

Did you know a smarter solution for translating my resource root object to the "session semantic root object" of sirius?

//create a sirius modeling project
IProject project = ModelingProjectManager.INSTANCE.createNewModelingProject(projectName, locationPath, true, monitor);

//create a resource file
ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createPlatformResourceURI("/" + projectName + "/" + projectName + "." + FILE_EXTENSION, true);
Resource resource = resourceSet.createResource(fileURI);
EObject rootObject = MyFactory.eINSTANCE.createRootObject();
resource.getContents().add(rootObject);
Map<Object, Object> options = new HashMap<Object, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
resource.save(options);

//create viewpoint
IFile airdFile = project.getFile("representations.aird");
if(!airdFile.exists())
	throw new Exception("could not found file:" + airdFile.getLocationURI());
URI airdFileURI = URI.createPlatformResourceURI(airdFile.getFullPath().toOSString(), true);
Session session = SessionManager.INSTANCE.getSession(airdFileURI, monitor);

//adding the resource also to Sirius session
AddSemanticResourceCommand addCommandToSession = new AddSemanticResourceCommand(session, fileURI, monitor );
session.getTransactionalEditingDomain().getCommandStack().execute(addCommandToSession);
session.save(monitor);

//find and add viewpoint
Set<Viewpoint> availableViewpoints = ViewpointSelection.getViewpoints(FILE_EXTENSION);
if(availableViewpoints.isEmpty())
	throw new Exception("Could not found viewport for fileextension " + FILE_EXTENSION);

Set<Viewpoint> viewpoints = new HashSet<Viewpoint>();
for(Viewpoint p : availableViewpoints)
	viewpoints.add(SiriusResourceHelper.getCorrespondingViewpoint(session, p));

ViewpointSelection.Callback callback = new ViewpointSelectionCallbackWithConfimation();
 
@SuppressWarnings("restriction")
RecordingCommand command = new ChangeViewpointSelectionCommand(
		session,
		callback,
		viewpoints, new HashSet<Viewpoint>(), true, monitor);
TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
domain.getCommandStack().execute(command);

rootObject = session.getSemanticResources().iterator().next().getContents().get(0);

//create representation
Collection<RepresentationDescription> descriptions = DialectManager.INSTANCE.getAvailableRepresentationDescriptions(session.getSelectedViewpoints(false),  rootObject );
if(descriptions.isEmpty())
	throw new Exception("Could not found representation description for object: " + rootObject);
RepresentationDescription description = descriptions.iterator().next();

DialectManager viewpointDialectManager = DialectManager.INSTANCE;
Command createViewCommand = new CreateRepresentationCommand(session,
		  description, rootObject, projectName, monitor);
 
session.getTransactionalEditingDomain().getCommandStack().execute(createViewCommand);

SessionManager.INSTANCE.notifyRepresentationCreated(session);

//open editor 
Collection<DRepresentation> representations = viewpointDialectManager.getRepresentations(description, session);
DRepresentation myDiagramRepresentation = representations.iterator().next();

DialectUIManager dialectUIManager = DialectUIManager.INSTANCE;
	dialectUIManager.openEditor(session,
		myDiagramRepresentation, monitor);
   
//save session and refresh workspace
session.save(monitor);
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
Re: Simplify diagram creation [message #1699887 is a reply to message #1409972] Sun, 28 June 2015 21:24 Go to previous messageGo to next message
qwer qwer is currently offline qwer qwerFriend
Messages: 9
Registered: June 2015
Junior Member
Hi,

could anyone tell me how to create this root object: EObject rootObject = MyFactory.eINSTANCE.createRootObject(); What does the method createRootObject exactly do?
Re: Simplify diagram creation [message #1699951 is a reply to message #1699887] Mon, 29 June 2015 12:54 Go to previous messageGo to next message
Laurent Fasani is currently offline Laurent FasaniFriend
Messages: 182
Registered: October 2014
Senior Member
Le 28/06/2015 23:24, qwer qwer a écrit :
> Hi,
>
> could anyone tell me how to create this root object: EObject rootObject
> = MyFactory.eINSTANCE.createRootObject(); What does the method
> createRootObject exactly do?

Hi qwer qwer

rootObject is an object of type RootObject that you defined in your meta
model. MyFactory, all your classes and all the stuff are generated using
EMF tool[1].

If you have other question about EMF please use the EMF forum.

Regards
Laurent

[1]
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.emf.doc%2Ftutorials%2Fclibmod%2Fclibmod.html&cp=21_1_0


Laurent Fasani - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Simplify diagram creation [message #1699990 is a reply to message #1699951] Mon, 29 June 2015 14:30 Go to previous messageGo to next message
qwer qwer is currently offline qwer qwerFriend
Messages: 9
Registered: June 2015
Junior Member
Hi,

I'm using the code from Richard Meyer but I'm getting following exception:

!MESSAGE Impossible to find an interpreter - Could not find a session for model element : mypackage.impl.RootObjectImpl@38657ca8 (name: "test) (id: "dsds") (description: "some test descr.")
!STACK 0
java.lang.RuntimeException
	at org.eclipse.sirius.tools.api.interpreter.InterpreterRegistry.getInterpreter(InterpreterRegistry.java:70)
	at org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.createRepresentation(DiagramDialectServices.java:143)
	at org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.createRepresentation(DiagramDialectServices.java:160)
	at org.eclipse.sirius.business.internal.dialect.DialectManagerImpl.createRepresentation(DialectManagerImpl.java:151)
	at org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand.doExecute(CreateRepresentationCommand.java:115)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	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:513)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	mypackage.gui.MyWizard.performFinish(MyWizard.java:177)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:827)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:432)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:628)
	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.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:826)
	at org.eclipse.jface.window.Window.open(Window.java:802)
	at sdq.ipd.uka.de.pcm.editor.gui.EditorAction.run(EditorAction.java:15)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	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:483)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

!ENTRY org.eclipse.ui 4 0 2015-06-29 16:18:44.318
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.getAllInitialyActiveLayers(DDiagramSynchronizer.java:287)
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.activateInitialLayers(DDiagramSynchronizer.java:270)
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.initDiagram(DDiagramSynchronizer.java:226)
	at org.eclipse.sirius.diagram.business.internal.sync.DDiagramSynchronizer.initDiagram(DDiagramSynchronizer.java:57)
	at org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.createRepresentation(DiagramDialectServices.java:147)
	at org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.createRepresentation(DiagramDialectServices.java:160)
	at org.eclipse.sirius.business.internal.dialect.DialectManagerImpl.createRepresentation(DialectManagerImpl.java:151)
	at org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand.doExecute(CreateRepresentationCommand.java:115)
	at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
	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:513)
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	at mypackage.gui.MyWizard.performFinish(MyWizard.java:177)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:827)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:432)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:628)
	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.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:826)
	at org.eclipse.jface.window.Window.open(Window.java:802)
	at sdq.ipd.uka.de.pcm.editor.gui.EditorAction.run(EditorAction.java:15)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
	at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	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:483)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)


The exception is coming from here:

session.getTransactionalEditingDomain().getCommandStack().execute(createViewCommand); 


Does anyone have an idea how to solve this problem?
Re: Simplify diagram creation [message #1700002 is a reply to message #1699990] Mon, 29 June 2015 15:06 Go to previous message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi 'qwer qwer' (would be 'azer azer' on a French keyboard..)



Le 29/06/2015 16:30, qwer qwer a écrit :
> Hi,
>
> I'm using the code from Richard Meyer but I'm getting following exception:

I think you forgot to add your element to a resource and maybe also to
create and save it.

See the code from Richard Meyer:
EObject rootObject = MyFactory.eINSTANCE.createRootObject();
resource.getContents().add(rootObject);

>
>
> !MESSAGE Impossible to find an interpreter - Could not find a session
> for model element : mypackage.impl.RootObjectImpl@38657ca8 (name: "test)
> (id: "dsds") (description: "some test descr.")
> !STACK 0
> java.lang.RuntimeException
> at
> org.eclipse.sirius.tools.api.interpreter.InterpreterRegistry.getInterpreter(InterpreterRegistry.java:70)
>
> at
> org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.createRepresentation(DiagramDialectServices.java:143)
> [...]
> org.eclipse.sirius.business.internal.dialect.DialectManagerImpl.createRepresentation(DialectManagerImpl.java:151)
>
> at
> org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand.doExecute(CreateRepresentationCommand.java:115)
> [...]
> org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
>
> at
> org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
>
> mypackage.gui.MyWizard.performFinish(MyWizard.java:177)
> [...]




The following NPE comes from the same cause: the semantic element has no
resource and Sirius cannot find a session for it.

> !ENTRY org.eclipse.ui 4 0 2015-06-29 16:18:44.318
> !MESSAGE Unhandled event loop exception
> !STACK 0
> java.lang.NullPointerException
> at
> org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.getAllInitialyActiveLayers(DDiagramSynchronizer.java:287)
>
> at
> org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.activateInitialLayers(DDiagramSynchronizer.java:270)
>
> at
> org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.initDiagram(DDiagramSynchronizer.java:226)
>
> at
> org.eclipse.sirius.diagram.business.internal.sync.DDiagramSynchronizer.initDiagram(DDiagramSynchronizer.java:57)
>
> at
> org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.createRepresentation(DiagramDialectServices.java:147)
>
> at
> org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.createRepresentation(DiagramDialectServices.java:160)
>
> at
> org.eclipse.sirius.business.internal.dialect.DialectManagerImpl.createRepresentation(DialectManagerImpl.java:151)
>
> at
> org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand.doExecute(CreateRepresentationCommand.java:115)
> [...]
> org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
>
> at mypackage.gui.MyWizard.performFinish(MyWizard.java:177)
> at

>
> The exception is coming from here:
>
> session.getTransactionalEditingDomain().getCommandStack().execute(createViewCommand);
>
> Does anyone have an idea how to solve this problem?

Regards

--
Maxime - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Automatic validation upon Direct Edit
Next Topic:NullPointerException when saving table representation
Goto Forum:
  


Current Time: Tue Apr 16 21:10:14 GMT 2024

Powered by FUDForum. Page generated in 0.77383 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top