本文整理汇总了Java中org.jboss.forge.addon.ui.controller.CommandController.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java CommandController.initialize方法的具体用法?Java CommandController.initialize怎么用?Java CommandController.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.forge.addon.ui.controller.CommandController
的用法示例。
在下文中一共展示了CommandController.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSpringBootVersion
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void checkSpringBootVersion() throws Exception {
CommandController controller = uiTestHarness
.createCommandController(SetupProjectCommand.class, project.getRoot());
controller.initialize();
// Checks the command metadata
assertTrue(controller.getCommand() instanceof SetupProjectCommand);
SetupProjectCommand springBootCommand = (SetupProjectCommand) controller.getCommand();
if (System.getenv("SPRING_BOOT_DEFAULT_VERSION") != null) {
assertEquals("1.5.1", controller.getValueFor("springBootVersion"));
}
else {
controller.getValueFor("springBootVersion");
assertEquals("1.5.4.RELEASE", controller.getValueFor("springBootVersion"));
}
}
示例2: testSomething
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void testSomething() throws Exception {
File tempDir = OperatingSystemUtils.createTempDir();
try {
Project project = projectFactory.createTempProject();
Assert.assertNotNull("Should have created a project", project);
CommandController command = testHarness.createCommandController(CamelSetupCommand.class, project.getRoot());
command.initialize();
command.setValueFor("kind", "camel-spring");
Result result = command.execute();
Assert.assertFalse("Should setup Camel in the project", result instanceof Failed);
command = testHarness.createCommandController(CamelGetComponentsCommand.class, project.getRoot());
command.initialize();
result = command.execute();
Assert.assertFalse("Should not fail", result instanceof Failed);
String message = result.getMessage();
System.out.println(message);
} finally {
tempDir.delete();
}
}
示例3: testDeleteRoute
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
protected void testDeleteRoute(Project project) throws Exception {
String key = "_camelContext1/cbr-route/_choice1/_when1/_to1";
CommandController command = testHarness.createCommandController(CamelDeleteNodeXmlCommand.class, project.getRoot());
command.initialize();
command.setValueFor("xml", "META-INF/spring/camel-context.xml");
setNodeValue(key, command);
assertValidAndExecutes(command);
List<ContextDto> contexts = getRoutesXml(project);
assertFalse("Should have loaded a camelContext", contexts.isEmpty());
assertNoNodeWithKey(contexts, key);
assertNodeWithKey(contexts, NEW_ROUTE_KEY);
}
示例4: getRoutesXml
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
protected List<ContextDto> getRoutesXml(Project project) throws Exception {
CommandController command = testHarness.createCommandController(CamelGetRoutesXmlCommand.class, project.getRoot());
command.initialize();
command.setValueFor("format", "JSON");
Result result = command.execute();
assertFalse("Should not fail", result instanceof Failed);
String message = result.getMessage();
System.out.println();
System.out.println();
System.out.println("JSON: " + message);
System.out.println();
List<ContextDto> answer = NodeDtos.parseContexts(message);
System.out.println();
System.out.println();
List<NodeDto> nodeList = NodeDtos.toNodeList(answer);
for (NodeDto node : nodeList) {
System.out.println(node.getLabel());
}
System.out.println();
return answer;
}
示例5: setupController
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
private void setupController(CommandController controller, File inputFile, File outputFile) throws Exception
{
controller.initialize();
Assert.assertTrue(controller.isEnabled());
controller.setValueFor(InputPathOption.NAME, Collections.singletonList(inputFile)); // FORGE-2524
final Object value = controller.getValueFor(InputPathOption.NAME);
Assume.assumeTrue(value instanceof Collection);
Assume.assumeTrue(((Collection) value).iterator().hasNext());
Assume.assumeTrue(((Collection) value).iterator().next() instanceof File);
Assume.assumeTrue(((Collection) value).iterator().next().equals(inputFile));
if (outputFile != null)
{
controller.setValueFor(OutputPathOption.NAME, outputFile);
}
controller.setValueFor(TargetOption.NAME, Collections.singletonList("eap"));
Assert.assertTrue(controller.canExecute());
controller.setValueFor("packages", "org.jboss");
Assert.assertTrue(controller.canExecute());
}
示例6: getCommand
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
private CommandController getCommand(String name, Path initialPath, HttpHeaders headers) throws Exception {
RestUIContext context = createUIContext(initialPath, headers);
UICommand command = commandFactory.getNewCommandByName(context, commandMap.get(name));
CommandController controller = controllerFactory.createController(context,
new RestUIRuntime(Collections.emptyList()), command);
controller.initialize();
return controller;
}
示例7: checkCommandMetadata
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void checkCommandMetadata() throws Exception {
CommandController controller = uiTestHarness
.createCommandController(SetupProjectCommand.class, project.getRoot());
controller.initialize();
// Checks the command metadata
assertTrue(controller.getCommand() instanceof SetupProjectCommand);
SetupProjectCommand springBootCommand = (SetupProjectCommand) controller.getCommand();
UICommandMetadata metadata = controller.getMetadata();
assertEquals("Spring Boot: Setup", metadata.getName());
assertEquals("Spring Boot", metadata.getCategory().getName());
Result result = controller.execute();
assertTrue("Created new Spring Boot", result.getMessage().contains("Created new Spring Boot"));
}
示例8: useCommand
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
protected void useCommand(RestUIContext context, String commandName, boolean shouldExecute) {
try {
UICommand command = commandFactory.getCommandByName(context, commandName);
if (command == null) {
LOG.warn("No such command! '" + commandName + "'");
return;
}
CommandController controller = commandControllerFactory.createController(context, runtime, command);
if (controller == null) {
LOG.warn("No such controller! '" + commandName + "'");
return;
}
controller.initialize();
WizardCommandController wizardCommandController = assertWizardController(controller);
Map<String, InputComponent<?, ?>> inputs = controller.getInputs();
Set<Map.Entry<String, InputComponent<?, ?>>> entries = inputs.entrySet();
for (Map.Entry<String, InputComponent<?, ?>> entry : entries) {
String key = entry.getKey();
InputComponent component = entry.getValue();
Object value = InputComponents.getValueFor(component);
Object completions = null;
UICompleter<?> completer = InputComponents.getCompleterFor(component);
if (completer != null) {
completions = completer.getCompletionProposals(context, component, "");
}
LOG.info(key + " = " + component + " value: " + value + " completions: " + completions);
}
validate(controller);
wizardCommandController = wizardCommandController.next();
if (shouldExecute) {
Result result = controller.execute();
printResult(result);
}
} catch (Exception e) {
LOG.error("Failed to create the " + commandName + " controller! " + e, e);
}
}
示例9: createController
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
protected CommandController createController(RestUIContext context, UICommand command) throws Exception {
RestUIRuntime runtime = new RestUIRuntime();
CommandController controller = commandControllerFactory.createController(context, runtime,
command);
controller.initialize();
return controller;
}
示例10: getCommand
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
private CommandController getCommand(String name, Path initialPath, HttpHeaders headers) throws Exception
{
RestUIContext context = createUIContext(initialPath, headers);
UICommand command = commandFactory.getNewCommandByName(context, commandMap.get(name));
CommandController controller = controllerFactory.createController(context,
new RestUIRuntime(Collections.emptyList()), command);
controller.initialize();
return controller;
}
示例11: testNewJobXml
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void testNewJobXml() throws Exception {
Project project = factory.createTempProject(Arrays.asList(ResourcesFacet.class, JavaSourceFacet.class));
JavaClassSource reader = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemReader.jv"));
JavaClassSource processor = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemProcessor.jv"));
JavaClassSource writer = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemWriter.jv"));
JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
JavaResource readerResource = java.saveJavaSource(reader);
JavaResource processorResource = java.saveJavaSource(processor);
JavaResource writerResource = java.saveJavaSource(writer);
CommandController commandController = harness.createCommandController(BatchNewJobXmlCommand.class, project.getRoot());
commandController.initialize();
// set values
commandController.setValueFor("reader", readerResource.getJavaType().getQualifiedName());
commandController.setValueFor("processor", processorResource.getJavaType().getQualifiedName());
commandController.setValueFor("writer", writerResource.getJavaType().getQualifiedName());
commandController.setValueFor("jobXML", "myJob.xml");
// validate
List<UIMessage> validate = commandController.validate();
Assert.assertEquals(0, validate.size());
// execute
Result result = commandController.execute();
// verify results
Assert.assertFalse(result instanceof Failed);
}
示例12: testNewJobXmlOptionalProcessor
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@Test
public void testNewJobXmlOptionalProcessor() throws Exception {
Project project = factory.createTempProject(Arrays.asList(ResourcesFacet.class, JavaSourceFacet.class));
JavaClassSource reader = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemReader.jv"));
JavaClassSource writer = Roaster.parse(JavaClassSource.class, getClass().getClassLoader().getResource("templates/MyItemWriter.jv"));
JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
JavaResource readerResource = java.saveJavaSource(reader);
JavaResource writerResource = java.saveJavaSource(writer);
CommandController commandController = harness.createCommandController(BatchNewJobXmlCommand.class, project.getRoot());
commandController.initialize();
// set values
commandController.setValueFor("reader", readerResource.getJavaType().getQualifiedName());
commandController.setValueFor("writer", writerResource.getJavaType().getQualifiedName());
commandController.setValueFor("jobXML", "myJob.xml");
// validate
List<UIMessage> validate = commandController.validate();
Assert.assertEquals(0, validate.size());
// execute
Result result = commandController.execute();
// verify results
Assert.assertFalse(result instanceof Failed);
}
示例13: openWizard
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
private void openWizard(UICommand command)
{
String name = command.getMetadata(uiContext).getName();
command = ForgeService.getInstance()
.getCommandFactory()
.getNewCommandByName(uiContext, name);
// Since wizard will be able to modify Command state, the cache should be invalidated
PluginService.getInstance().invalidateAndReloadCommands(uiContext);
PluginService.getInstance().addRecentCommand(command, uiContext);
UIProgressMonitor monitor = new UIProgressMonitorImpl();
((UIContextImpl) uiContext).setProgressMonitor(monitor);
UIRuntime uiRuntime = new UIRuntimeImpl(monitor);
CommandControllerFactory controllerFactory = ForgeService.getInstance().getCommandControllerFactory();
CommandController controller = controllerFactory.createController(uiContext, uiRuntime, command);
try
{
controller.initialize();
}
catch (Exception e)
{
ForgeNotifications.showErrorMessage(e);
}
if (controller.getInputs().isEmpty() && controller.canExecute())
{
new ForgeCommandTask(controller).queue();
}
else
{
ForgeWizardDialog dialog = new ForgeWizardDialog(controller);
dialog.show();
}
}
示例14: ForgeWizardStep
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
public ForgeWizardStep(ForgeWizardModel model, CommandController controller)
{
this.model = model;
this.navigationState = new NavigationState(model, controller);
try
{
controller.initialize();
}
catch (Exception e)
{
ForgeNotifications.showErrorMessage(e);
e.printStackTrace();
}
}
示例15: getCommandMetadata
import org.jboss.forge.addon.ui.controller.CommandController; //导入方法依赖的package包/类
@GET
@Path("/{command}")
@Produces(MediaType.APPLICATION_JSON)
public List<ControlMetadata> getCommandMetadata(@PathParam("command") String command,
@Context final HttpServletResponse response)
throws Exception
{
IDEUIContext context = new IDEUIContext();
UICommand cmd = commandFactory.get().getCommandByName(context, command);
if (cmd == null)
{
response.sendError(Response.Status.NOT_FOUND.getStatusCode());
return null;
}
CommandController controller = controllerFactory.get().createSingleController(
context, new UIRuntimeImpl(), cmd);
controller.initialize();
//Map<String,InputComponentMetadata> components = new HashMap<String,InputComponentMetadata>();
List<ControlMetadata> controlMetadata = new ArrayList<ControlMetadata>();
for (String key : controller.getInputs().keySet()) {
InputComponent component = controller.getInputs().get(key);
InputControl control = ControlRegistry.getControlFor(component);
ControlMetadata meta = new ControlMetadata();
control.populateMetadata(component, meta);
controlMetadata.add(meta);
}
return controlMetadata;
}