Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Referencing to UML elements in Xtext Editor
Referencing to UML elements in Xtext Editor [message #1759437] Tue, 11 April 2017 17:06 Go to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
Hi. I'm developing a language that supports references to UML elements, i found this example https://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/ in christian Blog and it's work fine, But i want that when i generate my DSL grammar then referencing to UML elements by tap CTRL+ SPACE i want just the name like the example in christian Blog : <Package> Test and Class A ==> test.A
But I want just the name of Class A like this : <Package> Test and Class A ==> A
is there any solution about it thinks .
Re: Referencing to UML elements in Xtext Editor [message #1759439 is a reply to message #1759437] Tue, 11 April 2017 17:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Can you be more precise

You want to simply have two references?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1759441 is a reply to message #1759439] Tue, 11 April 2017 17:37 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
i want to reference just the name of Class not the package in xtext editor like in your example i want to reference class A just but it reference class A with the package test like this :
test.A but i want this just the Class A how i do it
Re: Referencing to UML elements in Xtext Editor [message #1759447 is a reply to message #1759441] Tue, 11 April 2017 18:01 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
I want like this :
  • Attachment: uml.PNG
    (Size: 71.37KB, Downloaded 115 times)
Re: Referencing to UML elements in Xtext Editor [message #1759452 is a reply to message #1759447] Tue, 11 April 2017 19:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
But what if there are 2 As?

besides this: implements UmlQualifiedNameProvider

e.g. (untested)

public QualifiedName qualifiedName(org.eclipse....uml.Class clazz) {
return QualifiedName.create(clazz.getName()); // or simple name or .....
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 11 April 2017 19:10]

Report message to a moderator

Re: Referencing to UML elements in Xtext Editor [message #1759463 is a reply to message #1759452] Tue, 11 April 2017 21:01 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
I create this method in UmlQualifiedNameProvider class but what i put parameter in qualifiedName( ) <org.eclipse....uml.Class clazz> it's not clear please help me .
Re: Referencing to UML elements in Xtext Editor [message #1759474 is a reply to message #1759463] Wed, 12 April 2017 05:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
It the class class from the uml Package
I thought that was Obvious

http://download.eclipse.org/modeling/mdt/uml2/javadoc/5.0.0/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 12 April 2017 05:17]

Report message to a moderator

Re: Referencing to UML elements in Xtext Editor [message #1759485 is a reply to message #1759474] Wed, 12 April 2017 08:44 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
Hi Christian , I found the the uml package about the class it's work but i use activity diagram and i try to get name about two Uml elements (ActivityParameterNode , Pin ) in qualifiedName like this but it's not work how i do it ?

public QualifiedName qualifiedName(org.eclipse.uml2.uml.Class clazz , org.eclipse.uml2.uml.Activity activite ) {
return QualifiedName.create(clazz.getName()+ activite.getName());
}
Re: Referencing to UML elements in Xtext Editor [message #1759486 is a reply to message #1759485] Wed, 12 April 2017 08:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
thats not possible

either

public QualifiedName qualifiedName(org.eclipse.uml2.uml.Class clazz ) {
...
}

or

public QualifiedName qualifiedName(org.eclipse.uml2.uml.Activity activite ) {
....
}

you have to navigate /traverse from class to activity or vice versa or create multiple methods
(i dont know how the model/names you want to build and work on look exactly like)

and if you want to use a multi segement name

return QualifiedName.create(clazz.getName(), activite.getName());



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1759491 is a reply to message #1759486] Wed, 12 April 2017 09:43 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
No Message Body
Re: Referencing to UML elements in Xtext Editor [message #1759498 is a reply to message #1759491] Wed, 12 April 2017 10:45 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
I want to get name for two or more uml elements , i use this method return QualifiedName.create(clazz.getName(), activite.getName()); but just one work is Class and Activity not work in same method i don't know the problem.
Re: Referencing to UML elements in Xtext Editor [message #1759499 is a reply to message #1759498] Wed, 12 April 2017 11:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
as i said: created multiple methods

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1760163 is a reply to message #1759498] Mon, 24 April 2017 07:02 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Xtext uses a reflective mechanism (AKA PolymorphicDispatcher) to call the overridden qualifiedName method based on the actual type of the parameter.
This is why, as Christian said, you have to implement a qualifiedName(X element) method for each element type X for which you want a custom calculation of the fully qualified name.


---
Get professional support from the Xtext committers at www.typefox.io
Re: Referencing to UML elements in Xtext Editor [message #1764907 is a reply to message #1760163] Sat, 03 June 2017 13:34 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
Hi Christian , i have about use qualifiedName multiple methods like this for select just names of Activity Diagram elements,but doesn't work
public QualifiedName qualifiedName(org.eclipse.uml2.uml.Class clazz ) {
		return QualifiedName.create(clazz.getName());

		}
	public QualifiedName qualifiedName(org.eclipse.uml2.uml.Pin pins ) {
		return QualifiedName.create(pins.getName());

		}

It's work when i create single method like this , I don't know where's the Problem , can you help me please .
public QualifiedName qualifiedName(org.eclipse.uml2.uml.Class clazz ) {
		return QualifiedName.create(clazz.getName());

		}
Re: Referencing to UML elements in Xtext Editor [message #1764908 is a reply to message #1764907] Sat, 03 June 2017 13:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you debug the code? It is called? Did you have a look at the Xtext index using the openmodelement dialog? How does the reference look like? How does the name look like?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1764910 is a reply to message #1764908] Sat, 03 June 2017 13:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
How does the complete nameprovider class look like

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1764911 is a reply to message #1764910] Sat, 03 June 2017 13:57 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
when i create a single method it's work fine , but when i create the second method for another element , the second method doesnt work
Re: Referencing to UML elements in Xtext Editor [message #1764912 is a reply to message #1764911] Sat, 03 June 2017 14:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please give feedback on all the points I mentioned I cannot guess.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1764913 is a reply to message #1764912] Sat, 03 June 2017 14:12 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
how i debug this code and where i find openmodelement dialog this is the class UmlQualifiedNameProvider :
package org.eclipse.xtext.uml;
 
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
import org.eclipse.xtext.naming.QualifiedName;
 
public class UmlQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {
 
	public QualifiedName qualifiedName(org.eclipse.uml2.uml.Class clazz ) {
		return QualifiedName.create(clazz.getName());

		}
	public QualifiedName qualifiedName(org.eclipse.uml2.uml.Pin pins ) {
		return QualifiedName.create(pins.getName());

		}

	
}
Re: Referencing to UML elements in Xtext Editor [message #1764914 is a reply to message #1764913] Sat, 03 June 2017 14:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
- the open model element dialog is crtl/cmd + shift + f3 or in the navigate menu
- you debug by setting a breakpoint and start the runtime eclipse via the debug menu
- or add a sysout to e see if it is called.

how does the xml of the uml file look like you test with?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1764916 is a reply to message #1764914] Sat, 03 June 2017 14:53 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
i add sys.out in the two methods and it's running but return QualifiedName.create(pins.getName()); doesn't work for the 2 nd method
Re: Referencing to UML elements in Xtext Editor [message #1764918 is a reply to message #1764916] Sat, 03 June 2017 15:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Can you a bit more precise.
What does not work
How does your model look like etc



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing to UML elements in Xtext Editor [message #1764919 is a reply to message #1764918] Sat, 03 June 2017 15:07 Go to previous messageGo to next message
abdf mncr is currently offline abdf mncrFriend
Messages: 75
Registered: February 2017
Member
like this :
	public QualifiedName qualifiedName(org.eclipse.uml2.uml.Pin pins ) {
		System.out.println("Pins !!!!!!!!!!!");

		return QualifiedName.create(pins.getName());

		}

in the console display this Pins !!!!!!!!!!! but nothing change
Re: Referencing to UML elements in Xtext Editor [message #1764920 is a reply to message #1764919] Sat, 03 June 2017 15:10 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Please give me the damn information I damn asked you for.

Does the pin have a name?
Are the pins inside the open model element dialog
How does the name look like? Is it "hugo" or "bla blubb" or "12345"
How does the reference to the pin in the grammar look like?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:dead loop in parser triggered by content assist
Next Topic:MyDslDocumentProvider failed to save
Goto Forum:
  


Current Time: Tue Apr 16 16:40:50 GMT 2024

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

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

Back to the top