Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diagram?(xtext behavior activity diagram)
icon5.gif  Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diagram? [message #1038167] Wed, 10 April 2013 13:47 Go to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I am following the "domain-model" example, I create a ".dmodel" file in the run-time eclipse. For example, I defined a class "entity Father", part of the content is as follows. I would like to export the content of the "op activityInOneDay()" into a diagram like UML's activity diagram. Is it possible? Thank you in advance!


entity Father {
id: String
name: String
gender:Gender
wife: Mother
sons: List <Son>
daughters: List <Daughter>
hobbyList: List<String>

op activityInOneDay(): void {

getUp();
haveBreakfast();
workAtHome();
haveLunch();
}

op getUp(): void {

}

op haveBreakfast(): void {

}

op workAtHome(): void {

}

op haveLunch(): void {

}

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038310 is a reply to message #1038167] Wed, 10 April 2013 18:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

you can write a generator that does everything you want.

Here is a fast and stupid variant.

package org.eclipse.xtext.example.domainmodel

import org.eclipse.xtext.xbase.compiler.JvmModelGenerator
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.example.domainmodel.domainmodel.DomainModel
import org.eclipse.xtext.example.domainmodel.domainmodel.Entity
import org.eclipse.xtext.naming.IQualifiedNameProvider
import com.google.inject.Inject
import org.eclipse.xtext.example.domainmodel.domainmodel.Operation
import org.eclipse.xtext.xbase.XExpression
import org.eclipse.xtext.xbase.XBlockExpression
import org.eclipse.xtext.xbase.XFeatureCall

class MySuperGen extends JvmModelGenerator {
	
	@Inject extension IQualifiedNameProvider
	
	def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
	) {
		for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
			fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
				«FOR op : e.features.filter(typeof(Operation))»
				«op.name»:
				«op.body.print»
				«ENDFOR»
			''')
		}
	}
	
	def dispatch print(XExpression e) '''
		//TODO
	'''
	def dispatch print(XBlockExpression e) '''
		«FOR ex : e.expressions»
		«ex.print»
		«ENDFOR»
	'''
	def dispatch print(XFeatureCall e) '''
		«e.feature.simpleName»
	'''
	
}


	@Override
	public Class<? extends IGenerator> bindIGenerator() {
		return MySuperGen.class;
	}
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038313 is a reply to message #1038310] Wed, 10 April 2013 18:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Or you look for a solution to gerate an activity diag from a java class
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038334 is a reply to message #1038310] Wed, 10 April 2013 18:54 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you very much!!
Tomorrow, I have German course and am not going to my office. I would like to check the day after tomorrow because my laptop is in my office.
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038338 is a reply to message #1038313] Wed, 10 April 2013 18:58 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Actually, I also would like to generate an activity diagram from the "XExpression" in a behavior which is defined like "op" in the .dmodel file. Then I need not look into the code, because the code is transferred into the activity diagram (like UML). But, I guess it would be even more difficult!

Christian Dietrich wrote on Wed, 10 April 2013 14:12
Or you look for a solution to gerate an activity diag from a java class

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038347 is a reply to message #1038338] Wed, 10 April 2013 19:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
yes but the basic task is: you have to do it. there is no out of the box solution at eclipse.org/Xtext
maybe you can generate input for http://plantuml.sourceforge.net/
or search for a lib that create an activity diagram from a .java file
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038348 is a reply to message #1038347] Wed, 10 April 2013 19:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
P.S: Viel Spass beim Deutschkurs
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038372 is a reply to message #1038348] Wed, 10 April 2013 19:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Here an adopted generator for platuml


def dispatch print(XBlockExpression e) '''
		@startuml
		(*)«FOR ex : e.expressions SEPARATOR "\n"»--> "«ex.print»"«ENDFOR»
		--> (*)
		@enduml
		
	'''
	def dispatch print(XFeatureCall e) 
	'''«e.feature.simpleName»'''

https://dl.dropbox.com/u/6812814/test.Test.activityInOneDay.png
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038383 is a reply to message #1038372] Wed, 10 April 2013 20:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
And here the variant that directly creates -png files

	def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
	) {
		for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
			for (op : e.features.filter(typeof(Operation))) {
				val content = '''
				«op.body.print»
			'''.toString
				
				if (fsa instanceof IFileSystemAccessExtension3) {
					val out = new ByteArrayOutputStream()
				new SourceStringReader(content).generateImage(out)
					(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
				} else {
					fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
				}	
			}
		}
	}
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038394 is a reply to message #1038348] Wed, 10 April 2013 20:32 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you! ~~

Christian Dietrich wrote on Wed, 10 April 2013 15:15
P.S: Viel Spass beim Deutschkurs

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038395 is a reply to message #1038372] Wed, 10 April 2013 20:33 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I like this picture!
I hope it is not so difficult. I cannot wait to try it the day after tomorrow.

Christian Dietrich wrote on Wed, 10 April 2013 15:58
Here an adopted generator for platuml


def dispatch print(XBlockExpression e) '''
		@startuml
		(*)«FOR ex : e.expressions SEPARATOR "\n"»--> "«ex.print»"«ENDFOR»
		--> (*)
		@enduml
		
	'''
	def dispatch print(XFeatureCall e) 
	'''«e.feature.simpleName»'''

https://dl.dropbox.com/u/6812814/test.Test.activityInOneDay.png

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038396 is a reply to message #1038383] Wed, 10 April 2013 20:34 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Could you show me an example of the generated -png file?

Christian Dietrich wrote on Wed, 10 April 2013 16:17
And here the variant that directly creates -png files

	def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
	) {
		for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
			for (op : e.features.filter(typeof(Operation))) {
				val content = '''
				«op.body.print»
			'''.toString
				
				if (fsa instanceof IFileSystemAccessExtension3) {
					val out = new ByteArrayOutputStream()
				new SourceStringReader(content).generateImage(out)
					(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
				} else {
					fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
				}	
			}
		}
	}

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038400 is a reply to message #1038396] Wed, 10 April 2013 20:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi its the same as the one above.
but then i called plantuml manually like

	public static void main(String[] args) throws IOException, InterruptedException {
		File source = new File("src-gen/test.Test.activityInOneDay.txt");
		SourceFileReader reader = new SourceFileReader(source);
		for (GeneratedImage i : reader.getGeneratedImages()) {
			System.out.println(i);
		}
	}
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039448 is a reply to message #1038395] Fri, 12 April 2013 07:21 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I am trying the following code. I installed "plantUML" in my Eclipse. After I save the .dmodel file, in the "src_gen" file directory, I have the "my.model.Father.txt", whose content is as follows. Since I did not have the "activity diagram" as you, what might be improved? Thank you in advance!

activityInOneDay:
@startuml
(*)--> "getUp"
--> "haveBreakfast"
--> "workAtHome"
--> "haveLunch"
--> (*)
@enduml

getUp:
@startuml
(*)
--> (*)
@enduml

haveBreakfast:
@startuml
(*)
--> (*)
@enduml

workAtHome:
@startuml
(*)
--> (*)
@enduml

haveLunch:
@startuml
(*)
--> (*)
@enduml

initialization:
@startuml
(*)--> "//TODO
"
--> (*)
@enduml

getCurrentHobby:
@startuml
(*)--> "//TODO
"
--> "//TODO
"
--> "//TODO
"
--> (*)
@enduml



Hao Zhang wrote on Wed, 10 April 2013 16:33
I like this picture!
I hope it is not so difficult. I cannot wait to try it the day after tomorrow.

Christian Dietrich wrote on Wed, 10 April 2013 15:58
Here an adopted generator for platuml


def dispatch print(XBlockExpression e) '''
		@startuml
		(*)«FOR ex : e.expressions SEPARATOR "\n"»--> "«ex.print»"«ENDFOR»
		--> (*)
		@enduml
		
	'''
	def dispatch print(XFeatureCall e) 
	'''«e.feature.simpleName»'''

https://dl.dropbox.com/u/6812814/test.Test.activityInOneDay.png


Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039459 is a reply to message #1039448] Fri, 12 April 2013 07:34 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
The content of the MySuperGen is as follows. Thank you!


class MySuperGen extends JvmModelGenerator {

@Inject extension IQualifiedNameProvider

def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
«op.body.print»
«ENDFOR»
''')
}
}

