List of usage examples for org.eclipse.jface.dialogs IDialogSettings getLong
long getLong(String key) throws NumberFormatException;
From source file:com.bdaum.zoom.operations.internal.gen.AbstractGalleryGenerator.java
License:Open Source License
private static boolean originalModified(DialogSettings settings, File copiedFile, boolean downloadable, URI originalFile) {//from w w w .j a va 2s.c om if (copiedFile.exists() != downloadable) return true; IDialogSettings section = settings.getSection(originalFile.toString()); if (section == null) return true; if (Constants.FILESCHEME.equals(originalFile.getScheme())) { long timestamp = BatchUtilities.getImageFileModificationTimestamp(new File(originalFile)); if (section.getLong("modifiedAt") != timestamp) //$NON-NLS-1$ return true; } return false; }
From source file:com.bdaum.zoom.operations.internal.gen.AbstractGalleryGenerator.java
License:Open Source License
private static long getLongSetting(IDialogSettings section, String key) { try {//from w w w .j a v a2 s . c o m return section.getLong(key); } catch (Exception e) { return -1; } }
From source file:com.microsoft.tfs.client.common.ui.framework.dialog.DialogSettingsHelper.java
License:Open Source License
public static String getDebugInfo(final String dialogSettingsKey) { final IDialogSettings settings = getDialogSettings(dialogSettingsKey); long averageOpenTime = -1; long timeCounts = 0; try {/* w w w. j av a2 s . c o m*/ timeCounts = settings.getInt(TIME_COUNTS); averageOpenTime = settings.getLong(ACCUMULATED_OPEN_TIME) / timeCounts; } catch (final NumberFormatException ex) { averageOpenTime = -1; } return "stored origin (" //$NON-NLS-1$ + settings.get(DIALOG_ORIGIN_X) + "," //$NON-NLS-1$ + settings.get(DIALOG_ORIGIN_Y) + ")" //$NON-NLS-1$ + NEWLINE + "stored size (" //$NON-NLS-1$ + settings.get(DIALOG_WIDTH) + "," //$NON-NLS-1$ + settings.get(DIALOG_HEIGHT) + ")" //$NON-NLS-1$ + NEWLINE + "views: " //$NON-NLS-1$ + settings.get(VIEWS) + NEWLINE + ((averageOpenTime != -1) ? "average display time: " //$NON-NLS-1$ + averageOpenTime + " ms (" //$NON-NLS-1$ + timeCounts + " records)" //$NON-NLS-1$ + NEWLINE : "") //$NON-NLS-1$ + "since " //$NON-NLS-1$ + settings.get(SINCE); }
From source file:com.microsoft.tfs.client.common.ui.framework.dialog.DialogSettingsHelper.java
License:Open Source License
private static StoredDialogStatistics createStatistics(final IDialogSettings settings) { final String settingsKey = settings.getName(); Point origin = null;//w w w . j a v a 2s . c o m try { origin = new Point(settings.getInt(DIALOG_ORIGIN_X), settings.getInt(DIALOG_ORIGIN_Y)); } catch (final NumberFormatException ex) { } Point size = null; try { size = new Point(settings.getInt(DIALOG_WIDTH), settings.getInt(DIALOG_HEIGHT)); } catch (final NumberFormatException ex) { } Date since = null; final String sinceValue = settings.get(SINCE); if (sinceValue != null) { try { final SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT); since = formatter.parse(sinceValue); } catch (final ParseException ex) { } } int views = -1; long accumulatedOpenTimeMs = -1; int timeCounts = -1; try { views = settings.getInt(VIEWS); } catch (final NumberFormatException ex) { } try { accumulatedOpenTimeMs = settings.getLong(ACCUMULATED_OPEN_TIME); } catch (final NumberFormatException ex) { } try { timeCounts = settings.getInt(TIME_COUNTS); } catch (final NumberFormatException ex) { } long averageOpenTimeMs = -1; if (accumulatedOpenTimeMs != -1 && timeCounts != -1) { averageOpenTimeMs = accumulatedOpenTimeMs / timeCounts; } return new StoredDialogStatistics(settingsKey, origin, size, since, views, accumulatedOpenTimeMs, timeCounts, averageOpenTimeMs); }
From source file:com.microsoft.tfs.client.common.ui.framework.dialog.DialogSettingsHelper.java
License:Open Source License
public static void recordDialogClosed(final String dialogSettingsKey, final long elapsedTimeOpen) { final IDialogSettings settings = getDialogSettings(dialogSettingsKey); /*//from w w w .ja v a 2 s .c o m * Add to accumulated open time */ long accumulatedOpenTime = 0; try { accumulatedOpenTime = settings.getLong(ACCUMULATED_OPEN_TIME); } catch (final NumberFormatException ex) { // ignore } settings.put(ACCUMULATED_OPEN_TIME, accumulatedOpenTime + elapsedTimeOpen); /* * Add to time counts */ int timeCounts = 0; try { timeCounts = settings.getInt(TIME_COUNTS); } catch (final NumberFormatException ex) { // ignore } settings.put(TIME_COUNTS, timeCounts + 1); }
From source file:de.blizzy.backup.BackupApplication.java
License:Open Source License
static void scheduleBackupRun(boolean forceRunNow) { if (timer != null) { if (backupTimerTask != null) { backupTimerTask.cancel();//w w w . j a va 2 s . co m backupTimerTask = null; } backupTimerTask = new TimerTask() { @Override public void run() { runBackup(); } }; if (forceRunNow) { timer.schedule(backupTimerTask, 0); } else { IDialogSettings backupSection = Utils.getSection("backup"); //$NON-NLS-1$ long lastRun = backupSection.getLong("lastRun"); //$NON-NLS-1$ Settings settings = settingsManager.getSettings(); if (settings.isRunHourly()) { nextBackupRunTime = lastRun; } else { Calendar c = Calendar.getInstance(); c.setTimeInMillis(lastRun); c.set(Calendar.HOUR_OF_DAY, settings.getDailyHours()); c.set(Calendar.MINUTE, settings.getDailyMinutes()); nextBackupRunTime = c.getTimeInMillis(); } long now = System.currentTimeMillis(); for (;;) { nextBackupRunTime = clearSeconds(nextBackupRunTime); if (nextBackupRunTime > now) { break; } nextBackupRunTime += settings.isRunHourly() ? 60L * 60L * 1000L : 24L * 60L * 60L * 1000L; } timer.schedule(backupTimerTask, Math.max(nextBackupRunTime - now, 0)); } } }
From source file:net.refractions.udig.catalog.service.database.UserHostPage.java
License:Open Source License
private void populatePreviousConnections(Combo previousConnections) { IDialogSettings previous = getDialogSettings().getSection(PREVIOUS_CONNECTIONS); if (previous != null) { IDialogSettings[] sections = previous.getSections(); Arrays.sort(sections, new Comparator<IDialogSettings>() { public int compare(IDialogSettings o1, IDialogSettings o2) { long time1 = o1.getLong(TIMESTAMP); long time2 = o2.getLong(TIMESTAMP); if (time1 > time2) { return -1; }/*from ww w.jav a2 s . c o m*/ return 1; } }); List<String> items = new ArrayList<String>(sections.length); items.add(""); //$NON-NLS-1$ for (IDialogSettings connection : sections) { if (!connection.getBoolean(DELETED)) { StringBuilder name = new StringBuilder(); name.append(connection.get(USERNAME)); name.append('@'); name.append(connection.get(HOST)); name.append(':'); name.append(connection.get(PORT)); previousConnections.setData(name.toString(), connection); items.add(name.toString()); } } previousConnections.setItems(items.toArray(new String[0])); } }
From source file:net.tourbook.common.util.Util.java
License:Open Source License
/** * @param state//from www . j av a 2 s .c o m * @param key * @param defaultValue * @return Returns a long value from {@link IDialogSettings}. When the key is not found, the * default value is returned. */ public static long getStateLong(final IDialogSettings state, final String key, final long defaultValue) { if (state == null) { return defaultValue; } try { return state.get(key) == null ? defaultValue : state.getLong(key); } catch (final NumberFormatException e) { return defaultValue; } }
From source file:net.tourbook.importdata.WizardPageImportSettings.java
License:Open Source License
private void restoreDialogSettings() { final IDialogSettings settings = getDialogSettings(); // restore person _cboPerson.select(0);//ww w . j av a 2s.com Long savedPersonId; try { savedPersonId = settings.getLong(COMBO_PERSON_ID); if (savedPersonId != null) { int personIndex = 1; for (final TourPerson person : _people) { if (person.getPersonId() == savedPersonId) { _cboPerson.select(personIndex); System.setProperty(WizardImportData.SYSPROPERTY_IMPORT_PERSON, person.getName()); break; } personIndex++; } } } catch (final NumberFormatException e) { // irgnore } // restore device final String savedDeviceId = settings.get(COMBO_DEVICE_ID); _cboDevice.select(0); if (savedDeviceId != null) { int deviceIndex = 1; for (final ExternalDevice device : _deviceList) { if (device.deviceId.equals(savedDeviceId)) { _cboDevice.select(deviceIndex); break; } deviceIndex++; } } // restore port if (_isPortListAvailable) { // select the port which is stored in the settings final String savedPort = settings.get(COMBO_SERIAL_PORT); if (savedPort != null) { int portIndex = 0; for (final String port : _portList) { if (port.equalsIgnoreCase(savedPort)) { _cboPorts.select(portIndex); break; } portIndex++; } } } // restore raw data path _pathEditor.setStringValue(settings.get(TEXT_RAW_DATA_PATH)); }
From source file:net.tourbook.util.Util.java
License:Open Source License
/** * @param state/*from w ww . j a v a 2s. c o m*/ * @param key * @param defaultValue * @return Returns a long value from {@link IDialogSettings}. When the key is not found, the * default value is returned. */ public static long getStateLong(final IDialogSettings state, final String key, final long defaultValue) { try { return state.get(key) == null ? defaultValue : state.getLong(key); } catch (final NumberFormatException e) { return defaultValue; } }