diff options
author | Xavier Ducrohet <xav@android.com> | 2010-10-15 14:30:16 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-10-15 14:39:22 -0700 |
commit | 9bb15bbfe4b659261414ac0abd8f234631d1598f (patch) | |
tree | e58d65e15405fa3dc4e639359e6bdf013f79e7da /eclipse/plugins/com.android.ide.eclipse.adt | |
parent | b871eeac402d893e29de4db88be8ce55a6902bff (diff) | |
download | sdk-9bb15bbfe4b659261414ac0abd8f234631d1598f.zip sdk-9bb15bbfe4b659261414ac0abd8f234631d1598f.tar.gz sdk-9bb15bbfe4b659261414ac0abd8f234631d1598f.tar.bz2 |
Editors preference page.
For now, only the monitor density, used by the zoom control
in the GLE.
Change-Id: I01219609e6196d845d45e306f5b93c3acf0b2ee2
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml | 6 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/EditorsPage.java | 70 |
2 files changed, 76 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml index 4dfeadc..59bc496 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml +++ b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml @@ -343,6 +343,12 @@ 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 index 0000000..472b15b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/EditorsPage.java @@ -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; + } + } +} |