当前位置: 首页>>代码示例>>Java>>正文


Java UIExecutionContext.getUIContext方法代码示例

本文整理汇总了Java中org.jboss.forge.addon.ui.context.UIExecutionContext.getUIContext方法的典型用法代码示例。如果您正苦于以下问题:Java UIExecutionContext.getUIContext方法的具体用法?Java UIExecutionContext.getUIContext怎么用?Java UIExecutionContext.getUIContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.addon.ui.context.UIExecutionContext的用法示例。


在下文中一共展示了UIExecutionContext.getUIContext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    Map<Object, Object> attributeMap = uiContext.getAttributeMap();

    List<GitClonedRepoDetails> clonedRepos = (List<GitClonedRepoDetails>) attributeMap.get(AttributeMapKeys.GIT_CLONED_REPOS);
    if (clonedRepos != null) {
        for (GitClonedRepoDetails clonedRepo : clonedRepos) {
            Git git = clonedRepo.getGit();
            String gitUrl = clonedRepo.getGitUrl();
            UserDetails userDetails = clonedRepo.getUserDetails();
            File basedir = clonedRepo.getDirectory();
            String message = "Adding pipeline";
            try {
                LOG.info("Performing a git commit and push on URI " + gitUrl);
                gitAddCommitAndPush(git, gitUrl, userDetails, basedir, message);
            } catch (GitAPIException e) {
                return Results.fail("Failed to commit and push repository " + clonedRepo.getGitRepoName() + " due to " + e, e);
            } finally {
                removeTemporaryFiles(basedir);
            }
        }
    }
    return Results.success();
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:26,代码来源:GitCommitAndPushStep.java

示例2: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
   final UIContext uiContext = context.getUIContext();
   final Project project = helper.getProject(uiContext);

   final Map<Object, Object> attributeMap = uiContext.getAttributeMap();
   final JPADataSource dataSource = (JPADataSource) attributeMap.get(JPADataSource.class);

   persistenceOperations.setup(SpringBootJPAFacet.PERSISTENCE_UNIT_NAME, project, dataSource, false);

   // if we're using H2, Derby or HSQL embedded databases, we need to remove any previously set data
   // source properties
   if (!SpringBootPersistenceContainer.isNotEmbeddedDB(dataSource.getDatabase())) {
      SpringBootHelper.removeSpringDataPropertiesFromApplication(project);
   }
   
   return null;
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:19,代码来源:FinishJPASetupCommand.java

示例3: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    storeAttributes(uiContext);
    if (github == null) {
        return Results.fail("No github account setup");
    }

    String org = getOrganisationName(gitOrganisation.getValue());
    String repo = getGitHubRepositoryName().getValue();
    if (Strings.isNullOrBlank(repo)) {
        repo = getNamed().getValue();
    }

    String orgOrNoUser = org;
    if (Strings.isNotBlank(org)) {
        orgOrNoUser = "user";
    }
    String orgAndRepo = orgOrNoUser + "/" + repo;
    LOG.info("Creating github repository " + orgAndRepo);

    File basedir = getSelectionFolder(uiContext);
    if (basedir == null || !basedir.exists() || !basedir.isDirectory()) {
        return Results.fail("No project directory exists! " + basedir);
    }

    GitHubImportParameters importParameters = new GitHubImportParameters(org, repo, orgAndRepo, github);
    uiContext.getAttributeMap().put(GitHubImportParameters.class, importParameters);

    return super.execute(context);
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:32,代码来源:Fabric8ProjectInfoStep.java

示例4: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
   final UIContext uiContext = context.getUIContext();
   JPADataSource dataSource = (JPADataSource) uiContext.getAttributeMap().get(JPADataSource.class);
   updateDataSource(dataSource);

   final Properties properties = new Properties();
   setProperties(properties, dataSource);

   final Project project = helper.getProject(uiContext);
   SpringBootHelper.writeToApplicationProperties(project, properties);

   return null;
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:15,代码来源:AbstractDataSourceCommand.java

示例5: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    Project project = (Project) uiContext.getAttributeMap().get(Project.class);
    Archetype chosenArchetype = archetype.getValue();
    String coordinate = chosenArchetype.getGroupId() + ":" + chosenArchetype.getArtifactId() + ":"
            + chosenArchetype.getVersion();
    DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate);
    String repository = chosenArchetype.getRepository();
    if (!Strings.isNullOrEmpty(repository)) {
        if (repository.endsWith(".xml")) {
            int lastRepositoryPath = repository.lastIndexOf('/');
            if (lastRepositoryPath > -1)
                repository = repository.substring(0, lastRepositoryPath);
        }
        if (!repository.isEmpty()) {
            depQuery.setRepositories(new DependencyRepository("archetype", repository));
        }
    }
    Dependency resolvedArtifact = dependencyResolver.resolveArtifact(depQuery);
    FileResource<?> artifact = resolvedArtifact.getArtifact();
    MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
    File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();
    ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot,
            metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion());
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
    archetypeHelper.setPackageName(facet.getBasePackage());
    archetypeHelper.execute();
    return Results.success();
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:31,代码来源:FunktionArchetypeSelectionWizardStep.java

示例6: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    StopWatch watch = new StopWatch();
    UIContext uiContext = context.getUIContext();
    ProjectOverviewDTO projectOverview = getProjectOverview(uiContext);
    String result = formatResult(projectOverview);
    log.info("execute took " + watch.taken());
    return Results.success(result);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:10,代码来源:GetOverviewCommand.java

