public Promise<List<SourceEstimation>> resolve(Project project) { return ps.resolveSources(project.getLocation()); }
/** {@inheritDoc} */ @Override public void intercept(Resource resource) { if (resource.isFile() && POM_XML.equals(resource.getName())) { Project project = resource.getProject(); if (project != null && project.isTypeOf(MAVEN_ID) && resource.getParent().getLocation().equals(project.getLocation())) { String artifact = project.getAttribute(ARTIFACT_ID); if (!isNullOrEmpty(artifact) && !UNKNOWN_VALUE.equals(artifact)) { resource.addMarker(new PresentableTextMarker(artifact)); } } } } }
@Override public Promise<String> expand() { final Resource[] resources = appContext.getResources(); if (resources != null && resources.length == 1) { final Resource resource = resources[0]; Project project = resource.getProject(); if (!project.exists() || !isJavaProject(project)) { return promises.resolve(""); } if (project.getAttributes().containsKey(OUTPUT_FOLDER)) { return promises.resolve( appContext .getProjectsRoot() .append(project.getLocation()) .append(project.getAttributes().get(OUTPUT_FOLDER).get(0)) .toString()); } else { return promises.resolve( appContext.getProjectsRoot().append(project.getLocation()).toString()); } } return promises.resolve(""); } }
protected final Path[] getPaths(Project project, String srcType) { final List<String> srcFolders = project.getAttributes().get(srcType); if (srcFolders == null || srcFolders.isEmpty()) { return new Path[0]; } Path[] paths = new Path[0]; for (String srcFolder : srcFolders) { final int index = paths.length; paths = Arrays.copyOf(paths, index + 1); paths[index] = project.getLocation().append(srcFolder); } return paths; } }
private void checkProjectProblems(Project project) { final Optional<Marker> marker = project.getMarker(PROBLEM_PROJECT); if (!marker.isPresent()) { return; } final Project.ProblemProjectMarker problemProjectMarker = (Project.ProblemProjectMarker) marker.get(); final Map<Integer, String> problems = problemProjectMarker.getProblems(); // If no project folder on file system final String noProjectFolderProblem = problems.get(NO_PROJECT_ON_FILE_SYSTEM); final List<String> importingProjects = appContext.getImportingProjects(); if (!isNullOrEmpty(noProjectFolderProblem) && !importingProjects.contains(project.getPath())) { showImportDialog(project); } }
@Override public void update(ActionEvent e) { panel.clear(); Project project = appContext.getRootProject(); if (project != null && project.getAttributes().containsKey(GIT_CURRENT_HEAD_NAME)) { Label projectNameLabel = new Label(project.getName()); projectNameLabel.ensureDebugId("statusBarProjectBranchRepositoryName"); projectNameLabel.getElement().getStyle().setMarginLeft(5., Unit.PX); panel.add(projectNameLabel); SVGImage branchIcon = new SVGImage(resources.checkoutReference()); branchIcon.getSvgElement().getStyle().setMarginLeft(5., Unit.PX); panel.add(branchIcon); Label headLabel = new Label(project.getAttribute(GIT_CURRENT_HEAD_NAME)); headLabel.ensureDebugId("statusBarProjectBranchName"); headLabel.setTitle(constant.branchesControlTitle()); Style headLabelStyle = headLabel.getElement().getStyle(); headLabelStyle.setCursor(Cursor.POINTER); headLabelStyle.setMarginLeft(5., Unit.PX); headLabel.addClickHandler(event -> branchPresenter.showBranches(project)); panel.add(headLabel); } } }
public void initRepository(final Project project) { final GitOutputConsole console = gitOutputConsoleFactory.create(INIT_COMMAND_NAME); service .init(project.getLocation(), false) .then( ignored -> { console.print(constant.initSuccess()); consolesPanelPresenter.addCommandOutput(console); notificationManager.notify(constant.initSuccess()); project.synchronize(); }) .catchError( error -> { handleError(error.getCause(), console); consolesPanelPresenter.addCommandOutput(console); }); }
@Override public void actionPerformed(ActionEvent e) { final Resource resource = appContext.getResource(); checkNotNull(resource); final Project project = resource.getProject(); checkState(MavenAttributes.MAVEN_ID.equals(project.getType())); javaLanguageExtensionServiceClient .effectivePom(project.getLocation().toString()) .then( content -> { showEffectivePomInEditor(project, content); }) .catchError( error -> { notificationManager.notify( "Problem with generating effective pom file", error.getMessage(), FAIL, EMERGE_MODE); }); }
private List<String> getPathsToSelectedMavenProject() { final Resource[] resources = appContext.getResources(); if (resources == null) { return Collections.emptyList(); } Set<String> paths = new HashSet<>(); for (Resource resource : resources) { final Project project = resource.getProject(); if (project != null && project.isTypeOf(MavenAttributes.MAVEN_ID)) { paths.add(project.getLocation().toString()); } } return new ArrayList<>(paths); } }
element.setAttribute("project", project.getLocation().toString()); Container container = ((ContainerNode) node).getData(); if (container instanceof Project) { String head = container.getProject().getAttribute("git.current.head.name"); if (head != null) { Element nodeContainer = element.getFirstChildElement();
@Override public void apply(Project project) throws OperationException { Log.info(getClass(), "Project " + project.getName() + " imported."); } });
@NotNull private static List<String> doGetSourceFolders(Project projectConfig, String projectBuilder) { List<String> allSourceFolders = new LinkedList<>(); String projectPath = removeEndingPathSeparator(projectConfig.getPath()); Map<String, List<String>> attributes = projectConfig.getAttributes(); List<String> sourceFolders = attributes.get(SOURCE_FOLDER); if (sourceFolders != null) { for (String sourceFolder : sourceFolders) { allSourceFolders.add(projectPath + addStartingPathSeparator(sourceFolder) + '/'); } } List<String> testSourceFolders = attributes.get(projectBuilder + ".test.source.folder"); if (testSourceFolders != null) { for (String testSourceFolder : testSourceFolders) { allSourceFolders.add(projectPath + addStartingPathSeparator(testSourceFolder) + '/'); } } return allSourceFolders; }
private void reloadRepositoryData(Project project) { service .diff(project.getLocation(), null, NAME_STATUS, false, 0, REVISION, false) .then( diff -> { MutableAlteredFiles alteredFiles = new MutableAlteredFiles(project, diff); changes.put(project.getName(), alteredFiles); view.updateRepositoryChanges(project.getName(), alteredFiles.getFilesQuantity()); // update changed files list if this repository is selected if (project.getName().equals(view.getSelectedRepository())) { updateChangedFiles(alteredFiles); } }) .catchError( arg -> { notificationManager.notify(locale.diffFailed(), FAIL, NOT_EMERGE_MODE); }); }
.getFile(alteredFiles.getFileByIndex(currentFileIndex)) .then( file -> { final Path gitDirLocation = alteredFiles.getProject().getLocation(); final Path relPath = Path.valueOf(alteredFiles.getFileByIndex(currentFileIndex));
@Nullable private Project getProjectByPath(String path) { for (Project project : appContext.getProjects()) { if (path.equals(project.getPath())) { return project; } } return null; }
/** Import source projects */ private void importProjects() { final Project[] projects = appContext.getProjects(); Set<String> projectNames = new HashSet<>(); String createPolicy = factory.getPolicies() != null ? factory.getPolicies().getCreate() : null; for (Project project : projects) { if (project.getSource() == null || project.getSource().getLocation() == null) { continue; } if (project.exists()) { // to prevent warning when reusing same workspace if (!("perUser".equals(createPolicy) || "perAccount".equals(createPolicy))) { notificationManager.notify( "Import", locale.projectAlreadyImported(project.getName()), FAIL, FLOAT_MODE); } continue; } projectNames.add(project.getName()); } importProjects(projectNames); }
/** {@inheritDoc} */ @Override public void intercept(Resource resource) { if (!Boolean.valueOf(preferencesManager.getValue(PREF_SHOW_ARTIFACT_ID))) { return; } if (resource.isProject() && ((Project) resource).isTypeOf(MAVEN_ID)) { final String artifact = ((Project) resource).getAttribute(ARTIFACT_ID); if (!isNullOrEmpty(artifact) && !artifact.equals(resource.getName())) { resource.addMarker(new PresentableTextMarker(resource.getName() + " [" + artifact + "]")); } } } }
private Promise<CommandImpl> addCommand(Project project, CommandDto commandDto) { final String name = project.getName() + ": " + commandDto.getName(); final String absoluteProjectPath = appContext.getProjectsRoot().append(project.getPath()).toString(); final String commandLine = commandDto.getCommandLine().replaceAll(PROJECT_PATH_MACRO_REGEX, absoluteProjectPath); final CommandImpl command = new CommandImpl( name, commandLine, commandDto.getType(), commandDto.getAttributes(), new ApplicableContext(project.getPath())); return commandManager.createCommand(command); }