Search in sources :

Example 1 with DonateButton

use of com.igormaznitsa.sciareto.ui.misc.DonateButton in project netbeans-mmd-plugin by raydac.

the class MessagesService method doAction.

protected void doAction() {
    final Preferences prefs = PreferencesManager.getInstance().getPreferences();
    if (!prefs.getBoolean(PROPERTY_OFFER_TO_DONATE_WAS_SHOWN, false)) {
        final long totalUpstartTime = prefs.getLong(Main.PROPERTY_TOTAL_UPSTART, 0L);
        if (totalUpstartTime >= (1000L * 3600L * 24L)) {
            final Timer timer = new Timer(60000, new ActionListener() {

                @Override
                public void actionPerformed(@Nonnull final ActionEvent e) {
                    final String text = "<html>You have been using the application for long time!<br>If you like it then you could support us and <a href=\"#\">make a donation</a>!</html>";
                    final JHtmlLabel label = new JHtmlLabel(text);
                    label.addLinkListener(new JHtmlLabel.LinkListener() {

                        @Override
                        public void onLinkActivated(@Nonnull final JHtmlLabel source, @Nonnull final String link) {
                            new DonateButton().doClick();
                        }
                    });
                    NotificationManager.getInstance().showNotification(null, "Do you like the application?", NotificationManager.Type.INFO, label);
                    prefs.putBoolean(PROPERTY_OFFER_TO_DONATE_WAS_SHOWN, true);
                    PreferencesManager.getInstance().flush();
                }
            });
            timer.setRepeats(false);
            timer.start();
        }
    }
}
Also used : Timer(javax.swing.Timer) ActionListener(java.awt.event.ActionListener) Nonnull(javax.annotation.Nonnull) ActionEvent(java.awt.event.ActionEvent) DonateButton(com.igormaznitsa.sciareto.ui.misc.DonateButton) Preferences(java.util.prefs.Preferences) JHtmlLabel(com.igormaznitsa.sciareto.ui.misc.JHtmlLabel)

Aggregations

DonateButton (com.igormaznitsa.sciareto.ui.misc.DonateButton)1 JHtmlLabel (com.igormaznitsa.sciareto.ui.misc.JHtmlLabel)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Preferences (java.util.prefs.Preferences)1 Nonnull (javax.annotation.Nonnull)1 Timer (javax.swing.Timer)1