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);
}
Aggregations