Search in sources :

Example 1 with RepoBundleSelectionWizard

use of bndtools.wizards.repo.RepoBundleSelectionWizard in project bndtools by bndtools.

the class RepositoryBundleSelectionPart method doAdd.

private void doAdd() {
    try {
        RepoBundleSelectionWizard wizard = createBundleSelectionWizard(getBundles());
        if (wizard != null) {
            WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
            if (dialog.open() == Window.OK) {
                setBundles(wizard.getSelectedBundles());
                markDirty();
            }
        }
    } catch (Exception e) {
        ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error opening bundle resolver wizard.", e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) RepoBundleSelectionWizard(bndtools.wizards.repo.RepoBundleSelectionWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) URISyntaxException(java.net.URISyntaxException)

Example 2 with RepoBundleSelectionWizard

use of bndtools.wizards.repo.RepoBundleSelectionWizard in project bndtools by bndtools.

the class RepositoryBundleSelectionPart method createBundleSelectionWizard.

protected final RepoBundleSelectionWizard createBundleSelectionWizard(List<VersionedClause> bundles) throws Exception {
    RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(bundles, phase);
    setSelectionWizardTitleAndMessage(wizard);
    return wizard;
}
Also used : RepoBundleSelectionWizard(bndtools.wizards.repo.RepoBundleSelectionWizard)

Example 3 with RepoBundleSelectionWizard

use of bndtools.wizards.repo.RepoBundleSelectionWizard in project bndtools by bndtools.

the class RunRequirementsPart method doAddBundle.

private void doAddBundle() {
    try {
        RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
        wizard.setSelectionPageTitle("Add Bundle Requirement");
        WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
        if (Window.OK == dialog.open()) {
            List<VersionedClause> result = wizard.getSelectedBundles();
            Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
            for (VersionedClause bundle : result) {
                Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
                String versionRange = bundle.getVersionRange();
                if (versionRange != null && !"latest".equals(versionRange)) {
                    filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
                }
                Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
                adding.add(req);
            }
            updateViewerWithNewRequirements(adding);
        }
    } catch (Exception e) {
        ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles.", e));
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) RepoBundleSelectionWizard(bndtools.wizards.repo.RepoBundleSelectionWizard) LiteralFilter(aQute.libg.filters.LiteralFilter) Requirement(org.osgi.resource.Requirement) AndFilter(aQute.libg.filters.AndFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with RepoBundleSelectionWizard

use of bndtools.wizards.repo.RepoBundleSelectionWizard in project bndtools by bndtools.

the class RunBlacklistPart method doAddBundle.

private void doAddBundle() {
    try {
        RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
        wizard.setSelectionPageTitle("Add Bundle Blacklist");
        WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
        if (Window.OK == dialog.open()) {
            List<VersionedClause> result = wizard.getSelectedBundles();
            Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
            for (VersionedClause bundle : result) {
                Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
                String versionRange = bundle.getVersionRange();
                if (versionRange != null && !"latest".equals(versionRange)) {
                    filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
                }
                Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
                adding.add(req);
            }
            updateViewerWithNewBlacklist(adding);
        }
    } catch (Exception e) {
        ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles for blacklist.", e));
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) RepoBundleSelectionWizard(bndtools.wizards.repo.RepoBundleSelectionWizard) LiteralFilter(aQute.libg.filters.LiteralFilter) Requirement(org.osgi.resource.Requirement) AndFilter(aQute.libg.filters.AndFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) AndFilter(aQute.libg.filters.AndFilter) Filter(aQute.libg.filters.Filter) LiteralFilter(aQute.libg.filters.LiteralFilter) SimpleFilter(aQute.libg.filters.SimpleFilter) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

RepoBundleSelectionWizard (bndtools.wizards.repo.RepoBundleSelectionWizard)4 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 VersionedClause (aQute.bnd.build.model.clauses.VersionedClause)2 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)2 AndFilter (aQute.libg.filters.AndFilter)2 Filter (aQute.libg.filters.Filter)2 LiteralFilter (aQute.libg.filters.LiteralFilter)2 SimpleFilter (aQute.libg.filters.SimpleFilter)2 LinkedHashSet (java.util.LinkedHashSet)2 Requirement (org.osgi.resource.Requirement)2 URISyntaxException (java.net.URISyntaxException)1