def dispatch print(XExpression e) '''
//TODO
'''
/*def dispatch print(XBlockExpression e) '''
«FOR ex : e.expressions»
«ex.print»
«ENDFOR»
'''*/

def dispatch print(XBlockExpression e) '''
@startuml
(*)«FOR ex : e.expressions SEPARATOR "\n"»--> "«ex.print»"«ENDFOR»
--> (*)
@enduml

'''
def dispatch print(XFeatureCall e)
'''«e.feature.simpleName»'''



}
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039462 is a reply to message #1039448] Fri, 12 April 2013 07:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

dont get your point.
as said before: you have to feed the file into plantuml
(1) via the main method
(2) or via the adopted generator (in this case you have to add platuml to the classpath of the domainmodel project)
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039475 is a reply to message #1039462] Fri, 12 April 2013 08:00 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
For the approache (1) via the main method
Should I create a new "plug-in project" in the run-time eclipse and add the .dmodel as one of the dependency? Then I can have a main method?

For the approach (2)or via the adopted generator (in this case you have to add platuml to the classpath of the domainmodel project)

I cannot find the platuml library after I select "domainmodel project" ->"properties" -> "Java Build Path". So, how to add platuml to the classpath of the domainmodel project?
Thank you!

Christian Dietrich wrote on Fri, 12 April 2013 03:36
Hi,

