Fixed: [  Issue 70  ] Validation doesn't start until editing
https://code.google.com/p/protobuf-dt/issues/detail?id=70

Working on preference page for validation options.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/Preference.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/Preference.java
index cd3fec5..2a8cbed 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/Preference.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/Preference.java
@@ -32,6 +32,14 @@
   }
 
   /**
+   * Returns the name of this preference.
+   * @return the name of this preference.
+   */
+  public final String name() {
+    return name;
+  }
+
+  /**
    * Returns the value of this preference.
    * @return the value of this preference.
    */
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java
index cb22c3a..e5966fd 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java
@@ -49,7 +49,7 @@
   @Override protected final Control createContents(Composite parent) {
     Composite contents = contentParent(parent);
     doCreateContents(contents);
-    setupBtnEnabledProjectSettingsBinding();
+    if (isPropertyPage()) setupBtnEnabledProjectSettingsBinding();
     setupBinding(preferenceBinder);
     preferenceBinder.applyValues();
     updateContents();
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/general/GeneralPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/general/GeneralPreferencePage.java
index 0f22af1..00d99d6 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/general/GeneralPreferencePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/general/GeneralPreferencePage.java
@@ -28,17 +28,18 @@
 
   private static final String PREFERENCE_PAGE_ID = "com.google.eclipse.protobuf.Protobuf";
 
+  private Group grpValidation;
   private Button btnValidateOnActivation;
 
-  @Override protected void doCreateContents(Composite contents) {
-    // generated by WindowBuilder
-    Group grpValidation = new Group(contents, SWT.NONE);
+  @Override protected void doCreateContents(Composite parent) {
+    grpValidation = new Group(parent, SWT.NONE);
     grpValidation.setLayout(new GridLayout(1, false));
     grpValidation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
     grpValidation.setText(contentValidation);
 
     btnValidateOnActivation = new Button(grpValidation, SWT.CHECK);
     btnValidateOnActivation.setText(validateFilesOnActivation);
+    new Label(parent, SWT.NONE);
   }
 
   @Override protected BooleanPreference enableProjectSettingsPreference(IPreferenceStore store) {
@@ -52,7 +53,22 @@
       );
   }
 
-  @Override protected void onProjectSettingsActivation(boolean active) {}
+  @Override protected void updateContents() {
+    if (isPropertyPage()) {
+      boolean useProjectSettings = areProjectSettingsActive();
+      activateProjectSettings(useProjectSettings);
+      enableProjectSpecificOptions(useProjectSettings);
+    }
+  }
+
+  @Override protected void onProjectSettingsActivation(boolean active) {
+    enableProjectSpecificOptions(active);
+  }
+
+  private void enableProjectSpecificOptions(boolean isEnabled) {
+    grpValidation.setEnabled(isEnabled);
+    btnValidateOnActivation.setEnabled(isEnabled);
+  }
 
   @Override protected String preferencePageId() {
     return PREFERENCE_PAGE_ID;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java
index f949ea3..3593840 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java
@@ -1,10 +1,10 @@
 /*
  * 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.validation;
@@ -12,9 +12,9 @@
 import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.IMPORT__IMPORT_URI;
 import static org.eclipse.xtext.EcoreUtil2.getAllContentsOfType;
 
-import com.google.eclipse.protobuf.protobuf.Import;
-import com.google.eclipse.protobuf.util.ModelNodes;
+import java.util.List;
 
+import org.eclipse.core.resources.IProject;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.ui.*;
 import org.eclipse.ui.part.FileEditorInput;
@@ -25,31 +25,46 @@
 import org.eclipse.xtext.ui.editor.model.*;
 import org.eclipse.xtext.util.concurrent.IUnitOfWork;
 
-import java.util.List;
+import com.google.eclipse.protobuf.protobuf.Import;
+import com.google.eclipse.protobuf.ui.internal.ProtobufActivator;
+import com.google.eclipse.protobuf.ui.preferences.pages.general.*;
+import com.google.eclipse.protobuf.util.ModelNodes;
+import com.google.inject.Injector;
 
 /**
  * Validates a .proto file when it is opened or activated.
- * 
+ *
  * @author alruiz@google.com (Alex Ruiz)
  */
 public class ValidateOnActivation implements IPartListener2 {
 
+  private static final String LANGUAGE_NAME = "com.google.eclipse.protobuf.Protobuf";
+
   private final ModelNodes nodes = new ModelNodes();
-  
+
   public void partActivated(IWorkbenchPartReference partRef) {
     final XtextEditor editor = protoEditorFrom(partRef);
     if (editor == null) return;
+    if (!shouldValidateEditor(editor.getResource().getProject())) return;
     validate(editor);
   }
-  
+
+  private boolean shouldValidateEditor(IProject project) {
+    Injector injector = ProtobufActivator.getInstance().getInjector(LANGUAGE_NAME);
+    GeneralPreferencesFactory factory = injector.getInstance(GeneralPreferencesFactory.class);
+    if (factory == null) return false;
+    GeneralPreferences preferences = factory.preferences(project);
+    return preferences.validateFilesOnActivation();
+  }
+
   private XtextEditor protoEditorFrom(IWorkbenchPartReference partRef) {
     XtextEditor editor = xtextEditorFrom(partRef);
     if (editor == null) return null;
-    if (!"com.google.eclipse.protobuf.Protobuf".equals(editor.getLanguageName())) return null;
+    if (!LANGUAGE_NAME.equals(editor.getLanguageName())) return null;
     if (!(editor.getEditorInput() instanceof FileEditorInput)) return null;
     return editor;
   }
-  
+
   private XtextEditor xtextEditorFrom(IWorkbenchPartReference partRef) {
     IWorkbenchPage page = partRef.getPage();
     if (page == null) return null;
@@ -81,7 +96,7 @@
     if (uri == null) return;
     anImport.setImportURI(uri);
   }
-  
+
   private String uriAsEnteredInEditor(Import anImport) {
     INode node = nodes.firstNodeForFeature(anImport, IMPORT__IMPORT_URI);
     if (node == null) return null;