1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 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 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 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. 15 */ 16 17 package com.android.ide.eclipse.adt.internal.editors.manifest.descriptors; 18 19 import com.android.ide.common.api.IAttributeInfo; 20 import com.android.ide.eclipse.adt.internal.editors.descriptors.TextAttributeDescriptor; 21 import com.android.ide.eclipse.adt.internal.editors.manifest.model.UiClassAttributeNode; 22 import com.android.ide.eclipse.adt.internal.editors.manifest.model.UiClassAttributeNode.IPostTypeCreationAction; 23 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode; 24 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; 25 import com.android.sdklib.SdkConstants; 26 27 /** 28 * Describes an XML attribute representing a class name. 29 * It is displayed by a {@link UiClassAttributeNode}. 30 */ 31 public class ClassAttributeDescriptor extends TextAttributeDescriptor { 32 33 /** Superclass of the class value. */ 34 private String mSuperClassName; 35 36 private IPostTypeCreationAction mPostCreationAction; 37 38 /** indicates if the class parameter is mandatory */ 39 boolean mMandatory; 40 41 private final boolean mDefaultToProjectOnly; 42 43 /** 44 * Creates a new {@link ClassAttributeDescriptor} 45 * @param superClassName the fully qualified name of the superclass of the class represented 46 * by the attribute. 47 * @param xmlLocalName The XML name of the attribute (case sensitive, with android: prefix). 48 * @param uiName The UI name of the attribute. Cannot be an empty string and cannot be null. 49 * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. 50 * See {@link SdkConstants#NS_RESOURCES} for a common value. 51 * @param tooltip A non-empty tooltip string or null. 52 * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. 53 * @param mandatory indicates if the class attribute is mandatory. 54 */ 55 public ClassAttributeDescriptor(String superClassName, 56 String xmlLocalName, 57 String uiName, 58 String nsUri, 59 String tooltip, 60 IAttributeInfo attrInfo, 61 boolean mandatory) { 62 super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); 63 mSuperClassName = superClassName; 64 mDefaultToProjectOnly = true; 65 } 66 67 /** 68 * Creates a new {@link ClassAttributeDescriptor} 69 * @param superClassName the fully qualified name of the superclass of the class represented 70 * by the attribute. 71 * @param postCreationAction the {@link IPostTypeCreationAction} to be executed on the 72 * newly created class. 73 * @param xmlLocalName The XML local name of the attribute (case sensitive). 74 * @param uiName The UI name of the attribute. Cannot be an empty string and cannot be null. 75 * @param nsUri The URI of the attribute. Can be null if attribute has no namespace. 76 * See {@link SdkConstants#NS_RESOURCES} for a common value. 77 * @param tooltip A non-empty tooltip string or null. 78 * @param attrInfo The {@link IAttributeInfo} of this attribute. Can't be null. 79 * @param mandatory indicates if the class attribute is mandatory. 80 * @param defaultToProjectOnly True if only classes from the sources of this project should 81 * be shown by default in the class browser. 82 */ 83 public ClassAttributeDescriptor(String superClassName, 84 IPostTypeCreationAction postCreationAction, 85 String xmlLocalName, 86 String uiName, 87 String nsUri, 88 String tooltip, 89 IAttributeInfo attrInfo, 90 boolean mandatory, 91 boolean defaultToProjectOnly) { 92 super(xmlLocalName, uiName, nsUri, tooltip, attrInfo); 93 mSuperClassName = superClassName; 94 mPostCreationAction = postCreationAction; 95 mDefaultToProjectOnly = defaultToProjectOnly; 96 } 97 98 /** 99 * @return A new {@link UiClassAttributeNode} linked to this descriptor. 100 */ 101 @Override 102 public UiAttributeNode createUiNode(UiElementNode uiParent) { 103 return new UiClassAttributeNode(mSuperClassName, mPostCreationAction, 104 mMandatory, this, uiParent, mDefaultToProjectOnly); 105 } 106 } 107