Search in sources :

Example 6 with ModuleInfo

use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.

the class ModuleDeleterImpl method markForDisable.

public Collection<File> markForDisable(Collection<ModuleInfo> modules, ProgressHandle handle) {
    if (modules == null) {
        throw new IllegalArgumentException("ModuleInfo argument cannot be null.");
    }
    if (handle != null) {
        handle.switchToDeterminate(modules.size() + 1);
    }
    Collection<File> configs = new HashSet<File>();
    int i = 0;
    for (ModuleInfo moduleInfo : modules) {
        File config = locateConfigFile(moduleInfo);
        assert config != null : "Located config file for " + moduleInfo.getCodeName();
        assert config.exists() : config + " config file must exists for " + moduleInfo.getCodeName();
        err.log(Level.FINE, "Locate config file of " + moduleInfo.getCodeNameBase() + ": " + config);
        if (config != null) {
            configs.add(config);
        }
        if (handle != null) {
            handle.progress(++i);
        }
    }
    return configs;
}
Also used : ModuleInfo(org.openide.modules.ModuleInfo) File(java.io.File) HashSet(java.util.HashSet)

Example 7 with ModuleInfo

use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.

the class ModuleUpdateUnitImpl method getVisibleAncestor.

@Override
public UpdateUnit getVisibleAncestor() {
    if (visibleAncestor == null) {
        assert getInstalled() != null : this + " is installed";
        ModuleUpdateElementImpl installedImpl = (ModuleUpdateElementImpl) Trampoline.API.impl(getInstalled());
        TreeSet<Module> visible = new TreeSet<Module>(new Comparator<Module>() {

            @Override
            public int compare(Module o1, Module o2) {
                return o1.getCodeNameBase().compareTo(o2.getCodeNameBase());
            }
        });
        Set<Module> seen = new HashSet<Module>();
        for (ModuleInfo mi : installedImpl.getModuleInfos()) {
            visible.addAll(findVisibleAncestor(Utilities.toModule(mi), seen));
        }
        String cat = installedImpl.getCategory();
        String installationCluster = installedImpl.getInstallationCluster();
        if (BROAD_CATEGORY.contains(cat)) {
            cat = null;
        }
        UpdateUnit shot = null;
        UpdateUnit spare = null;
        UpdateUnit strike = null;
        for (Module visMod : visible) {
            visibleAncestor = Utilities.toUpdateUnit(visMod);
            UpdateElementImpl visibleImpl = Trampoline.API.impl(visibleAncestor.getInstalled());
            String visTargetCluster = null;
            String visCat = null;
            if (visibleImpl != null && visibleImpl instanceof ModuleUpdateElementImpl) {
                visTargetCluster = ((ModuleUpdateElementImpl) visibleImpl).getInstallationCluster();
                visCat = visibleImpl.getCategory();
            }
            if (installationCluster != null && installationCluster.equals(visTargetCluster)) {
                spare = visibleAncestor;
            } else if (visCat != null && visCat.equals(cat)) {
                strike = visibleAncestor;
                break;
            } else if (shot == null) {
                shot = visibleAncestor;
            }
        }
        visibleAncestor = strike != null ? strike : spare != null ? spare : shot;
        // if it's still unknown - try visible representative in given cluster
        if (visibleAncestor == null && installationCluster != null) {
            for (UpdateElement visEl : UpdateManagerImpl.getInstance().getInstalledKits(installationCluster)) {
                visibleAncestor = visEl.getUpdateUnit();
                if (installedImpl.getRawCategory().equals(visEl.getCategory())) {
                    visibleAncestor = visEl.getUpdateUnit();
                    break;
                }
            }
        }
    }
    return visibleAncestor;
}
Also used : UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit) UpdateElement(org.netbeans.api.autoupdate.UpdateElement) ModuleInfo(org.openide.modules.ModuleInfo) TreeSet(java.util.TreeSet) Module(org.netbeans.Module) HashSet(java.util.HashSet)

Example 8 with ModuleInfo

use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.

the class ArtificialFeaturesProvider method createFeatureItem.

