Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [MWE2] Accessing the current workspace from a workflow component
[MWE2] Accessing the current workspace from a workflow component [message #549363] Mon, 26 July 2010 14:12 Go to next message
awidegreen  is currently offline awidegreen Friend
Messages: 14
Registered: July 2010
Junior Member
Hallo,

I'm currently developing a workflow component for accessing projects in the currently loaded workspace. I want to use the eclipse filesystem facilities (workspace, project) and jdt for parsing a given java project.

Therefore I used the standard accessing procedure like:
...
@Override
public void checkConfiguration(Issues issues) {
   super.checkConfiguration(issues);
	
   if (projectNames == null || projectNames.isEmpty()) {
      issues.addError("You need to specify a project.");
      return;
   }
		
   for (String projectName : projectNames) {
      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); //exception
      ...
   }
...
}

While running the workflow with this component (executed from an eclipse launch-config), I get a RuntimeException saying that the "Workspace is closed".
0    [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow workflow.SpecificationParser: Workspace is closed.
java.lang.RuntimeException: Problems running workflow workflow.SpecificationParser: Workspace is closed.
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:82)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)


I'm not quite if the component is running in the given OSGi-context - that would explain that the workspace is closed.

So, is there a suitable way to access the workspace that component?

Thanks,
a widegreen
Re: [MWE2] Accessing the current workspace from a workflow component [message #549387 is a reply to message #549363] Mon, 26 July 2010 14:54 Go to previous messageGo to next message
Missing name Missing nameFriend
Messages: 20
Registered: May 2010
Junior Member
Use PlatformUI.getWorkbench()
Re: [MWE2] Accessing the current workspace from a workflow component [message #549552 is a reply to message #549387] Tue, 27 July 2010 08:06 Go to previous messageGo to next message
awidegreen  is currently offline awidegreen Friend
Messages: 14
Registered: July 2010
Junior Member
Hallo,

obviously, this isn't the right way. After resolving the plugin-dependencies (ui.workbench, swt and jface), I just want to dump the workbench-object (toString):
System.out.println(PlatformUI.getWorkbench().toString());


This also results in a RuntimeException with the message:
0    [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow workflow.SpecificationParser: Workbench has not been created yet.
java.lang.RuntimeException: Problems running workflow workflow.SpecificationParser: Workbench has not been created yet.
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:82)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: java.lang.IllegalStateException: Workbench has not been created yet.


More ideas? ;)

Thanks,
a widegreen
Re: [MWE2] Accessing the current workspace from a workflow component [message #549571 is a reply to message #549552] Tue, 27 July 2010 09:03 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

how do you start the workflow? Do you use "Run as MWE2 Workflow" from
the context menu? In this case you are not working within the current
IDE anymore.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: [MWE2] Accessing the current workspace from a workflow component [message #549582 is a reply to message #549571] Tue, 27 July 2010 09:29 Go to previous messageGo to next message
awidegreen  is currently offline awidegreen Friend
Messages: 14
Registered: July 2010
Junior Member
Yes I do and that is what I just observed ... a new java process is started.
Re: [MWE2] Accessing the current workspace from a workflow component [message #549626 is a reply to message #549582] Tue, 27 July 2010 11:58 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

> Yes I do and that is what I just observed ... a new java process is
> started.

Of course, you can contribute your own action to your development ide
(via a plugin) that starts the workflow within the running Eclipse.
However, it is not recommended at all to do so with workflows that
influence any static registries (as e.g. any LanguageStandaloneSetup).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: [MWE2] Accessing the current workspace from a workflow component [message #551672 is a reply to message #549626] Mon, 09 August 2010 06:48 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The reason why there are some *Standalone classes is that MWE(2) workflows are usually executed "outside" the Eclipse platform, i.e. as a standalone Java process. This is important to be able to run these processes within build systems or other IDEs without the need to run it as an Eclipse application. Most of the registrations should be done automatically when executed within a plugin. This means this would result into two different workflows when you still want to test your generator without the Eclipse runtime.

Kind regards,
~Karsten


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Previous Topic:problem to make a plugin to run the generation of models with xtext
Next Topic:Cross-references to external EMF models (revisited)
Goto Forum:
  


Current Time: Thu Mar 28 08:53:47 GMT 2024

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

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

Back to the top