Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » [Sirius] Access to local resources of modeling project
[Sirius] Access to local resources of modeling project [message #1854672] Fri, 02 September 2022 05:24 Go to next message
Akira Tanaka is currently offline Akira TanakaFriend
Messages: 98
Registered: March 2010
Member
Dear Eclipse/Sirius experts,

This is a question for Desktop version of Sirius.

I am working on a Sirius-Xtext project where:
- First, defined an Xtext grammar and generated Xtext aretefacts
- Created another Eclipse instance that contains above Xtext plugin
- Defined viewpoint specification project. In that, I defined an odesign file under description folder, and wrote some functionality to generated Services.java

index.php/fa/42453/0/

To test above, I created a test project, which is a normal Modeling project except for one thing, which is a resource folder that contains more than one Xtext (textual) dsl models.

What I like to achieve is, by writing a Java service that reads those Xtext textual models (as text files), do some text processing, and reflect the result to a property view definition part of the odesign file.

However, I do not know how to get access to text files under resources folder from within Java services. I tried typical File IO mechanism in Java but did not work.

File newFile = new File("resources/test.txt");
newFile.createNewFile();
if (!newFile.exists()) {
System.out.println("file does not exist");
}
FileReader fr = new FileReader(newFile);
int data;
while ((data = fr.read()) != -1) {
System.out.println((char) data);
}
fr.close();
System.out.println(newFile);


The real objective is to implement "scoping" for references in property view. With default implementation, the number of reference candidates (in several cases) is too large (>100) and without name ordering (i.e. it's difficult to use from users' point of view).

The question is about the right way (in services) to access local resources of the modeling project.

Your advice is very much appreciated.
Re: [Sirius] Access to local resources of modeling project [message #1854707 is a reply to message #1854672] Fri, 02 September 2022 22:22 Go to previous message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hi,

I am not sure why your code snippet, but I am pretty sure that in Sirius when we need to read a file we use FileInputStream rather than FileReader. If the file is an XML file, we use SaxParserFactory.

I know less about XText, but I think an alternative is that you should be able to load these models in your Sirius session and acces these resource directly from it as semantic resources and navigate to find what information you want.

Best regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Adding a "Load Resources" tool to Sirius diagram viewpoint, unsure how to do so.
Next Topic:Extending Sirius UI (tab-bar)
Goto Forum:
  


Current Time: Sat Jul 27 11:05:01 GMT 2024

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

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

Back to the top