Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EVL - Getting the name of the file in which the model is stored
EVL - Getting the name of the file in which the model is stored [message #1690706] Mon, 30 March 2015 17:13 Go to next message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 65
Registered: September 2014
Member

Hello,

I've been trying to get the current file's name in EVL. The concept is that my class SXM holds an attribute called name. This attribute is supposed to get the name of the file in which the SXM is stored if it is not set. However, I can not find a way to retrieve the current file's name through EVL.

Is there a way to do this?

An example:
context SXM {

  constraint HasName {
      check : self.name.isDefined()
      message : 'The model element ' + self.eClass().name + '  should define a name'    
      fix {
          title : 'Name to ' + //get file name

          do {
          	  
              self.name := //get file name
          }
      }  
  }
}

Re: EVL - Getting the name of the file in which the model is stored [message #1690738 is a reply to message #1690706] Mon, 30 March 2015 23:13 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Niko,

self.eResource().uri should return the URI [1] of the resource that contains the model element in question.

Cheers,
Dimitris

[1] http://download.eclipse.org/modeling/emf/emf/javadoc/2.5.0/org/eclipse/emf/common/util/URI.html
Re: EVL - Getting the name of the file in which the model is stored [message #1690759 is a reply to message #1690738] Tue, 31 March 2015 05:46 Go to previous messageGo to next message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 65
Registered: September 2014
Member

Thank you Dimitri,

This is exactly what I was after.

A small question that I don't know if it appropriate to be make a new thread out of.

"Is there any real difference between getAllOfAType and xyzClass.All"

var target := UserInput.choose('Select target',
                       _Model.getAllOfType(Input.name));

var target := UserInput.choose('Select Input',
                  Input.all);


Also I noticed that getAllOfAType is not included in the PDF of epsilon under EOL is there any way to find the list of these methods online?

Best, Nikos

[Updated on: Tue, 31 March 2015 05:49]

Report message to a moderator

Re: EVL - Getting the name of the file in which the model is stored [message #1690793 is a reply to message #1690759] Tue, 31 March 2015 10:17 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Niko,

.all is an alias for getAllOfKind()/allOfKind - which returns all instances of the type *and* any of its subtypes. getAllOfType()/allOfType returns all instances of the type only.

Cheers,
Dimitris
Re: EVL - Getting the name of the file in which the model is stored [message #1690848 is a reply to message #1690793] Tue, 31 March 2015 15:18 Go to previous messageGo to next message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 65
Registered: September 2014
Member

Thank you Dimitris!

Best, Nikos

[Updated on: Tue, 31 March 2015 19:56]

Report message to a moderator

Re: EVL - Getting the name of the file in which the model is stored [message #1690910 is a reply to message #1690848] Tue, 31 March 2015 21:17 Go to previous message
Nikos Margaritis is currently offline Nikos MargaritisFriend
Messages: 65
Registered: September 2014
Member

Just giving out a solution in case anybody is interested.

operation YourElement getFileName() : String {
	return self.eResource().uri.trimFileExtension().toString().split("/").last();
}
Previous Topic:Custom properties in eugenia generated editor.
Next Topic:EVL - Validation error for attribute "function"
Goto Forum:
  


Current Time: Fri Apr 19 14:07:44 GMT 2024

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

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

Back to the top