private List<SortKey> readColumnOrderFromPreferences() {
   try {
     return PreferencesUtils.readSortKeysFromPrefs(this.prefs);
   } catch (PreferencesException ex) {
     LOG.error("The column order could not be loaded from preferences.", ex);
     return Collections.emptyList();
   }
 }
  private TimelimitTaskTableModel newTimelimitTaskTableModel() {
    final TimelimitTaskTableModel result = new TimelimitTaskTableModel();

    // add columns:
    final List<String> lstFieldNames =
        new LinkedList<String>(CollectableTimelimitTask.clcte.getFieldNames());

    // sort using the order stored in the preferences:
    List<String> lstFieldNameOrderTemp;
    try {
      lstFieldNameOrderTemp = PreferencesUtils.getStringList(this.prefs, PREFS_NODE_SELECTEDFIELDS);
    } catch (PreferencesException ex) {
      LOG.error(
          "Failed to retrieve list of selected fields from the preferences. They will be empty.");
      lstFieldNameOrderTemp = new ArrayList<String>();
    }
    final List<String> lstFieldNameOrder = lstFieldNameOrderTemp;

    Collections.sort(
        lstFieldNames,
        new Comparator<String>() {
          private int getOrder(Object o) {
            int result = lstFieldNameOrder.indexOf(o);
            if (result == -1) {
              // new fields are shown at the end:
              result = lstFieldNameOrder.size();
            }
            return result;
          }

          @Override
          public int compare(String o1, String o2) {
            int iDiff = getOrder(o1) - getOrder(o2);
            return (iDiff == 0) ? 0 : (iDiff / Math.abs(iDiff));
          }
        });

    int iColumn = 0;
    final List<String> lstNamesOfFieldsToDisplay =
        CollectableTimelimitTask.clcte.getNamesOfFieldsToDisplay();
    for (Iterator<String> iter = lstFieldNames.iterator(); iter.hasNext(); ) {
      final String sFieldName = iter.next();
      final CollectableEntityField clctef =
          CollectableTimelimitTask.clcte.getEntityField(sFieldName);
      if (lstNamesOfFieldsToDisplay.contains(sFieldName)) {
        result.addColumn(iColumn++, clctef);
      }
    }

    if (result.getColumnCount() > 0) {
      result.setSortKeys(Collections.singletonList(new SortKey(0, SortOrder.ASCENDING)), false);
    }

    return result;
  }
  private List<Integer> readColumnWidthsFromPreferences() {
    List<Integer> lstColumnWidths = null;
    try {
      lstColumnWidths = PreferencesUtils.getIntegerList(this.prefs, PREFS_NODE_SELECTEDFIELDWIDTHS);
    } catch (PreferencesException ex) {
      LOG.error("Die Spaltenbreite konnte nicht aus den Preferences geladen werden.", ex);
      return lstColumnWidths;
    }

    return lstColumnWidths;
  }
 public void storeOrderBySelectedColumnToPreferences() {
   try {
     PreferencesUtils.writeSortKeysToPrefs(
         this.prefs, this.timelimittaskview.getTimelimitTaskTableModel().getSortKeys());
   } catch (PreferencesException e1) {
     Errors.getInstance()
         .showExceptionDialog(
             this.getTabbedPane().getComponentPanel(),
             getSpringLocaleDelegate()
                 .getMessage(
                     "PersonalTaskController.19", "Fehler beim Abspeichern der Einstellungen"),
             e1);
   }
 }
 public void storeIntervalTasksToPreferences() {
   final Integer[] refreshInterval = {
     new Integer((getSingleScheduledRefreshableView().getRefreshInterval()))
   };
   try {
     PreferencesUtils.putIntegerArray(
         prefs, PREFS_NODE_TIMELIMITTASKS_REFRESH_INTERVAL_SELECTED, refreshInterval);
   } catch (PreferencesException e1) {
     Errors.getInstance()
         .showExceptionDialog(
             this.getTabbedPane().getComponentPanel(),
             getSpringLocaleDelegate()
                 .getMessage(
                     "PersonalTaskController.18", "Fehler beim Abspeichern der Einstellungen"),
             e1);
   }
 }
 private int readIntervalTasksFromPreferences() {
   List<Integer> refreshIntervalTasksSelectedList;
   try {
     refreshIntervalTasksSelectedList =
         PreferencesUtils.getIntegerList(
             prefs, PREFS_NODE_TIMELIMITTASKS_REFRESH_INTERVAL_SELECTED);
   } catch (PreferencesException ex) {
     LOG.error(
         getSpringLocaleDelegate()
             .getMessage(
                 "PersonalTaskController.10",
                 "Der Filterzustand konnte nicht aus den Einstellungen gelesen werden"),
         ex);
     return 0;
   }
   if (refreshIntervalTasksSelectedList.isEmpty()) return 0;
   return refreshIntervalTasksSelectedList.get(0);
 }
 private void storeColumnWidthsInPrefs(JTable tbl) throws PreferencesException {
   PreferencesUtils.putIntegerList(
       this.prefs, PREFS_NODE_SELECTEDFIELDWIDTHS, CollectableTableHelper.getColumnWidths(tbl));
 }
 /** stores the selected columns (fields) in user preferences */
 private void storeSelectedFieldNamesInPrefs(List<String> lstSelectedFieldNames)
     throws PreferencesException {
   PreferencesUtils.putStringList(this.prefs, PREFS_NODE_SELECTEDFIELDS, lstSelectedFieldNames);
 }