1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ParcelDescriptorChildren.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package org
.openoffice
.netbeans
.modules
.office
.nodes
;
34 import javax
.swing
.event
.ChangeEvent
;
35 import javax
.swing
.event
.ChangeListener
;
37 import org
.w3c
.dom
.NodeList
;
38 import org
.w3c
.dom
.Element
;
40 import org
.openide
.nodes
.*;
41 import org
.openoffice
.netbeans
.modules
.office
.actions
.ParcelDescriptorParserCookie
;
43 /** List of children of a containing node.
44 * Remember to document what your permitted keys are!
48 public class ParcelDescriptorChildren
extends Children
.Keys
implements ChangeListener
{
50 private ParcelDescriptorParserCookie parserCookie
= null;
52 public ParcelDescriptorChildren(ParcelDescriptorParserCookie cookie
) {
53 parserCookie
= cookie
;
56 private void refreshKeys() {
60 if (parserCookie
== null ||
61 (nl
= parserCookie
.getScriptElements()) == null ||
62 (len
= nl
.getLength()) == 0) {
63 setKeys(Collections
.EMPTY_SET
);
67 ArrayList keys
= new ArrayList(len
);
68 for (int i
= 0; i
< len
; i
++)
73 protected void addNotify() {
75 parserCookie
.addChangeListener(this);
79 protected void removeNotify() {
81 parserCookie
.removeChangeListener(this);
82 setKeys(Collections
.EMPTY_SET
);
85 protected Node
[] createNodes(Object key
) {
86 Element el
= (Element
)key
;
87 System
.out
.println("element is: " + el
);
88 return new Node
[] {new ScriptNode(el
)};
91 public void stateChanged(ChangeEvent e
) {