Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Obtaining *all* referenced projects (including plugins and external folders)
Obtaining *all* referenced projects (including plugins and external folders) [message #331500] Wed, 10 September 2008 14:46 Go to next message
Patrick Schoenbach is currently offline Patrick SchoenbachFriend
Messages: 110
Registered: July 2009
Senior Member
Hi,

at the moment, our plugin uses getReferencedProjects() of IProject to
find out the referenced projects. However, this does not work if
projects in a second runtime Eclipse instance contain references to the
workspace of the "outer" Eclipse instance.

How do I get all referenced projects including references to external
folders?

--
Regards,
Patrick

--
Patrick Schönbach
Software Engineer

PGP public key available. Key ID: 0B7DDE39
Or email to pgp@robustsoft.de with subject 'pschoenb'.
Fingerprint: BE80 0E7E B68E CE99 623C 902D 62A6 806A 0B7D DE39

web: http://www.itemis.de
mail: schoenbach@itemis.de
xing: https://www.xing.com/profile/Patrick_Schoenbach

itemis AG
Schauenburgerstraße 116
24118 Kiel
Germany

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Dr. Burkhard Igel(Vors.), Stephan Grollmann, Michael
Neuhaus
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331501 is a reply to message #331500] Wed, 10 September 2008 15:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33183
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010209090000040208030802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

I wonder if you need to consider the dynamic references:

project.getDescription().getDynamicReferences()



Patrick Sch


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331512 is a reply to message #331501] Wed, 10 September 2008 19:58 Go to previous messageGo to next message
Patrick Schoenbach is currently offline Patrick SchoenbachFriend
Messages: 110
Registered: July 2009
Senior Member
On Wed, 10 Sep 2008 11:35:34 -0400, Ed Merks wrote:

> Patrick,
>
> I wonder if you need to consider the dynamic references:
>
> project.getDescription().getDynamicReferences()

This method returns an empty array in my case.

--
Regards,
Patrick

--
Patrick Schönbach
Software Engineer

PGP public key available. Key ID: 0B7DDE39
Or email to pgp@robustsoft.de with subject 'pschoenb'.
Fingerprint: BE80 0E7E B68E CE99 623C 902D 62A6 806A 0B7D DE39

web: http://www.itemis.de
mail: schoenbach@itemis.de
xing: https://www.xing.com/profile/Patrick_Schoenbach

itemis AG
Schauenburgerstraße 116
24118 Kiel
Germany

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Dr. Burkhard Igel(Vors.), Stephan Grollmann, Michael
Neuhaus
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331513 is a reply to message #331512] Wed, 10 September 2008 21:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33183
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090708090609040109060908
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

I have a feeling that this is just the way it works. The referenced
IProjects, if they aren't actually in your workspace, are not going to
be accessible via the IProject anyway, even if the methods did return
them (and the methods do hint that they would). Maybe I should ask more
generally what you're trying to do? For sure you won't be able to
access these other projects via the Eclipse resource APIs...


Patrick Sch


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331515 is a reply to message #331513] Wed, 10 September 2008 22:05 Go to previous messageGo to next message
Patrick Schoenbach is currently offline Patrick SchoenbachFriend
Messages: 110
Registered: July 2009
Senior Member
On Wed, 10 Sep 2008 17:20:08 -0400, Ed Merks wrote:

> Patrick,
>
> I have a feeling that this is just the way it works. The referenced
> IProjects, if they aren't actually in your workspace, are not going to
> be accessible via the IProject anyway, even if the methods did return
> them (and the methods do hint that they would). Maybe I should ask more
> generally what you're trying to do? For sure you won't be able to
> access these other projects via the Eclipse resource APIs...

Actually, my goal is to find and load a referenced Ecore. The current
code works, except for external folders, and we want to fix this. See:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=244516

--
Regards,
Patrick

--
Patrick Schönbach
Software Engineer

PGP public key available. Key ID: 0B7DDE39
Or email to pgp@robustsoft.de with subject 'pschoenb'.
Fingerprint: BE80 0E7E B68E CE99 623C 902D 62A6 806A 0B7D DE39

web: http://www.itemis.de
mail: schoenbach@itemis.de
xing: https://www.xing.com/profile/Patrick_Schoenbach

itemis AG
Schauenburgerstraße 116
24118 Kiel
Germany

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Dr. Burkhard Igel(Vors.), Stephan Grollmann, Michael
Neuhaus
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331519 is a reply to message #331515] Thu, 11 September 2008 10:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33183
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010800090507050505030401
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

I see that https://bugs.eclipse.org/bugs/show_bug.cgi?id=246764 is
resolved the way I would have expected...

It sounds like this issue is related to

https://bugs.eclipse.org/bugs/show_bug.cgi?id=220218

Any mechanism designed to walk through IProject/IJavaProject is simply
not going to work at all if the things you want to search are not in the
workspace so definitely you need to take a different direction.

I'm not sure if things like
EcorePlugin.getEPackageNsURIToGenModelLocationMap() help; that would
help only if the .ecore files you're trying to locate are those of
models that are installed in the runtime itself...

In the Ecore editor we do the following when setting up the editor to
read the Ecore model

public void createModel()
{

editingDomain.getResourceSet().getURIConverter().getURIMap() .putAll(EcorePlugin.computePlatformURIMap());

What this does is ensure that references of the form
platform:/resource/<project-name>/... are redirected to
platform:/plugin/<plugin-id>/... (where project name and plugin-id are
expected to match) if the project isn't in the workspace but there is a
generated modeling in the runtime that has registered its model/*.ecore
serialized version. And also references of the form
platform:/plugin/<plugin-id>/... are redirected to
platform:/resource/<project-name>/... so that even for registered
models, the workspace version takes precedence... I'm not sure if this
approach would help...

In general, it seems to me that finding Ecore models should not rely on
project references or even on plugin dependencies. Any registered model
should be available...


Patrick Sch


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331522 is a reply to message #331519] Thu, 11 September 2008 11:23 Go to previous messageGo to next message
Patrick Schoenbach is currently offline Patrick SchoenbachFriend
Messages: 110
Registered: July 2009
Senior Member
On Thu, 11 Sep 2008 06:15:49 -0400, Ed Merks wrote:
> What this does is ensure that references of the form
> platform:/resource/<project-name>/... are redirected to
> platform:/plugin/<plugin-id>/... (where project name and plugin-id are
> expected to match) if the project isn't in the workspace but there is a
> generated modeling in the runtime that has registered its model/*.ecore
> serialized version. And also references of the form
> platform:/plugin/<plugin-id>/... are redirected to
> platform:/resource/<project-name>/... so that even for registered
> models, the workspace version takes precedence... I'm not sure if this
> approach would help...

It might help or it might not. But I am not sure yet, that I fully
understand how this works. Could you please elaborate?

--
Regards,
Patrick

--
Patrick Schönbach
Software Engineer

PGP public key available. Key ID: 0B7DDE39
Or email to pgp@robustsoft.de with subject 'pschoenb'.
Fingerprint: BE80 0E7E B68E CE99 623C 902D 62A6 806A 0B7D DE39

web: http://www.itemis.de
mail: schoenbach@itemis.de
xing: https://www.xing.com/profile/Patrick_Schoenbach

itemis AG
Schauenburgerstraße 116
24118 Kiel
Germany

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Dr. Burkhard Igel(Vors.), Stephan Grollmann, Michael
Neuhaus
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331523 is a reply to message #331522] Thu, 11 September 2008 12:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33183
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070008020002020203070806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

Generated models produce this registration:

<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri="http://www.example.com/Library"
class="com.example.library.impl.LibraryPackageImpl"
*genModel="model/Library.genmodel"*/>
</extension>

When we populate the package registry, we also populate
EcorePlugin.getEPackageNsURIToGenModelLocationMap. This lets us know
for each registered package where it's development time GenModel is and
hence where its development time .ecore model is (because that GenModel
references it). From that information we can determine all the plugins
that have GenModels and from that we can build URI maps that redirect
non-existing projects to their plugins and plugins to project in the
work space that takes precedence. Looking at the source code and
Javadoc for these EcorePlugin methods should help understand what they
are doing.

Maybe you could elaborate on the problem you are trying to solve?


Patrick Sch


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331548 is a reply to message #331523] Thu, 11 September 2008 16:38 Go to previous messageGo to next message
Patrick Schoenbach is currently offline Patrick SchoenbachFriend
Messages: 110
Registered: July 2009
Senior Member
On Thu, 11 Sep 2008 08:13:07 -0400, Ed Merks wrote:

> Maybe you could elaborate on the problem you are trying to solve?

Well, actually the problematic code location looks as follows:

private EPackage[] getMetamodelsForProjectInternal(IJavaProject
project, Set<String> visited) {
if (visited.contains(project.getProject().getName()))
return new EPackage[0];
visited.add(project.getProject().getName());

ProjectAnalyzer projectAnalyzer =
getProjectAnalyzer(project.getProject());
if (projectAnalyzer == null) {
return new EPackage[0];
}
// wait if analyzation is currently executed
while (projectAnalyzer.getState() == Job.RUNNING ||
projectAnalyzer.getState() == Job.WAITING) {
try {
Thread.sleep(500l);
if (EmfToolsPlugin.trace)
System.out.println("Waiting 500ms for ProjectAnalyzer of project "
+ project.getProject().getName() + " to finish.");
} catch (InterruptedException e) {
EmfToolsLog.logError(e);
}
}
Map<String, EPackage> packages = new HashMap<String,
EPackage>(projectAnalyzer.getNamedEPackageMap());
try {
for (IProject p : project.getProject().getReferencedProjects()) {
IJavaProject jp = JavaCore.create(p);
EPackage[] ps = getMetamodelsForProjectInternal(jp, visited);
for (EPackage package1 : ps) {
if (!packages.containsKey(package1.getNsURI())) {
packages.put(package1.getNsURI(), package1);
}
}
}
} catch (CoreException e) {
EmfToolsLog.logError(e);
}
return packages.values().toArray(new
EPackage[packages.values().size()]);
}

The ProjectAnalyzer mentioned in the code, tries to obtain an IResource
to the found Ecore file. The problem is that all this does not work, if
the Ecore model is located in an external folder.

--
Regards,
Patrick

--
Patrick Schönbach
Software Engineer

PGP public key available. Key ID: 0B7DDE39
Or email to pgp@robustsoft.de with subject 'pschoenb'.
Fingerprint: BE80 0E7E B68E CE99 623C 902D 62A6 806A 0B7D DE39

web: http://www.itemis.de
mail: schoenbach@itemis.de
xing: https://www.xing.com/profile/Patrick_Schoenbach

itemis AG
Schauenburgerstraße 116
24118 Kiel
Germany

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Dr. Burkhard Igel(Vors.), Stephan Grollmann, Michael
Neuhaus
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331552 is a reply to message #331548] Thu, 11 September 2008 17:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33183
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050901010503060705000701
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

Comments below.

Patrick Sch


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331554 is a reply to message #331552] Thu, 11 September 2008 17:42 Go to previous messageGo to next message
Patrick Schoenbach is currently offline Patrick SchoenbachFriend
Messages: 110
Registered: July 2009
Senior Member
On Thu, 11 Sep 2008 13:17:39 -0400, Ed Merks wrote:

> Yes, and it's simply impossible to make this work. At some point I hope
> to find time to be able to build a package registry that's able to work
> with the target platform as in that EMF bugzilla I referenced. But
> unless you change your design not to rely on everything being in the
> workspace, there's really nothing you can do...

Ok. Is there currently a possible design that would be able to find
models in the workspace, inside deployed plugins, *and* external
folders?

--
Patrick Schönbach
Software Engineer

PGP public key available. Key ID: 0B7DDE39
Or email to pgp@robustsoft.de with subject 'pschoenb'.
Fingerprint: BE80 0E7E B68E CE99 623C 902D 62A6 806A 0B7D DE39

web: http://www.itemis.de
mail: schoenbach@itemis.de
xing: https://www.xing.com/profile/Patrick_Schoenbach

itemis AG
Schauenburgerstraße 116
24118 Kiel
Germany

Rechtlicher Hinweis:
Amtsgericht Dortmund, HRB 20621
Vorstand: Wolfgang Neuhaus, Jens Wagener, Dr. Georg Pietrek
Aufsichtsrat: Dr. Burkhard Igel(Vors.), Stephan Grollmann, Michael
Neuhaus
Re: Obtaining *all* referenced projects (including plugins and external folders) [message #331561 is a reply to message #331554] Thu, 11 September 2008 18:27 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33183
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050008010306010104000906
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Patrick,

In the workspace you could do what you have now. In deployed plugins,
it's possible to force the plugin URL to be converted to a file URL, and
of course that turns it into the final case of pawing through the file
system directly. It's probably good to take a step back and look
consider very carefully how what's being done here is similar to the way
PDE manages and provides access to the target platform... You might
want to treat the problem you're trying to fix as a short term
limitation. Perhaps when I'm in Germany the week of Oct 13th we can
discuss the design choices...


Patrick Sch


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:same package in two different bundles: a problem?
Next Topic:How to get rid of "Run as...,Debug As" in my context menu
Goto Forum:
  


Current Time: Thu Jul 18 04:24:06 GMT 2024

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

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

Back to the top