use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.
the class UpdateManagerImpl method getAvailableProviders.
public Collection<ModuleInfo> getAvailableProviders(String token) {
Collection<ModuleInfo> res;
final Cache c = getCache();
if (token.startsWith("cnb.")) {
// NOI18N
UpdateUnit updateUnit = c.getUpdateUnit(token.substring(4));
if (updateUnit != null && !updateUnit.getAvailableUpdates().isEmpty()) {
return Trampoline.API.impl(updateUnit.getAvailableUpdates().get(0)).getModuleInfos();
}
}
Collection<ModuleInfo> providers = c.createMapToken2AvailableProviders().get(token);
if (providers == null || providers.isEmpty()) {
res = new HashSet<ModuleInfo>(0) {
Cache keepIt = c;
};
} else {
res = new HashSet<ModuleInfo>(providers) {
Cache keepIt = c;
};
}
return res;
}
use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.
the class UpdateManagerImpl method getInstalledProviders.
public Collection<ModuleInfo> getInstalledProviders(String token) {
Collection<ModuleInfo> res;
final Cache c = getCache();
if (token.startsWith("cnb.")) {
// NOI18N
UpdateUnit updateUnit = c.getUpdateUnit(token.substring(4));
if (updateUnit != null && updateUnit.getInstalled() != null) {
return Trampoline.API.impl(updateUnit.getInstalled()).getModuleInfos();
}
}
Collection<ModuleInfo> providers = c.createMapToken2InstalledProviders().get(token);
if (providers == null || providers.isEmpty()) {
res = new HashSet<ModuleInfo>(0) {
Cache keepIt = c;
};
} else {
res = new HashSet<ModuleInfo>(providers) {
Cache keepIt = c;
};
}
return res;
}
use of org.openide.modules.ModuleInfo 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;
}
use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.
the class UpdateUnitFactory method addElement.
private void addElement(Map<String, UpdateUnit> impls, UpdateElement element, UpdateProvider provider) {
// find if corresponding element exists
UpdateUnit unit = impls.get(element.getCodeName());
// XXX: it's should be moved in UI what should filter all elements w/ broken dependencies
// #101515: Plugin Manager must filter updates by platform dependency
boolean passed = false;
UpdateElementImpl elImpl = Trampoline.API.impl(element);
if (elImpl instanceof ModuleUpdateElementImpl && elImpl.getModuleInfos() != null && elImpl.getModuleInfos().size() == 1) {
for (Dependency d : elImpl.getModuleInfos().get(0).getDependencies()) {
if (Dependency.TYPE_REQUIRES == d.getType()) {
// log.log (Level.FINEST, "Dependency: NAME: " + d.getName () + ", TYPE: " + d.getType () + ": " + d.toString ());
if (d.getName().startsWith("org.openide.modules.os")) {
// NOI18N
for (ModuleInfo info : InstalledModuleProvider.getInstalledModules().values()) {
if (Arrays.asList(info.getProvides()).contains(d.getName())) {
log.log(Level.FINEST, element + " which requires OS " + d + " succeed.");
passed = true;
break;
}
}
if (!passed) {
log.log(Level.FINE, element + " which requires OS " + d + " fails.");
return;
}
}
}
}
}
UpdateUnitImpl unitImpl = null;
if (unit == null) {
switch(elImpl.getType()) {
case MODULE:
unitImpl = new ModuleUpdateUnitImpl(element.getCodeName());
break;
case KIT_MODULE:
unitImpl = new KitModuleUpdateUnitImpl(element.getCodeName());
break;
case STANDALONE_MODULE:
case FEATURE:
unitImpl = new FeatureUpdateUnitImpl(element.getCodeName(), elImpl.getType());
break;
case CUSTOM_HANDLED_COMPONENT:
unitImpl = new NativeComponentUpdateUnitImpl(element.getCodeName());
break;
case LOCALIZATION:
unitImpl = new LocalizationUpdateUnitImpl(element.getCodeName());
break;
default:
assert false : "Unsupported for type " + elImpl.getType();
}
unit = Trampoline.API.createUpdateUnit(unitImpl);
impls.put(unit.getCodeName(), unit);
} else {
unitImpl = Trampoline.API.impl(unit);
}
if (provider == InstalledUpdateProvider.getDefault()) {
if (unitImpl.getInstalled() == null) {
unitImpl.setInstalled(element);
}
} else if (provider instanceof BackupUpdateProvider) {
unitImpl.setBackup(element);
} else {
// suppose common UpdateProvider
unitImpl.addUpdate(element);
}
// set UpdateUnit into element
elImpl.setUpdateUnit(unit);
}
use of org.openide.modules.ModuleInfo in project netbeans-rcp-lite by outersky.
the class ModuleDeleterImpl method markForDelete.
public Collection<File> markForDelete(Collection<ModuleInfo> modules, ProgressHandle handle) throws IOException {
storageFilesForDelete = null;
if (modules == null) {
throw new IllegalArgumentException("ModuleInfo argument cannot be null.");
}
if (handle != null) {
handle.switchToDeterminate(modules.size() * 2 + 1);
}
Collection<File> configFiles = new HashSet<File>();
int i = 0;
for (ModuleInfo moduleInfo : modules) {
Collection<File> configs = locateAllConfigFiles(moduleInfo);
assert configs != null : "Located config files for " + moduleInfo.getCodeName();
assert !configs.isEmpty() : configs + " config files must exists for " + moduleInfo.getCodeName();
configFiles.addAll(configs);
err.log(Level.FINE, "Locate config files of " + moduleInfo.getCodeNameBase() + ": " + configs);
if (handle != null) {
handle.progress(++i);
}
}
getStorageFilesForDelete().addAll(configFiles);
for (ModuleInfo moduleInfo : modules) {
removeModuleFiles(moduleInfo, true);
if (handle != null) {
handle.progress(++i);
}
}
return getStorageFilesForDelete();
}
Aggregations