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;
27 * Resource Qualifier for Navigation Method.
29 public final class NavigationMethodQualifier extends ResourceQualifier {
31 public static final String NAME = "Navigation Method";
33 private NavigationMethod mValue;
36 * Navigation Method enum.
38 public static enum NavigationMethod {
39 DPAD("dpad", "D-pad"), //$NON-NLS-1$
40 TRACKBALL("trackball", "Trackball"), //$NON-NLS-1$
41 WHEEL("wheel", "Wheel"), //$NON-NLS-1$
42 NONAV("nonav", "No Navigation"); //$NON-NLS-1$
44 private String mValue;
45 private String mDisplay;
47 private NavigationMethod(String value, String display) {
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 public static NavigationMethod getEnum(String value) {
58 for (NavigationMethod orient : values()) {
59 if (orient.mValue.equals(value)) {
67 public String getValue() {
71 public String getDisplayValue() {
75 public static int getIndex(NavigationMethod value) {
77 for (NavigationMethod nav : values()) {
88 public static NavigationMethod getByIndex(int index) {
90 for (NavigationMethod value : values()) {
100 public NavigationMethodQualifier() {
104 public NavigationMethodQualifier(NavigationMethod value) {
108 public NavigationMethod getValue() {
113 public String getName() {
118 public String getShortName() {
124 public Image getIcon() {
125 return IconFactory.getInstance().getIcon("navpad"); //$NON-NLS-1$
129 public boolean isValid() {
130 return mValue != null;
134 public boolean checkAndSet(String value, FolderConfiguration config) {
135 NavigationMethod method = NavigationMethod.getEnum(value);
136 if (method != null) {
137 NavigationMethodQualifier qualifier = new NavigationMethodQualifier(method);
138 config.setNavigationMethodQualifier(qualifier);
146 public boolean equals(Object qualifier) {
147 if (qualifier instanceof NavigationMethodQualifier) {
148 return mValue == ((NavigationMethodQualifier)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$