示例7: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@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));
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:13,代码来源:ScanClassesCommand.java

示例8: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    updateAttributes(uiContext);
    return Results.success();
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:7,代码来源:ChooseBoosterStep.java

示例9: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    storeAttributes(uiContext);
    Map<Object, Object> attributeMap = uiContext.getAttributeMap();
    attributeMap.put("hasJenkinsFile", hasJenkinsFile);
    PipelineDTO value = pipeline.getValue();
    attributeMap.put("selectedPipeline", value);
    List<File> folders = getProjectFolders(uiContext);
    StatusDTO status = new StatusDTO();
    if (folders.isEmpty()) {
        status.warning(LOG, "Cannot copy the pipeline to the project as no folders found!");
    }
    for (File basedir : folders) {
        if (basedir == null || !basedir.isDirectory()) {
            status.warning(LOG, "Cannot copy the pipeline to the project as no basedir!");
        } else {
            if (value != null) {
                String pipelinePath = value.getValue();
                if (Strings.isNullOrBlank(pipelinePath)) {
                    status.warning(LOG, "Cannot copy the pipeline to the project as the pipeline has no Jenkinsfile configured!");
                } else {
                    String pipelineText = getPipelineContent(pipelinePath, context.getUIContext());
                    if (Strings.isNullOrBlank(pipelineText)) {
                        status.warning(LOG, "Cannot copy the pipeline to the project as no pipeline text could be loaded!");
                    } else {
                        if ((isImportRepositoryFlow(attributeMap) && overrideJenkinsFile.getValue())
                                || isQuickstartFlow(attributeMap)) {
                            // overrrideJenkinsFile is null for quickstart wizard flow
                            // the user in import wizard flow has not opt out for the override
                            File newFile = new File(basedir, ProjectConfigs.LOCAL_FLOW_FILE_NAME);
                            Files.writeToFile(newFile, pipelineText.getBytes());
                            LOG.debug("Written Jenkinsfile to " + newFile);
                        }
                    }
                }
            }
            if ((isImportRepositoryFlow(attributeMap) && overrideJenkinsFile.getValue())
                    || isQuickstartFlow(attributeMap)) {
                updatePomVersions(uiContext, status, basedir);
            }
        }
    }
    return Results.success("Added Jenkinsfile to project", status);
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:46,代码来源:ChoosePipelineStep.java

示例10: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    Project project = (Project) uiContext.getAttributeMap().get(Project.class);
    if (project == null) {
        project = getSelectedProject(context.getUIContext());
    }
    MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);

    String projectName = metadataFacet.getProjectName();
    String groupId = metadataFacet.getProjectGroupName();
    String version = metadataFacet.getProjectVersion();
    File folder = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();

    Map<String, SpringBootDependencyDTO> selectedDTOs = new HashMap<>();
    int[] selected = dependencies.getSelectedIndexes();
    CollectionStringBuffer csbSpringBoot = new CollectionStringBuffer(",");
    CollectionStringBuffer csbFabric8 = new CollectionStringBuffer(",");
    for (int val : selected) {
        SpringBootDependencyDTO dto = choices.get(val);
        if (isFabric8Dependency(dto.getId())) {
            csbFabric8.append(dto.getId());
        } else {
            csbSpringBoot.append(dto.getId());
        }
        selectedDTOs.put(dto.getId(), dto);
    }
    String springBootDeps = csbSpringBoot.toString();
    String fabric8Deps = csbFabric8.toString();
    // boot version need the RELEASE suffix
    String bootVersion = springBootVersion.getValue() + ".RELEASE";

    String url = String.format("%s?bootVersion=%s&groupId=%s&artifactId=%s&version=%s&packageName=%s&dependencies=%s",
            STARTER_URL, bootVersion, groupId, projectName, version, groupId, springBootDeps);

    LOG.info("About to query url: " + url);

    // use http client to call start.spring.io that creates the project
    OkHttpClient client = createOkHttpClient();

    Request request = new Request.Builder().url(url).build();

    Response response = client.newCall(request).execute();
    InputStream is = response.body().byteStream();

    // some archetypes might not use maven or use the maven source layout so lets remove
    // the pom.xml and src folder if its already been pre-created
    // as these will be created if necessary via the archetype jar's contents
    File pom = new File(folder, "pom.xml");
    if (pom.isFile() && pom.exists()) {
        pom.delete();
    }
    File src = new File(folder, "src");
    if (src.isDirectory() && src.exists()) {
        recursiveDelete(src);
    }

    File name = new File(folder, projectName + ".zip");
    if (name.exists()) {
        name.delete();
    }

    FileOutputStream fos = new FileOutputStream(name, false);
    copyAndCloseInput(is, fos);
    close(fos);

    // unzip the download from spring starter
    unzip(name, folder);

    LOG.info("Unzipped file to folder: {}", folder.getAbsolutePath());

    // and delete the zip file
    name.delete();

    if (!Strings.isEmpty(fabric8Deps)) {
        addFabric8DependenciesToPom(project, fabric8Deps, selectedDTOs);
    }

    // are there any fabric8 dependencies to add afterwards?
    return Results.success("Created new Spring Boot project in directory: " + folder.getName());
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:82,代码来源:SpringBootNewProjectCommand.java

示例11: execute

import org.jboss.forge.addon.ui.context.UIExecutionContext; //导入方法依赖的package包/类
@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);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:51,代码来源:GetPropertiesCommand.java


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