-
Notifications
You must be signed in to change notification settings - Fork 3
/
eclipseGeneratorHandler.mtl
61 lines (49 loc) · 2.05 KB
/
eclipseGeneratorHandler.mtl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
[comment encoding = UTF-8 /]
[module eclipseGenerator('http://www.eclipse.org/acceleo/4.0')/]
[import org::eclipse::acceleo::aql::ide::ui::module::requests::requests/]
[import org::eclipse::acceleo::aql::ide::ui::module::services::Services/]
[**
* Generate the plugin.xml file.
* @param projectUIName the UI project name
*/]
[template public generatorHandlerFile(module : acceleo::Module, projectUIName : String)]
[file (projectUIName + '/src/' + projectUIName.replaceAll('\\.', '/') + '/handlers/' + module.getEclipseHandlerClassName() + '.java', overwrite, 'UTF-8')]
[protected ('copyright') startTagPrefix('//') endTagPrefix('//')]
[/protected]
package [projectUIName/].handlers;
[protected ('imports') startTagPrefix('//') endTagPrefix('//')]
import java.util.Iterator;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import [module.getReceiverQualifiedClassName()/];
import org.eclipse.jface.viewers.IStructuredSelection;
import [projectUIName/].[module.getEclipseClassName()/];
import org.eclipse.ui.handlers.HandlerUtil;
[/protected]
/**
* Command handler for [module.getQualifiedName()/].
*
* @author [''.getUserName()/]
* @generated
*/
public class [module.getEclipseHandlerClassName()/] extends AbstractHandler {
/**
* @generated
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event);
final Iterator<?> it = selection.iterator();
while (it.hasNext()) {
final Object selected = it.next();
if (selected instanceof [module.getReceiverClassName()/]) {
final [module.getEclipseClassName()/] generator = new [module.getEclipseClassName()/](([module.getReceiverClassName()/])selected);
generator.generate();
}
}
return null;
}
}
[/file]
[/template]