Fixed: [Issue 89] Proto buffer editor needs to have options to remove
whitespace at end of lines

Code cleanup. Fixed property page.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/save/SaveActionsPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/save/SaveActionsPreferencePage.java
index ecbf94e..7c7fb5f 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/save/SaveActionsPreferencePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/save/SaveActionsPreferencePage.java
@@ -14,6 +14,8 @@
 
 import org.eclipse.jface.preference.*;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.*;
 import org.eclipse.swt.widgets.*;
 import org.eclipse.ui.*;
@@ -60,8 +62,9 @@
     btnInAllLines.setText("In all lines");
     
     setUpBinding();
-    
     preferenceBinder.applyValues();
+    updateContents();
+    addEventListeners();
     return contents;
   }
 
@@ -73,6 +76,20 @@
         bindSelectionOf(btnInEditedLines).to(preferences.inEditedLines())
     );
   }
+  
+  private void addEventListeners() {
+    btnRemoveTrailingwhitespace.addSelectionListener(new SelectionAdapter() {
+      @Override public void widgetSelected(SelectionEvent e) {
+        updateContents();
+      }
+    });
+  }
+  
+  private void updateContents() {
+    boolean enabled = btnRemoveTrailingwhitespace.getSelection();
+    btnInEditedLines.setEnabled(enabled);
+    btnInAllLines.setEnabled(enabled);
+  }
 
   @Override protected final IPreferenceStore doGetPreferenceStore() {
     return preferenceStoreAccess.getWritablePreferenceStore();
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/SimpleReference.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/SimpleReference.java
new file mode 100644
index 0000000..1e85910
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/SimpleReference.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ * 
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * 
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.util;
+
+/**
+ * A reference to an object. This class is not thread-safe.
+ * @param T the type of the object being referenced.
+ * 
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class SimpleReference<T> {
+
+  private T value;
+
+  /**
+   * Creates a new <code>{@link SimpleReference}</code> with a {@code null} value.
+   */
+  public SimpleReference() {}
+  
+  /**
+   * Creates a new <code>{@link SimpleReference}</code>.
+   * @param value the initial value of this reference.
+   */
+  public SimpleReference(T value) {
+    this.value = value;
+  }
+  
+  /**
+   * Returns this reference's value.
+   * @return this reference's value.
+   */
+  public T get() {
+    return value;
+  }
+  
+  /**
+   * Sets this reference's value.
+   * @param newValue the new value to set.
+   */
+  public void set(T newValue) {
+    value = newValue;
+  }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/editor/Editors.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/editor/Editors.java
index 492cf12..534a50d 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/editor/Editors.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/editor/Editors.java
@@ -17,6 +17,7 @@
 import static org.eclipse.core.runtime.Status.OK_STATUS;
 import static org.eclipse.core.runtime.SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK;
 
+import com.google.eclipse.protobuf.ui.util.SimpleReference;
 import com.google.inject.Singleton;
 
 import org.apache.log4j.Logger;
@@ -41,24 +42,25 @@
   public IRegion[] calculateChangedLineRegions(final ITextFileBuffer buffer,
       final IDocument current, final IProgressMonitor monitor)
       throws CoreException {
-    final IRegion[][] result = new IRegion[1][];
-    final IStatus[] errorStatus = new IStatus[] { OK_STATUS };
+    final SimpleReference<IRegion[]> result = new SimpleReference<IRegion[]>();
+    final SimpleReference<IStatus> errorStatus = new SimpleReference<IStatus>(OK_STATUS);
     try {
       SafeRunner.run(new ISafeRunnable() {
         public void handleException(Throwable exception) {
           logger.error(exception.getMessage(), exception);
-          errorStatus[0] = new Status(ERROR, PLUGIN_ID, 0, errorCalculatingChangedRegions, exception);
-          result[0] = null;
+          errorStatus.set(new Status(ERROR, PLUGIN_ID, 0, errorCalculatingChangedRegions, exception));
+          result.set(null);
         }
 
         public void run() throws Exception {
           monitor.beginTask(calculatingChangedRegions, 20);
           IFileStore fileStore = buffer.getFileStore();
+          System.out.println("file store" + fileStore.getClass());
           ITextFileBufferManager fileBufferManager = createTextFileBufferManager();
           fileBufferManager.connectFileStore(fileStore, getSubProgressMonitor(monitor, 15));
           try {
             IDocument old = ((ITextFileBuffer) fileBufferManager.getFileStoreFileBuffer(fileStore)).getDocument();
-            result[0] = getChangedLineRegions(old);
+            result.set(getChangedLineRegions(old));
           } finally {
             fileBufferManager.disconnectFileStore(fileStore, getSubProgressMonitor(monitor, 5));
             monitor.done();
@@ -106,9 +108,10 @@
         }
       });
     } finally {
-      if (!errorStatus[0].isOK()) throw new CoreException(errorStatus[0]);
+      IStatus status = errorStatus.get();
+      if (!status.isOK()) throw new CoreException(status);
     }
-    return result[0];
+    return result.get();
   }
   
   private static IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {