001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.visualweb.css2;
042:
043: import java.awt.Graphics;
044:
045: import org.w3c.dom.Element;
046: import org.w3c.dom.Node;
047: import org.w3c.dom.NodeList;
048:
049: import org.netbeans.modules.visualweb.designer.DesignerUtils;
050: import org.netbeans.modules.visualweb.designer.WebForm;
051: import org.netbeans.modules.visualweb.designer.html.HtmlTag;
052:
053: /**
054: * FieldSetBox represents a <fieldset> tag, and
055: * a potential child <legend> tag
056: *
057: * TODO -- this class is NOT DONE!!
058: *
059: * @author Tor Norbye
060: */
061: public class FieldSetBox extends ContainerBox {
062:
063: /** Use the "getObjectBox" factory method instead */
064: private FieldSetBox(WebForm webform, Element element,
065: BoxType boxType, boolean inline, boolean replaced) {
066: super (webform, element, boxType, inline, replaced);
067: }
068:
069: /** Create a new framebox, or provide one from a cache */
070: public static CssBox getFieldSetBox(WebForm webform,
071: Element element, BoxType boxType, HtmlTag tag,
072: boolean inline) {
073: return new FieldSetBox(webform, element, boxType, inline, false);
074: }
075:
076: // Fieldsets get an automatic border
077: protected void initializeBorder() {
078: int defWidth = 1;
079: int defStyle = CssBorder.STYLE_SOLID;
080: border = CssBorder.getBorder(getElement(), defWidth, defStyle,
081: CssBorder.FRAME_UNSET);
082:
083: if (border != null) {
084: leftBorderWidth = border.getLeftBorderWidth();
085: topBorderWidth = border.getTopBorderWidth();
086: bottomBorderWidth = border.getBottomBorderWidth();
087: rightBorderWidth = border.getRightBorderWidth();
088: }
089:
090: // Create the field set label
091: considerDesignBorder();
092: }
093:
094: public void paint(Graphics g, int px, int py) {
095: super .paint(g, px, py);
096:
097: if (hidden) {
098: return;
099: }
100:
101: // Paint frame
102: //paintFacesWatermark(g, px+getX()+leftMargin, py+getY()+effectiveTopMargin);
103: }
104:
105: /** When building the box hierarchy, instead of adding content
106: * for children, add the string attribute content
107: */
108: protected void createChildren(CreateContext context) {
109: Element element = getElement();
110: if (element == null) {
111: return;
112: }
113:
114: NodeList list = element.getChildNodes();
115: int len = list.getLength();
116: setProbableChildCount(len);
117:
118: // Look for <legend> and special handle it
119: for (int i = 0; i < len; i++) {
120: org.w3c.dom.Node child = (org.w3c.dom.Node) list.item(i);
121:
122: if ((child.getNodeType() == Node.TEXT_NODE)
123: && COLLAPSE
124: && DesignerUtils.onlyWhitespace(child
125: .getNodeValue())) {
126: continue;
127: }
128:
129: addNode(context, child, null, null, null);
130: }
131:
132: /*
133:
134:
135: NodeList list = body.getChildNodes();
136: int len = list.getLength();
137: setProbableChildCount(len);
138:
139: for (int i = 0; i < len; i++) {
140: org.w3c.dom.Node child = (org.w3c.dom.Node) list.item(i);
141: if (child.getNodeType() == Node.TEXT_NODE
142: && COLLAPSE
143: && Utilities.onlyWhitespace(child.getNodeValue())) {
144: continue;
145: }
146: addNode(cc, child, null, null, null);
147: }
148:
149: fixedBoxes = cc.getFixedBoxes();
150: */
151: }
152: }
|