Search in sources :

Example 6 with InstallSupport

use of org.netbeans.api.autoupdate.InstallSupport in project netbeans-rcp-lite by outersky.

the class PluginManager method openInstallWizard.

/**
 * Open standard dialog for installing set of modules. Shows it to the user,
 * asks for confirmation, license acceptance, etc. The whole operation requires
 * AWT dispatch thread access (to show the dialog) and blocks
 * (until the user clicks through), so either call from AWT dispatch thread
 * directly, or be sure you hold no locks and block no progress of other
 * threads to avoid deadlocks.
 * <p>
 * Single module installation can be handled easily by
 * {@link #installSingle(java.lang.String, java.lang.String, java.lang.Object[])}.
 *<pre>
 *{@link OperationContainer}<InstallSupport> container = OperationContainer.createForInstall();
 *for ({@link UpdateUnit} u : {@link UpdateManager#getUpdateUnits(org.netbeans.api.autoupdate.UpdateManager.TYPE[]) UpdateManager.getDefault().getUpdateUnits(UpdateManager.TYPE.MODULE)}) {
 *    if (u.getCodeName().matches("org.my.favorite.module")) {
 *        if (u.getAvailableUpdates().isEmpty()) {
 *            continue;
 *        }
 *        container.add(u.getAvailableUpdates().get(0));
 *    }
 *}
 *PluginManager.openInstallWizard(container);
 *</pre>
 *
 * @param container the container with list of modules for install
 * @return true if all the requested modules were successfully installed,
 *    false otherwise.
 * @see #installSingle(java.lang.String, java.lang.String, java.lang.Object[])
 * @see #install(java.util.Set, java.lang.Object[])
 */
public static boolean openInstallWizard(OperationContainer<InstallSupport> container) {
    if (container == null) {
        // NOI18N
        throw new IllegalArgumentException("OperationContainer cannot be null.");
    }
    List<OperationContainer.OperationInfo<InstallSupport>> all = container.listAll();
    if (all.isEmpty()) {
        // NOI18N
        throw new IllegalArgumentException("OperationContainer cannot be empty.");
    }
    List<OperationContainer.OperationInfo<InstallSupport>> invalid = container.listInvalid();
    if (!invalid.isEmpty()) {
        // NOI18N
        throw new IllegalArgumentException("OperationContainer cannot contain invalid elements but " + invalid);
    }
    OperationInfo<InstallSupport> info = all.get(0);
    OperationType doOperation = info.getUpdateUnit().getInstalled() == null ? OperationType.INSTALL : OperationType.UPDATE;
    return new InstallUnitWizard().invokeWizard(new InstallUnitWizardModel(doOperation, container), false);
}
Also used : OperationInfo(org.netbeans.api.autoupdate.OperationContainer.OperationInfo) InstallSupport(org.netbeans.api.autoupdate.InstallSupport) InstallUnitWizard(org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard) OperationType(org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType) InstallUnitWizardModel(org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizardModel)

Aggregations

InstallSupport (org.netbeans.api.autoupdate.InstallSupport)6 ArrayList (java.util.ArrayList)2 OperationInfo (org.netbeans.api.autoupdate.OperationContainer.OperationInfo)2 OperationException (org.netbeans.api.autoupdate.OperationException)2 Restarter (org.netbeans.api.autoupdate.OperationSupport.Restarter)2 UpdateElement (org.netbeans.api.autoupdate.UpdateElement)2 UpdateUnit (org.netbeans.api.autoupdate.UpdateUnit)2 ProgressHandle (org.netbeans.api.progress.ProgressHandle)2 InstallUnitWizard (org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard)2 InstallUnitWizardModel (org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizardModel)2 OperationType (org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType)2 Dialog (java.awt.Dialog)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 JLabel (javax.swing.JLabel)1 Installer (org.netbeans.api.autoupdate.InstallSupport.Installer)1 Validator (org.netbeans.api.autoupdate.InstallSupport.Validator)1 OperationSupport (org.netbeans.api.autoupdate.OperationSupport)1 UpdateUnitProvider (org.netbeans.api.autoupdate.UpdateUnitProvider)1 Unit (org.netbeans.modules.autoupdate.ui.Unit)1