Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » discover Java/KDM Model programaticaly(how to discover a JavaModel from Java sourcecode programmatically)
discover Java/KDM Model programaticaly [message #553899] Thu, 19 August 2010 11:25 Go to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi

i want to write a program that can discover a Javamodel from Java sourcecode.

This is what Fred Madiot pointed out to me already:

Quote:

Fred Madiot said...

Hi,

Here is an example of code showing how to programmatically create a java model from java source code :

    // Create a discoverer for a Java project
    DiscoverJavaModelFromJavaProject javaDiscoverer = new DiscoverJavaModelFromJavaProject();

    // Parameters of the discoverer
    Map javaDiscoveryParameters = new HashMap();
    javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_SILENT_MODE,true);
    javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_BROWSE_RESULT,false);

    // Execute the discoverer (javaProject is a IJavaProject)
    javaDiscoverer.discoverElement(javaProject, javaDiscoveryParameters);

    // Get the result model
    Resource javaModel=(Resource) javaDiscoveryParameters .get(DefaultDiscoverer.PARAMETER_TARGET_RESOURCE)


If you need help, you can post your questions directly on the MoDisco forum :
http://www.eclipse.org/forums/index.php?t=thread&frm_id= 21&
August 12, 2010 1:01 AM



that is a very great hint and I got it almost to work that way, apart from a few NullPointerExceptions....

Now my question is how do I construct a IJavaProject from the sourcecode located sommewhere on my disk?


I want to build a function something like:
public IJavaProject getJavaProjectFromSource(String pathToSource);


Does anyone have an idea how to do that? Or does someone know that something like that has been done already?

I will be very pleased for every little hint on the subject.
Thanx very much in advance.

