Cleaning up preferences-related code.
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 6105f8b..9d9c461 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 @@ doCreateContents(contents); setupBinding(preferenceBinder); preferenceBinder.applyValues(); - onPageCreation(); + updateContents(); return contents; } @@ -123,9 +123,6 @@ */ protected abstract void setupBinding(PreferenceBinder preferenceBinder); - /** Method invoked after the page has been created. By default this method does nothing. */ - protected void onPageCreation() {} - /** * Returns the id of this preference page. * @return the id of this preference page. @@ -160,7 +157,7 @@ /** * Indicates whether this page is a "Project Properties" page or not. * @return {@code true} if this page is a "Project Properties" page, or {@code false} if this page is a - * "Worspace Settings" page. + * "Workspace Settings" page. */ protected final boolean isPropertyPage() { return project != null; @@ -213,12 +210,12 @@ @Override protected final void performDefaults() { preferenceBinder.applyDefaults(); - defaultsPerformed(); + updateContents(); super.performDefaults(); } - /** Method invoked after this page's defaults have been processed. By default this method does nothing. */ - protected void defaultsPerformed() {} + /** Refreshes this page with the stored/default preference values. */ + protected void updateContents() {} /** Marks this page as "valid." */ protected final void pageIsNowValid() {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java index a76f5d6..81c9908 100644 --- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java +++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java
@@ -150,6 +150,7 @@ FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.SHEET); String file = dialog.open(); if (file != null) txtProtocFilePath.setText(file); + checkState(); } }); btnRefreshResources.addSelectionListener(new SelectionAdapter() { @@ -195,6 +196,9 @@ @Override protected void setupBinding(PreferenceBinder preferenceBinder) { RawPreferences preferences = new RawPreferences(getPreferenceStore()); + if (isPropertyPage()) { + preferenceBinder.add(bindSelectionOf(btnEnableProjectSettings).to(preferences.enableProjectSettings())); + } preferenceBinder.addAll( bindSelectionOf(btnCompileProtoFiles).to(preferences.compileProtoFiles()), bindSelectionOf(btnUseProtocInSystemPath).to(preferences.useProtocInSystemPath()), @@ -210,20 +214,13 @@ bindCodeGeneration(codeGenerationSettings.python()) .to(preferences.pythonCodeGenerationEnabled(), preferences.pythonOutputDirectory()) ); - if (isPropertyPage()) { - preferenceBinder.add(bindSelectionOf(btnEnableProjectSettings).to(preferences.enableProjectSettings())); - } } - @Override protected void onPageCreation() { - defaultsPerformed(); - } - - @Override protected void defaultsPerformed() { + @Override protected void updateContents() { boolean compileProtoFiles = btnCompileProtoFiles.getSelection(); boolean shouldEnableCompilerOptions = compileProtoFiles; if (isPropertyPage()) { - boolean useProjectSettings = btnEnableProjectSettings.isEnabled(); + boolean useProjectSettings = areProjectSettingsActive(); activateProjectSettings(useProjectSettings); enableProjectSpecificOptions(useProjectSettings); shouldEnableCompilerOptions = shouldEnableCompilerOptions && useProjectSettings;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencePage.java index 925bcb2..3c5f8d0 100644 --- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencePage.java +++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencePage.java
@@ -138,16 +138,12 @@ directoryPathsEditor.directoryPaths(unmodifiableList(paths)); } - @Override protected void onPageCreation() { - defaultsPerformed(); - } - /** {@inheritDoc} */ @Override protected void onProjectSettingsActivation(boolean active) { enableProjectOptions(active); } - @Override protected void defaultsPerformed() { + @Override protected void updateContents() { enableProjectOptions(true); }