Search in sources :

Example 36 with RepositoryPlugin

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;
}
Also used : Project(aQute.bnd.build.Project) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 37 with RepositoryPlugin

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());
    }
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) Project(aQute.bnd.build.Project) HyperlinkStyler(org.bndtools.utils.jface.HyperlinkStyler)

Example 38 with RepositoryPlugin

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)));
    }
}
Also used : IndexProvider(aQute.bnd.service.IndexProvider) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 39 with RepositoryPlugin

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;
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 40 with RepositoryPlugin

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());
            }
        }
    }
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) Baseline(aQute.bnd.differ.Baseline) Info(aQute.bnd.differ.Baseline.Info)

Aggregations

RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)62 Version (aQute.bnd.version.Version)25 File (java.io.File)24 Workspace (aQute.bnd.build.Workspace)12 IOException (java.io.IOException)10 Project (aQute.bnd.build.Project)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 Jar (aQute.bnd.osgi.Jar)7 CoreException (org.eclipse.core.runtime.CoreException)7 RemoteRepositoryPlugin (aQute.bnd.service.RemoteRepositoryPlugin)5 VersionRange (aQute.bnd.version.VersionRange)5 Description (aQute.lib.getopt.Description)5 Parameters (aQute.bnd.header.Parameters)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PartInitException (org.eclipse.ui.PartInitException)4 Attrs (aQute.bnd.header.Attrs)3