Java Code Examples for org.jboss.forge.addon.ui.context.UIBuilder#add()

The following examples show how to use org.jboss.forge.addon.ui.context.UIBuilder#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewIntegrationTestBuildCommand.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeUI(final UIBuilder builder) throws Exception {
    super.initializeUI(builder);

    buildName.setDefaultValue(new Callable<String>() {
        @Override
        public String call() throws Exception {
            Model mavenModel = getMavenModel(builder);
            if (mavenModel != null) {
                return mavenModel.getArtifactId() + "-int-test";
            }
            return null;
        }
    });
    builder.add(buildName);
    builder.add(mavenCommand);
    builder.add(image);
    builder.add(gitUri);
}
 
Example 2
Source File: ReplicationControllerDelete.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    super.initializeUI(builder);

    // populate autocompletion options
    replicationControllerId.setCompleter(new UICompleter<String>() {
        @Override
        public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
            List<String> list = new ArrayList<String>();
            ReplicationControllerList replicationControllers = getKubernetes().replicationControllers().inNamespace(getNamespace()).list();
            if (replicationControllers != null) {
                List<ReplicationController> items = replicationControllers.getItems();
                if (items != null) {
                    for (ReplicationController item : items) {
                        String id = KubernetesHelper.getName(item);
                        list.add(id);
                    }
                }
            }
            Collections.sort(list);
            return list;
        }
    });

    builder.add(replicationControllerId);
}
 
Example 3
Source File: CamelProjectAddDataFormatCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    Project project = getSelectedProject(builder);

    dtos = new CamelDataFormatsCompleter(project, getCamelCatalog()).getValueChoices();
    List<String> names = new ArrayList<>();
    for (DataFormatDto dto : dtos) {
        names.add(dto.getName());
    }
    dataformatName.setValueChoices(names);

    builder.add(dataformatName);
}
 
Example 4
Source File: CamelAddEndpointCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    Map<Object, Object> attributeMap = builder.getUIContext().getAttributeMap();
    attributeMap.remove("navigationResult");

    Project project = getSelectedProject(builder.getUIContext());
    String selectedFile = getSelectedFile(builder.getUIContext());
    final String currentFile = asRelativeFile(builder.getUIContext(), selectedFile);
    attributeMap.put("currentFile", currentFile);

    // include custom components
    discoverCustomCamelComponentsOnClasspathAndAddToCatalog(camelCatalog, project);

    boolean xmlFile = isSelectedFileXml(builder.getUIContext());

    // determine if the current cursor position is in a route where we should be either consumer or producer only
    AtomicBoolean consumerOnly = new AtomicBoolean();
    AtomicBoolean producerOnly = new AtomicBoolean();
    determineConsumerAndProducerOnly(consumerOnly, producerOnly, builder.getUIContext(), xmlFile, currentFile);
    attributeMap.put("consumerOnly", Boolean.toString(consumerOnly.get()));
    attributeMap.put("producerOnly", Boolean.toString(producerOnly.get()));

    List<String> names = camelCatalog.findComponentNames();
    LOG.info("All component names +++ start +++");
    for (String name : names) {
        LOG.info(name);
    }
    LOG.info("All component names +++ end +++");
    LOG.info("ConsumerOnly: " + consumerOnly.get());
    LOG.info("ProducerOnly: " + producerOnly.get());

    // filter the list of components based on consumer and producer only
    configureComponentName(project, componentName, consumerOnly.get(), producerOnly.get());

    builder.add(componentName);
}
 
Example 5
Source File: ConfigureComponentPropertiesStep.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void initializeUI(UIBuilder builder) throws Exception {
    if (inputs != null) {
        for (InputComponent input : inputs) {
            builder.add(input);
        }
    }
}
 
Example 6
Source File: NamespaceSet.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
    public void initializeUI(UIBuilder builder) throws Exception {
        super.initializeUI(builder);

        // TODO load the list of namespaces...
/*
        namespace.setCompleter(new UICompleter<String>() {
            @Override
            public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
                List<String> list = new ArrayList<String>();
                PodList pods = getKubernetes().getPods();
                if (pods != null) {
                    List<Pod> items = pods.getItems();
                    if (items != null) {
                        for (Pod item : items) {
                            String id = getName(item);
                            list.add(id);
                        }
                    }
                }
                Collections.sort(list);
                System.out.println("Completion list is " + list);
                return list;
            }
        });
*/

        builder.add(namespace);
    }
 
Example 7
Source File: AbstractPodCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    super.initializeUI(builder);

    // populate autocompletion options
    podId.setCompleter(new UICompleter<String>() {
        @Override
        public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
            List<String> list = new ArrayList<String>();
            PodList pods = getKubernetes().pods().list();
            if (pods != null) {
                List<Pod> items = pods.getItems();
                if (items != null) {
                    for (Pod item : items) {
                        String id = KubernetesHelper.getName(item);
                        list.add(id);
                    }
                }
            }
            Collections.sort(list);
            System.out.println("Completion list is " + list);
            return list;
        }
    });

    builder.add(podId);
}
 
