mavis
Class Settings

java.lang.Object
  extended by mavis.Settings

public class Settings
extends java.lang.Object

Singleton class for holding all global settings. All changes are automatically written to file after a short delay.


Field Summary
private static LastExecutor autosaveQueue
          Queue for scheduling save operations after properties/sequences have been changed
private static java.lang.Runnable autosaveRunnable
          Operation that will save the properties/sequences.
private static StyledWrapper defaultWrapper
           
private static int DIRECTORY_HISTORY_SIZE
           
private static java.util.List<java.io.File> directoryHistory
          List for holding the recently used directories.
private static StyledWrapper doneRecentlyWrapper
           
private static StyledWrapper measuringWrapper
           
private static int PROJECT_HISTORY_SIZE
           
private static java.util.List<java.io.File> projectHistory
          List for holding the recently used project files.
private static java.util.Properties properties
          All properties in a map.
private static java.io.File propertiesFile
          File where the properties will be saved in XML format
private static boolean propertiesModified
          true if the properties have been modified, otherwise false
private static java.util.List<MeasurementSequence> sequences
          All saved sequences
private static boolean sequencesModified
          true if the sequences have been modified, otherwise false
private static java.util.List<java.io.File> tableDirectoryHistory
          List for holding the recently used directories.
private static StyledWrapper warningWrapper
           
 
Constructor Summary
Settings()
           
 
Method Summary
static void firePropertiesModified()
          Invokes autosaving for the properities.
static void fireSequencesModified()
          Invokes autosaving for the sequences.
static java.io.File[] getCalibrationProjectFiles()
           
static java.lang.String getCSVfileSeparator()
          Formatting - CSV file field separator used in exported ASCII measurement data
static java.util.List<SequenceColumn> getDefaultColumns()
           
static StyledWrapper getDefaultWrapperInstance()
          Returns a copy of the default StyledWrapper.
static java.io.File[] getDirectoryHistory()
           
static StyledWrapper getDoneRecentlyWrapperInstance()
          Returns a copy of the StyledWrapper for recently measured projects.
static boolean getGraphsCheckBox()
           
static MeasurementResult getHolderCalibration()
           
static java.io.File getHolderCalibrationFile()
           
static java.io.File getLastDirectory()
           
static java.io.File getLastTableDirectory()
           
static StyledWrapper getMeasuringWrapperInstance()
          Returns a copy of the StyledWrapper for measuring projects.
static java.lang.String getPrintoutNumberFormat()
          Formatting - Number format for printouts
static java.io.File[] getProjectHistory()
           
private static java.lang.String getProperty(java.lang.String key)
          Returns the value that maps to the specified key.
private static java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the value that maps to the specified key.
static boolean getSampleDataCheckBox()
           
static MeasurementSequence[] getSequences()
          Returns all saved sequences in sorted order.
static java.io.File[] getTableDirectoryHistory()
           
static java.lang.String getTableNumberFormat()
          Formatting - Number format for table
static StyledWrapper getWarningWrapperInstance()
          Returns a copy of the StyledWrapper for projects with warnings.
static int getWindowHeight()
           
static boolean getWindowMaximized()
           
static int getWindowWidth()
           
static java.lang.Object getXXX()
          Generic accessor for all properties.
private static void loadDirectoryHistory()
           
private static void loadProjectHistory()
           
private static void loadTableDirectoryHistory()
           
static void save()
          Saves the settings after a while when no changes have come.
static boolean saveNow()
          Saves the settings and keeps waiting until its done.
static boolean setCSVfileSeparator(java.lang.String newSeparator)
           
static void setGraphsCheckBox(boolean tick)
           
static boolean setPrintoutNumberFormat(java.lang.String format)
           
private static void setProperty(java.lang.String key, java.lang.String value)
          Associates the specified value with the specified key.
static void setSampleDataCheckBox(boolean tick)
           
static boolean setTableNumberFormat(java.lang.String format)
           
static boolean setWindowHeight(int value)
           
static boolean setWindowMaximized(boolean value)
           
static boolean setWindowWidth(int value)
           
static boolean setXXX(java.lang.Object value)
          Generic accessor for all properties.
static boolean updateDirectoryHistory(java.io.File visited)
           
static boolean updateProjectHistory(java.io.File visited)
           
static boolean updateTableDirectoryHistory(java.io.File visited)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_HISTORY_SIZE

private static final int DIRECTORY_HISTORY_SIZE
See Also:
Constant Field Values

PROJECT_HISTORY_SIZE

private static final int PROJECT_HISTORY_SIZE
See Also:
Constant Field Values

defaultWrapper

private static final StyledWrapper defaultWrapper

measuringWrapper

private static final StyledWrapper measuringWrapper

doneRecentlyWrapper

private static final StyledWrapper doneRecentlyWrapper

warningWrapper

private static final StyledWrapper warningWrapper

properties

private static java.util.Properties properties
All properties in a map.


propertiesFile

private static java.io.File propertiesFile
File where the properties will be saved in XML format


propertiesModified

private static boolean propertiesModified
true if the properties have been modified, otherwise false


sequences

private static java.util.List<MeasurementSequence> sequences
All saved sequences


sequencesModified

private static boolean sequencesModified
true if the sequences have been modified, otherwise false


directoryHistory

private static java.util.List<java.io.File> directoryHistory
List for holding the recently used directories. Used to cache the values read from the properties.


