use of org.netbeans.api.autoupdate.UpdateUnit in project netbeans-rcp-lite by outersky.
the class UpdateUnitFactory method mergeInstalledUpdateUnit.
private UpdateUnit mergeInstalledUpdateUnit(UpdateUnit uu) {
UpdateUnit fromCache = UpdateManagerImpl.getInstance().getUpdateUnit(uu.getCodeName());
if (fromCache != null && fromCache.getInstalled() != null) {
UpdateUnitImpl impl = Trampoline.API.impl(uu);
impl.setInstalled(fromCache.getInstalled());
}
return uu;
}
use of org.netbeans.api.autoupdate.UpdateUnit in project netbeans-rcp-lite by outersky.
the class LocalDownloadSupport method addUpdateUnits.
final void addUpdateUnits(File... newFiles) {
Collection<UpdateUnit> alreadyInstalled = new HashSet<UpdateUnit>();
for (File nbm : newFiles) {
UpdateUnit u = null;
if (NBM_FILE_FILTER.accept(nbm) || OSGI_BUNDLE_FILTER.accept(nbm)) {
u = createUpdateUnitFromNBM(nbm, false);
}
if (u != null) {
if (u.getAvailableUpdates() == null || u.getAvailableUpdates().isEmpty()) {
// already installed
alreadyInstalled.add(u);
} else if (getCodeName2Unit().containsKey(u.getCodeName())) {
UpdateElement uE1 = u.getAvailableUpdates().get(0);
UpdateElement uE2 = getCodeName2Unit().get(u.getCodeName()).getAvailableUpdates().get(0);
UpdateUnit winnerUnit;
File winnerFile;
UpdateUnit looserUnit;
File looserFile;
// both are valid, an user have to choose
// NOI18N
String name1 = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationPlugin", uE1.getDisplayName(), uE1.getSpecificationVersion());
// NOI18N
String name2 = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationPlugin", uE2.getDisplayName(), uE2.getSpecificationVersion());
Object res = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(// NOI18N
NbBundle.getMessage(LocalDownloadSupport.class, "NotificationAlreadyPresent", name2, name1), // NOI18N
NbBundle.getMessage(LocalDownloadSupport.class, "NotificationAlreadyPresentTitle")));
if (NotifyDescriptor.YES_OPTION.equals(res)) {
winnerUnit = uE1.getUpdateUnit();
winnerFile = nbm;
looserUnit = uE2.getUpdateUnit();
looserFile = getNbm(winnerUnit.getCodeName());
} else if (NotifyDescriptor.NO_OPTION.equals(res)) {
winnerUnit = uE2.getUpdateUnit();
winnerFile = getNbm(winnerUnit.getCodeName());
looserUnit = uE1.getUpdateUnit();
looserFile = nbm;
} else {
// CANCEL_OPTION
break;
}
getNbm2CodeName().remove(looserFile);
getCodeName2Unit().remove(looserUnit.getCodeName());
getNbm2CodeName().put(winnerFile, winnerUnit.getCodeName());
getCodeName2Unit().put(winnerUnit.getCodeName(), winnerUnit);
fileList.removeFile(looserFile);
Containers.forUpdateNbms().removeAll();
Containers.forAvailableNbms().removeAll();
} else {
getNbm2CodeName().put(nbm, u.getCodeName());
getCodeName2Unit().put(u.getCodeName(), u);
}
} else {
fileList.removeFile(nbm);
}
}
if (!alreadyInstalled.isEmpty()) {
String msg;
if (alreadyInstalled.size() == 1) {
// NOI18N
msg = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationOneAlreadyInstalled", getDisplayNames(alreadyInstalled));
} else {
// NOI18N
msg = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationMoreAlreadyInstalled", getDisplayNames(alreadyInstalled));
}
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE));
}
}
use of org.netbeans.api.autoupdate.UpdateUnit in project netbeans-rcp-lite by outersky.
the class LocalDownloadSupport method removeInstalledUnit.
public void removeInstalledUnit() {
synchronized (LocalDownloadSupport.class) {
Iterator<UpdateUnit> it = getCodeName2Unit().values().iterator();
while (it.hasNext()) {
UpdateUnit u = it.next();
if (u.getInstalled() != null && u.getAvailableUpdates().isEmpty()) {
it.remove();
getNbm2CodeName().remove(getNbm(u.getCodeName()));
}
}
}
}
use of org.netbeans.api.autoupdate.UpdateUnit in project netbeans-rcp-lite by outersky.
the class InstalledTableModel method getToolTipText.
@Override
public String getToolTipText(int row, int col) {
if (col == 3) {
Unit.Installed u = (Unit.Installed) getUnitAtRow(row);
assert u != null : "Unit must found at row " + row;
String key = null;
UpdateElement ue = u.getRelevantElement();
UpdateUnit uu = u.getRelevantElement().getUpdateUnit();
if (uu.isPending()) {
// installed?
if (ue.getUpdateUnit().getInstalled() == null || !ue.getUpdateUnit().getInstalled().equals(ue)) {
key = "InstallTab_PendingForInstall_Tooltip";
} else {
key = "InstallTab_PendingForDeactivate_Tooltip";
}
} else if (ue.isEnabled()) {
key = "InstallTab_Active_Tooltip";
} else {
key = "InstallTab_InActive_Tooltip";
}
return (key != null) ? getBundle(key) : null;
} else if (col == 0) {
Unit.Installed u = (Unit.Installed) getUnitAtRow(row);
assert u != null : "Unit must found at row " + row;
String key = null;
UpdateElement ue = u.getRelevantElement();
if (!u.canBeMarked()) {
// NOI18N
key = "InstallTab_ReadOnly_Tooltip";
}
return (key != null) ? getBundle(key, ue.getDisplayName()) : super.getToolTipText(row, col);
}
return super.getToolTipText(row, col);
}
use of org.netbeans.api.autoupdate.UpdateUnit in project netbeans-rcp-lite by outersky.
the class UnitDetails method getDependencies.
private String getDependencies(Unit.Update uu, boolean collectDependencies) {
if (!collectDependencies) {
return "<i>" + getBundle("UnitDetails_Plugin_Collecting_Dependencies") + "</i><br>";
}
Unit u = uu;
if (u instanceof Unit.CompoundUpdate) {
Unit.CompoundUpdate cu = (Unit.CompoundUpdate) u;
StringBuilder desc = new StringBuilder();
for (UpdateUnit internalUnits : cu.getUpdateUnits()) {
appendInternalUpdates(desc, internalUnits.getAvailableUpdates().get(0));
}
return desc.toString();
} else {
return "";
}
}
Aggregations