Created
June 8, 2015 21:49
-
-
Save agoncal/b469439a9dfe09ec69ee to your computer and use it in GitHub Desktop.
This file contains 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 { | |
@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 { | |
UIContext uiContext = context.getUIContext(); | |
JavaResource resource = (JavaResource) uiContext.getInitialSelection().get(); | |
JavaClassSource javaClass = resource.getJavaType(); | |
javaClass.setName("MyClass").setPackage("org.helloAddon").addField().setName("myfield").setType(String.class); | |
resource.setContents(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