Skip to main content



      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 13:13 Go to next message
Eclipse UserFriend
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 19:13 Go to previous messageGo to next message
Eclipse UserFriend
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 01:46 Go to previous messageGo to next message
Eclipse UserFriend
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 01:49] by 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 06:17 Go to previous messageGo to next message
Eclipse UserFriend
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 11:18 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Dimitris!

Best, Nikos

[Updated on: Tue, 31 March 2015 15:56] by 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 17:17 Go to previous message
Eclipse UserFriend
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 Nov 07 08:02:38 EST 2025

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

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

Back to the top