Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Automatically create diagram on instance creation
Automatically create diagram on instance creation [message #1498364] Thu, 04 December 2014 10:57 Go to next message
Steven Kauffmann is currently offline Steven KauffmannFriend
Messages: 19
Registered: November 2014
Junior Member
Hi all,

I have defined a diagram representation for a certain domain class. I don't find a way to automatically create such a diagram on the moment that an new instance of such a domain class is created.

The initialization option is only executed when the viewpoint specification is loaded so this is not what we would like to have. Are there other possibilities to let it create a diagram on instance creation?

Best regards,
Steven
Re: Automatically create diagram on instance creation [message #1498382 is a reply to message #1498364] Thu, 04 December 2014 11:12 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Steven,

Le 04/12/2014 11:57, Steven Kauffmann a écrit :
> Hi all,
>
> I have defined a diagram representation for a certain domain class. I
> don't find a way to automatically create such a diagram on the moment
> that an new instance of such a domain class is created.
>
> The initialization option is only executed when the viewpoint
> specification is loaded so this is not what we would like to have. Are
> there other possibilities to let it create a diagram on instance creation?

I currently see two possibilies. You could create an aggregate pre
commit only listener or a ModelChangeTrigger (and add it to the
SessionEventBroker which is already an aggregate pre commit listener),
and react to the creation of an instance of your domain class. And init
the wanted representation on it using
DialectManager.INSTANCE.createRepresentation(..) for exemple.

If you want to open the editor you can take a look to
DialectUIManager.INSTANCE.openEditor(..). But this will open the editor
with a
PlatformUI.getWorkbench().getDisplay().syncExec(someRunnableToOpenTheEditor),
so you might have to call it asynchronously or in post commit (and so
maybe use some aggregate pre and post commit listener to do the creation
in precommit, and the open in post commit).


>
> Best regards,
> Steven

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
Re: Automatically create diagram on instance creation [message #1498666 is a reply to message #1498382] Thu, 04 December 2014 15:27 Go to previous messageGo to next message
Steven Kauffmann is currently offline Steven KauffmannFriend
Messages: 19
Registered: November 2014
Junior Member
Hi Maxime,

I'm new to sirius and based on the description in your reply, I still don't know how to get started with this. Is some documentation available?

Best regards,
Steven
Re: Automatically create diagram on instance creation [message #1503649 is a reply to message #1498382] Mon, 08 December 2014 17:03 Go to previous messageGo to next message
Steven Kauffmann is currently offline Steven KauffmannFriend
Messages: 19
Registered: November 2014
Junior Member
Hi Maxime,

I found some code in this forum that helped me to get started, but my test code is unfortunately not working (generates a nullpointer exception):

To get my current session I do:

IWorkbenchPart workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
IFile file = (IFile) workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);
				
URI diagramURI = URI.createURI("/" + file.getProject().getName() + "/" + file.getProjectRelativePath().toOSString());
final Session session = SessionManager.INSTANCE.getSession(diagramURI, new NullProgressMonitor());


To get the description:
Collection<RepresentationDescription> descs = DialectManager.INSTANCE.getAvailableRepresentationDescriptions(session.getSelectedViewpoints(false), fSpecification);


And to finally create the diagram:
for (RepresentationDescription desc : descs) {
   if( desc.getName().equals("FDiagram")) {
      if (DialectManager.INSTANCE.canCreate(fSpecification, desc)) {
          DialectManager.INSTANCE.createRepresentation("new FDiagram", fSpecification, desc, session, new NullProgressMonitor());
      }
   }
}


But when executing the command the createRepresentation line generate a nullpointer exception:

!ENTRY org.eclipse.emf.common 2 0 2014-12-08 18:00:58.437
!MESSAGE An exception was ignored during command execution
!STACK 0
org.eclipse.emf.common.util.WrappedException: An exception was ignored during command execution
	at org.eclipse.emf.common.command.BasicCommandStack.handleError(BasicCommandStack.java:281)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.handleError(AbstractTransactionalCommandStack.java:125)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:229)
	at org.eclipse.sirius.table.ui.tools.internal.editor.action.CreateLineAction.run(CreateLineAction.java:61)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:519)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	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(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: org.eclipse.emf.transaction.RollbackException: Uncaught exception during pre-commit trigger processing
	at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:213)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
	at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
	... 32 more



Any idea what is wrong?

Best regards,
Steven
Re: Automatically create diagram on instance creation [message #1504441 is a reply to message #1503649] Tue, 09 December 2014 08:56 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Le 08/12/2014 18:03, Steven Kauffmann a écrit :
> Hi Maxime,

Hi Steven,

>
> I found some code in this forum that helped me to get started, but my
> test code is unfortunately not working (generates a nullpointer exception):
>
> To get my current session I do:
>
>
> IWorkbenchPart workbenchPart =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
>
> IFile file = (IFile)
> workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);
>
>
> URI diagramURI = URI.createURI("/" + file.getProject().getName() + "/" +
> file.getProjectRelativePath().toOSString());
> final Session session = SessionManager.INSTANCE.getSession(diagramURI,
> new NullProgressMonitor());
>
>
> To get the description:
>
> Collection<RepresentationDescription> descs =
> DialectManager.INSTANCE.getAvailableRepresentationDescriptions(session.getSelectedViewpoints(false),
> fSpecification);
>
>
> And to finally create the diagram:
>
> for (RepresentationDescription desc : descs) {
> if( desc.getName().equals("FDiagram")) {
> if (DialectManager.INSTANCE.canCreate(fSpecification, desc)) {
> DialectManager.INSTANCE.createRepresentation("new FDiagram",
> fSpecification, desc, session, new NullProgressMonitor());
> }
> }
> }
>
>
> But when executing the command the createRepresentation line generate a
> nullpointer exception:
>
>
> !ENTRY org.eclipse.emf.common 2 0 2014-12-08 18:00:58.437
> !MESSAGE An exception was ignored during command execution
> !STACK 0
> org.eclipse.emf.common.util.WrappedException: An exception was ignored
> during command execution
> at
> org.eclipse.emf.common.command.BasicCommandStack.handleError(BasicCommandStack.java:281)
>
> at
> org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.handleError(AbstractTransactionalCommandStack.java:125)
>
> at
> org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:229)
>
> at
> org.eclipse.sirius.table.ui.tools.internal.editor.action.CreateLineAction.run(CreateLineAction.java:61)
>
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:519)
> at
> org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
>
> at
> org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
>
> at
> org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
>
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
> at
> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
>
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
>
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
>
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
> at
> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
>
> 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(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
> Caused by: org.eclipse.emf.transaction.RollbackException: Uncaught
> exception during pre-commit trigger processing
> at
> org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:213)
>
> at
> org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
>
> at
> org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
>
> ... 32 more
>
>
>
> Any idea what is wrong?

