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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations