Search in sources :

Example 21 with UpdateUnit

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;
}
Also used : UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit)

Example 22 with UpdateUnit

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));
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit) UpdateElement(org.netbeans.api.autoupdate.UpdateElement) JarFile(java.util.jar.JarFile) File(java.io.File) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 23 with UpdateUnit

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()));
            }
        }
    }
}
Also used : UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit)

Example 24 with UpdateUnit

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);
}
Also used : UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit) UpdateElement(org.netbeans.api.autoupdate.UpdateElement) UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit)

Example 25 with UpdateUnit

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 "";
    }
}
Also used : UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit) UpdateUnit(org.netbeans.api.autoupdate.UpdateUnit)

Aggregations

UpdateUnit (org.netbeans.api.autoupdate.UpdateUnit)26 UpdateElement (org.netbeans.api.autoupdate.UpdateElement)13 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 ModuleInfo (org.openide.modules.ModuleInfo)5 Module (org.netbeans.Module)4 DummyModuleInfo (org.netbeans.modules.autoupdate.updateprovider.DummyModuleInfo)4 IOException (java.io.IOException)3 TreeSet (java.util.TreeSet)3 UpdateUnitProvider (org.netbeans.api.autoupdate.UpdateUnitProvider)3 File (java.io.File)2 JarFile (java.util.jar.JarFile)2 InstallSupport (org.netbeans.api.autoupdate.InstallSupport)2 OperationException (org.netbeans.api.autoupdate.OperationException)2 OperationSupport (org.netbeans.api.autoupdate.OperationSupport)2 ProgressHandle (org.netbeans.api.progress.ProgressHandle)2 Dialog (java.awt.Dialog)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 TreeMap (java.util.TreeMap)1