I think this might be related to Bug 447669 [1], some Table/Tree
Navigation tools were created with a variable without name, causing this
kind of NPEs in the refresh/actions done after the use of the
corresponding tool. Bug 453545 [2] has been created to detect the
variables with empty names during validation.

Could you check the children variables elements of the Table/Tree
Navigation tools in your Viewpoint Specification Model (.odesign) ? If
you find some variable without name, this could be the cause of your issue.

Regards

>
> Best regards,
> Steven


--
Maxime - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
--
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=453545
[2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=447669


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Automatically create diagram on instance creation [message #1504780 is a reply to message #1504441] Tue, 09 December 2014 14:57 Go to previous messageGo to next message
Steven Kauffmann is currently offline Steven KauffmannFriend
Messages: 19
Registered: November 2014
Junior Member
Hi Maxime,

What do you exactly mean with
Quote:
the children variables elements of the Table/Tree
Navigation tools in your Viewpoint Specification Model


Are this variables that you create in a navigation expression in for instance a cross table description?
At this moment a navigation expression is not defined in my cross table description.

I removed some parts in my cross table and diagram description to have it as minimal as possible (to avoid that the nullpointer is generated because of a mistake). But the nullpointer exception is still there.

Probably there is still an issue with my java code.

The code that should create the diagram is in a doexecute function of a Recordingcommand.

public Command transactionAboutToCommit(ResourceSetChangeEvent event)
			throws RollbackException {
                   
                   // some code to get session and fSpecification as seen in my previous post

                   RecordingCommand cmd2 = new RecordingCommand(getTarget()) {
			@Override
            		protected void doExecute() {
                            Collection<RepresentationDescription> descs = DialectManager.INSTANCE.getAvailableRepresentationDescriptions(session.getSelectedViewpoints(true), fSpecification);
                            for (RepresentationDescription desc : descs) {
                              if( desc.getName().equals("FDiagram")) {
                                if (DialectManager.INSTANCE.canCreate(fSpecification, desc)) {
                                     DialectManager.INSTANCE.createRepresentation("new FDiagram",fSpecification, desc, session, new NullProgressMonitor());
                                }
                              }
	                    }
                         }
                   };
      cmd.append(cmd2);
}


Is this correct? I'm not sure if the getTarget() argument of the RecordingCommand is ok? Or are there others things I'm doing wrong?
When I put a breakpoint on the line DialectManager.INSTANCE.createRepresentation("new FDiagram",fSpecification, desc, session, new NullProgressMonitor()); the session and fSpecification variables are not shown in my debug window. When I put a breakpoint outside the doexecute function than I do get them and the content of these variables seems to be ok. Is it because of the doexecute function that these variables are not visible in the debug window?

Regards,
Steven
Re: Automatically create diagram on instance creation [message #1504856 is a reply to message #1504780] Tue, 09 December 2014 16:22 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Le 09/12/2014 15:57, Steven Kauffmann a écrit :
> Hi Maxime,

Hi Steven
>
> What do you exactly mean with
> Quote:
>> the children variables elements of the Table/Tree Navigation tools in
>> your Viewpoint Specification Model
>
>
> Are this variables that you create in a navigation expression in for
> instance a cross table description?

No, I speak about the variable available in the tools : when you create
a tool (in a ToolSection or in a line mapping for example), the tool is
directly created with some children variables initiated with a default
name. And in some cases, the TableNavigation and TreeNavigation tools
were previously wrongly created with some children variable without name
leading to your kind of stack.

The attached screenshot shows the result of the creation of a
TableNavigation tool and a TreeNavigationTool : the variables are shown
as children of the tools, they can be renamed by the specifier and and
will be available during the tool execution, they are intended to be
used in the model operation defined as children of the tool (or of its
Begin operation).

If you have those kinf of tool in your VSM and if your are impacted by
the bug I mentionned in my previous post, you will have the two Element
Select Variable variables created without name whereas on my screenshot
you can see their default name: "container".




> At this moment a navigation expression is not defined in my cross table
> description.



>
> I removed some parts in my cross table and diagram description to have
> it as minimal as possible (to avoid that the nullpointer is generated
> because of a mistake). But the nullpointer exception is still there.
>
> Probably there is still an issue with my java code.
>
> The code that should create the diagram is in a doexecute function of a
> Recordingcommand.
>
>
> public Command transactionAboutToCommit(ResourceSetChangeEvent event)
> throws RollbackException {
> // some code to get session and fSpecification as
> seen in my previous post
>
> RecordingCommand cmd2 = new
> RecordingCommand(getTarget()) {
> @Override
> protected void doExecute() {
> Collection<RepresentationDescription> descs
> =
> DialectManager.INSTANCE.getAvailableRepresentationDescriptions(session.getSelectedViewpoints(true),
> fSpecification);
> for (RepresentationDescription desc : descs) {
> if( desc.getName().equals("FDiagram")) {
> if
> (DialectManager.INSTANCE.canCreate(fSpecification, desc)) {
>
> DialectManager.INSTANCE.createRepresentation("new
> FDiagram",fSpecification, desc, session, new NullProgressMonitor());
> }
> }
> }
> }
> };
> cmd.append(cmd2);
> }
>
>
> Is this correct? I'm not sure if the getTarget() argument of the
> RecordingCommand is ok? Or are there others things I'm doing wrong?
> When I put a breakpoint on the line
> DialectManager.INSTANCE.createRepresentation("new
> FDiagram",fSpecification, desc, session, new NullProgressMonitor()); the
> session and fSpecification variables are not shown in my debug window.
> When I put a breakpoint outside the doexecute function than I do get
> them and the content of these variables seems to be ok. Is it because of
> the doexecute function that these variables are not visible in the debug
> window?

I think that your command is not executed because the NPE is thrown
during the execution of a command which has been added to the list of
precommit commands before your own command.

>
> Regards,
> Steven
>
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
Re: Automatically create diagram on instance creation [message #1505644 is a reply to message #1504856] Wed, 10 December 2014 07:44 Go to previous messageGo to next message
Steven Kauffmann is currently offline Steven KauffmannFriend
Messages: 19
Registered: November 2014
Junior Member
HI Maxime,

Quote:

No, I speak about the variable available in the tools : when you create
a tool (in a ToolSection or in a line mapping for example), the tool is
directly created with some children variables initiated with a default
name. And in some cases, the TableNavigation and TreeNavigation tools
were previously wrongly created with some children variable without name
leading to your kind of stack.

The attached screenshot shows the result of the creation of a
TableNavigation tool and a TreeNavigationTool : the variables are shown
as children of the tools, they can be renamed by the specifier and and
will be available during the tool execution, they are intended to be
used in the model operation defined as children of the tool (or of its
Begin operation).

If you have those kinf of tool in your VSM and if your are impacted by
the bug I mentionned in my previous post, you will have the two Element
Select Variable variables created without name whereas on my screenshot
you can see their default name: "container".


Thanks for the clarification. I checked all the children variables and they all have a name so it seems that I'm not affected by the bug that you are referring to.

When I do a validation on a label edit I get the warning that the variables are not known in the current context (see attached files). When I debug the java action the parameters seems to be ok. Is this a bug?

Quote:

I think that your command is not executed because the NPE is thrown
during the execution of a command which has been added to the list of
precommit commands before your own command.


When I put the following line (located in the command doexexecute function)

DialectManager.INSTANCE.createRepresentation("new FDiagram", fSpecification, desc, session, new NullProgressMonitor());


in comment I do not get any nullpointer exception so it seems that the precommit command is execute.

Best regards,
Steven

[Updated on: Wed, 10 December 2014 13:13]

Report message to a moderator

Re: Automatically create diagram on instance creation [message #1507046 is a reply to message #1505644] Thu, 11 December 2014 09:16 Go to previous messageGo to next message
Steven Kauffmann is currently offline Steven KauffmannFriend
Messages: 19
Registered: November 2014
Junior Member
Hi Maxime,

The cause of the nullpointer exception seems to be a wrong session parameter.

This was the code to get the session id:
IWorkbenchPart workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
IFile file = (IFile) workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);
				
URI diagramURI = URI.createURI("/" + file.getProject().getName() + "/" + file.getProjectRelativePath().toOSString());
final Session session = SessionManager.INSTANCE.getSession(diagramURI, new NullProgressMonitor());


During debugging the diagrumURI was ok and the session was not null.

But when running the following code:
Collection<Session> listofsessions = SessionManager.INSTANCE.getSessions();


The session received via the URI didn't match any session available in the listofsessions.

Now I have modified the code into:
final Session session = SessionManager.INSTANCE.getSession(fSpecification);


This session is also available in the listofsessions and when executing the createRepresentation code, the nullpointer exception is gone and a new diagram is created. Any idea what went wrong in my first piece of code?

Regards,
Steven
Re: Automatically create diagram on instance creation [message #1507069 is a reply to message #1507046] Thu, 11 December 2014 09:45 Go to previous message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Steven,

Le 11/12/2014 10:16, Steven Kauffmann a écrit :
> Hi Maxime,

>
> The cause of the nullpointer exception seems to be a wrong session
> parameter.
>
> This was the code to get the session id:
>
> IWorkbenchPart workbenchPart =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
>
> IFile file = (IFile)
> workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);
>
>
> URI diagramURI = URI.createURI("/" + file.getProject().getName() + "/" +
> file.getProjectRelativePath().toOSString());
> final Session session = SessionManager.INSTANCE.getSession(diagramURI,
> new NullProgressMonitor());
>
>
> During debugging the diagrumURI was ok and the session was not null.
>
> But when running the following code:
>
> Collection<Session> listofsessions = SessionManager.INSTANCE.getSessions();
>
>
> The session received via the URI didn't match any session available in
> the listofsessions.
>
> Now I have modified the code into:
>
> final Session session = SessionManager.INSTANCE.getSession(fSpecification);
>
>
> This session is also available in the listofsessions and when executing
> the createRepresentation code, the nullpointer exception is gone and a
> new diagram is created. Any idea what went wrong in my first piece of code?

I think your issue came from the fact you called URI.createURI and not
URI.createPlatformResourceURI (for example
URI.createPlatformResourceURI(file.getFullPath().toOSString(), true)).


>
> Regards,
> Steven

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:Forcing an element to be created/ or placed within a specific container.
Next Topic:Edge connections to list elements
Goto Forum:
  


Current Time: Thu Apr 25 01:38:02 GMT 2024

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

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

Back to the top