Package org.apache.felix.sigil.common.model.osgi

Examples of org.apache.felix.sigil.common.model.osgi.IRequiredBundle


        }

        // requires
        for (IRequiredBundle require : bundle.getRequires())
        {
            IRequiredBundle clone = (IRequiredBundle) require.clone();
            clone.setParent(null);
            info.addRequiredBundle(clone);
        }

        // fragment
        IRequiredBundle fragment = bundle.getFragmentHost();
        if (fragment != null)
        {
            info.setFragmentHost(fragment);
        }
View Full Code Here


     */
    private void setFragments(String id, IBundleModelElement info)
    {
        Properties defaultBundles = config.getProps(null, BldConfig.P_BUNDLE_VERSION);
        Map<String, Map<String, String>> fragments = new TreeMap<String, Map<String, String>>();
        IRequiredBundle fragment = info.getFragmentHost();
        if (fragment != null)
        {
            Map<String, String> map2 = new TreeMap<String, String>();
            String name = fragment.getSymbolicName();
            VersionRange versions = defaultVersion(fragment.getVersions(),
                defaultBundles.getProperty(name));
            if (versions != null)
                map2.put(BldAttr.VERSION_ATTRIBUTE, versions.toString());
            fragments.put(name, map2);
        }
View Full Code Here

        converter = new IFormValueConverter()
        {
            public String getLabel(Object value)
            {
                IRequiredBundle b = (IRequiredBundle) value;
                return b == null ? null : b.getSymbolicName() + " " + b.getVersions();
            }

            public Object getValue(String label)
            {
                return null;
            }
        };

        fragmentHostEntry = new SigilFormEntry(body, toolkit, "Fragment Host",
            "Browse...", converter);
        fragmentHostEntry.setFormEntryListener(new SigilFormEntryAdapter()
        {
            @Override
            public void textValueChanged(SigilFormEntry form)
            {
                fragmentHost = (IRequiredBundle) form.getValue();
                checkDirty();
            }

            @Override
            public void browseButtonSelected(SigilFormEntry form)
            {
                NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog(
                    getSection().getShell(), "Add Required Bundle", getProjectModel(),
                    null, getBundle().getBundleInfo().getRequiredBundles());

                if (dialog.open() == Window.OK)
                {
                    IRequiredBundle required = ModelElementFactory.getInstance().newModelElement(
                        IRequiredBundle.class);
                    required.setSymbolicName(dialog.getSelectedName());
                    required.setVersions(dialog.getSelectedVersions());
                    form.setValue(required);
                }
            }
        });
        fragmentHostEntry.setFreeText(false);
View Full Code Here

            return bundle.getBundleInfo().getSymbolicName();
        }

        if (element instanceof IRequiredBundle)
        {
            IRequiredBundle req = (IRequiredBundle) element;
            return req.getSymbolicName() + " " + req.getVersions();
        }

        if (element instanceof IPackageImport)
        {
            IPackageImport req = (IPackageImport) element;
            return req.getPackageName() + " " + req.getVersions();
        }

        if (element instanceof IPackageExport)
        {
            IPackageExport pe = (IPackageExport) element;
View Full Code Here

        addLibs(bundle, dest, spec);

        addContents(contents, spec);

        IRequiredBundle fh = bundle.getFragmentHost();
        if (fh != null)
        {
            StringBuilder sb = new StringBuilder();
            sb.append(fh.getSymbolicName());
            addVersions(fh.getVersions(), sb);
            spec.setProperty(Constants.FRAGMENT_HOST, sb.toString());
        }

        return spec;
    }
View Full Code Here

        throws ModelElementFactoryException
    {
        for (String imp : QuoteUtil.split(reqStr))
        {
            String[] parts = imp.split(";");
            IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
                IRequiredBundle.class);
            req.setSymbolicName(parts[0]);

            if (parts.length > 1)
            {
                if (parts[1].toLowerCase().startsWith("version="))
                {
                    req.setVersions(VersionRange.parseVersionRange(parts[1].substring("version=".length())));
                }
                else if (parts[1].toLowerCase().startsWith("specification-version="))
                {
                    req.setVersions(VersionRange.parseVersionRange(parts[1].substring("specification-version=".length())));
                }
            }
            info.addRequiredBundle(req);
        }
    }
View Full Code Here

     * @param str
     */
    private static void addHost(IBundleModelElement info, String str)
    {
        String[] parts = str.split(";");
        IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
            IRequiredBundle.class);
        req.setSymbolicName(parts[0].trim());

        if (parts.length > 1)
        {
            String part = parts[1].toLowerCase().trim();
            if (part.startsWith("bundle-version="))
            {
                req.setVersions(VersionRange.parseVersionRange(part.substring("bundle-version=".length())));
            }
        }
        info.setFragmentHost(req);
    }
View Full Code Here

            // We must use an OSGi version range to specify the exact version,
            // otherwise it will resolve to "specified version or above".
            range = "[" + revision + "," + revision + "]";
        }

        IRequiredBundle bundle = ModelElementFactory.getInstance().newModelElement(
            IRequiredBundle.class);
        bundle.setSymbolicName(id.getName());
        bundle.setVersions(VersionRange.parseVersionRange(range));

        Log.verbose("searching for " + bundle);

        try
        {
View Full Code Here

                            unused.add(pi);
                        }
                    }
                    else if (element instanceof IRequiredBundle)
                    {
                        IRequiredBundle rb = (IRequiredBundle) element;
                        IRepositoryManager manager = project.getRepositoryManager();
                        ResolutionConfig config = new ResolutionConfig(
                            ResolutionConfig.INCLUDE_OPTIONAL
                                | ResolutionConfig.IGNORE_ERRORS);
                        try
View Full Code Here

        for (IModelElement e : requirements)
        {
            if (e instanceof IRequiredBundle)
            {
                IRequiredBundle host = project.getBundle().getBundleInfo().getFragmentHost();
                if (host != null)
                {
                    if (host.equals(e))
                    {
                        return new IAccessRule[] { ALLOW_ALL_RULE };
                    }
                    else
                    {
View Full Code Here

TOP

Related Classes of org.apache.felix.sigil.common.model.osgi.IRequiredBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.