2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.eclipse.org/org/documents/epl-v10.php
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.ide.eclipse.adt.internal.resources.configurations;
19 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
20 import com.android.sdklib.IAndroidTarget;
22 import org.eclipse.swt.graphics.Image;
28 * Resource Qualifier for Text Input Method.
30 public final class TextInputMethodQualifier extends ResourceQualifier {
32 public static final String NAME = "Text Input Method";
34 private TextInputMethod mValue;
37 * Screen Orientation enum.
39 public static enum TextInputMethod {
40 NOKEY("nokeys", "No Keys"), //$NON-NLS-1$
41 QWERTY("qwerty", "Qwerty"), //$NON-NLS-1$
42 TWELVEKEYS("12key", "12 Key"); //$NON-NLS-1$
44 private String mValue;
45 private String mDisplayValue;
47 private TextInputMethod(String value, String displayValue) {
49 mDisplayValue = displayValue;
53 * Returns the enum for matching the provided qualifier value.
54 * @param value The qualifier value.
55 * @return the enum for the qualifier value or null if no matching was found.
57 static TextInputMethod getEnum(String value) {
58 for (TextInputMethod orient : values()) {
59 if (orient.mValue.equals(value)) {
67 public String getValue() {
71 public String getDisplayValue() {
75 public static int getIndex(TextInputMethod value) {
77 for (TextInputMethod input : values()) {
88 public static TextInputMethod getByIndex(int index) {
90 for (TextInputMethod value : values()) {
100 public TextInputMethodQualifier() {
104 public TextInputMethodQualifier(TextInputMethod value) {
108 public TextInputMethod getValue() {
113 public String getName() {
118 public String getShortName() {
123 public Image getIcon() {
124 return IconFactory.getInstance().getIcon("text_input"); //$NON-NLS-1$
128 public boolean isValid() {
129 return mValue != null;
133 public boolean checkAndSet(String value, FolderConfiguration config) {
134 TextInputMethod method = TextInputMethod.getEnum(value);
135 if (method != null) {
136 TextInputMethodQualifier qualifier = new TextInputMethodQualifier();
137 qualifier.mValue = method;
138 config.setTextInputMethodQualifier(qualifier);
146 public boolean equals(Object qualifier) {
147 if (qualifier instanceof TextInputMethodQualifier) {
148 return mValue == ((TextInputMethodQualifier)qualifier).mValue;
155 public int hashCode() {
156 if (mValue != null) {
157 return mValue.hashCode();
164 * Returns the string used to represent this qualifier in the folder name.
167 public String getFolderSegment(IAndroidTarget target) {
168 if (mValue != null) {
169 return mValue.getValue();
172 return ""; //$NON-NLS-1$
176 public String getStringValue() {
177 if (mValue != null) {
178 return mValue.getDisplayValue();
181 return ""; //$NON-NLS-1$