blob: 6112d253ede59f5ad036029f8f5d87f014a7c2f3 [file] [log] [blame]
nitind958d79a2004-11-23 19:23:00 +00001/*******************************************************************************
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_williams56777022005-04-11 06:21:55 +000011package org.eclipse.wst.html.core.internal.contentmodel;
nitind958d79a2004-11-23 19:23:00 +000012
13
14
15import java.util.Arrays;
16
david_williams4ad020f2005-04-18 08:00:30 +000017import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace;
david_williamsc06c86f2005-03-18 18:23:41 +000018import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
19import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
20import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
21import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
22import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
nitind958d79a2004-11-23 19:23:00 +000023
24/**
25 * BUTTON.
26 */
27final 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.
nitind958d79a2004-11-23 19:23:00 +000075 */
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}