Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] How to indicate progress while executing a template ?
[Xpand] How to indicate progress while executing a template ? [message #533956] Mon, 17 May 2010 14:45 Go to next message
Harald M is currently offline Harald MFriend
Messages: 10
Registered: March 2010
Junior Member
Hello,

I want to show the progress of several generation steps in a ProgressMonitorDialog. In the standard java steps it is easy to do a monitor.worked(numberOfTicks).
Is it possible to give a similar feedback in the Xpand template code ?

With the following code I am able to run the the Xpand template, but I get no feedback for the progress view.

The generation is called from an IRunnableWithProgress:

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
import org.eclipse.emf.mwe.core.monitor.ProgressMonitorAdapter;

monitor.beginTask("Generating xxx", 10);
[...]
monitor.worked(1);
[...]
ProgressMonitor oawMonitor;
oawMonitor = new ProgressMonitorAdapter(new SubProgressMonitor(monitor, 5));
generateFiles(model, path, oawMonitor);
[...]
monitor.done();


The template is executed via XpandFacade:
public static void generateFiles(Model model, String path, ProgressMonitor monitor) {
   // configure outlet
   OutputImpl output = new OutputImpl();
   output.addOutlet(new Outlet(path));

   // create execution context
   XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(output, null);
   EmfRegistryMetaModel metamodel = new EmfRegistryMetaModel();
   execCtx.registerMetaModel(metamodel);
   execCtx.setMonitor(monitor);

   // generate
   XpandFacade facade = XpandFacade.create(execCtx);
   facade.evaluate("templates::simulation::Template_all::main", model);
}


Thanks,

Harald
Re: [Xpand] How to indicate progress while executing a template ? [message #534675 is a reply to message #533956] Wed, 19 May 2010 20:13 Go to previous messageGo to next message
Harald M is currently offline Harald MFriend
Messages: 10
Registered: March 2010
Junior Member
Any idea ?

Is org.eclipse.emf.mwe.core.monitor.ProgressMonitor a possible approach ?
Re: [Xpand] How to indicate progress while executing a template ? [message #534729 is a reply to message #534675] Thu, 20 May 2010 07:27 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Harald M. schrieb:
> Any idea ?
>
> Is org.eclipse.emf.mwe.core.monitor.ProgressMonitor a possible approach ?

You need to get access to the progress monitor, which could be done by
putting it into the global vars map in the execution context and then
later report progress using xtend.

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Xpand] How to indicate progress while executing a template ? [message #535840 is a reply to message #534729] Tue, 25 May 2010 23:24 Go to previous messageGo to next message
Harald M is currently offline Harald MFriend
Messages: 10
Registered: March 2010
Junior Member
Hi Sven,

the hint to report progress using xtend was very helpful.
Thank you.

In my solution I do not use a global vars map.
The execution context set with "execCtx.setMonitor(monitor)" is now accessable in Xtent.

In the online help I found the (new?) description to build an IExecutionContextAware Java extension.
In that Java extension I created some delegate methods
- MonitorSubTask(String name)
- MonitorWorked(int work)
that do the job... Smile

Harald
Re: [Xpand] How to indicate progress while executing a template ? [message #878120 is a reply to message #535840] Mon, 28 May 2012 15:38 Go to previous message
mrodrigo Missing name is currently offline mrodrigo Missing nameFriend
Messages: 6
Registered: March 2011
Junior Member
Harald M wrote on Wed, 26 May 2010 01:24
Hi Sven,

the hint to report progress using xtend was very helpful.
Thank you.

In my solution I do not use a global vars map.
The execution context set with "execCtx.setMonitor(monitor)" is now accessable in Xtent.

In the online help I found the (new?) description to build an IExecutionContextAware Java extension.
In that Java extension I created some delegate methods
- MonitorSubTask(String name)
- MonitorWorked(int work)
that do the job... Smile

Harald



Hello Harald,

Can you post more information about your method to show progress during templates execution?

Thank you so much!

Best regards,

mrodrigo
Previous Topic:xtend2, UML2, MWE2
Next Topic:[xPand] Access OCL derivation during generation
Goto Forum:
  


Current Time: Fri Apr 19 22:08:20 GMT 2024

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

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

Back to the top