dont get your point.
as said before: you have to feed the file into plantuml
(1) via the main method
(2) or via the adopted generator (in this case you have to add platuml to the classpath of the domainmodel project)

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039479 is a reply to message #1039475] Fri, 12 April 2013 08:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

i dont know if this came clear; plantuml has nothing todo with xtext.
=> it is a complete "selfmade" solution by you


you have to download plantuml.
(1) for the main include the jar your preferred way
(2)for the adopted generatorthrow it into a lib folder in the domainmdodel project
and edit the manifest e.g

Bundle-ClassPath: lib/plantuml.jar,
 .
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039489 is a reply to message #1039479] Fri, 12 April 2013 08:14 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
The content of the "MANIFEST.MF" of the "domainmodel" project is as follows. Does this mean I can get generated UML activity diagram via the adopted generator which is defined in the "class MySuperGen extends JvmModelGenerator"?


Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Xtext Domainmodel Example
Bundle-Vendor: Eclipse Modeling Project
Bundle-Version: 2.3.0.qualifier
Bundle-SymbolicName: org.eclipse.xtext.example.domainmodel; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtext;bundle-version="2.3.0";visibility:=reexport,
org.eclipse.xtext.generator;bundle-version="2.3.0";resolution:=optional;x-installation:=greedy,
org.eclipse.xtend;bundle-version="1.1.0",
org.eclipse.xtend.typesystem.emf;bundle-version="1.0.1",
org.eclipse.xpand;bundle-version="1.1.0",
org.eclipse.xtext.util;bundle-version="2.3.0",
org.eclipse.emf.ecore,
org.eclipse.emf.common,
org.eclipse.emf.mwe2.launch;bundle-version="2.0.0";resolution:=optional;x-installation:=greedy,
org.antlr.runtime;bundle-version="[3.2.0,3.2.1)",
org.eclipse.xtext.xbase;bundle-version="2.3.0",
org.eclipse.xtext.common.types,
org.eclipse.xtext.xbase.lib;bundle-version="2.3.0";visibility:=reexport,
org.eclipse.xtext.ui.codetemplates;bundle-version="2.0.0",
net.sourceforge.plantuml.eclipse;bundle-version="1.1.8"
Export-Package: org.eclipse.xtext.example.domainmodel,
org.eclipse.xtext.example.domainmodel.domainmodel,
org.eclipse.xtext.example.domainmodel.domainmodel.impl,
org.eclipse.xtext.example.domainmodel.domainmodel.util,
org.eclipse.xtext.example.domainmodel.formatting,
org.eclipse.xtext.example.domainmodel.jvmmodel,
org.eclipse.xtext.example.domainmodel.parser.antlr,
org.eclipse.xtext.example.domainmodel.parser.antlr.internal,
org.eclipse.xtext.example.domainmodel.services,
org.eclipse.xtext.example.domainmodel.validation,
org.eclipse.xtext.example.domainmodel.valueconverter,
org.eclipse.xtext.example.domainmodel.serializer
Bundle-ClassPath: lib/plantuml.jar,
.
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.apache.log4j,
org.apache.commons.logging



Christian Dietrich wrote on Fri, 12 April 2013 04:03
Hi,

i dont know if this came clear; plantuml has nothing todo with xtext.
=> it is a complete "selfmade" solution by you


you have to download plantuml.
(1) for the main include the jar your preferred way
(2)for the adopted generatorthrow it into a lib folder in the domainmdodel project
and edit the manifest e.g

Bundle-ClassPath: lib/plantuml.jar,
 .

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039493 is a reply to message #1039489] Fri, 12 April 2013 08:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Yes
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039496 is a reply to message #1039493] Fri, 12 April 2013 08:25 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
But I still cannot get the UML activity diagram in the "my.model.Father.txt". Should I create a plugin project and have a main method, then I can maunally create the image, like the one you write as follows? Thank you!