public static FeatureItem createFeatureItem(String codeName, Set<ModuleUpdateElementImpl> modules, Set<FeatureUpdateElementImpl> features, UpdateElementImpl original, String additionalDescription) {
    Set<String> containsModulesOrFeatures = new HashSet<String>();
    String versionN = "";
    for (ModuleUpdateElementImpl impl : modules) {
        ModuleInfo info = impl.getModuleInfo();
        containsModulesOrFeatures.add(info.getCodeName() + " > " + info.getSpecificationVersion());
        SpecificationVersion spec = info.getSpecificationVersion();
        versionN = addVersion(versionN, spec);
    }
    for (FeatureUpdateElementImpl impl : features) {
        containsModulesOrFeatures.add(impl.getCodeName() + " > " + impl.getSpecificationVersion());
        SpecificationVersion spec = impl.getSpecificationVersion();
        versionN = addVersion(versionN, spec);
    }
    String description = original == null || original.getDescription() == null || original.getDescription().length() == 0 ? "" : original.getDescription();
    description = additionalDescription == null || additionalDescription.length() == 0 ? description : description + additionalDescription;
    String displayName = original == null || original.getDisplayName() == null || original.getDisplayName().length() == 0 ? codeName : original.getDisplayName();
    String version = original == null || original.getSpecificationVersion() == null ? versionN : original.getSpecificationVersion().toString();
    return new FeatureItem(codeName, version, containsModulesOrFeatures, displayName, description, null);
}
Also used : SpecificationVersion(org.openide.modules.SpecificationVersion) FeatureUpdateElementImpl(org.netbeans.modules.autoupdate.services.FeatureUpdateElementImpl) ModuleInfo(org.openide.modules.ModuleInfo) HashSet(java.util.HashSet) ModuleUpdateElementImpl(org.netbeans.modules.autoupdate.services.ModuleUpdateElementImpl)

Example 9 with ModuleInfo

use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.

the class InstalledModuleProvider method getModuleInfos.

@Override
protected synchronized Map<String, ModuleInfo> getModuleInfos(boolean force) {
    if (moduleInfos == null || force) {
        Collection<? extends ModuleInfo> infos = Collections.unmodifiableCollection(result.allInstances());
        moduleInfos = new HashMap<String, ModuleInfo>();
        for (ModuleInfo info : infos) {
            moduleInfos.put(info.getCodeNameBase(), info);
        }
    }
    assert moduleInfos != null;
    return new HashMap<String, ModuleInfo>(moduleInfos);
}
Also used : ModuleInfo(org.openide.modules.ModuleInfo) HashMap(java.util.HashMap)

Example 10 with ModuleInfo

use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.

the class DependencyAggregator method getRequested.

public static Collection<UpdateUnit> getRequested(Dependency dep) {
    switch(dep.getType()) {
        case Dependency.TYPE_MODULE:
            return Collections.singleton(UpdateManagerImpl.getInstance().getUpdateUnit(dep.getName()));
        case Dependency.TYPE_NEEDS:
        case Dependency.TYPE_REQUIRES:
        case Dependency.TYPE_RECOMMENDS:
            Collection<UpdateUnit> requestedUnits = new HashSet<UpdateUnit>();
            Collection<ModuleInfo> installedProviders = UpdateManagerImpl.getInstance().getInstalledProviders(dep.getName());
            if (installedProviders.isEmpty()) {
                Collection<ModuleInfo> availableProviders = UpdateManagerImpl.getInstance().getAvailableProviders(dep.getName());
                if (availableProviders.isEmpty()) {
                    return null;
                } else {
                    for (ModuleInfo mi : availableProviders) {
                        UpdateUnit availableUnit = UpdateManagerImpl.getInstance().getUpdateUnit(mi.getCodeNameBase());
                        if (availableUnit != null) {
                            requestedUnits.add(availableUnit);
                        }
                    }
                    return requestedUnits;
                }
            } else {
                for (ModuleInfo mi : installedProviders) {
                    UpdateUnit installedUnit = UpdateManagerImpl.getInstance().getUpdateUnit(mi.getCodeNameBase());
                    if (installedUnit != null) {
                        requestedUnits.add(installedUnit);
                    }
                }
                return requestedUnits;
            }
        case Dependency.TYPE_JAVA:
        case Dependency.TYPE_PACKAGE:
            break;
    }
    return null;
}
Also used : UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit) ModuleInfo(org.openide.modules.ModuleInfo) HashSet(java.util.HashSet)

Aggregations

ModuleInfo (org.openide.modules.ModuleInfo)33 HashSet (java.util.HashSet)8 SpecificationVersion (org.openide.modules.SpecificationVersion)7 HashMap (java.util.HashMap)6 UpdateUnit (org.netbeans.api.autoupdate.UpdateUnit)5 UpdateElement (org.netbeans.api.autoupdate.UpdateElement)4 IOException (java.io.IOException)3 Module (org.netbeans.Module)3 Dependency (org.openide.modules.Dependency)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 UpdateItem (org.netbeans.spi.autoupdate.UpdateItem)2 DataLoader (org.openide.loaders.DataLoader)2 Lookup (org.openide.util.Lookup)2 NbMarshalledObject (org.openide.util.io.NbMarshalledObject)2 InfoTextPanel (au.gov.asd.tac.constellation.utilities.gui.InfoTextPanel)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Enumeration (java.util.Enumeration)1