use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class RepositoryTreeContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
Object[] result = null;
if (parentElement instanceof RepositoryPlugin) {
RepositoryPlugin repo = (RepositoryPlugin) parentElement;
result = getRepositoryBundles(repo);
} else if (parentElement instanceof RepositoryBundle) {
RepositoryBundle bundle = (RepositoryBundle) parentElement;
result = getRepositoryBundleVersions(bundle);
} else if (parentElement instanceof Project) {
Project project = (Project) parentElement;
result = getProjectBundles(project);
}
return result;
}
use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class RepositoryTreeLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
int index = cell.getColumnIndex();
if (element instanceof RepositoryPlugin) {
if (index == 0) {
RepositoryPlugin repo = (RepositoryPlugin) element;
cell.setText(repo.getName());
Image image;
if (RepoUtils.isWorkspaceRepo(repo))
image = projectImg;
else if (isRemoteRepo((RepositoryPlugin) element))
image = remoteRepoImg;
else
image = localRepoImg;
cell.setImage(image);
}
} else if (element instanceof Project) {
if (index == 0) {
@SuppressWarnings("resource") Project project = (Project) element;
StyledString label = new StyledString(project.getName());
if (showRepoId)
label.append(" [Workspace]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(projectImg);
}
} else if (element instanceof ProjectBundle) {
if (index == 0) {
StyledString label = new StyledString(((ProjectBundle) element).getBsn());
if (showRepoId)
label.append(" [Workspace]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
} else if (element instanceof RepositoryBundle) {
if (index == 0) {
RepositoryBundle bundle = (RepositoryBundle) element;
StyledString label = new StyledString(bundle.getText());
if (showRepoId)
label.append(" [" + bundle.getRepo().getName() + "]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
} else if (element instanceof RepositoryBundleVersion) {
if (index == 0) {
RepositoryBundleVersion bundleVersion = (RepositoryBundleVersion) element;
String versionText = bundleVersion.getText();
if (versionText.contains(" ⇩")) {
versionText = versionText.replaceAll(" ⇩", "");
cell.setImage(arrowImg);
}
StyledString styledString = new StyledString(versionText, StyledString.COUNTER_STYLER);
cell.setText(styledString.getString());
cell.setStyleRanges(styledString.getStyleRanges());
}
} else if (element instanceof RepositoryResourceElement) {
RepositoryResourceElement resourceElem = (RepositoryResourceElement) element;
StyledString label = new StyledString();
label.append(resourceElem.getIdentity()).append(" ");
label.append(resourceElem.getVersionString(), StyledString.COUNTER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(matchImg);
} else if (element instanceof ContinueSearchElement) {
StyledString label = new StyledString("Continue Search on JPM4J.org...", new HyperlinkStyler());
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
} else if (element instanceof LoadingContentElement) {
cell.setText("Loading content...");
cell.setImage(loadingImg);
} else if (element != null) {
// Catch-all
cell.setText(element.toString());
}
}
use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class RepositoryTreeContentProvider method addRepositoryPlugins.
private void addRepositoryPlugins(Collection<Object> result, Workspace workspace) {
workspace.getErrors().clear();
List<RepositoryPlugin> repoPlugins = workspace.getPlugins(RepositoryPlugin.class);
for (String error : workspace.getErrors()) {
logger.logError(error, null);
}
for (RepositoryPlugin repoPlugin : repoPlugins) {
if (CACHE_REPOSITORY.equals(repoPlugin.getName()))
continue;
if (repoPlugin instanceof IndexProvider) {
IndexProvider indexProvider = (IndexProvider) repoPlugin;
if (!supportsPhase(indexProvider))
continue;
}
if (showRepos)
result.add(repoPlugin);
else
result.addAll(Arrays.asList(getRepositoryBundles(repoPlugin)));
}
}
use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class ReleaseHelper method getReleaseRepo.
public static RepositoryPlugin getReleaseRepo(Project project) {
RepositoryPlugin repo = null;
String repoName = project.getProperty(Constants.RELEASEREPO);
if (repoName != null && Constants.NONE.equals(repoName))
return null;
List<RepositoryPlugin> repos = project.getPlugins(RepositoryPlugin.class);
for (RepositoryPlugin r : repos) {
if (r.canWrite()) {
if (repoName == null || r.getName().equals(repoName)) {
repo = r;
break;
}
}
}
return repo;
}
use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.
the class ReleaseHelper method initializeProjectDiffs.
public static void initializeProjectDiffs(List<ProjectDiff> projects) {
String[] repos = getReleaseRepositories();
for (ProjectDiff projectDiff : projects) {
RepositoryPlugin repoPlugin = ReleaseHelper.getReleaseRepo(projectDiff.getProject());
String repo;
if (repoPlugin != null) {
repo = repoPlugin.getName();
} else {
repo = null;
}
if (repo == null) {
if (repos.length > 0) {
repo = repos[0];
} else {
repo = "";
}
}
projectDiff.setReleaseRepository(repo);
projectDiff.setDefaultReleaseRepository(repo);
for (Baseline baseline : projectDiff.getBaselines()) {
if (ReleaseUtils.needsRelease(baseline)) {
projectDiff.setRelease(true);
projectDiff.setReleaseRequired(true);
if (!baseline.getNewerVersion().equals(baseline.getSuggestedVersion())) {
projectDiff.setVersionUpdateRequired(true);
continue;
}
for (Info info : baseline.getPackageInfos()) {
if (!info.newerVersion.equals(info.suggestedVersion)) {
projectDiff.setVersionUpdateRequired(true);
break;
}
}
} else {
baseline.setSuggestedVersion(baseline.getOlderVersion());
}
}
}
}
Aggregations