Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » MOFScript » [MOFScript] Integration
[MOFScript] Integration [message #469051] Tue, 14 October 2008 20:29 Go to next message
Diego is currently offline DiegoFriend
Messages: 6
Registered: July 2009
Junior Member
Hello Gøran,

I was trying to integrate MOFScript in my tool here and had some problems
doing so. As before, i need your help.

How can i set the generation root programatically (without the preference
window)?
-i found a .properties file amongst the eclipse plugins and the root
directory path is set there (MofScriptEditorPlugin.properties), thought it
could be the point but wasn't able to found it's source (or sources).

#we won't need the [MOFScript] anymore, will we? hehe

Cheers,

Diego Q.
Re: Integration [message #469055 is a reply to message #469051] Fri, 17 October 2008 14:59 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Diego,

No, no more [MOFScript] prefix :)

You can set this by using:

execMgr = ExecutionManager.getExecutionManager( ) ;
execMgr.setRootDirectory(path);

Best Regards,
G
Re: Integration [message #469056 is a reply to message #469055] Tue, 28 October 2008 17:57 Go to previous messageGo to next message
Diego is currently offline DiegoFriend
Messages: 6
Registered: July 2009
Junior Member
Hi again,

ok ..

execMgr = ExecutionManager.getExecutionManager();
execMgr.setRootDirectory(path);

worked, but only when i do ALL the transformation programatically.

taht is, i created an UI. there's a button performing the code below:

MofScriptTextEditor editor =
(MofScriptTextEditor)PlatformUI.getWorkbench().getActiveWork benchWindow().getActivePage().getActiveEditor();
editor.execute("model2text");

which calls the dialog to choose the input model. the problem is that when
i set the output directory programatically and execute the transformation
by this action the default output (c:/temp/) is set again.

How can i solve this?

consider that i have no way to set the output directory by the following
ways:
1-preferences(MofScript Preferences) #mine is bugged, default is always
set this way.

2-right-click on file -> properties -> MofScriptPropreties -> Select
Output Directory

if i had a way to do the (2-right-click on file -> properties ->
MofScriptPropreties -> Select Output Directory) programatically maybe my
problems could be solved.

My regards!
Re: Integration [message #469061 is a reply to message #469056] Mon, 03 November 2008 16:16 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Diego,

I am not sure if I understand your problem,

can you set this in the MOFScript editor as you are supposed to?

What is the scenario you want to implement?

Best Regards,
G
Re: Integration [message #469064 is a reply to message #469061] Mon, 03 November 2008 20:10 Go to previous messageGo to next message
Diego is currently offline DiegoFriend
Messages: 6
Registered: July 2009
Junior Member
Hello Goran,

I'll try to explain everything that is happening here. My bad english
won't help however.
My team is working on a transformation tool (model to model, model to
code) and we have chosen the MofScript API to perform the model to code
generation. So, we created a plugin project (RCP) on eclipse and
integrated the MofScript's funcionalities.
By using MofScript plugin we have found that the Root Generation Dir is
not correctly set by the Menu: Window - Preferences - MofScript Preference
- Root Generation Dir. Everytime i set it to a new directory e.g. c:/new/
and perform the transformation, the output dir is set (for some unknown
reason) to its default (c:/temp/).
To solve this we discovered that if we use the popUpMenu in the package
explorer: Right-Click on .m2t file - Properties - MofScript Properties -
Select Root Output Directory, and set the output directory by there, it
works fine. But the problem is that on the tool we are developing, there's
no package explorer to right click the .m2t file.
As an option, we tried to make all the transformation programatically,
as i said in the previous post:
..
..
..
execMgr = ExecutionManager.getExecutionManager();
execMgr.setRootDirectory(path);
..
..
..

which sets the output directory correctly. Fine, but we were having some
problems with the programatically transformation (soon, another post =D)
and we decided to follow the user interface way, at least for now.
Then, we tried to ONLY set the output dir programatically, as above,
and then execute the transformation by the user interface, on the execute
transformation button. It didn't work, the default dir (c:/temp/) was set
again.
So, i was thinking about a way to perform programatically the
Right-click on .m2t file -> properties -> MofScriptPropreties -> Select
Output Directory (which works here). Any idea on how to solve this?
Hope you understand the problem and sorry to bother one more time.

Thanks in advance,

Diego Queiroz
Re: Integration [message #469068 is a reply to message #469064] Wed, 12 November 2008 14:28 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
The property page that you are looking for is the MOFScriptPropertyPage.

The ExecutionUtility has the following method that you can take a look at:

/**
* Sets the root directory property for a given file resource
* The root directory property is used when generating output files
* If a transformation only specifies relative paths, this property is used
* for absolute location
* @param file
*/
public void setRootDirectoryProperty (IFile file) {
String rootDir = null;
try {
rootDir = file.getPersistentProperty(new QualifiedName("",
MofScriptPropertyPage.OUTPUT_DIRECTORY_PROPERTY));
if (rootDir == null) {
rootDir =
MofScriptEditorPlugin.getDefault().getPreferenceString(MofSc riptPreferences.ROOT_DIRECTORY);
if (rootDir != null)
file.setPersistentProperty(new QualifiedName("",
MofScriptPropertyPage.OUTPUT_DIRECTORY_PROPERTY), rootDir);
}
} catch (CoreException xec) {
rootDir =
MofScriptEditorPlugin.getDefault().getPreferenceString(MofSc riptPreferences.ROOT_DIRECTORY);
}
if (rootDir != null && !rootDir.equals(""))
ExecutionManager.getExecutionManager().setRootDirectory(root Dir);
}




Best Regards,
G
Re: Integration [message #566015 is a reply to message #469051] Fri, 17 October 2008 14:59 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Diego,

No, no more [MOFScript] prefix :)

You can set this by using:

execMgr = ExecutionManager.getExecutionManager( ) ;
execMgr.setRootDirectory(path);

Best Regards,
G
Re: Integration [message #566030 is a reply to message #469055] Tue, 28 October 2008 17:57 Go to previous message
Diego is currently offline DiegoFriend
Messages: 6
Registered: July 2009
Junior Member
Hi again,

ok ..

execMgr = ExecutionManager.getExecutionManager();
execMgr.setRootDirectory(path);

worked, but only when i do ALL the transformation programatically.

taht is, i created an UI. there's a button performing the code below:

MofScriptTextEditor editor =
(MofScriptTextEditor)PlatformUI.getWorkbench().getActiveWork benchWindow().getActivePage().getActiveEditor();
editor.execute("model2text");

which calls the dialog to choose the input model. the problem is that when
i set the output directory programatically and execute the transformation
by this action the default output (c:/temp/) is set again.

How can i solve this?

consider that i have no way to set the output directory by the following
ways:
1-preferences(MofScript Preferences) #mine is bugged, default is always
set this way.

2-right-click on file -> properties -> MofScriptPropreties -> Select
Output Directory

if i had a way to do the (2-right-click on file -> properties ->
MofScriptPropreties -> Select Output Directory) programatically maybe my
problems could be solved.

My regards!
Re: Integration [message #566051 is a reply to message #469056] Mon, 03 November 2008 16:16 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
Hello Diego,

I am not sure if I understand your problem,

can you set this in the MOFScript editor as you are supposed to?

What is the scenario you want to implement?

Best Regards,
G
Re: Integration [message #566070 is a reply to message #469061] Mon, 03 November 2008 20:10 Go to previous message
Diego is currently offline DiegoFriend
Messages: 6
Registered: July 2009
Junior Member
Hello Goran,

I'll try to explain everything that is happening here. My bad english
won't help however.
My team is working on a transformation tool (model to model, model to
code) and we have chosen the MofScript API to perform the model to code
generation. So, we created a plugin project (RCP) on eclipse and
integrated the MofScript's funcionalities.
By using MofScript plugin we have found that the Root Generation Dir is
not correctly set by the Menu: Window - Preferences - MofScript Preference
- Root Generation Dir. Everytime i set it to a new directory e.g. c:/new/
and perform the transformation, the output dir is set (for some unknown
reason) to its default (c:/temp/).
To solve this we discovered that if we use the popUpMenu in the package
explorer: Right-Click on .m2t file - Properties - MofScript Properties -
Select Root Output Directory, and set the output directory by there, it
works fine. But the problem is that on the tool we are developing, there's
no package explorer to right click the .m2t file.
As an option, we tried to make all the transformation programatically,
as i said in the previous post:
..
..
..
execMgr = ExecutionManager.getExecutionManager();
execMgr.setRootDirectory(path);
..
..
..

which sets the output directory correctly. Fine, but we were having some
problems with the programatically transformation (soon, another post =D)
and we decided to follow the user interface way, at least for now.
Then, we tried to ONLY set the output dir programatically, as above,
and then execute the transformation by the user interface, on the execute
transformation button. It didn't work, the default dir (c:/temp/) was set
again.
So, i was thinking about a way to perform programatically the
Right-click on .m2t file -> properties -> MofScriptPropreties -> Select
Output Directory (which works here). Any idea on how to solve this?
Hope you understand the problem and sorry to bother one more time.

Thanks in advance,

Diego Queiroz
Re: Integration [message #566084 is a reply to message #469064] Wed, 12 November 2008 14:28 Go to previous message
Gøran K. Olsen is currently offline Gøran K. OlsenFriend
Messages: 184
Registered: July 2009
Senior Member
The property page that you are looking for is the MOFScriptPropertyPage.

The ExecutionUtility has the following method that you can take a look at:

/**
* Sets the root directory property for a given file resource
* The root directory property is used when generating output files
* If a transformation only specifies relative paths, this property is used
* for absolute location
* @param file
*/
public void setRootDirectoryProperty (IFile file) {
String rootDir = null;
try {
rootDir = file.getPersistentProperty(new QualifiedName("",
MofScriptPropertyPage.OUTPUT_DIRECTORY_PROPERTY));
if (rootDir == null) {
rootDir =
MofScriptEditorPlugin.getDefault().getPreferenceString(MofSc riptPreferences.ROOT_DIRECTORY);
if (rootDir != null)
file.setPersistentProperty(new QualifiedName("",
MofScriptPropertyPage.OUTPUT_DIRECTORY_PROPERTY), rootDir);
}
} catch (CoreException xec) {
rootDir =
MofScriptEditorPlugin.getDefault().getPreferenceString(MofSc riptPreferences.ROOT_DIRECTORY);
}
if (rootDir != null && !rootDir.equals(""))
ExecutionManager.getExecutionManager().setRootDirectory(root Dir);
}




Best Regards,
G
Previous Topic:[MOFScript] Integration
Next Topic:Recursive import?
Goto Forum:
  


Current Time: Fri Mar 29 06:21:48 GMT 2024

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

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

Back to the top