public static void main(String[] args) throws IOException, InterruptedException {
File source = new File("src-gen/test.Test.activityInOneDay.txt");
SourceFileReader reader = new SourceFileReader(source);
for (GeneratedImage i : reader.getGeneratedImages()) {
System.out.println(i);
}
}

Christian Dietrich wrote on Fri, 12 April 2013 04:21
Yes

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039503 is a reply to message #1039496] Fri, 12 April 2013 08:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi

if you call this java main it shall convert the text to png
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039507 is a reply to message #1039479] Fri, 12 April 2013 08:37 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I do not know if I understand correctly. From what you said, I can have the uml activity diagram if I follow either of the following approach. I think, now I am following the second approach. I include the platuml lib in the domainmodel project, now. But at the moment, I do not have the activity diagram yet. What might be my mistakes? Thank you!

Christian Dietrich wrote on Fri, 12 April 2013 04:03
Hi,

i dont know if this came clear; plantuml has nothing todo with xtext.
=> it is a complete "selfmade" solution by you


you have to download plantuml.
(1) for the main include the jar your preferred way
(2)for the adopted generatorthrow it into a lib folder in the domainmdodel project
and edit the manifest e.g

Bundle-ClassPath: lib/plantuml.jar,
 .

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039523 is a reply to message #1039507] Fri, 12 April 2013 08:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

you may have a look at

http://christiandietrich.wordpress.com/2013/04/12/xtext-model-visualization-with-plantuml/
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039537 is a reply to message #1039523] Fri, 12 April 2013 09:16 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I think the following might be my mistakes:
1. I do not have plantuml.jar in the file directory of "Eclipse xText" set up file directory, but I installed the plantuml following the webpage: http://plantuml.sourceforge.net/eclipse.html, Is this also OK? Or I have to download a "plantuml.jar"?

2. I do not have Graphviz in the run-time eclipse. The error information is as the following diagram. Should I install it following the webpage :http://sourceforge.net/apps/mediawiki/textuml/index.php?title=Install_Instructions
Thank you!
index.php/fa/14353/0/


Christian Dietrich wrote on Fri, 12 April 2013 04:57
Hi,

you may have a look at

http://christiandietrich.wordpress.com/2013/04/12/xtext-model-visualization-with-plantuml/

  • Attachment: Untitled2.png
    (Size: 106.63KB, Downloaded 519 times)
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039539 is a reply to message #1039523] Fri, 12 April 2013 09:16 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
One should note that this example only works with Xtext 2.4.
Still, nice, quick example. Thank you, Christian.
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039566 is a reply to message #1039539] Fri, 12 April 2013 09:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
@Hao Zhang

(1) download the jar
(2) include it as described
(3) install graphvis to mac/linux/windows whatever and take care that it is on path.
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039570 is a reply to message #1039566] Fri, 12 April 2013 09:56 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you very much for your patience!
But now, I am updating the xtext to 2.4, then many small errors appear.

Christian Dietrich wrote on Fri, 12 April 2013 05:54
@Hao Zhang

(1) download the jar
(2) include it as described
(3) install graphvis to mac/linux/windows whatever and take care that it is on path.

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039571 is a reply to message #1039570] Fri, 12 April 2013 09:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Best thing is to recreate the project
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039574 is a reply to message #1039571] Fri, 12 April 2013 10:01 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Yes, I did recreate a "domain-model" example in the xtext 2.4. Then I just copy and paste the files that I have modified in the xtext2.3.1 into the 2.4 version. Then, many small errors which have nothing to do with my code appear.

Christian Dietrich wrote on Fri, 12 April 2013 05:58
Best thing is to recreate the project

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039611 is a reply to message #1039574] Fri, 12 April 2013 10:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Sorry without any specific information i cannot give advice
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039669 is a reply to message #1039611] Fri, 12 April 2013 12:33 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
Thank you!
Now, I get the -png file in xText 2.4.
Next, I would like to try to manually call these -png files. Thank you again!


Christian Dietrich wrote on Fri, 12 April 2013 06:58
Sorry without any specific information i cannot give advice

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039686 is a reply to message #1039669] Fri, 12 April 2013 13:05 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
I would like to have the ".txt" files, ".png" files, and the ".java" code. Therefore, I write the code as follows in the "class MySuperGen extends JvmModelGenerator". But in the end, I can only have the ".txt" files and the ".png" files. The ".java" code cannot be automatically generated. What might be improved? Thank you!