Cheers Björn
Re: discover Java/KDM Model programaticaly [message #553934 is a reply to message #553899] Thu, 19 August 2010 13:13 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi,

Modisco Java Discoverer uses the JDT DOM Parser to visit a
org.eclipse.jdt.core.dom.CompilationUnit and transforms it to a
org.eclipse.gmt.modisco.java.Model, then you could use direclty the
org.eclipse.gmt.modisco.java.io.java.JDTVisitor and the
org.eclipse.jdt.core.dom.ASTParser to produces your wanted
org.eclipse.gmt.modisco.java.Model

I have writen a simple example below :

package test;

import java.io.File;
import java.io.FileReader;
import java.util.Collections;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gmt.modisco.java.Model;
import org.eclipse.gmt.modisco.java.emf.JavaFactory;
import org.eclipse.gmt.modisco.java.io.java.JDTVisitor;
import org.eclipse.gmt.modisco.java.io.java.binding.BindingManager;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstant s;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

public class ModiscoTests {

public static void main(String[] args) throws Exception {
File file = new File("datas/Comp111Impl.java");
ASTParser parser = ASTParser.newParser(AST.JLS3);
FileReader fileReader = new FileReader(file);
char buffer[] = new char[(int) file.length()];
fileReader.read(buffer);
parser.setSource(buffer);
parser.setResolveBindings(true);

CompilerOptions options = new CompilerOptions();
options.verbose = true;
options.complianceLevel = ClassFileConstants.JDK1_5;
options.sourceLevel = ClassFileConstants.JDK1_5;

parser.setCompilerOptions(options.getMap());
CompilationUnit compilationUnit = (CompilationUnit) parser
.createAST(null);
compilationUnit.recordModifications();

JavaFactory factory = JavaFactory.eINSTANCE;
Model model = factory.createModel();
BindingManager bindingManager = new BindingManager(factory);
String path = file.getCanonicalPath();
String javaContent = String.copyValueOf(buffer);
JDTVisitor visitor = new JDTVisitor(factory, model, bindingManager,
path, javaContent, false, false);
compilationUnit.accept(visitor);

ResourceSet resourceSet = new ResourceSetImpl();
URI javaModelURI =
URI.createFileURI(file.getName().replaceFirst("java", ".javaxmi"));
Resource resource = resourceSet.createResource(javaModelURI);
resource.getContents().add(model);
resource.save(Collections.emptyMap());
}
}


But unfortunately Modisco is tied to OSGI Runtime Model (it uses
BundleActivator to get runtime informations), then this sample isn't
usable standalone. It would be nice to have Modisco usable standalone,
by using the org.eclipse.core.runtime.Platform.isRunning() operation
when accessing BundleActivator.
I had the same problem in the past.

Best Regards.

On 19/08/2010 13:25, bjorn.t@web.de wrote:
> Hi
>
> i want to write a program that can discover a Javamodel from Java
> sourcecode.
>
> This is what Fred Madiot pointed out to me already:
>
> Quote:
>> Fred Madiot said...
>>
>> Hi,
>>
>> Here is an example of code showing how to programmatically create a
>> java model from java source code :
>>
>>
>> // Create a discoverer for a Java project
>> DiscoverJavaModelFromJavaProject javaDiscoverer = new
>> DiscoverJavaModelFromJavaProject();
>>
>> // Parameters of the discoverer
>> Map javaDiscoveryParameters = new HashMap();
>> javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_SILE NT_MODE,true);
>>
>> javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_BROW SE_RESULT,false);
>>
>>
>> // Execute the discoverer (javaProject is a IJavaProject)
>> javaDiscoverer.discoverElement(javaProject, javaDiscoveryParameters);
>>
>> // Get the result model
>> Resource javaModel=(Resource) javaDiscoveryParameters
>> .get(DefaultDiscoverer.PARAMETER_TARGET_RESOURCE)
>>
>>
>> If you need help, you can post your questions directly on the MoDisco
>> forum :
>> http://www.eclipse.org/forums/index.php?t=thread&frm_id= 21&
>> August 12, 2010 1:01 AM
>
>
> that is a very great hint and I got it almost to work that way, apart
> from a few NullPointerExceptions....
>
> Now my question is how do I construct a IJavaProject from the sourcecode
> located sommewhere on my disk?
>
>
> I want to build a function something like:
>
> public IJavaProject getJavaProjectFromSource(String pathToSource);
>
>
> Does anyone have an idea how to do that? Or does someone know that
> something like that has been done already?
>
> I will be very pleased for every little hint on the subject.
> Thanx very much in advance.
>
> Cheers Björn
>
Re: discover Java/KDM Model programaticaly [message #554108 is a reply to message #553934] Fri, 20 August 2010 07:58 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
To complete Esteban response, it is true that MoDisco Java discoverer
requires a workspace in a running Eclipse instance.

So if you want to have a IJavaProject instance from your sourcepath, you
need to first import your project (from your 'pathToSource') into an
Eclipse workspace project.

Then the two following lines will do the trick :

IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("PROJECT_NAME ");
IJavaProject javaProject = JavaCore.create(project);

(where PROJECT_NAME is the name of project in the workspace)


I don't know how much you are familiar with Eclipse plugins
developement, but here is the way to launch your application :

In order to acces to the given workspace, your client program (which
launches the java discovery) should be launched as an "Eclipse
Application" rather than an "Java Application", and the "Workspace Data
Location" should target the workspace containing the PROJECT_NAME project.
So your client program should be available through a plugin project (UI
workbench action or standalone "Eclipse Application")

Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: discover Java/KDM Model programaticaly [message #554365 is a reply to message #554108] Sun, 22 August 2010 12:23 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Fabien Giquel wrote on Fri, 20 August 2010 03:58
To complete Esteban response, it is true that MoDisco Java discoverer
requires a workspace in a running Eclipse instance.

So if you want to have a IJavaProject instance from your sourcepath, you
need to first import your project (from your 'pathToSource') into an
Eclipse workspace project.

Then the two following lines will do the trick :

IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("PROJECT_NAME ");
IJavaProject javaProject = JavaCore.create(project);

(where PROJECT_NAME is the name of project in the workspace)


I don't know how much you are familiar with Eclipse plugins
developement, but here is the way to launch your application :

In order to acces to the given workspace, your client program (which
launches the java discovery) should be launched as an "Eclipse
Application" rather than an "Java Application", and the "Workspace Data
Location" should target the workspace containing the PROJECT_NAME project.
So your client program should be available through a plugin project (UI
workbench action or standalone "Eclipse Application")

Fabien.


Hi Fabien,

thank you very much for this helpful information.
This got me to the point where I want to be Smile

except from the part with "...need to first import your project (from your 'pathToSource') into an Eclipse workspace project..."

Does anyone know how to do that programaticaly? I would like to import
my javasources into an Eclipse workspace project silently... only having the pathToSource and making up some PROJECT_NAME.

I am running my app as Eclipse App anyway so the workspace is available...

Thanx in advance

Cheers Björn
Re: discover Java/KDM Model programaticaly [message #554751 is a reply to message #554365] Tue, 24 August 2010 10:35 Go to previous messageGo to next message
Gabriel BARBIER is currently offline Gabriel BARBIERFriend
Messages: 106
Registered: July 2009
Senior Member
Hello Björn,
You may find an example of how to create a project in your workspace and populate it programmatically in the tests of
MoDisco. Please have a look of tests for java discoverer specifically (SimpleBlackBoxDiscovery, etc.) in SVN.

And to retrieve MoDisco sources: http://wiki.eclipse.org/MoDisco#Getting_involved

Regards,
Gabriel

bjorn.t@web.de wrote:
> Fabien Giquel wrote on Fri, 20 August 2010 03:58
>> To complete Esteban response, it is true that MoDisco Java discoverer
>> requires a workspace in a running Eclipse instance.
>>
>> So if you want to have a IJavaProject instance from your sourcepath,
>> you need to first import your project (from your 'pathToSource') into
>> an Eclipse workspace project.
>>
>> Then the two following lines will do the trick :
>>
>> IProject project =
>> ResourcesPlugin.getWorkspace().getRoot().getProject("PROJECT_NAME ");
>> IJavaProject javaProject = JavaCore.create(project);
>>
>> (where PROJECT_NAME is the name of project in the workspace)
>>
>>
>> I don't know how much you are familiar with Eclipse plugins
>> developement, but here is the way to launch your application :
>>
>> In order to acces to the given workspace, your client program (which
>> launches the java discovery) should be launched as an "Eclipse
>> Application" rather than an "Java Application", and the "Workspace
>> Data Location" should target the workspace containing the PROJECT_NAME
>> project.
>> So your client program should be available through a plugin project
>> (UI workbench action or standalone "Eclipse Application")
>>
>> Fabien.
>
>
> Hi Fabien,
>
> thank you very much for this helpful information.
> This got me to the point where I want to be :)
>
> except from the part with "...need to first import your project (from
> your 'pathToSource') into an Eclipse workspace project..."
> Does anyone know how to do that programaticaly? I would like to import
> my javasources into an Eclipse workspace project silently... only having
> the pathToSource and making up some PROJECT_NAME.
>
> I am running my app as Eclipse App anyway so the workspace is available...
>
> Thanx in advance
>
> Cheers Björn
>
Re: discover Java/KDM Model programaticaly [message #557251 is a reply to message #554751] Mon, 06 September 2010 09:36 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi Gabriel,

thank you very much for that hint that helped me a lot!

Cheers Björn

Now there is anotherproblem:

when trying to run an Java Discovery on a JavaProject I keep getting this exception:

java.lang.ExceptionInInitializerError
	at org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(JavaReader.java:158)
	at org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJavaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
	at org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit>(JDTVisitorUtils.java:61)
	... 3 more


doing right this in my code:
JavaActivator javaActivator = JavaActivator.getDefault();
		javaDiscoverer.discoverElement(this.javaProject,
				javaDiscoveryParameters);


it has to do with the fact that
javaActivator==null
in my code as well as in the JDTVisitorUtils line 61.

Does anyone have an idea why this could be ?

Thank you in advance
Cheers Björn

[Updated on: Mon, 06 September 2010 09:38]

Report message to a moderator

Re: discover Java/KDM Model programaticaly [message #557287 is a reply to message #554751] Mon, 06 September 2010 13:15 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi Gabriel,

thank you very much for that hint that helped me a lot!

Apart from the fact that the JavaProjectFactory uses:

Activator.getDefault()

which always returns NULL in my code... do you have an idea why that is the case?

Cheers Björn



Now there is anotherproblem:

when trying to run an Java Discovery on a JavaProject I keep getting this exception:

java.lang.ExceptionInInitializerError
	at org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(JavaReader.java:158)
	at org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJavaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
	at org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit>(JDTVisitorUtils.java:61)
	... 3 more



doing right this in my code:

JavaActivator javaActivator = JavaActivator.getDefault();
		javaDiscoverer.discoverElement(this.javaProject,
				javaDiscoveryParameters);



it has to do with the fact that

javaActivator==null


in my code as well as in the JDTVisitorUtils line 61.

Does anyone have an idea why this could be ?

Thank you in advance
Cheers Björn
Re: discover Java/KDM Model programaticaly [message #557306 is a reply to message #557287] Mon, 06 September 2010 14:32 Go to previous messageGo to next message
Gabriel BARBIER is currently offline Gabriel BARBIERFriend
Messages: 106
Registered: July 2009
Senior Member
Hello Björn,
Could you confirm that you are trying to launch your program using "Run as ... Eclipse application". It is needed to run
your program on top of osgi framework which will manage the life cycle of your plug-in ? And to be sure, have you
created your project using wizard for eclipse plug-ins ? Your previous post seems to indicate that it should be ok, let
see it as a double check ;-)

Another question, which Activator do you use ? You have to use the one you have created with your plug-in project. (Also
check your project dependencies, it should not contains a dependency to java.discoverer.tests ...)

And to use the JavaProjectFactory, last but not least, you have to copy/paste the class in your plug-in project (as it
is contextual).

If all the previous hints are not helpful, could you send us your project ?

Regards,
Gabriel

bjorn.t@web.de wrote:
> Hi Gabriel,
>
> thank you very much for that hint that helped me a lot!
>
> Apart from the fact that the JavaProjectFactory uses:
>
> Activator.getDefault()
> which always returns NULL in my code... do you have an idea why that is
> the case?
>
> Cheers Björn
>
>
>
> Now there is anotherproblem:
>
> when trying to run an Java Discovery on a JavaProject I keep getting
> this exception:
>
>
> java.lang.ExceptionInInitializerError
> at
> org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(Ja vaReader.java:158)
>
> at
> org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJa vaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit >(JDTVisitorUtils.java:61)
>
> ... 3 more
>
>
>
> doing right this in my code:
>
>
> JavaActivator javaActivator = JavaActivator.getDefault();
> javaDiscoverer.discoverElement(this.javaProject,
> javaDiscoveryParameters);
>
>
>
> it has to do with the fact that
>
>
> javaActivator==null
>
>
> in my code as well as in the JDTVisitorUtils line 61.
>
> Does anyone have an idea why this could be ?
>
> Thank you in advance
> Cheers Björn
Re: discover Java/KDM Model programaticaly [message #557377 is a reply to message #557306] Tue, 07 September 2010 08:34 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi Gabriel,

thank you for your hints.
Yes I am starting the plugin with "Run as Eclipse App..."
Yes I did create the plugin with the wizzard, and i am using my own Activator that was generated by the wizzard.
After checking your suggestions i removed a coouple of not needed dependencies...
and now Activator.getDefault() seems to call the method inside my activator.
I copied the code from the factory in the projekt, so the Factory does work now.

Thank you very much!!!

Now I still have a problem with the discovery part:
When calling the javaDiscoverer with ...discoverElement(...) like this:
		DiscoverJavaModelFromJavaProject javaDiscoverer = new DiscoverJavaModelFromJavaProject();

		// Parameters of the discoverer
		Map javaDiscoveryParameters = new HashMap();
		javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_SILENT_MODE,
				true);
		javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_BROWSE_RESULT,
				false);

		// Execute the discoverer (javaProject is a IJavaProject)
			try {
				this.javaProject.open(new NullProgressMonitor());
				// /IPackageFragmentRoot[] packageFragmentRoots =
				// this.javaProject.getAllPackageFragmentRoots();
				IPackageFragment[] packageFragment = this.javaProject
						.getPackageFragments();
				for (int i = 0; i < packageFragment.length; i++) {
					packageFragment[i].open(new NullProgressMonitor());
					System.out.println(packageFragment[i].getElementName());
				}
			} catch (CoreException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		javaDiscoverer.discoverElement(this.javaProject, javaDiscoveryParameters);


I get this exception:
!ENTRY org.eclipse.core.jobs 4 2 2010-09-07 10:26:45.275
!MESSAGE An internal error occurred during: "Discovering Java model".
!STACK 0
java.lang.ExceptionInInitializerError
	at org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(JavaReader.java:158)
	at org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJavaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
	at org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit>(JDTVisitorUtils.java:61)
	... 3 more



it looks like

JavaActivator.getDefault()==null


in line 60 of org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils:

	private static final boolean TRACE_QN = JavaActivator.getDefault()
			.isDebugging()
			&& new Boolean(Platform.getDebugOption(JDTVisitorUtils.TRACEID_QN));


called from DiscoverJavaModelFromJavaProject (line 194) -> JavaReader.readModel (line 158) -> JDTVisitorUtils (line 60)...

does anyone have any idea what could be missing?
Thank you very much for some help!

Cheers Björn

[Updated on: Tue, 07 September 2010 08:49]

Report message to a moderator

Re: discover Java/KDM Model programaticaly [message #557636 is a reply to message #557377] Wed, 08 September 2010 11:55 Go to previous messageGo to next message
Gabriel BARBIER is currently offline Gabriel BARBIERFriend
Messages: 106
Registered: July 2009
Senior Member
Hello Björn,
I'm glad that you were able to go through previous problem. And your code looks great.

The new problem seems to be more "strange", as it is now the JavaActivator.getDefault() which returns null. The plug-in
of java discoverer is not managed correctly ... but why ?
Could you validate the launch configuration you are using to test (to check if all needed plug-ins are available) ? And
also, could you verify if your plug-in has the same dependencies as the plug-in to test the java discoverer ?

Regards
Gabriel


bjorn.t@web.de wrote:
> Hi Gabriel,
>
> thank you for your hints.
> Yes I am starting the plugin with "Run as Eclipse App..."
> Yes I did create the plugin with the wizzard, and i am using my own
> Activator that was generated by the wizzard.
> After checking your suggestions i removed a coouple of not needed
> dependencies...
> and now Activator.getDefault() seems to call the method inside my
> activator.
> I copied the code from the factory in the projekt, so the Factory does
> work now.
>
> Thank you very much!!!
>
> Now I still have a problem with the discovery part:
> When calling the javaDiscoverer like this:
>
> DiscoverJavaModelFromJavaProject javaDiscoverer = new
> DiscoverJavaModelFromJavaProject();
>
> // Parameters of the discoverer
> Map javaDiscoveryParameters = new HashMap();
>
> javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_SILE NT_MODE,
> true);
>
> javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_BROW SE_RESULT,
> false);
>
> // Execute the discoverer (javaProject is a IJavaProject)
> try {
> this.javaProject.open(new NullProgressMonitor());
> // /IPackageFragmentRoot[] packageFragmentRoots =
> // this.javaProject.getAllPackageFragmentRoots();
> IPackageFragment[] packageFragment = this.javaProject
> .getPackageFragments();
> for (int i = 0; i < packageFragment.length; i++) {
> packageFragment[i].open(new NullProgressMonitor());
>
> System.out.println(packageFragment[i].getElementName());
> }
> } catch (CoreException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> javaDiscoverer.discoverElement(this.javaProject,
> javaDiscoveryParameters);
>
>
> i get this exception:
> !ENTRY org.eclipse.core.jobs 4 2 2010-09-07 10:26:45.275
> !MESSAGE An internal error occurred during: "Discovering Java model".
> !STACK 0
> java.lang.ExceptionInInitializerError
> at
> org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(Ja vaReader.java:158)
>
> at
> org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJa vaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit >(JDTVisitorUtils.java:61)
>
> ... 3 more
>
>
> does anyone have any idea what could be missing?
> Thank you very much for some help!
>
> Cheers Björn
>
Re: discover Java/KDM Model programaticaly [message #557895 is a reply to message #557636] Thu, 09 September 2010 11:25 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
hi,

that was again a very good advice!

I was missing "org.eclipse.gmt.modisco.java.discoverer" in the dependencies..

Thank you very much !
Re: discover Java/KDM Model programaticaly [message #575734 is a reply to message #553934] Fri, 20 August 2010 07:58 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
To complete Esteban response, it is true that MoDisco Java discoverer
requires a workspace in a running Eclipse instance.

So if you want to have a IJavaProject instance from your sourcepath, you
need to first import your project (from your 'pathToSource') into an
Eclipse workspace project.

Then the two following lines will do the trick :

IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("PROJECT_NAME ");
IJavaProject javaProject = JavaCore.create(project);

(where PROJECT_NAME is the name of project in the workspace)


I don't know how much you are familiar with Eclipse plugins
developement, but here is the way to launch your application :

In order to acces to the given workspace, your client program (which
launches the java discovery) should be launched as an "Eclipse
Application" rather than an "Java Application", and the "Workspace Data
Location" should target the workspace containing the PROJECT_NAME project.
So your client program should be available through a plugin project (UI
workbench action or standalone "Eclipse Application")

Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: discover Java/KDM Model programaticaly [message #575766 is a reply to message #554108] Sun, 22 August 2010 12:23 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Fabien Giquel wrote on Fri, 20 August 2010 03:58
> To complete Esteban response, it is true that MoDisco Java discoverer
> requires a workspace in a running Eclipse instance.
>
> So if you want to have a IJavaProject instance from your sourcepath, you
> need to first import your project (from your 'pathToSource') into an
> Eclipse workspace project.
>
> Then the two following lines will do the trick :
>
> IProject project =
> ResourcesPlugin.getWorkspace().getRoot().getProject("PROJECT_NAME ");
> IJavaProject javaProject = JavaCore.create(project);
>
> (where PROJECT_NAME is the name of project in the workspace)
>
>
> I don't know how much you are familiar with Eclipse plugins
> developement, but here is the way to launch your application :
>
> In order to acces to the given workspace, your client program (which
> launches the java discovery) should be launched as an "Eclipse
> Application" rather than an "Java Application", and the "Workspace Data
> Location" should target the workspace containing the PROJECT_NAME project.
> So your client program should be available through a plugin project (UI
> workbench action or standalone "Eclipse Application")
>
> Fabien.


Hi Fabien,

thank you very much for this helpful information.
This got me to the point where I want to be :)

except from the part with "...need to first import your project (from your 'pathToSource') into an Eclipse workspace project..."

Does anyone know how to do that programaticaly? I would like to import
my javasources into an Eclipse workspace project silently... only having the pathToSource and making up some PROJECT_NAME.

I am running my app as Eclipse App anyway so the workspace is available...

Thanx in advance

Cheers Björn
Re: discover Java/KDM Model programaticaly [message #575788 is a reply to message #575766] Tue, 24 August 2010 10:35 Go to previous messageGo to next message
Gabriel BARBIER is currently offline Gabriel BARBIERFriend
Messages: 106
Registered: July 2009
Senior Member
Hello Björn,
You may find an example of how to create a project in your workspace and populate it programmatically in the tests of
MoDisco. Please have a look of tests for java discoverer specifically (SimpleBlackBoxDiscovery, etc.) in SVN.

And to retrieve MoDisco sources: http://wiki.eclipse.org/MoDisco#Getting_involved

Regards,
Gabriel

bjorn.t@web.de wrote:
> Fabien Giquel wrote on Fri, 20 August 2010 03:58
>> To complete Esteban response, it is true that MoDisco Java discoverer
>> requires a workspace in a running Eclipse instance.
>>
>> So if you want to have a IJavaProject instance from your sourcepath,
>> you need to first import your project (from your 'pathToSource') into
>> an Eclipse workspace project.
>>
>> Then the two following lines will do the trick :
>>
>> IProject project =
>> ResourcesPlugin.getWorkspace().getRoot().getProject("PROJECT_NAME ");
>> IJavaProject javaProject = JavaCore.create(project);
>>
>> (where PROJECT_NAME is the name of project in the workspace)
>>
>>
>> I don't know how much you are familiar with Eclipse plugins
>> developement, but here is the way to launch your application :
>>
>> In order to acces to the given workspace, your client program (which
>> launches the java discovery) should be launched as an "Eclipse
>> Application" rather than an "Java Application", and the "Workspace
>> Data Location" should target the workspace containing the PROJECT_NAME
>> project.
>> So your client program should be available through a plugin project
>> (UI workbench action or standalone "Eclipse Application")
>>
>> Fabien.
>
>
> Hi Fabien,
>
> thank you very much for this helpful information.
> This got me to the point where I want to be :)
>
> except from the part with "...need to first import your project (from
> your 'pathToSource') into an Eclipse workspace project..."
> Does anyone know how to do that programaticaly? I would like to import
> my javasources into an Eclipse workspace project silently... only having
> the pathToSource and making up some PROJECT_NAME.
>
> I am running my app as Eclipse App anyway so the workspace is available...
>
> Thanx in advance
>
> Cheers Björn
>
Re: discover Java/KDM Model programaticaly [message #575891 is a reply to message #554751] Mon, 06 September 2010 09:36 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi Gabriel,

thank you very much for that hint that helped me a lot!

Cheers Björn

Now there is anotherproblem:

when trying to run an Java Discovery on a JavaProject I keep getting this exception:

java.lang.ExceptionInInitializerError
at org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(Ja vaReader.java:158)
at org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJa vaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
at org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit >(JDTVisitorUtils.java:61)
... 3 more

doing right this in my code:
JavaActivator javaActivator = JavaActivator.getDefault();
javaDiscoverer.discoverElement(this.javaProject,
javaDiscoveryParameters);

does anyone have an idea why this could be ?

Thank you in advance
Cheers Björn
Re: discover Java/KDM Model programaticaly [message #575915 is a reply to message #554751] Mon, 06 September 2010 13:15 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi Gabriel,

thank you very much for that hint that helped me a lot!

Apart from the fact that the JavaProjectFactory uses:

Activator.getDefault()
which always returns NULL in my code... do you have an idea why that is the case?

Cheers Björn



Now there is anotherproblem:

when trying to run an Java Discovery on a JavaProject I keep getting this exception:


java.lang.ExceptionInInitializerError
at org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(Ja vaReader.java:158)
at org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJa vaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
at org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit >(JDTVisitorUtils.java:61)
... 3 more



doing right this in my code:


JavaActivator javaActivator = JavaActivator.getDefault();
javaDiscoverer.discoverElement(this.javaProject,
javaDiscoveryParameters);



it has to do with the fact that


javaActivator==null


in my code as well as in the JDTVisitorUtils line 61.

Does anyone have an idea why this could be ?

Thank you in advance
Cheers Björn
Re: discover Java/KDM Model programaticaly [message #575935 is a reply to message #575915] Mon, 06 September 2010 14:32 Go to previous messageGo to next message
Gabriel BARBIER is currently offline Gabriel BARBIERFriend
Messages: 106
Registered: July 2009
Senior Member
Hello Björn,
Could you confirm that you are trying to launch your program using "Run as ... Eclipse application". It is needed to run
your program on top of osgi framework which will manage the life cycle of your plug-in ? And to be sure, have you
created your project using wizard for eclipse plug-ins ? Your previous post seems to indicate that it should be ok, let
see it as a double check ;-)

Another question, which Activator do you use ? You have to use the one you have created with your plug-in project. (Also
check your project dependencies, it should not contains a dependency to java.discoverer.tests ...)

And to use the JavaProjectFactory, last but not least, you have to copy/paste the class in your plug-in project (as it
is contextual).

If all the previous hints are not helpful, could you send us your project ?

Regards,
Gabriel

bjorn.t@web.de wrote:
> Hi Gabriel,
>
> thank you very much for that hint that helped me a lot!
>
> Apart from the fact that the JavaProjectFactory uses:
>
> Activator.getDefault()
> which always returns NULL in my code... do you have an idea why that is
> the case?
>
> Cheers Björn
>
>
>
> Now there is anotherproblem:
>
> when trying to run an Java Discovery on a JavaProject I keep getting
> this exception:
>
>
> java.lang.ExceptionInInitializerError
> at
> org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(Ja vaReader.java:158)
>
> at
> org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJa vaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit >(JDTVisitorUtils.java:61)
>
> ... 3 more
>
>
>
> doing right this in my code:
>
>
> JavaActivator javaActivator = JavaActivator.getDefault();
> javaDiscoverer.discoverElement(this.javaProject,
> javaDiscoveryParameters);
>
>
>
> it has to do with the fact that
>
>
> javaActivator==null
>
>
> in my code as well as in the JDTVisitorUtils line 61.
>
> Does anyone have an idea why this could be ?
>
> Thank you in advance
> Cheers Björn
Re: discover Java/KDM Model programaticaly [message #575960 is a reply to message #557306] Tue, 07 September 2010 08:34 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi Gabriel,

thank you for your hints.
Yes I am starting the plugin with "Run as Eclipse App..."
Yes I did create the plugin with the wizzard, and i am using my own Activator that was generated by the wizzard.
After checking your suggestions i removed a coouple of not needed dependencies...
and now Activator.getDefault() seems to call the method inside my activator.
I copied the code from the factory in the projekt, so the Factory does work now.

Thank you very much!!!

Now I still have a problem with the discovery part:
When calling the javaDiscoverer like this:

DiscoverJavaModelFromJavaProject javaDiscoverer = new DiscoverJavaModelFromJavaProject();

// Parameters of the discoverer
Map javaDiscoveryParameters = new HashMap();
javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_SILE NT_MODE,
true);
javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_BROW SE_RESULT,
false);

// Execute the discoverer (javaProject is a IJavaProject)
try {
this.javaProject.open(new NullProgressMonitor());
// /IPackageFragmentRoot[] packageFragmentRoots =
// this.javaProject.getAllPackageFragmentRoots();
IPackageFragment[] packageFragment = this.javaProject
.getPackageFragments();
for (int i = 0; i < packageFragment.length; i++) {
packageFragment[i].open(new NullProgressMonitor());
System.out.println(packageFragment[i].getElementName());
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

javaDiscoverer.discoverElement(this.javaProject, javaDiscoveryParameters);


i get this exception:
!ENTRY org.eclipse.core.jobs 4 2 2010-09-07 10:26:45.275
!MESSAGE An internal error occurred during: "Discovering Java model".
!STACK 0
java.lang.ExceptionInInitializerError
at org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(Ja vaReader.java:158)
at org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJa vaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
at org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit >(JDTVisitorUtils.java:61)
... 3 more


does anyone have any idea what could be missing?
Thank you very much for some help!

Cheers Björn
Re: discover Java/KDM Model programaticaly [message #576039 is a reply to message #575960] Wed, 08 September 2010 11:55 Go to previous messageGo to next message
Gabriel BARBIER is currently offline Gabriel BARBIERFriend
Messages: 106
Registered: July 2009
Senior Member
Hello Björn,
I'm glad that you were able to go through previous problem. And your code looks great.

The new problem seems to be more "strange", as it is now the JavaActivator.getDefault() which returns null. The plug-in
of java discoverer is not managed correctly ... but why ?
Could you validate the launch configuration you are using to test (to check if all needed plug-ins are available) ? And
also, could you verify if your plug-in has the same dependencies as the plug-in to test the java discoverer ?

Regards
Gabriel


bjorn.t@web.de wrote:
> Hi Gabriel,
>
> thank you for your hints.
> Yes I am starting the plugin with "Run as Eclipse App..."
> Yes I did create the plugin with the wizzard, and i am using my own
> Activator that was generated by the wizzard.
> After checking your suggestions i removed a coouple of not needed
> dependencies...
> and now Activator.getDefault() seems to call the method inside my
> activator.
> I copied the code from the factory in the projekt, so the Factory does
> work now.
>
> Thank you very much!!!
>
> Now I still have a problem with the discovery part:
> When calling the javaDiscoverer like this:
>
> DiscoverJavaModelFromJavaProject javaDiscoverer = new
> DiscoverJavaModelFromJavaProject();
>
> // Parameters of the discoverer
> Map javaDiscoveryParameters = new HashMap();
>
> javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_SILE NT_MODE,
> true);
>
> javaDiscoveryParameters.put(DefaultDiscoverer.PARAMETER_BROW SE_RESULT,
> false);
>
> // Execute the discoverer (javaProject is a IJavaProject)
> try {
> this.javaProject.open(new NullProgressMonitor());
> // /IPackageFragmentRoot[] packageFragmentRoots =
> // this.javaProject.getAllPackageFragmentRoots();
> IPackageFragment[] packageFragment = this.javaProject
> .getPackageFragments();
> for (int i = 0; i < packageFragment.length; i++) {
> packageFragment[i].open(new NullProgressMonitor());
>
> System.out.println(packageFragment[i].getElementName());
> }
> } catch (CoreException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> javaDiscoverer.discoverElement(this.javaProject,
> javaDiscoveryParameters);
>
>
> i get this exception:
> !ENTRY org.eclipse.core.jobs 4 2 2010-09-07 10:26:45.275
> !MESSAGE An internal error occurred during: "Discovering Java model".
> !STACK 0
> java.lang.ExceptionInInitializerError
> at
> org.eclipse.gmt.modisco.java.io.java.JavaReader.readModel(Ja vaReader.java:158)
>
> at
> org.eclipse.gmt.modisco.java.actions.DiscoverJavaModelFromJa vaProject$2.run(DiscoverJavaModelFromJavaProject.java:194)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.gmt.modisco.java.io.java.JDTVisitorUtils.<clinit >(JDTVisitorUtils.java:61)
>
> ... 3 more
>
>
> does anyone have any idea what could be missing?
> Thank you very much for some help!
>
> Cheers Björn
>
Re: discover Java/KDM Model programaticaly [message #576058 is a reply to message #557636] Thu, 09 September 2010 11:25 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
hi,

that was again a very good advice!

I was missing "org.eclipse.gmt.modisco.java.discoverer" in the dependencies..

Thank you very much !
Re: discover Java/KDM Model programaticaly [message #629289 is a reply to message #553899] Mon, 27 September 2010 16:50 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi,

when running the MoDisco PlugIn discovering a javamodel from javacode and a kdmmodel from javamodel, I get the following errors on the console:

when starting as eclipse app including modisco:
** (Eclipse:5008): CRITICAL **: murrine_style_draw_box: assertion `height >= -1' failed


later when running the

DiscoverKdmModelFromJavaModel.discoverElement(model, parameters);


method I get this error:

Cannot set feature comment to value [org.eclipse.gmt.modisco.java.emf.impl.LineCommentImpl@7d869bc7 (content: // asdf, enclosedByParent: false, prefixOfParent: true)], inter-model references are forbidden. Configure launching options to allow them.
Cannot set feature comment to value [org.eclipse.gmt.modisco.java.emf.impl.LineCommentImpl@5aa86d82 (content: // asdfasdf, enclosedByParent: false, prefixOfParent: true)], inter-model references are forbidden. Configure launching options to allow them.
Cannot set feature comment to value [org.eclipse.gmt.modisco.java.emf.impl.JavadocImpl@5c594008 (content: /** 
 * Componente: ERSTECOMPONENTE
 * @component ERSTECOMPONENTE
 */
, enclosedByParent: false, prefixOfParent: true)], inter-model references are forbidden. Configure launching options to allow them.
Cannot set feature comment to value [org.eclipse.gmt.modisco.java.emf.impl.JavadocImpl@18815832 (content: /** 
 * Componente: ERSTECOMPONENTE
 * @component ERSTECOMPONENTE
 */
, enclosedByParent: false, prefixOfParent: true)], inter-model references are forbidden. Configure launching options to allow them.
Cannot set feature comment to value [org.eclipse.gmt.modisco.java.emf.impl.JavadocImpl@1804686d (content: /** 
 * Componente: ERSTECOMPONENTE
 * @component ERSTECOMPONENTE
 */
, enclosedByParent: false, prefixOfParent: true)], inter-model references are forbidden. Configure launching options to allow them.


why is the line comment a inter model reference and how do i configure launching?

does anyone have an idea where these two come from?

it looks like the transformation from javamodel to kdmmodel fails, since the are comments to be found in the javamodel but none in the kdmmodel.
Where do i need to look to fix that ?


Thanx in advance!
Cheers Björn

[Updated on: Mon, 27 September 2010 17:50]

Report message to a moderator

Re: discover Java/KDM Model programaticaly [message #629420 is a reply to message #629289] Tue, 28 September 2010 07:53 Go to previous messageGo to next message
Gabriel BARBIER is currently offline Gabriel BARBIERFriend
Messages: 106
Registered: July 2009
Senior Member
Hello,

First message seems to be e4 related, do you use it or have tried it ? And basically it is not as important as it seems.

The second message is an indicator of elements that could not be translated from java model to kdm model. It means there
is some comments that are not translated, so you could fill a bug and we will fix it asap (it would be better if you
could attach also the project or an example of code to reproduce this bug).

Regards
Gabriel

Björn wrote:
> Hi,
>
> when running the MoDisco PlugIn discovering a javamodel from javacode
> and a kdmmodel from javamodel, I get the following errors on the console:
>
> when starting as eclipse app including modisco:
> ** (Eclipse:5008): CRITICAL **: murrine_style_draw_box: assertion
> `height >= -1' failed
>
> later when running the
> discoverJavaModelFromJavaProject.discoverElement(javaProject ,
> parameters);
> method I get this error:
>
> Cannot set feature comment to value
> [org.eclipse.gmt.modisco.java.emf.impl.LineCommentImpl@7d869bc7
> (content: // asdf, enclosedByParent: false, prefixOfParent: true)],
> inter-model references are forbidden. Configure launching options to
> allow them.
> Cannot set feature comment to value
> [org.eclipse.gmt.modisco.java.emf.impl.LineCommentImpl@5aa86d82
> (content: // asdfasdf, enclosedByParent: false, prefixOfParent: true)],
> inter-model references are forbidden. Configure launching options to
> allow them.
> Cannot set feature comment to value
> [org.eclipse.gmt.modisco.java.emf.impl.JavadocImpl@5c594008 (content:
> /** * Componente: ERSTECOMPONENTE
> * @component ERSTECOMPONENTE
> */
> , enclosedByParent: false, prefixOfParent: true)], inter-model
> references are forbidden. Configure launching options to allow them.
> Cannot set feature comment to value
> [org.eclipse.gmt.modisco.java.emf.impl.JavadocImpl@18815832 (content:
> /** * Componente: ERSTECOMPONENTE
> * @component ERSTECOMPONENTE
> */
> , enclosedByParent: false, prefixOfParent: true)], inter-model
> references are forbidden. Configure launching options to allow them.
> Cannot set feature comment to value
> [org.eclipse.gmt.modisco.java.emf.impl.JavadocImpl@1804686d (content:
> /** * Componente: ERSTECOMPONENTE
> * @component ERSTECOMPONENTE
> */
> , enclosedByParent: false, prefixOfParent: true)], inter-model
> references are forbidden. Configure launching options to allow them.
>
>
> does anyone have an idea where these two come from?
>
> Thanx in advance!
> Cheers Björn
Re: discover Java/KDM Model programaticaly [message #629866 is a reply to message #629420] Wed, 29 September 2010 19:09 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi,

thank you for the reply.

I also believe that there is a problem with the transformation from javamodel to kdmmodel.

I filed a bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=326584

Can someone tell me where to look ? Would that be in the "javaToKdm.atl" ?

Thanx!

Cheers
Björn
Re: discover Java/KDM Model programaticaly [message #630223 is a reply to message #629866] Fri, 01 October 2010 07:56 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Bjorn,

you are right, there are some trouble with comment translation to kdm.
Yes, the file to fix is "java2kdm.atl". This work must be done in having
a look at the related "kdm2uml.atl" transformation (java->kdm->uml
chain). I am currently working on this problem and you will have some
information through the bugzilla 326584.

Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: discover Java/KDM Model programaticaly [message #630493 is a reply to message #630223] Sun, 03 October 2010 11:05 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Hi,

thanx for the help !

I have another problem running modisco from an simple plain old java-project "Main":
Within which I have a main-method that starts an instance and a method from the modisco plugin class KDMSourceDiscoverer.

When doing so, after adding all the dependencies to my Main-project, I keep getting this NullPointerException using the KDMSourceDiscoverer:

Exception in thread "main" java.lang.NullPointerException
    at org.eclipse.gmt.modisco.kdm.source.discoverer.KDMSourceDiscoverer.<init>(KDMSourceDiscoverer.java:60)


the problem seem to be that in line 60:
private IContentType textContentType = this.contentTypeManager
            .getContentType(Activator.PLUGIN_ID + ".textFile");


Activator is null!

How would I need to configure my "Main" java-project to be able to run methods from a (the modisco-) plugin without writing a plugin myself?

Thanx for some hints!
Cheers
Björn

[Updated on: Sun, 03 October 2010 11:07]

Report message to a moderator

Re: discover Java/KDM Model programaticaly [message #630574 is a reply to message #630493] Mon, 04 October 2010 08:41 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Bjorn,

sorry but the kdm source discoverer does not work when called from a plain old java project "Main".
Well, i suppose some refactoring would make it working so, but more generally the MoDisco components have been designed to work on top of an OSGI/Eclipse framework, since it makes a wide use of workspace resources management and also extension points mechanism.

More precisely, the problem here is that the discoverer uses the Platform content type manager, to have information about files content. Such a manager is initialized only within a running OSGI/Eclipse instance.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: discover Java/KDM Model programaticaly [message #630815 is a reply to message #630223] Tue, 05 October 2010 07:44 Go to previous messageGo to next message
Björn is currently offline BjörnFriend
Messages: 29
Registered: August 2010
Junior Member
Fabien Giquel wrote on Fri, 01 October 2010 03:56
Hi Bjorn,

you are right, there are some trouble with comment translation to kdm.
Yes, the file to fix is "java2kdm.atl". This work must be done in having
a look at the related "kdm2uml.atl" transformation (java->kdm->uml
chain). I am currently working on this problem and you will have some
information through the bugzilla 326584.

Fabien.


Hi,

thanx for fixing the "java2kdm.atl" it works now Smile

I want to take some action-elements from the java modell and add them to the kdm model (e.g. actionflow).

Where and how would be the point to start changing the "java2kdm.atl" to be able to do that?

For some hints I would be very thankful.

Cheers
Björn
Re: discover Java/KDM Model programaticaly [message #630853 is a reply to message #630815] Tue, 05 October 2010 10:23 Go to previous message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Bjorn,

to update the java2kdm.atl file, please follow the steps :

- checkout from ou SVN the sources of project
" https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.mod isco/plugins/trunk/org.eclipse.gmt.modisco.java.discoverer"

- add the "Atl" nature to project in modifying the .project by adding :

<buildCommand>
<name>org.eclipse.m2m.atl.adt.builder.atlBuilder</name>
<arguments>
</arguments>
</buildCommand> <nature>org.eclipse.m2m.atl.adt.builder.atlNature</nature>

- update the "java2kdm.atl"
- refer to the official ATL documentation from Help contents
- use the MoDisco button in toolbar "open a model from the EMF Package
registry" to have informations about the metamodels involved "kdm.code"
and "java"
-> the java2kdm.asm (compiled transformation) will be regenerated for
each modification

- Start a second instance of Eclipse from your workspace which will take
in account your workspace "java.discoverer" fork project in order to
test it.

Regards.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Previous Topic:Problem with SVN
Next Topic:Discovering KDM Model from a Java Project
Goto Forum:
  


Current Time: Thu Apr 18 15:44:20 GMT 2024

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

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

Back to the top