• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CommandController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.forge.addon.ui.controller.CommandController的典型用法代码示例。如果您正苦于以下问题:Java CommandController类的具体用法?Java CommandController怎么用?Java CommandController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommandController类属于org.jboss.forge.addon.ui.controller包,在下文中一共展示了CommandController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"));
	}
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:17,代码来源:SetupCommandTest.java


示例2: getCommandInput

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
@Override
@GET
@Path("/commandInput/{name}/{namespace}/{projectName}/{path: .*}")
@Produces(MediaType.APPLICATION_JSON)
public Response getCommandInput(@PathParam("name") final String name,
                                @PathParam("namespace") String namespace, @PathParam("projectName") String projectName,
                                @PathParam("path") String resourcePath) throws Exception {
    return withUIContext(namespace, projectName, resourcePath, false, new RestUIFunction<Response>() {
        @Override
        public Response apply(RestUIContext context) throws Exception {
            CommandInputDTO answer = null;
            UICommand command = getCommandByName(context, name);
            if (command != null) {
                CommandController controller = createController(context, command);
                answer = UICommands.createCommandInputDTO(context, command, controller);
            }
            if (answer != null) {
                return Response.ok(answer).build();
            } else {
                return Response.status(Status.NOT_FOUND).build();
            }
        }
    });
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:25,代码来源:CommandsResource.java


示例3: configureAttributeMaps

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
protected void configureAttributeMaps(UserDetails userDetails, CommandController controller, ExecutionRequest executionRequest) {
    Map<Object, Object> attributeMap = controller.getContext().getAttributeMap();
    if (userDetails != null) {
        attributeMap.put("gitUser", userDetails.getUser());
        attributeMap.put("gitPassword", userDetails.getPassword());
        attributeMap.put("gitAuthorEmail", userDetails.getEmail());
        attributeMap.put("gitAddress", userDetails.getAddress());
        attributeMap.put("gitUrl", userDetails.getAddress());
        attributeMap.put("localGitUrl", userDetails.getInternalAddress());
        attributeMap.put("gitBranch", userDetails.getBranch());
        attributeMap.put("projectName", executionRequest.getProjectName());
        attributeMap.put("buildName", executionRequest.getProjectName());
        attributeMap.put("namespace", executionRequest.getNamespace());
        attributeMap.put("jenkinsfilesFolder", projectFileSystem.getJenkinsfilesLibraryFolder());
        projectFileSystem.asyncCloneOrPullJenkinsWorkflows(userDetails);
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:18,代码来源:CommandsResource.java


示例4: 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();
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:27,代码来源:NewComponentInstanceTest.java


示例5: 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);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:NewNodeXmlTest.java


示例6: setNodeValue

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
protected void setNodeValue(String key, CommandController command) {
    Object value = key;
    SelectComponent nodeInput = (SelectComponent) command.getInput("node");
    Iterable<NodeDto> valueChoices = nodeInput.getValueChoices();
    NodeDto found = NodeDtos.findNodeByKey(valueChoices, key);
    if (found != null) {
        value = found;
        System.out.println("Found node " + value);
    } else {
        System.out.println("Failed to find node with key '" + key + "' in the node choices: " + nodeInput.getValueChoices());
    }
    command.setValueFor("node", value);

    System.out.println("Set value of node " + value + " currently has " + nodeInput.getValue());

    if (nodeInput.getValue() == null) {
        command.setValueFor("node", key);
        System.out.println("Set value of node " + value + " currently has " + nodeInput.getValue());
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:21,代码来源:NewNodeXmlTest.java


示例7: 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;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:26,代码来源:NewNodeXmlTest.java


示例8: getCommandInfo

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
@GET
@javax.ws.rs.Path("/commands/{commandName}")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getCommandInfo(
         @PathParam("commandName") @DefaultValue(DEFAULT_COMMAND_NAME) String commandName,
         @Context HttpHeaders headers)
         throws Exception
{
   validateCommand(commandName);
   JsonObjectBuilder builder = createObjectBuilder();
   try (CommandController controller = getCommand(commandName, ForgeInitializer.getRoot(), headers))
   {
      helper.describeController(builder, controller);
   }
   return builder.build();
}
 
开发者ID:fabric8-launcher,项目名称:launchpad-backend,代码行数:17,代码来源:LaunchResource.java


示例9: checkCommandMetadata

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
@Test
public void checkCommandMetadata() throws Exception
{
   try (CommandController controller = uiTestHarness.createCommandController(SetupCommand.class,
            project.getRoot()))
   {
      controller.initialize();
      // Checks the command metadata
      assertTrue(controller.getCommand() instanceof SetupCommand);
      UICommandMetadata metadata = controller.getMetadata();
      assertEquals("WildFly Swarm: Setup", metadata.getName());
      assertEquals("WildFly Swarm", metadata.getCategory().getName());
      assertNull(metadata.getCategory().getSubCategory());
      assertEquals(3, controller.getInputs().size());
      assertFalse(controller.hasInput("dummy"));
      assertTrue(controller.hasInput("httpPort"));
      assertTrue(controller.hasInput("contextPath"));
      assertTrue(controller.hasInput("portOffset"));
   }
}
 
开发者ID:forge,项目名称:wildfly-swarm-addon,代码行数:21,代码来源:SetupCommandTest.java


示例10: 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());
}
 
开发者ID:windup,项目名称:windup,代码行数:22,代码来源:WindupCommandTest.java


示例11: getCommandInfo

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
@GET
@javax.ws.rs.Path("/commands/{commandName}")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getCommandInfo(
        @PathParam("commandName") @DefaultValue(DEFAULT_COMMAND_NAME) String commandName,
        @Context HttpHeaders headers)
        throws Exception {
    validateCommand(commandName);
    JsonObjectBuilder builder = createObjectBuilder();
    try (CommandController controller = getCommand(commandName, ForgeInitializer.getRoot(), headers)) {
        helper.describeController(builder, controller);
    }
    return builder.build();
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:15,代码来源:LaunchResource.java


示例12: validateCommand

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
@POST
@javax.ws.rs.Path("/commands/{commandName}/validate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject validateCommand(JsonObject content,
                                  @PathParam("commandName") @DefaultValue(DEFAULT_COMMAND_NAME) String commandName,
                                  @Context HttpHeaders headers)
        throws Exception {
    validateCommand(commandName);
    JsonObjectBuilder builder = createObjectBuilder();
    try (CommandController controller = getCommand(commandName, ForgeInitializer.getRoot(), headers)) {
        controller.getContext().getAttributeMap().put("action", "validate");
        helper.populateController(content, controller);
        int stepIndex = content.getInt("stepIndex", 1);
        if (controller instanceof WizardCommandController) {
            WizardCommandController wizardController = (WizardCommandController) controller;
            for (int i = 0; i < stepIndex; i++) {
                wizardController.next().initialize();
                helper.populateController(content, wizardController);
            }
        }
        helper.describeValidation(builder, controller);
        helper.describeInputs(builder, controller);
        helper.describeCurrentState(builder, controller);
    }
    return builder.build();
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:28,代码来源:LaunchResource.java


示例13: nextStep

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
@POST
@javax.ws.rs.Path("/commands/{commandName}/next")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject nextStep(JsonObject content,
                           @PathParam("commandName") @DefaultValue(DEFAULT_COMMAND_NAME) String commandName,
                           @Context HttpHeaders headers)
        throws Exception {
    validateCommand(commandName);
    int stepIndex = content.getInt("stepIndex", 1);
    JsonObjectBuilder builder = createObjectBuilder();
    try (CommandController controller = getCommand(commandName, ForgeInitializer.getRoot(), headers)) {
        if (!(controller instanceof WizardCommandController)) {
            throw new WebApplicationException("Controller is not a wizard", Status.BAD_REQUEST);
        }
        controller.getContext().getAttributeMap().put("action", "next");
        WizardCommandController wizardController = (WizardCommandController) controller;
        helper.populateController(content, controller);
        for (int i = 0; i < stepIndex; i++) {
            wizardController.next().initialize();
            helper.populateController(content, wizardController);
        }
        helper.describeMetadata(builder, controller);
        helper.describeInputs(builder, controller);
        helper.describeCurrentState(builder, controller);
    }
    return builder.build();
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:29,代码来源:LaunchResource.java


示例14: 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;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:9,代码来源:LaunchResource.java


示例15: 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"));
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:15,代码来源:SetupCommandTest.java


示例16: assertWizardController

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
protected static WizardCommandController assertWizardController(CommandController controller) {
    if (controller instanceof WizardCommandController) {
        return (WizardCommandController) controller;
    } else {
        fail("controller is not a wizard! " + controller.getClass());
        return null;
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:9,代码来源:ProjectGenerator.java


示例17: 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);
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:40,代码来源:ProjectGenerator.java


示例18: createCommandInputDTO

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
public static CommandInputDTO createCommandInputDTO(RestUIContext context, UICommand command, CommandController controller) throws Exception {
    CommandInfoDTO info = createCommandInfoDTO(context, command);
    CommandInputDTO inputInfo = new CommandInputDTO(info);
    Map<String, InputComponent<?, ?>> inputs = controller.getInputs();
    if (inputs != null) {
        Set<Map.Entry<String, InputComponent<?, ?>>> entries = inputs.entrySet();
        for (Map.Entry<String, InputComponent<?, ?>> entry : entries) {
            String key = entry.getKey();
            InputComponent<?, ?> input = entry.getValue();
            PropertyDTO dto = UICommands.createInputDTO(context, input);
            inputInfo.addProperty(key, dto);
        }
    }
    return inputInfo;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:16,代码来源:UICommands.java


示例19: populateController

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
public static void populateController(Map<String, Object> requestedInputs, CommandController controller, ConverterFactory converterFactory) {
    if (requestedInputs != null) {
        Map<String, InputComponent<?, ?>> inputs = controller.getInputs();
        Set<String> inputKeys = new HashSet<>(inputs.keySet());
        inputKeys.retainAll(requestedInputs.keySet());
        Set<Map.Entry<String, InputComponent<?, ?>>> entries = inputs.entrySet();
        for (Map.Entry<String, InputComponent<?, ?>> entry : entries) {
            String key = entry.getKey();
            Object value = requestedInputs.get(key);
            controller.setValueFor(key, Proxies.unwrap(value));
        }
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:14,代码来源:UICommands.java


示例20: createValidationResult

import org.jboss.forge.addon.ui.controller.CommandController; //导入依赖的package包/类
public static ValidationResult createValidationResult(RestUIContext context, CommandController controller, List<UIMessage> messages) {
    boolean valid = controller.isValid();
    boolean canExecute = controller.canExecute();

    RestUIProvider provider = context.getProvider();
    String out = provider.getOut();
    String err = provider.getErr();
    return new ValidationResult(toDtoList(messages), valid, canExecute, out, err);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:10,代码来源:UICommands.java



注:本文中的org.jboss.forge.addon.ui.controller.CommandController类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerLocalizationCleanupEvent类代码示例发布时间:2022-05-22
下一篇:
Java RpcDeniedReply类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap