Search in sources :

Example 1 with UpdateItemImpl

use of org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl in project netbeans-rcp-lite by outersky.

the class Utilities method maybeAddImplicitHostDependency.

private static boolean maybeAddImplicitHostDependency(UpdateElement el, Set<Dependency> deps) {
    // check fragment, add implicit dependencies
    UpdateElementImpl elImpl = Trampoline.API.impl(el);
    UpdateItemImpl uiImpl = elImpl.getInstallInfo().getUpdateItemImpl();
    if (!uiImpl.isFragment()) {
        return false;
    }
    String fhost = uiImpl.getFragmentHost();
    Collection<Dependency> hostDep = Dependency.create(Dependency.TYPE_MODULE, fhost);
    err.fine(hostDep.toString());
    return deps.addAll(hostDep);
}
Also used : UpdateItemImpl(org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl)

Example 2 with UpdateItemImpl

use of org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl in project netbeans-rcp-lite by outersky.

the class UpdateUnitFactory method appendUpdateItems.

Map<String, UpdateUnit> appendUpdateItems(Map<String, UpdateUnit> originalUnits, UpdateProvider provider) {
    assert originalUnits != null : "Map of original UnitImpl cannot be null";
    boolean trusted = UpdateUnitProviderImpl.loadTrusted(provider);
    Map<String, UpdateItem> items;
    try {
        items = provider.getUpdateItems();
    } catch (IOException ioe) {
        log.log(Level.INFO, "Cannot read UpdateItem from UpdateProvider " + provider, ioe);
        return originalUnits;
    }
    assert items != null : "UpdateProvider[" + provider.getName() + "] should return non-null items.";
    // append updates
    for (String simpleItemId : items.keySet()) {
        UpdateElement updateEl = null;
        try {
            // create UpdateItemImpl
            UpdateItemImpl itemImpl = Trampoline.SPI.impl(items.get(simpleItemId));
            boolean isKitModule = false;
            if (itemImpl instanceof ModuleItem) {
                ModuleInfo mi = ((ModuleItem) itemImpl).getModuleInfo();
                assert mi != null : "ModuleInfo must be found for " + itemImpl;
                isKitModule = Utilities.isKitModule(mi);
            }
            if (itemImpl instanceof InstalledModuleItem) {
                if (isKitModule) {
                    KitModuleUpdateElementImpl impl = new KitModuleUpdateElementImpl((InstalledModuleItem) itemImpl, null);
                    updateEl = Trampoline.API.createUpdateElement(impl);
                } else {
                    ModuleUpdateElementImpl impl = new ModuleUpdateElementImpl((InstalledModuleItem) itemImpl, null);
                    updateEl = Trampoline.API.createUpdateElement(impl);
                }
            } else if (itemImpl instanceof ModuleItem) {
                if (isKitModule) {
                    KitModuleUpdateElementImpl impl = new KitModuleUpdateElementImpl((ModuleItem) itemImpl, provider.getDisplayName());
                    updateEl = Trampoline.API.createUpdateElement(impl);
                } else {
                    ModuleUpdateElementImpl impl = new ModuleUpdateElementImpl((ModuleItem) itemImpl, provider.getDisplayName());
                    updateEl = Trampoline.API.createUpdateElement(impl);
                }
            } else if (itemImpl instanceof LocalizationItem) {
                updateEl = Trampoline.API.createUpdateElement(new LocalizationUpdateElementImpl((LocalizationItem) itemImpl, provider.getDisplayName()));
            } else if (itemImpl instanceof NativeComponentItem) {
                updateEl = Trampoline.API.createUpdateElement(new NativeComponentUpdateElementImpl((NativeComponentItem) itemImpl, provider.getDisplayName()));
            } else if (itemImpl instanceof FeatureItem) {
                FeatureUpdateElementImpl impl = new FeatureUpdateElementImpl.Agent((FeatureItem) itemImpl, provider.getDisplayName(), UpdateManager.TYPE.FEATURE);
                updateEl = Trampoline.API.createUpdateElement(impl);
            } else {
                assert false : "Unknown type of UpdateElement " + updateEl;
            }
        } catch (IllegalArgumentException iae) {
            log.log(Level.INFO, iae.getLocalizedMessage(), iae);
        }
        // add element to map
        if (updateEl != null) {
            Trampoline.API.impl(updateEl).setCatalogTrusted(trusted);
            addElement(originalUnits, updateEl, provider);
        }
    }
    return originalUnits;
}
Also used : UpdateElement(org.netbeans.api.autoupdate.UpdateElement) FeatureItem(org.netbeans.modules.autoupdate.updateprovider.FeatureItem) NativeComponentItem(org.netbeans.modules.autoupdate.updateprovider.NativeComponentItem) IOException(java.io.IOException) InstalledModuleItem(org.netbeans.modules.autoupdate.updateprovider.InstalledModuleItem) ModuleItem(org.netbeans.modules.autoupdate.updateprovider.ModuleItem) UpdateItemImpl(org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl) UpdateItem(org.netbeans.spi.autoupdate.UpdateItem) ModuleInfo(org.openide.modules.ModuleInfo) LocalizationItem(org.netbeans.modules.autoupdate.updateprovider.LocalizationItem) InstalledModuleItem(org.netbeans.modules.autoupdate.updateprovider.InstalledModuleItem)

Example 3 with UpdateItemImpl

use of org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl in project netbeans-rcp-lite by outersky.

the class InstallSupportImpl method updateFragmentStatus.

private void updateFragmentStatus(UpdateElementImpl el, File nbmFile) throws IOException {
    UpdateItemImpl impl = el.getInstallInfo().getUpdateItemImpl();
    if (!(impl instanceof ModuleItem)) {
        return;
    }
    ModuleItem mod = (ModuleItem) impl;
    if (mod.isFragment()) {
        String fhost = mod.getFragmentHost();
        Module m = Utilities.toModule(fhost);
        if (m != null && m.isEnabled()) {
            impl.setNeedsRestart(Boolean.TRUE);
        }
    }
    Map<String, UpdateItem> items;
    try {
        items = AutoupdateInfoParser.getUpdateItems(nbmFile);
    } catch (SAXException ex) {
        throw new IOException(ex);
    }
    for (UpdateItem realItem : items.values()) {
        UpdateItemImpl realImpl = Trampoline.SPI.impl(realItem);
        if (realImpl instanceof ModuleItem) {
            ModuleItem realMod = (ModuleItem) realImpl;
            if (!realMod.getCodeName().equals(el.getCodeName())) {
                continue;
            }
            String fhost = realMod.getFragmentHost();
            if (fhost != null && !impl.isFragment()) {
                mod.setFragmentHost(fhost);
                Module m = Utilities.toModule(fhost);
                if (m != null && m.isEnabled()) {
                    impl.setNeedsRestart(Boolean.TRUE);
                }
            }
        }
    }
}
Also used : ModuleItem(org.netbeans.modules.autoupdate.updateprovider.ModuleItem) UpdateItemImpl(org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl) UpdateItem(org.netbeans.spi.autoupdate.UpdateItem) Module(org.netbeans.Module) SAXException(org.xml.sax.SAXException)

Aggregations

UpdateItemImpl (org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl)3 ModuleItem (org.netbeans.modules.autoupdate.updateprovider.ModuleItem)2 UpdateItem (org.netbeans.spi.autoupdate.UpdateItem)2 IOException (java.io.IOException)1 Module (org.netbeans.Module)1 UpdateElement (org.netbeans.api.autoupdate.UpdateElement)1 FeatureItem (org.netbeans.modules.autoupdate.updateprovider.FeatureItem)1 InstalledModuleItem (org.netbeans.modules.autoupdate.updateprovider.InstalledModuleItem)1 LocalizationItem (org.netbeans.modules.autoupdate.updateprovider.LocalizationItem)1 NativeComponentItem (org.netbeans.modules.autoupdate.updateprovider.NativeComponentItem)1 ModuleInfo (org.openide.modules.ModuleInfo)1 SAXException (org.xml.sax.SAXException)1