Java Code Examples for org.jboss.forge.addon.ui.context.UIContext#getAttributeMap()
The following examples show how to use
org.jboss.forge.addon.ui.context.UIContext#getAttributeMap() .
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: CamelAddNodeXmlCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { UIContext context = builder.getUIContext(); Map<Object, Object> attributeMap = context.getAttributeMap(); attributeMap.remove("navigationResult"); Project project = getSelectedProject(context); String currentFile = getSelectedFile(context); String selected = configureXml(project, xml, currentFile); parents = configureXmlNodes(context, project, selected, xml, parent); nameFilter.setValueChoices(CamelCommandsHelper.createEipLabelValues(project, getCamelCatalog())); nameFilter.setDefaultValue("<all>"); name.setValueChoices(CamelCommandsHelper.createAllEipDtoValues(project, getCamelCatalog(), nameFilter)); // include converter from string->dto name.setValueConverter(text -> createEipDto(getCamelCatalog(), text)); builder.add(xml).add(parent).add(nameFilter).add(name); }
Example 2
Source File: CamelAddEndpointXmlCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public void initializeUI(UIBuilder builder) throws Exception { UIContext context = builder.getUIContext(); Map<Object, Object> attributeMap = context.getAttributeMap(); attributeMap.remove("navigationResult"); Project project = getSelectedProject(context); String currentFile = getSelectedFile(context); // include custom components discoverCustomCamelComponentsOnClasspathAndAddToCatalog(camelCatalog, project); configureComponentName(project, componentName, false, false); String selected = configureXml(project, xml, currentFile); nodes = configureXmlNodes(context, project, selected, xml, node); builder.add(xml).add(node).add(componentName); }
Example 3
Source File: ScanClassesCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext uiExecutionContext) throws Exception { CommandHelpers.putComponentValuesInAttributeMap(uiExecutionContext, inputComponents); UIContext uiContext = uiExecutionContext.getUIContext(); Map<Object, Object> map = uiContext.getAttributeMap(); String search = (String) (map.get("search") != null ? map.get("search") : ""); Project project = getSelectedProject(uiContext); ClassScanner scanner = ClassScanner.newInstance(project); final SortedSet<String> answer = scanner.findClassNames(search, 0); scanner.dispose(); return Results.success(toJson(answer)); }
Example 4
Source File: ScaffoldableEntitySelectionWizard.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
@Override public NavigationResult next(UINavigationContext context) throws Exception { UIContext uiContext = context.getUIContext(); Map<Object, Object> attributeMap = uiContext.getAttributeMap(); ResourceCollection resourceCollection = new ResourceCollection(); if (targets.getValue() != null) { for (JavaClassSource klass : targets.getValue()) { Project project = getSelectedProject(uiContext); JavaSourceFacet javaSource = project.getFacet(JavaSourceFacet.class); Resource<?> resource = javaSource.getJavaResource(klass); if (resource != null) { resourceCollection.addToCollection(resource); } } } attributeMap.put(ResourceCollection.class, resourceCollection); Boolean shouldGenerateRestResources = generateRestResources.getValue(); if (shouldGenerateRestResources.equals(Boolean.TRUE)) { return Results.navigateTo(JSONRestResourceFromEntityCommand.class); } return null; }
Example 5
Source File: GetPropertiesCommand.java From fabric8-forge with Apache License 2.0 | 4 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { CommandHelpers.putComponentValuesInAttributeMap(context, inputComponents); UIContext uiContext = context.getUIContext(); Map<Object, Object> map = uiContext.getAttributeMap(); List<String> classNames = (List<String>) map.get("classNames"); if (classNames == null || classNames.size() == 0) { return Results.fail("No className field provided"); } Project project = Projects.getSelectedProject(getProjectFactory(), uiContext); // force build PackagingFacet packaging = project.getFacet(PackagingFacet.class); ProjectBuilder builder = packaging.createBuilder(); builder.runTests(false); builder.addArguments("clean", "compile"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream stdout = new PrintStream(baos, true); try { builder.build(stdout, stdout); } catch (BuildException be) { // no point in continuing the operation return Results.fail("Failed to build project: " + be + "\n\n" + baos.toString()); } ClassLoaderFacet classLoaderFacet = project.getFacet(ClassLoaderFacet.class); URLClassLoader classLoader = classLoaderFacet.getClassLoader(); Map<String, List<Object>> answer = new HashMap<String, List<Object>>(); for (String className : classNames) { List<Object> props = new ArrayList<Object>(); Class clazz; try { clazz = classLoader.loadClass(className); BeanInfo beanInfo = java.beans.Introspector.getBeanInfo(clazz); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { // ignore the class property if (propertyDescriptor.getName().equals("class")) { continue; } PropertyDTO info = new PropertyDTO(propertyDescriptor); props.add(info); } } catch (Exception e) { props.add("Failed to load class, error: " + e.getMessage()); } answer.put(className, props); } classLoader.close(); String result = toJson(answer); return Results.success(result); }