def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {

// output for image in editor
fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
«op.body.print»
«ENDFOR»
''')
}

for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
for (op : e.features.filter(typeof(Operation))) {
val content = '''
«op.body.print»
'''.toString

if (fsa instanceof IFileSystemAccessExtension3) {
val out = new ByteArrayOutputStream()
new SourceStringReader(content).generateImage(out)
(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
} else {
fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
}
}
}

}
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039689 is a reply to message #1039686] Fri, 12 April 2013 13:09 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
If I change "op activityInOneDay()" to the following code, which means I have a "if (getUp())" inside it. Could it be possible to write a new activity diagram which can show the "if" just like that in the UML? Thank you!

op activityInOneDay(): void {

if (getUp())
{
haveBreakfast();
}
haveBreakfast();

workAtHome();
haveLunch();
}
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039692 is a reply to message #1039689] Fri, 12 April 2013 13:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

its your turn now to do this (extend the generator)

~Christian
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039693 is a reply to message #1039692] Fri, 12 April 2013 13:13 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
The error information is as follows, if I want to have all of them.

!SESSION 2013-04-12 15:11:42.620 -----------------------------------------------
eclipse.buildId=M20130204-1200
java.version=1.7.0_17
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data D:\TodayNewEight/../runtime-TodayNewEight -dev file:D:/TodayNewEight/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog

!ENTRY org.eclipse.update.configurator 4 0 2013-04-12 15:11:44.180
!MESSAGE Unable to find feature.xml in directory: C:\eclipsexText64\features\org.eclipse.equinox.p2.discovery.feature_1.0.100.v20120524-0542-4-Bh9oB58A5N9L28PCQ

!ENTRY org.eclipse.core.resources 2 10035 2013-04-12 15:11:44.914
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
0 [Worker-0] ERROR org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:146)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

!ENTRY org.apache.log4j 4 0 2013-04-12 15:11:59.087
!MESSAGE org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.

!STACK 0
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:146)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

!ENTRY org.eclipse.egit.ui 2 0 2013-04-12 15:11:59.996
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.egit.ui 2 0 2013-04-12 15:12:00.012
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'H:\'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
7696 [Worker-2] ERROR org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:146)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

!ENTRY org.apache.log4j 4 0 2013-04-12 15:12:06.783
!MESSAGE org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.

!STACK 0
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:146)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


Christian Dietrich wrote on Fri, 12 April 2013 09:12
Hi,

its your turn now to do this (extend the generator)

~Christian

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039696 is a reply to message #1039693] Fri, 12 April 2013 13:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Same again:

the generator i posted is a starting point. it is YOUR job to make it perfect
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039699 is a reply to message #1039689] Fri, 12 April 2013 13:22 Go to previous messageGo to next message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member
OK! Could you give me some hints how to automatically generate the activity diagram of the "op activityInOneDay()" with "if (getUp())"?

Hao Zhang wrote on Fri, 12 April 2013 09:09
If I change "op activityInOneDay()" to the following code, which means I have a "if (getUp())" inside it. Could it be possible to write a new activity diagram which can show the "if" just like that in the UML? Thank you!

op activityInOneDay(): void {

if (getUp())
{
haveBreakfast();
}
haveBreakfast();

workAtHome();
haveLunch();
}

[Updated on: Fri, 12 April 2013 13:23]

Report message to a moderator

Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039711 is a reply to message #1039699] Fri, 12 April 2013 13:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi

XExpression has not only the subclasses XFeatureCall and XBlockExpression but XIfExpression too
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039712 is a reply to message #1039699] Fri, 12 April 2013 13:44 Go to previous messageGo to previous message
Hao Zhang is currently offline Hao ZhangFriend
Messages: 107
Registered: April 2013
Senior Member

I am following the "internalDoGenerate", which can only generate the ".txt" files, but there is error information about the "print" information, which is "
Cannot infer type from recursive usage. Type 'Object' is used." Could you have some idea how to fix it?

def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {

fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
«op.body.print»
«ENDFOR»
''')

}
}



def dispatch print(XFeatureCall e)
'''«e.feature.simpleName»'''




Previous Topic:Xtext Grammar - Referencing
Next Topic:Build path specifies execution environment J2SE-1.5.
Goto Forum:
  


Current Time: Sat Dec 20 23:05:06 GMT 2014

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

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