2 * Copyright (C) 2008 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.editors.descriptors;
19 import com.android.ide.eclipse.adt.internal.editors.ui.FlagValueCellEditor;
20 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode;
21 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
22 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiFlagAttributeNode;
23 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiListAttributeNode;
25 import org.eclipse.jface.viewers.CellEditor;
26 import org.eclipse.swt.widgets.Composite;
29 * Describes a text attribute that can only contains some predefined values.
30 * It is displayed by a {@link UiListAttributeNode}.
32 * Note: in Android resources, a "flag" is a list of fixed values where one or
33 * more values can be selected using an "or", e.g. "align='left|top'".
34 * By contrast, an "enum" is a list of fixed values of which only one can be
35 * selected at a given time, e.g. "gravity='right'".
37 * This class handles the "flag" case.
38 * The "enum" case is done using {@link ListAttributeDescriptor}.
40 public class FlagAttributeDescriptor extends TextAttributeDescriptor {
42 private String[] mNames;
45 * Creates a new {@link FlagAttributeDescriptor} which automatically gets its
46 * values from the FrameworkResourceManager.
48 public FlagAttributeDescriptor(String xmlLocalName, String uiName, String nsUri,
50 super(xmlLocalName, uiName, nsUri, tooltip);
54 * Creates a new {@link FlagAttributeDescriptor} which uses the provided values.
56 public FlagAttributeDescriptor(String xmlLocalName, String uiName, String nsUri,
57 String tooltip, String[] names) {
58 super(xmlLocalName, uiName, nsUri, tooltip);
63 * @return The initial names of the flags. Can be null, in which case the Framework
64 * resource parser should be checked.
66 public String[] getNames() {
71 * @return A new {@link UiListAttributeNode} linked to this descriptor.
74 public UiAttributeNode createUiNode(UiElementNode uiParent) {
75 return new UiFlagAttributeNode(this, uiParent);
78 // ------- IPropertyDescriptor Methods
81 public CellEditor createPropertyEditor(Composite parent) {
82 return new FlagValueCellEditor(parent);