Created
June 8, 2015 22:05
-
-
Save agoncal/b8871d8df0e0c307e18c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyCommand extends AbstractUICommand { | |
| @Inject | |
| ProjectFactory projectFactory; | |
| @Override | |
| public UICommandMetadata getMetadata(UIContext context) { | |
| return Metadata.forCommand(MyCommand.class).name("toto") | |
| .category(Categories.create("JavaEE")); | |
| } | |
| @Override | |
| public void initializeUI(UIBuilder builder) throws Exception { | |
| } | |
| @Override | |
| public Result execute(UIExecutionContext context) throws Exception { | |
| final JavaClassSource javaClass = Roaster.create(JavaClassSource.class); | |
| javaClass.setName("MyClass").setPackage("org.helloAddon").addField().setName("myfield").setType(String.class); | |
| Projects.getSelectedProject(projectFactory, context.getUIContext()).getFacet(JavaSourceFacet.class).saveJavaSource(javaClass); | |
| return Results.success("Command 'toto' successfully executed!"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment