OSDN Git Service

Editors preference page.
authorXavier Ducrohet <xav@android.com>
Fri, 15 Oct 2010 21:30:16 +0000 (14:30 -0700)
committerXavier Ducrohet <xav@android.com>
Fri, 15 Oct 2010 21:39:22 +0000 (14:39 -0700)
For now, only the monitor density, used by the zoom control
in the GLE.

Change-Id: I01219609e6196d845d45e306f5b93c3acf0b2ee2

eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/EditorsPage.java [new file with mode: 0644]
eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/LogCatPreferencePage.java

index 4dfeadc..59bc496 100644 (file)
             id="com.android.ide.eclipse.common.preferences.UsagePreferencePage"
             name="Usage Stats">
       </page>
+      <page
+            category="com.android.ide.eclipse.preferences.main"
+            class="com.android.ide.eclipse.adt.internal.preferences.EditorsPage"
+            id="com.android.ide.eclipse.adt.preferences.EditorsPage"
+            name="Editors">
+      </page>
    </extension>
    <extension
          point="org.eclipse.core.runtime.preferences">
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/EditorsPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/EditorsPage.java
new file mode 100644 (file)
index 0000000..472b15b
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.preferences;
+
+import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.sdkuilib.internal.widgets.ResolutionChooserDialog;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.StringButtonFieldEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * Preference page for the editors.
+ */
+public class EditorsPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+    public EditorsPage() {
+        super(GRID);
+        setPreferenceStore(AdtPlugin.getDefault().getPreferenceStore());
+    }
+
+    public void init(IWorkbench workbench) {
+        // pass
+    }
+
+    @Override
+    protected void createFieldEditors() {
+        addField(new DensityFieldEditor(AdtPrefs.PREFS_MONITOR_DENSITY,
+                "Monitor Density", getFieldEditorParent()));
+    }
+
+    /**
+     * Custom {@link StringButtonFieldEditor} to call out to {@link ResolutionChooserDialog}
+     * when the button is called.
+     */
+    private static class DensityFieldEditor extends StringButtonFieldEditor {
+
+        public DensityFieldEditor(String name, String labelText, Composite parent) {
+            super(name, labelText, parent);
+            setChangeButtonText("Compute...");
+        }
+
+        @Override
+        protected String changePressed() {
+            ResolutionChooserDialog dialog = new ResolutionChooserDialog(getShell());
+            if (dialog.open() == Window.OK) {
+                return Integer.toString(dialog.getDensity());
+            }
+
+            return null;
+        }
+    }
+}
index 6c1ae4f..6bcec04 100644 (file)
@@ -19,12 +19,11 @@ package com.android.ide.eclipse.ddms.preferences;
 import com.android.ide.eclipse.ddms.DdmsPlugin;
 import com.android.ide.eclipse.ddms.views.LogCatView;
 
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
-import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
 import org.eclipse.jface.preference.ComboFieldEditor;
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
 import org.eclipse.jface.preference.FontFieldEditor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.SWTError;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
@@ -48,8 +47,7 @@ public class LogCatPreferencePage extends FieldEditorPreferencePage implements
                 "Display Font:", getFieldEditorParent());
         addField(ffe);
 
-        Preferences prefs = DdmsPlugin.getDefault().getPluginPreferences();
-        prefs.addPropertyChangeListener(new IPropertyChangeListener() {
+        getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent event) {
                 // get the name of the property that changed.
                 String property = event.getProperty();