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;
26 * Resource Qualifier for Touch Screen type.
28 public final class TouchScreenQualifier extends ResourceQualifier {
30 public static final String NAME = "Touch Screen";
32 private TouchScreenType mValue;
35 * Screen Orientation enum.
37 public static enum TouchScreenType {
38 NOTOUCH("notouch", "No Touch"), //$NON-NLS-1$
39 STYLUS("stylus", "Stylus"), //$NON-NLS-1$
40 FINGER("finger", "Finger"); //$NON-NLS-1$
42 private String mValue;
43 private String mDisplayValue;
45 private TouchScreenType(String value, String displayValue) {
47 mDisplayValue = displayValue;
51 * Returns the enum for matching the provided qualifier value.
52 * @param value The qualifier value.
53 * @return the enum for the qualifier value or null if no matching was found.
55 public static TouchScreenType getEnum(String value) {
56 for (TouchScreenType orient : values()) {
57 if (orient.mValue.equals(value)) {
65 public String getValue() {
69 public String getDisplayValue() {
73 public static int getIndex(TouchScreenType touch) {
75 for (TouchScreenType t : values()) {
86 public static TouchScreenType getByIndex(int index) {
88 for (TouchScreenType value : values()) {
99 public TouchScreenQualifier() {
103 public TouchScreenQualifier(TouchScreenType touchValue) {
107 public TouchScreenType getValue() {
112 public String getName() {
117 public String getShortName() {
122 public Image getIcon() {
123 return IconFactory.getInstance().getIcon("touch"); //$NON-NLS-1$
127 public boolean isValid() {
128 return mValue != null;
132 public boolean checkAndSet(String value, FolderConfiguration config) {
133 TouchScreenType type = TouchScreenType.getEnum(value);
135 TouchScreenQualifier qualifier = new TouchScreenQualifier();
136 qualifier.mValue = type;
137 config.setTouchTypeQualifier(qualifier);
145 public boolean equals(Object qualifier) {
146 if (qualifier instanceof TouchScreenQualifier) {
147 return mValue == ((TouchScreenQualifier)qualifier).mValue;
153 public int hashCode() {
154 if (mValue != null) {
155 return mValue.hashCode();
162 * Returns the string used to represent this qualifier in the folder name.
165 public String getFolderSegment(IAndroidTarget target) {
166 if (mValue != null) {
167 return mValue.getValue();
170 return ""; //$NON-NLS-1$
174 public String getStringValue() {
175 if (mValue != null) {
176 return mValue.getDisplayValue();
179 return ""; //$NON-NLS-1$