Last active
October 21, 2015 16:56
-
-
Save gastaldi/7f3958146e8872d6db46 to your computer and use it in GitHub Desktop.
Trigger follow-up actions to other commands: https://issues.jboss.org/browse/FORGE-2506
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
| package org.myaddon; | |
| import javax.inject.Inject; | |
| import org.jboss.forge.addon.ui.command.AbstractUICommand; | |
| import org.jboss.forge.addon.ui.context.UIBuilder; | |
| import org.jboss.forge.addon.ui.context.UIExecutionContext; | |
| import org.jboss.forge.addon.ui.context.UINavigationContext; | |
| import org.jboss.forge.addon.ui.input.UIInput; | |
| import org.jboss.forge.addon.ui.metadata.WithAttributes; | |
| import org.jboss.forge.addon.ui.result.NavigationResult; | |
| import org.jboss.forge.addon.ui.result.Result; | |
| import org.jboss.forge.addon.ui.result.Results; | |
| import org.jboss.forge.addon.ui.wizard.UIWizardStep; | |
| public class JPAExtensionCommand extends AbstractUICommand implements UIWizardStep { | |
| @Inject | |
| @WithAttributes(label = "Enable Hibernate Search?") | |
| private UIInput<Boolean> enableSearch; | |
| @Inject | |
| private UIInput<String> name; | |
| @Override | |
| public NavigationResult next(UINavigationContext context) throws Exception { | |
| return null; | |
| } | |
| @Override | |
| public void initializeUI(UIBuilder builder) throws Exception { | |
| name.setEnabled(() -> enableSearch.getValue()); | |
| builder.add(enableSearch).add(name); | |
| } | |
| @Override | |
| public Result execute(UIExecutionContext context) throws Exception { | |
| String msg; | |
| if (enableSearch.getValue()) { | |
| msg = "Search Enabled, " + name.getValue(); | |
| } else { | |
| msg = "Search Disabled, " + name.getValue(); | |
| } | |
| return Results.success(msg); | |
| } | |
| } |
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
| package org.myaddon; | |
| import org.jboss.forge.addon.javaee.jpa.ui.setup.JPASetupWizard; | |
| import org.jboss.forge.addon.ui.context.UINavigationContext; | |
| import org.jboss.forge.addon.ui.result.NavigationResult; | |
| import org.jboss.forge.addon.ui.result.navigation.NavigationResultBuilder; | |
| import org.jboss.forge.addon.ui.result.navigation.NavigationResultTransformer; | |
| public class JPANavigationResultTransformer implements NavigationResultTransformer { | |
| @Override | |
| public boolean handles(UINavigationContext context) { | |
| return (context.getCurrentCommand() instanceof JPASetupWizard); | |
| } | |
| @Override | |
| public NavigationResult transform(UINavigationContext context, NavigationResult currentFlow) { | |
| return NavigationResultBuilder.create(currentFlow).add(JPAExtensionCommand.class).build(); | |
| } | |
| @Override | |
| public int priority() { | |
| return 0; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment