Search in sources :

Example 1 with InstallUnitWizard

use of org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard in project netbeans-rcp-lite by outersky.

the class AutoupdateCheckScheduler method notifyAvailable.

public static void notifyAvailable(final Collection<LazyUnit> units, final OperationType type) {
    if (units == null || units.isEmpty()) {
        if (updatesNotification != null) {
            updatesNotification.clear();
            updatesNotification = null;
        }
        return;
    }
    // Some modules found
    ActionListener onMouseClickAction = new ActionListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void actionPerformed(ActionEvent ae) {
            boolean wizardFinished = false;
            RequestProcessor.Task t = PluginManagerUI.getRunningTask();
            if (t != null && !t.isFinished()) {
                DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(NbBundle.getMessage(AutoupdateCheckScheduler.class, // NOI18N
                "AutoupdateCheckScheduler_InstallInProgress"), NotifyDescriptor.WARNING_MESSAGE));
                return;
            }
            try {
                wizardFinished = new InstallUnitWizard().invokeLazyWizard(units, type, false);
            } finally {
                if (wizardFinished) {
                    PluginManagerUI pluginManagerUI = PluginManagerAction.getPluginManagerUI();
                    if (pluginManagerUI != null) {
                        pluginManagerUI.updateUnitsChanged();
                    }
                    Installer.RP.post(doCheckAvailableUpdates);
                }
            }
        }
    };
    int updateCount = units.size();
    String title = updateCount == 1 ? // NOI18N
    NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_UpdateFound_ToolTip", updateCount) : // NOI18N
    NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_UpdatesFound_ToolTip", updateCount);
    synchronized (AutoupdateCheckScheduler.class) {
        if (updatesNotification != null) {
            updatesNotification.clear();
            updatesNotification = null;
        }
        updatesNotification = NotificationDisplayer.getDefault().notify(title, ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/newUpdates.png", false), NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_UpdateFound_Hint"), onMouseClickAction, NotificationDisplayer.Priority.HIGH);
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) PluginManagerUI(org.netbeans.modules.autoupdate.ui.PluginManagerUI) ActionListener(java.awt.event.ActionListener) InstallUnitWizard(org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard) ActionEvent(java.awt.event.ActionEvent) RequestProcessor(org.openide.util.RequestProcessor)

Example 2 with InstallUnitWizard

use of org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard 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 3 with InstallUnitWizard

use of org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard 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)

Example 4 with InstallUnitWizard

use of org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard in project netbeans-rcp-lite by outersky.

the class CheckForUpdatesProviderImpl method openCheckForUpdatesWizard.

@Override
public boolean openCheckForUpdatesWizard(boolean reload) {
    boolean wizardFinished = false;
    RequestProcessor.Task t = PluginManagerUI.getRunningTask();
    if (t != null && !t.isFinished()) {
        DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(NbBundle.getMessage(AutoupdateCheckScheduler.class, // NOI18N
        "AutoupdateCheckScheduler_InstallInProgress"), NotifyDescriptor.WARNING_MESSAGE));
        return false;
    }
    Collection<LazyInstallUnitWizardIterator.LazyUnit> units = LazyInstallUnitWizardIterator.LazyUnit.loadLazyUnits(OperationWizardModel.OperationType.UPDATE);
    try {
        wizardFinished = new InstallUnitWizard().invokeLazyWizard(units, OperationWizardModel.OperationType.UPDATE, reload);
    } finally {
        if (wizardFinished) {
            PluginManagerUI pluginManagerUI = PluginManagerAction.getPluginManagerUI();
            if (pluginManagerUI != null) {
                pluginManagerUI.updateUnitsChanged();
            }
        }
    }
    return wizardFinished;
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) PluginManagerUI(org.netbeans.modules.autoupdate.ui.PluginManagerUI) InstallUnitWizard(org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard) RequestProcessor(org.openide.util.RequestProcessor)

Aggregations

InstallUnitWizard (org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard)4 InstallSupport (org.netbeans.api.autoupdate.InstallSupport)2 OperationInfo (org.netbeans.api.autoupdate.OperationContainer.OperationInfo)2 PluginManagerUI (org.netbeans.modules.autoupdate.ui.PluginManagerUI)2 InstallUnitWizardModel (org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizardModel)2 OperationType (org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType)2 NotifyDescriptor (org.openide.NotifyDescriptor)2 RequestProcessor (org.openide.util.RequestProcessor)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1