nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2004 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
david_williams | 5677702 | 2005-04-11 06:21:55 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.html.core.internal.contentmodel; |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 12 | |
| 13 | |
| 14 | |
| 15 | import java.util.Arrays; |
| 16 | |
david_williams | 4ad020f | 2005-04-18 08:00:30 +0000 | [diff] [blame] | 17 | import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; |
david_williams | c06c86f | 2005-03-18 18:23:41 +0000 | [diff] [blame] | 18 | import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; |
| 19 | import org.eclipse.wst.xml.core.internal.contentmodel.CMContent; |
| 20 | import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType; |
| 21 | import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; |
| 22 | import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap; |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * BUTTON. |
| 26 | */ |
| 27 | final class HedBUTTON extends HedFlowContainer { |
| 28 | |
| 29 | /** |
| 30 | */ |
| 31 | public HedBUTTON(ElementCollection collection) { |
| 32 | super(HTML40Namespace.ElementName.BUTTON, collection); |
| 33 | layoutType = LAYOUT_BLOCK; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * %attrs; |
| 38 | * %reserved; ... empty. |
| 39 | * (name CDATA #IMPLIED) |
| 40 | * (value CDATA #IMPLIED) |
| 41 | * (type (button|submit|reset) submit) ... should be defined locally. |
| 42 | * (disabled (disabled) #IMPLIED) |
| 43 | * (tabindex NUMBER #IMPLIED) |
| 44 | * (accesskey %Character; #IMPLIED) |
| 45 | * (onfocus %Script; #IMPLIED) |
| 46 | * (onblur %Script; #IMPLIED) |
| 47 | */ |
| 48 | protected void createAttributeDeclarations() { |
| 49 | if (attributes != null) |
| 50 | return; // already created. |
| 51 | if (attributeCollection == null) |
| 52 | return; // fatal |
| 53 | |
| 54 | attributes = new CMNamedNodeMapImpl(); |
| 55 | |
| 56 | // %attrs; |
| 57 | attributeCollection.getAttrs(attributes); |
| 58 | |
| 59 | String[] names = {HTML40Namespace.ATTR_NAME_NAME, HTML40Namespace.ATTR_NAME_VALUE, HTML40Namespace.ATTR_NAME_DISABLED, HTML40Namespace.ATTR_NAME_TABINDEX, HTML40Namespace.ATTR_NAME_ACCESSKEY, HTML40Namespace.ATTR_NAME_ONFOCUS, HTML40Namespace.ATTR_NAME_ONBLUR}; |
| 60 | attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); |
| 61 | |
| 62 | // (type (button|submit|reset) submit) ... should be defined locally. |
| 63 | HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); |
| 64 | String[] values = {HTML40Namespace.ATTR_VALUE_BUTTON, HTML40Namespace.ATTR_VALUE_SUBMIT, HTML40Namespace.ATTR_VALUE_RESET}; |
| 65 | atype.setEnumValues(values); |
| 66 | |
| 67 | HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(HTML40Namespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); |
| 68 | attributes.putNamedItem(HTML40Namespace.ATTR_NAME_TYPE, attr); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Exclusion. |
| 73 | * <code>FORM</code> has the exclusion. |
| 74 | * It is <code>FORM</code> itself. |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 75 | */ |
| 76 | public CMContent getExclusion() { |
| 77 | if (exclusion != null) |
| 78 | return exclusion; // already created. |
| 79 | if (elementCollection == null) |
| 80 | return null; // fatal |
| 81 | |
| 82 | exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); |
| 83 | String[] names = {HTML40Namespace.ElementName.A, HTML40Namespace.ElementName.FORM, HTML40Namespace.ElementName.ISINDEX, HTML40Namespace.ElementName.FIELDSET, HTML40Namespace.ElementName.IFRAME}; |
| 84 | elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); |
| 85 | elementCollection.getFormctrl(exclusion); |
| 86 | |
| 87 | return exclusion; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | */ |
| 92 | public CMNamedNodeMap getProhibitedAncestors() { |
| 93 | if (prohibitedAncestors != null) |
| 94 | return prohibitedAncestors; |
| 95 | |
| 96 | String[] names = {HTML40Namespace.ElementName.BUTTON}; |
| 97 | prohibitedAncestors = elementCollection.getDeclarations(names); |
| 98 | |
| 99 | return prohibitedAncestors; |
| 100 | } |
| 101 | } |