Search in sources :

Example 1 with PluginManagerUI

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

the class AutoupdateCheckScheduler method getRefresher.

private static Runnable getRefresher(final UpdateUnitProvider p, final Collection<String> problems, final ProgressHandle progress) {
    return new Runnable() {

        @Override
        public void run() {
            try {
                err.log(Level.FINE, "Start refresh " + p.getName() + "[" + p.getDisplayName() + "]");
                p.refresh(progress, true);
                PluginManagerUI pluginManagerUI = PluginManagerAction.getPluginManagerUI();
                if (pluginManagerUI != null) {
                    if (pluginManagerUI.initTask.isFinished()) {
                        pluginManagerUI.updateUnitsChanged();
                    }
                }
                Utilities.showProviderNotification(p);
            } catch (IOException ioe) {
                if (ioe instanceof UnknownHostException || ioe.getCause() instanceof UnknownHostException) {
                // Most likely just offline. Do not print a stack trace. DownloadListener.notifyException already issuing warning.
                } else {
                    err.log(Level.INFO, null, ioe);
                }
                if (problems != null) {
                    problems.add(ioe.getLocalizedMessage());
                }
            } finally {
                err.log(Level.FINEST, "Refresh of " + p.getName() + "[" + p.getDisplayName() + "]" + " is finish.");
            }
        }
    };
}
Also used : PluginManagerUI(org.netbeans.modules.autoupdate.ui.PluginManagerUI) UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException)

Example 2 with PluginManagerUI

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

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

the class PluginManagerAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent ev) {
    if (dlg == null) {
        JButton close = new JButton();
        close.setDefaultCapable(false);
        Mnemonics.setLocalizedText(close, NbBundle.getMessage(PluginManagerAction.class, "PluginManager_CloseButton_Name"));
        String initialTab = null;
        if (ev.getID() == 100) {
            initialTab = ev.getActionCommand();
        }
        pluginManagerUI = new PluginManagerUI(close, initialTab);
        DialogDescriptor dd = new DialogDescriptor(pluginManagerUI, NbBundle.getMessage(PluginManagerAction.class, "PluginManager_Panel_Name"), // modal
        false, new JButton[] { close }, close, DialogDescriptor.DEFAULT_ALIGN, null, null);
        dd.setOptions(new Object[0]);
        dlg = DialogDisplayer.getDefault().createDialog(dd);
        dlg.setVisible(true);
        dlg.addWindowListener(new WindowListener() {

            public void windowOpened(WindowEvent e) {
            }

            public void windowClosing(WindowEvent e) {
                dlg = null;
                pluginManagerUI = null;
            }

            public void windowClosed(WindowEvent e) {
                dlg = null;
                pluginManagerUI = null;
            }

            public void windowIconified(WindowEvent e) {
            }

            public void windowDeiconified(WindowEvent e) {
            }

            public void windowActivated(WindowEvent e) {
            }

            public void windowDeactivated(WindowEvent e) {
            }
        });
    } else {
        dlg.requestFocus();
    }
}
Also used : PluginManagerUI(org.netbeans.modules.autoupdate.ui.PluginManagerUI) WindowListener(java.awt.event.WindowListener) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) DialogDescriptor(org.openide.DialogDescriptor)

Example 4 with PluginManagerUI

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

PluginManagerUI (org.netbeans.modules.autoupdate.ui.PluginManagerUI)4 InstallUnitWizard (org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard)2 NotifyDescriptor (org.openide.NotifyDescriptor)2 RequestProcessor (org.openide.util.RequestProcessor)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 WindowEvent (java.awt.event.WindowEvent)1 WindowListener (java.awt.event.WindowListener)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 JButton (javax.swing.JButton)1 DialogDescriptor (org.openide.DialogDescriptor)1