Search in sources :

Example 1 with InstallUnitWizardModel

use of org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizardModel 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.
 *
 * @param container the container with list of modules for install
 * @param runInBackground if <code>true</code> then installation run in the background after license acceptance
 */
public static void openInstallWizard(OperationContainer<InstallSupport> container, boolean runInBackground) {
    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;
    new InstallUnitWizard().invokeWizard(new InstallUnitWizardModel(doOperation, container), true, runInBackground);
}
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)

Example 2 with InstallUnitWizardModel

use of org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizardModel 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)2 OperationInfo (org.netbeans.api.autoupdate.OperationContainer.OperationInfo)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