Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » accessing file from eol(java.io.File gives wrong path?)
accessing file from eol [message #538733] Tue, 08 June 2010 13:55 Go to next message
Endre Balogh is currently offline Endre BaloghFriend
Messages: 38
Registered: May 2010
Member
Hi,

I'm trying to parameterize my generator script with a traditional .properties file. The code is the following:

var properties = new Native("java.util.Properties");
var file = new Native("java.io.File")("generator.properties");
file.getAbsolutePath().println();
var fileIS = new Native("java.io.FileInputStream")(file);
properties.load(fileIS);
properties.getProperty("Truth").println();


I placed the .properties file in the project folder and also near the generator script, but it kept failing silently; then I added the println for the file path, and instead of the expected
(workspace)/(projectname)/generator.properties
I got
(eclipse installation folder)/generator.properties

If I place the file in the eclipse installation folder, it works.

My questions are: a) can the file variable be made to point to the project folder instead? b) how would this go down if I created a standalone java application for the script and run it from the graphical editor of a spawned eclipse instance? c) is there another approach (such as accessing files directly from EOL)?

If there is no proper solution, I will just use UserInput.prompt to obtain the values I need every time the generator script is executed, but it would be a lot nicer if the user could configure this thing beforehand.

Cheers,
Endre
Re: accessing file from eol [message #538737 is a reply to message #538733] Tue, 08 June 2010 14:11 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Endre,

An interesting question, thanks!

Would it be feasible to specify properties in a model file, rather than in a plain text file? A simple properties metamodel might have the following Emfatic syntax:

class Properties {
  val Property[*] properties;
}

class Property {
  attr EString[1] name;
  attr EJavaObject[1] value;
}


Getting a property value would then use the following EOL, which could be placed in an operation:

var someValue = Properties.all.first.properties.selectOne(p|p.name = "SomeName").value;


If this is not suitable for your needs, let me know and Dimitris or I will investigate the issues you're having with properties files.

Cheers,
Louis.
Re: accessing file from eol [message #538757 is a reply to message #538737] Tue, 08 June 2010 14:53 Go to previous message
Endre Balogh is currently offline Endre BaloghFriend
Messages: 38
Registered: May 2010
Member
Hi Louis,

Thanks for the swift reply and the great idea! I will implement this approach, and get back to you if I run into any trouble.

Cheers,
Endre
Re: accessing file from eol [message #589868 is a reply to message #538733] Tue, 08 June 2010 14:11 Go to previous message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Endre,

An interesting question, thanks!

Would it be feasible to specify properties in a model file, rather than in a plain text file? A simple properties metamodel might have the following Emfatic syntax:

class Properties {
val Property[*] properties;
}

class Property {
attr EString[1] name;
attr EJavaObject[1] value;
}

Getting a property value would then use the following EOL, which could be placed in an operation:

var someValue = Properties.all.first.properties.selectOne(p|p.name = "SomeName").value;

If this is not suitable for your needs, let me know and Dimitris or I will investigate the issues you're having with properties files.

Cheers,
Louis.
Re: accessing file from eol [message #589877 is a reply to message #589868] Tue, 08 June 2010 14:53 Go to previous message
Endre Balogh is currently offline Endre BaloghFriend
Messages: 38
Registered: May 2010
Member
Hi Louis,

Thanks for the swift reply and the great idea! I will implement this approach, and get back to you if I run into any trouble.

Cheers,
Endre
Previous Topic:accessing file from eol
Next Topic:Loading models into IModel objects
Goto Forum:
  


Current Time: Thu Apr 18 02:06:04 GMT 2024

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

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

Back to the top