/** * collect all branches * @param fs * @return */ private Map<String, Branch> getBranches(final FileSystem fs) { final Map<String, Branch> branches = new HashMap<>(); for (final org.uberfire.java.nio.file.Path path : fs.getRootDirectories()) { final String branchName = getBranchName(path); branches.put(branchName, new Branch(branchName, convert(path))); } return branches; }
private boolean containsBranch(final Collection<Branch> branches, final String branchName) { for (final Branch branch : branches) { if (branchName.equals(branch.getName())) { return true; } } return false; } }
private Branch getBranch(final Repository repository, final Path convertedPath) { for (final Branch branch : repository.getBranches()) { if (branch.getPath().equals(convertedPath)) { return branch; } } return null; }
@Override public void init(final ProjectBranchBreadcrumb presenter) { final Branch currentBranch = presenter.getCurrentBranch(); final List<Item<Branch>> items = presenter.getBranches().stream() .map(b -> new Item<>(b, b.getName(), b.equals(currentBranch) ? CHECKED : UNCHECKED, presenter::onBranchChanged, Item.Type.OPTION)) .collect(toList()); items.add(new Item<>(null, "", UNCHECKED, null, Item.Type.SEPARATOR)); items.add(new Item<>(null, ts.format(LibraryConstants.AddBranch), UNCHECKED, b -> { final AddBranchPopUpPresenter addBranchPopUpPresenter = addBranchPopUpPresenters.get(); addBranchPopUpPresenter.show(); }, Item.Type.ACTION)); branchesDropdown.setup(items, currentBranch.getName()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } WorkspaceProject workspaceProject = (WorkspaceProject) o; if (requiresRefresh != workspaceProject.requiresRefresh) { return false; } if (!repository.equals(workspaceProject.repository)) { return false; } if (!branch.equals(workspaceProject.branch)) { return false; } if (mainModule != null ? !mainModule.equals(workspaceProject.mainModule) : workspaceProject.mainModule != null) { return false; } return organizationalUnit.equals(workspaceProject.organizationalUnit); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } WorkspaceProject workspaceProject = (WorkspaceProject) o; if (requiresRefresh != workspaceProject.requiresRefresh) { return false; } if (!repository.equals(workspaceProject.repository)) { return false; } if (!branch.equals(workspaceProject.branch)) { return false; } if (mainModule != null ? !mainModule.equals(workspaceProject.mainModule) : workspaceProject.mainModule != null) { return false; } return organizationalUnit.equals(workspaceProject.organizationalUnit); }
private Branch makeBranch(final String branchName, final String repoName) { final Path path = mock(Path.class); doReturn("default://" + branchName + "@" + repoName + "/").when(path).toURI(); return new Branch(branchName, path); } }
@Override public Optional<Branch> getBranch(Path branchRoot) { for (final Branch branch : getBranches()) { if (branch.getPath().equals(branchRoot)) { return Optional.of(branch); } } return Optional.empty(); }
public void addBranch(final Branch branch) { branches.put(branch.getName(), branch); } }
public void goToProject(final WorkspaceProject project, final Branch branch) { libraryInternalPreferences.load(loadedLibraryInternalPreferences -> { final Optional<Branch> lastBranchOpened = loadedLibraryInternalPreferences.getLastBranchOpened(project); final Command goToProjectCommand = () -> projectService.call((RemoteCallback<WorkspaceProject>) this::goToProject).resolveProject(project.getSpace(), branch); if (!lastBranchOpened.isPresent() || !lastBranchOpened.get().equals(branch)) { loadedLibraryInternalPreferences.setLastBranchOpened(project, branch); loadedLibraryInternalPreferences.save(goToProjectCommand, error -> { }); } else { goToProjectCommand.execute(); } }, error -> { }); }
private Branch makeBranch(final String branchName, final String repoName) { final Path path = mock(Path.class); doReturn("default://" + branchName + "@" + repoName + "/").when(path).toURI(); return new Branch(branchName, path); } }
/** * Short cut for the WorkspaceProject root. * @return The root path of the active branch. */ public Path getRootPath() { return this.getBranch().getPath(); }
private Collection<String> toBranchNames(final Collection<Branch> branches) { final ArrayList<String> result = new ArrayList<>(); for (final Branch branch : branches) { result.add(branch.getName()); } return result; } }
private Branch makeBranch(final String branchName, final String repoName) { final Path path = mock(Path.class); doReturn("default://" + branchName + "@" + repoName + "/").when(path).toURI(); return new Branch(branchName, path); } }
@Override public WorkspaceProject resolveProject(final Space space, final Branch branch) { return resolveProject(space, branch.getPath()); }
private boolean hasBranchBeenRemoved(final Repository repository, final String branchName) { return !repository .getBranches() .stream() .anyMatch(branch -> branch.getName().equals(branchName)); }
@Override public WorkspaceProject resolveProject(final Space space, final Branch branch) { return resolveProject(space, branch.getPath()); }
public void show(final Branch branch) { this.branch = branch; view.show(branch.getName()); }