public WorkspacePreferences() {
    super("Workspace"); // $NON-NLS-1$
    this.preferences = ResourcesPlugin.getPlugin().getPluginPreferences();

    final String version = preferences.getString(ICoreConstants.PREF_VERSION_KEY);
    if (!ICoreConstants.PREF_VERSION.equals(version)) upgradeVersion(version);

    // initialize cached preferences (for better performance)
    super.setAutoBuilding(preferences.getBoolean(ResourcesPlugin.PREF_AUTO_BUILDING));
    super.setSnapshotInterval(preferences.getInt(ResourcesPlugin.PREF_SNAPSHOT_INTERVAL));
    super.setMaxBuildIterations(preferences.getInt(ResourcesPlugin.PREF_MAX_BUILD_ITERATIONS));
    super.setApplyFileStatePolicy(
        preferences.getBoolean(ResourcesPlugin.PREF_APPLY_FILE_STATE_POLICY));
    super.setMaxFileStates(preferences.getInt(ResourcesPlugin.PREF_MAX_FILE_STATES));
    super.setMaxFileStateSize(preferences.getLong(ResourcesPlugin.PREF_MAX_FILE_STATE_SIZE));
    super.setFileStateLongevity(preferences.getLong(ResourcesPlugin.PREF_FILE_STATE_LONGEVITY));
    super.setOperationsPerSnapshot(
        preferences.getInt(PreferenceInitializer.PREF_OPERATIONS_PER_SNAPSHOT));
    super.setDeltaExpiration(preferences.getLong(PreferenceInitializer.PREF_DELTA_EXPIRATION));

    // This property listener ensures we are being updated properly when changes
    // are done directly to the preference store.
    preferences.addPropertyChangeListener(
        new Preferences.IPropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent event) {
            synchronizeWithPreferences(event.getProperty());
          }
        });
  }
 protected void synchronizeWithPreferences(String property) {
   // do not use the value in the event - may be a string instead
   // of the expected type. Retrieve it from the preferences store
   // using the type-specific method
   if (property.equals(ResourcesPlugin.PREF_AUTO_BUILDING))
     super.setAutoBuilding(preferences.getBoolean(ResourcesPlugin.PREF_AUTO_BUILDING));
   else if (property.equals(ResourcesPlugin.PREF_SNAPSHOT_INTERVAL))
     super.setSnapshotInterval(preferences.getLong(ResourcesPlugin.PREF_SNAPSHOT_INTERVAL));
   else if (property.equals(ResourcesPlugin.PREF_MAX_BUILD_ITERATIONS))
     super.setMaxBuildIterations(preferences.getInt(ResourcesPlugin.PREF_MAX_BUILD_ITERATIONS));
   else if (property.equals(ResourcesPlugin.PREF_APPLY_FILE_STATE_POLICY))
     super.setApplyFileStatePolicy(
         preferences.getBoolean(ResourcesPlugin.PREF_APPLY_FILE_STATE_POLICY));
   else if (property.equals(ResourcesPlugin.PREF_MAX_FILE_STATES))
     super.setMaxFileStates(preferences.getInt(ResourcesPlugin.PREF_MAX_FILE_STATES));
   else if (property.equals(ResourcesPlugin.PREF_MAX_FILE_STATE_SIZE))
     super.setMaxFileStateSize(preferences.getLong(ResourcesPlugin.PREF_MAX_FILE_STATE_SIZE));
   else if (property.equals(ResourcesPlugin.PREF_FILE_STATE_LONGEVITY))
     super.setFileStateLongevity(preferences.getLong(ResourcesPlugin.PREF_FILE_STATE_LONGEVITY));
   else if (property.equals(PreferenceInitializer.PREF_OPERATIONS_PER_SNAPSHOT))
     super.setOperationsPerSnapshot(
         preferences.getInt(PreferenceInitializer.PREF_OPERATIONS_PER_SNAPSHOT));
   else if (property.equals(PreferenceInitializer.PREF_DELTA_EXPIRATION))
     super.setDeltaExpiration(preferences.getLong(PreferenceInitializer.PREF_DELTA_EXPIRATION));
 }
 /** Helper method that copies all attributes from a workspace description object to another. */
 private static void copyFromTo(WorkspaceDescription source, WorkspaceDescription target) {
   target.setAutoBuilding(source.isAutoBuilding());
   target.setBuildOrder(source.getBuildOrder());
   target.setMaxBuildIterations(source.getMaxBuildIterations());
   target.setApplyFileStatePolicy(source.isApplyFileStatePolicy());
   target.setFileStateLongevity(source.getFileStateLongevity());
   target.setMaxFileStates(source.getMaxFileStates());
   target.setMaxFileStateSize(source.getMaxFileStateSize());
   target.setSnapshotInterval(source.getSnapshotInterval());
   target.setOperationsPerSnapshot(source.getOperationsPerSnapshot());
   target.setDeltaExpiration(source.getDeltaExpiration());
 }