Java Code Examples for java.util.prefs.Preferences#getLong()

The following examples show how to use java.util.prefs.Preferences#getLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessagesService.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
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();
    }
  }
}
 
Example 2
Source File: Feedback.java    From Raccoon with Apache License 2.0 6 votes vote down vote up
/**
 * Call this when the user performs a "use" action.
 * 
 * @param center
 *          a component to center the feedback dialog upon (or null).
 */
public static void used(JFrame center) {
	Preferences prefs = Preferences.userNodeForPackage(Feedback.class);
	if (prefs.getBoolean(KEY_DONE, false)) {
		return;
	}
	long count = prefs.getLong(KEY_COUNT, 0) + 1;
	prefs.putLong(KEY_COUNT, count);

	long first = prefs.getLong(KEY_FIRST, 0);
	if (first == 0) {
		first = System.currentTimeMillis();
		prefs.putLong(KEY_FIRST, first);
	}
	try {
		prefs.flush();
	}
	catch (BackingStoreException e) {
		e.printStackTrace();
	}
	if (count >= USES) {
		if (System.currentTimeMillis() >= first + (DAYS * 24 * 60 * 60 * 1000)) {
			showDialog(center);
		}
	}
}
 
Example 3
Source File: SettingsTab.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private long lastModification(UpdateUnitProvider unitProvider) {
    Preferences p = NbPreferences.root().node("/org/netbeans/modules/autoupdate");//NOI18N
    return p.getLong(unitProvider.getName()+"_"+UnitTab.PROP_LAST_CHECK, 0);//NOI18N
}
 
Example 4
Source File: ModuleOptions.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private boolean initialized() {
    Preferences pref = NbPreferences.root ().node ("/org/netbeans/modules/autoupdate");
    long last = pref.getLong("lastCheckTime", -1);
    return last != -1;
}
 
Example 5
Source File: PreferencesUsageDataStore.java    From pdfsam with GNU Affero General Public License v3.0 4 votes vote down vote up
public long getTotalUsage() {
    Preferences node = Preferences.userRoot().node(USAGE_PATH);
    return node.getLong(TASKS_EXECUTED_KEY, 0);
}