Example 8
Source File: CamelProjectAddComponentCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    final Project project = getSelectedProject(builder);

    filter.setValueChoices(CamelCommandsHelper.createComponentLabelValues(project, getCamelCatalog()));
    filter.setDefaultValue("<all>");

    // we use the componentName in the next step so do not add it to this builder
    builder.add(filter);
}
 
Example 9
Source File: ConfigureEipPropertiesStep.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void initializeUI(UIBuilder builder) throws Exception {
    if (inputs != null) {
        for (InputComponent input : inputs) {
            builder.add(input);
        }
    }
}
 
Example 10
Source File: DevOpsEditOptionalStep.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
    public void initializeUI(UIBuilder builder) throws Exception {
        StopWatch watch = new StopWatch();

        final UIContext context = builder.getUIContext();

        letsChat = (LetsChatClient) builder.getUIContext().getAttributeMap().get("letsChatClient");
        taigaClient = (TaigaClient) builder.getUIContext().getAttributeMap().get("taigaClient");

/*        chatRoom.setCompleter(new UICompleter<String>() {
            @Override
            public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
                // TODO: call only once to init getChatRoomNames
                return filterCompletions(getChatRoomNames(), value);
            }
        });
        issueProjectName.setCompleter(new UICompleter<String>() {
            @Override
            public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
                // TODO: call only once to init getIssueProjectNames
                return filterCompletions(getIssueProjectNames(), value);
            }
        });*/

        // lets initialise the data from the current config if it exists
        ProjectConfig config = (ProjectConfig) context.getAttributeMap().get("projectConfig");
        if (config != null) {
            CommandHelpers.setInitialComponentValue(chatRoom, config.getChatRoom());
            CommandHelpers.setInitialComponentValue(issueProjectName, config.getIssueProjectName());
            CommandHelpers.setInitialComponentValue(codeReview, config.getCodeReview());
        }

        builder.add(chatRoom);
        builder.add(issueProjectName);
        builder.add(codeReview);

        LOG.info("initializeUI took " + watch.taken());
    }
 
Example 11
Source File: CamelProjectAddLanguageCommand.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    Project project = getSelectedProject(builder);

    dtos = new CamelLanguagesCompleter(project, getCamelCatalog()).getValueChoices();
    List<String> names = new ArrayList<>();
    for (LanguageDto dto : dtos) {
        names.add(dto.getName());
    }
    languageName.setValueChoices(names);

    builder.add(languageName);
}
 
Example 12
Source File: RouteListCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    name.setCompleter(new CamelContextCompleter(getController()));
    builder.add(name);
}
 
Example 13
Source File: EndpointStatsCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    name.setCompleter(new CamelContextCompleter(getController()));
    builder.add(name);
}
 
Example 14
Source File: PodsList.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    super.initializeUI(builder);
    builder.add(filterText);
}
 
Example 15
Source File: ReplicationControllersList.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    super.initializeUI(builder);
    builder.add(filterText);
}
 
Example 16
Source File: Apply.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
    public void initializeUI(UIBuilder builder) throws Exception {
        super.initializeUI(builder);

        // TODO complete on files
/*
        file.setCompleter(new UICompleter<String>() {
            @Override
            public Iterable<String> getCompletionProposals(UIContext context, InputComponent<?, String> input, String value) {
                List<String> list = new ArrayList<String>();
                ServiceList services = getKubernetes().getServices();
                if (services != null) {
                    List<Service> items = services.getItems();
                    if (items != null) {
                        for (Service item : items) {
                            String id = item.getName();
                            list.add(id);
                        }
                    }
                }
                Collections.sort(list);
                return list;
            }
        });
*/
        file.addValidator(new UIValidator() {
            @Override
            public void validate(UIValidationContext validationContext) {
                InputComponent<?, ?> inputComponent = validationContext.getCurrentInputComponent();
                Object value = inputComponent.getValue();
                if (value instanceof File) {
                    File aFile = (File) value;
                    if (!aFile.exists()) {
                        validationContext.addValidationError(inputComponent, "File does not exist!");
                    } else if (!aFile.isFile()) {
                        validationContext.addValidationError(inputComponent, "File is a directory!");
                    } else {
                        String extension = Files.getFileExtension(aFile);
                        if (extension == null || !extension.toLowerCase().equals("json")) {
                            validationContext.addValidationWarning(inputComponent, "File does not use the .json extension");
                        }
                    }
                }
            }
        });

        builder.add(file);
    }
 
Example 17
Source File: RouteResetStatsCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    name.setCompleter(new CamelContextCompleter(getController()));
    builder.add(name);
}
 
Example 18
Source File: ContextStopCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    name.setCompleter(new CamelContextCompleter(getController()));
    builder.add(name);
}
 
Example 19
Source File: RestShowCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    name.setCompleter(new CamelContextCompleter(getController()));
    builder.add(name);
}
 
Example 20
Source File: ContextResumeCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    name.setCompleter(new CamelContextCompleter(getController()));
    builder.add(name);
}