Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » [SOLVED] JDT API: Searching for classes in plug-ins
[SOLVED] JDT API: Searching for classes in plug-ins [message #896106] Tue, 17 July 2012 09:31 Go to next message
Stefan WülfrathFriend
Messages: 18
Registered: February 2012
Junior Member
Hi,

I have the following situation:

I've defined two DSLs (LibraryDSL and NetworkDSL). The LibraryDSL can be used to define so called element types and allows you to reference a Java class containing the Java implementation of such a type. This looks something like this:
library MyLibrary {
  type ElementType {
    implementingClass = "org.example.MyImplementingClass";
  }
}


The classes referenced by the LibraryDSL must be in the project's classpath.

This works pretty fine using the JDT's SearchEngine.

This project (call it "TheLibraryProject") containing the LibraryDSL file and the implementation classes is a plug-in project. It is created by the system developers.

Additionally there is the NetworkDSL. NetworkDSL files reference the LibraryDSL and are created by the user. The NetworkDSL files are created in a general project ("NetworkProject") without a Java or PDE nature. They look something like this:
import "platform:/plugin/org.example/MyLibrary.librarydsl";
network nw {
  element elem1 of ElementType {
  }
}


Now I want to implement a builder for the "NetworkProject" which reads the .networkdsl file and creates instances of the implementation class for each network element.

How can I search for classes in a plug-in from a non-Java project?

Thank you very much for your help!

Best regards,
Stefan Wülfrath

[Updated on: Wed, 18 July 2012 12:24]

Report message to a moderator

Re: JDT API: Searching for classes in plug-ins [message #896294 is a reply to message #896106] Tue, 17 July 2012 22:35 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
How can I search for classes in a plug-in from a non-Java project?

why do you ask this in the JDT forum? Smile

We're not the exports for non-Java projects. And if searching for Java classes is required, what's wrong with adding the Java nature to those projects?

best,
Stephan
Re: JDT API: Searching for classes in plug-ins [message #896332 is a reply to message #896294] Wed, 18 July 2012 05:29 Go to previous messageGo to next message
Stefan WülfrathFriend
Messages: 18
Registered: February 2012
Junior Member
Hi,

thank you for your answer. Maybe I should copy this topic to the PDE forum.

I'm developing a new Eclipse plug-in including a new project nature. Now I want to develop a builder for that new project nature. This builder reads the network file (written in NetworkDSL), its included element library file (written in LibraryDSL) and searches for the classes referenced by the library file.

An important note: The library file and its referenced classes are deployed as an extra plug-in!

So my builder must read the files and search the Library plug-in for the referenced classes.

For searching the classes I want/have to use the JDT Java class search provided the JDT Core API. So, how can I do this?

Thank you very much for your help!

Best regards,
Stefan Wülfrath
Re: JDT API: Searching for classes in plug-ins [message #896451 is a reply to message #896106] Wed, 18 July 2012 12:24 Go to previous messageGo to next message
Stefan WülfrathFriend
Messages: 18
Registered: February 2012
Junior Member
Hi,

I've found a solution for my problem.

If you want to get the class of any plug-in installed in your Eclipse you can use the following two lines:

Bundle bundle = Platform.getBundle("the.plugin.id");
Class<?> myClass = bundle.loadClass("org.example.MyClass");

Here you are.

I've used the URI of my library file to get the plug-in ID and then used the class identifier specified in the library file to get the class.

Best regards,

Stefan
Re: JDT API: Searching for classes in plug-ins [message #896518 is a reply to message #896332] Wed, 18 July 2012 16:08 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Stefan Wülfrath wrote on Wed, 18 July 2012 07:29
I'm developing a new Eclipse plug-in including a new project nature.


BTW: a project can have multiple natures, so nothing should stop you from having your own nature and the Java nature and perhaps the PDE nature so you can ask the project for files on its class path.

Anyway, since you don't seem to require finding the class file, just accessing the loaded class, your solution might be OK.

Stephan
Previous Topic:Eclipse(Indigo) launch failed after google app engine plugin install
Next Topic:RSE error
Goto Forum:
  


Current Time: Fri Apr 26 20:20:47 GMT 2024

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

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

Back to the top