Sample Code: Getting Sort Preferences
String sortPreferencesKey = getClass().getName() + ".sortPreferences";
Properties properties = ...
// Save the current sort properties as a preference.
properties.setProperty(sortPreferencesKey,
properties.getProperty(VConsoleProperties.SORTEDCOLUMN));
...
// Get previously saved preferences. If none exist, then
// presumably the user disabled sorting in the previous
// session, and we should honor that.
//
String sortPreferences = properties.getProperty(sortPreferencesKey);
if ((sortPreferences != null) && !sortPreferences.equals("null")) {
// Sort preferences are in "[+/-]#" format, where:
// + implies ascending sort order
// - implies descending sort order
// # is the columns number to sort by
// Extract the sort order
String sortOrder = VConsoleActions.SORTUP;
if (sortPreferences.indexOf('-') >= 0)
sortOrder = VConsoleActions.SORTDOWN;
// Extract the sort column
Integer[] sortColumn = new Integer[1];
try {
int n = Integer.parseInt(sortPreferences.substring(1));
sortColumn[0] = new Integer(n);
} catch (Exception e) {
// Should never get here, but Murphy's Law...
sortColumn[0] = new Integer(0);
}
// Apply sort criteria to display model
VConsoleEvent e = new VConsoleEvent(myTool, sortOrder, sortColumn);
myTool.fireConsoleAction(e);
// Update console UI controls on applied sort criteria
properties.setProperty(VConsoleProperties.SORTEDCOLUMN, sortPreferences);
}