tableDirectoryHistory

private static java.util.List<java.io.File> tableDirectoryHistory
List for holding the recently used directories. Used to cache the values read from the properties.


projectHistory

private static java.util.List<java.io.File> projectHistory
List for holding the recently used project files. Used to cache the values read from the properties.


autosaveQueue

private static LastExecutor autosaveQueue
Queue for scheduling save operations after properties/sequences have been changed


autosaveRunnable

private static java.lang.Runnable autosaveRunnable
Operation that will save the properties/sequences.

Constructor Detail

Settings

public Settings()
Method Detail

firePropertiesModified

public static void firePropertiesModified()
Invokes autosaving for the properities.


fireSequencesModified

public static void fireSequencesModified()
Invokes autosaving for the sequences.


save

public static void save()
Saves the settings after a while when no changes have come. The method call will return immediately and will not wait for the file to be written.


saveNow

public static boolean saveNow()
Saves the settings and keeps waiting until its done. If no settings have been modified, will do nothing.

Returns:
true if there were no errors in writing the files or everything was already saved. Otherwise false.

getProperty

private static java.lang.String getProperty(java.lang.String key)
Returns the value that maps to the specified key.

Parameters:
key - key whose associated value is to be returned.
Returns:
the value associated with key, or null if none exists.

getProperty

private static java.lang.String getProperty(java.lang.String key,
                                            java.lang.String defaultValue)
Returns the value that maps to the specified key.

Parameters:
key - key whose associated value is to be returned.
defaultValue - a default value
Returns:
the value associated with key, or defaultValue if none exists.

setProperty

private static void setProperty(java.lang.String key,
                                java.lang.String value)
Associates the specified value with the specified key. Will invoke autosaving.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key, or null to remove the value.
Throws:
java.lang.NullPointerException - if key is null.

getXXX

public static java.lang.Object getXXX()
Generic accessor for all properties. Returns the value from Properties in appropriate type.

Returns:
Value associated with key

setXXX

public static boolean setXXX(java.lang.Object value)
Generic accessor for all properties. Checks whether the value is ok and sets it. Will invoke autosaving.

Returns:
true if value was correct, otherwise false.

getCSVfileSeparator

public static java.lang.String getCSVfileSeparator()
Formatting - CSV file field separator used in exported ASCII measurement data


setCSVfileSeparator

public static boolean setCSVfileSeparator(java.lang.String newSeparator)

getPrintoutNumberFormat

public static java.lang.String getPrintoutNumberFormat()
Formatting - Number format for printouts


setPrintoutNumberFormat

public static boolean setPrintoutNumberFormat(java.lang.String format)

getTableNumberFormat

public static java.lang.String getTableNumberFormat()
Formatting - Number format for table


setTableNumberFormat

public static boolean setTableNumberFormat(java.lang.String format)

getWindowWidth

public static int getWindowWidth()

setWindowWidth

public static boolean setWindowWidth(int value)

getWindowHeight

public static int getWindowHeight()

setWindowHeight

public static boolean setWindowHeight(int value)

getWindowMaximized

public static boolean getWindowMaximized()

setWindowMaximized

public static boolean setWindowMaximized(boolean value)

getLastDirectory

public static java.io.File getLastDirectory()

getDirectoryHistory

public static java.io.File[] getDirectoryHistory()

getLastTableDirectory

public static java.io.File getLastTableDirectory()

getTableDirectoryHistory

public static java.io.File[] getTableDirectoryHistory()

updateDirectoryHistory

public static boolean updateDirectoryHistory(java.io.File visited)

updateTableDirectoryHistory

public static boolean updateTableDirectoryHistory(java.io.File visited)

loadDirectoryHistory

private static void loadDirectoryHistory()

loadTableDirectoryHistory

private static void loadTableDirectoryHistory()

getProjectHistory

public static java.io.File[] getProjectHistory()

updateProjectHistory

public static boolean updateProjectHistory(java.io.File visited)

loadProjectHistory

private static void loadProjectHistory()

setSampleDataCheckBox

public static void setSampleDataCheckBox(boolean tick)

setGraphsCheckBox

public static void setGraphsCheckBox(boolean tick)

getSampleDataCheckBox

public static boolean getSampleDataCheckBox()

getGraphsCheckBox

public static boolean getGraphsCheckBox()

getSequences

public static MeasurementSequence[] getSequences()
Returns all saved sequences in sorted order.


getDefaultColumns

public static java.util.List<SequenceColumn> getDefaultColumns()

getCalibrationProjectFiles

public static java.io.File[] getCalibrationProjectFiles()

getHolderCalibrationFile

public static java.io.File getHolderCalibrationFile()

getHolderCalibration

public static MeasurementResult getHolderCalibration()

getDefaultWrapperInstance

public static StyledWrapper getDefaultWrapperInstance()
Returns a copy of the default StyledWrapper.


getMeasuringWrapperInstance

public static StyledWrapper getMeasuringWrapperInstance()
Returns a copy of the StyledWrapper for measuring projects.


getDoneRecentlyWrapperInstance

public static StyledWrapper getDoneRecentlyWrapperInstance()
Returns a copy of the StyledWrapper for recently measured projects.


getWarningWrapperInstance

public static StyledWrapper getWarningWrapperInstance()
Returns a copy of the StyledWrapper for projects with warnings.