Probably obsoleted by contrib/genericnavigator, which should be more user-friendly
authorjglick@netbeans.org
Mon, 17 Jul 2006 11:38:13 -0400
changeset 176380d1971244160
parent 17637 8e7bf7621429
child 17639 588407182672
Probably obsoleted by contrib/genericnavigator, which should be more user-friendly
and better able to handle documents with parse errors (or simply missing DTDs).
Regexps are not as precise as an XML parser but this is probably less important than
ease of configuration and robustness against minor problems.
The official XML navigator panel is still pretty useless for real documents like XHTML.
xmlnavigation/.cvsignore
xmlnavigation/build.xml
xmlnavigation/manifest.mf
xmlnavigation/nbproject/.cvsignore
xmlnavigation/nbproject/project.properties
xmlnavigation/nbproject/project.xml
xmlnavigation/src/org/netbeans/modules/xmlnavigation/Bundle.properties
xmlnavigation/src/org/netbeans/modules/xmlnavigation/XMLNavigatorPanel.java
xmlnavigation/src/org/netbeans/modules/xmlnavigation/layer.xml
xmlnavigation/test/unit/src/org/netbeans/modules/xmlnavigation/XMLNavigatorPanelTest.java
     1.1 --- a/xmlnavigation/.cvsignore	Thu Jun 29 16:15:32 2006 -0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,1 +0,0 @@
     1.4 -build
     2.1 --- a/xmlnavigation/build.xml	Thu Jun 29 16:15:32 2006 -0400
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,5 +0,0 @@
     2.4 -<?xml version="1.0" encoding="UTF-8"?>
     2.5 -<project basedir="." default="netbeans" name="contrib/xmlnavigation">
     2.6 -    <description>Builds, tests, and runs the project org.netbeans.modules.xmlnavigation</description>
     2.7 -    <import file="../../nbbuild/templates/projectized.xml"/>
     2.8 -</project>
     3.1 --- a/xmlnavigation/manifest.mf	Thu Jun 29 16:15:32 2006 -0400
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,6 +0,0 @@
     3.4 -Manifest-Version: 1.0
     3.5 -OpenIDE-Module: org.netbeans.modules.xmlnavigation
     3.6 -OpenIDE-Module-Layer: org/netbeans/modules/xmlnavigation/layer.xml
     3.7 -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/xmlnavigation/Bundle.properties
     3.8 -OpenIDE-Module-Specification-Version: 1.2
     3.9 -
     4.1 --- a/xmlnavigation/nbproject/.cvsignore	Thu Jun 29 16:15:32 2006 -0400
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,1 +0,0 @@
     4.4 -private
     5.1 --- a/xmlnavigation/nbproject/project.properties	Thu Jun 29 16:15:32 2006 -0400
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,2 +0,0 @@
     5.4 -test.unit.cp.extra=\
     5.5 -    ${xml/api.dir}/modules/org-netbeans-api-xml.jar
     6.1 --- a/xmlnavigation/nbproject/project.xml	Thu Jun 29 16:15:32 2006 -0400
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,78 +0,0 @@
     6.4 -<?xml version="1.0" encoding="UTF-8"?>
     6.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
     6.6 -    <type>org.netbeans.modules.apisupport.project</type>
     6.7 -    <configuration>
     6.8 -        <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
     6.9 -            <code-name-base>org.netbeans.modules.xmlnavigation</code-name-base>
    6.10 -            <module-dependencies>
    6.11 -                <dependency>
    6.12 -                    <code-name-base>org.netbeans.api.xml</code-name-base>
    6.13 -                    <build-prerequisite/>
    6.14 -                    <compile-dependency/>
    6.15 -                    <run-dependency>
    6.16 -                        <release-version>1</release-version>
    6.17 -                        <specification-version>1.10</specification-version>
    6.18 -                    </run-dependency>
    6.19 -                </dependency>
    6.20 -                <dependency>
    6.21 -                    <code-name-base>org.netbeans.spi.navigator</code-name-base>
    6.22 -                    <build-prerequisite/>
    6.23 -                    <compile-dependency/>
    6.24 -                    <run-dependency>
    6.25 -                        <release-version>1</release-version>
    6.26 -                        <specification-version>1.0</specification-version>
    6.27 -                    </run-dependency>
    6.28 -                </dependency>
    6.29 -                <dependency>
    6.30 -                    <code-name-base>org.openide.awt</code-name-base>
    6.31 -                    <build-prerequisite/>
    6.32 -                    <compile-dependency/>
    6.33 -                    <run-dependency>
    6.34 -                        <specification-version>6.5</specification-version>
    6.35 -                    </run-dependency>
    6.36 -                </dependency>
    6.37 -                <dependency>
    6.38 -                    <code-name-base>org.openide.filesystems</code-name-base>
    6.39 -                    <build-prerequisite/>
    6.40 -                    <compile-dependency/>
    6.41 -                    <run-dependency>
    6.42 -                        <specification-version>6.2</specification-version>
    6.43 -                    </run-dependency>
    6.44 -                </dependency>
    6.45 -                <dependency>
    6.46 -                    <code-name-base>org.openide.loaders</code-name-base>
    6.47 -                    <build-prerequisite/>
    6.48 -                    <compile-dependency/>
    6.49 -                    <run-dependency>
    6.50 -                        <specification-version>5.5</specification-version>
    6.51 -                    </run-dependency>
    6.52 -                </dependency>
    6.53 -                <dependency>
    6.54 -                    <code-name-base>org.openide.nodes</code-name-base>
    6.55 -                    <build-prerequisite/>
    6.56 -                    <compile-dependency/>
    6.57 -                    <run-dependency>
    6.58 -                        <specification-version>6.5</specification-version>
    6.59 -                    </run-dependency>
    6.60 -                </dependency>
    6.61 -                <dependency>
    6.62 -                    <code-name-base>org.openide.text</code-name-base>
    6.63 -                    <build-prerequisite/>
    6.64 -                    <compile-dependency/>
    6.65 -                    <run-dependency>
    6.66 -                        <specification-version>6.5</specification-version>
    6.67 -                    </run-dependency>
    6.68 -                </dependency>
    6.69 -                <dependency>
    6.70 -                    <code-name-base>org.openide.util</code-name-base>
    6.71 -                    <build-prerequisite/>
    6.72 -                    <compile-dependency/>
    6.73 -                    <run-dependency>
    6.74 -                        <specification-version>6.4</specification-version>
    6.75 -                    </run-dependency>
    6.76 -                </dependency>
    6.77 -            </module-dependencies>
    6.78 -            <public-packages/>
    6.79 -        </data>
    6.80 -    </configuration>
    6.81 -</project>
     7.1 --- a/xmlnavigation/src/org/netbeans/modules/xmlnavigation/Bundle.properties	Thu Jun 29 16:15:32 2006 -0400
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,8 +0,0 @@
     7.4 -OpenIDE-Module-Display-Category=XML
     7.5 -OpenIDE-Module-Long-Description=\
     7.6 -    Shows a Navigator view for various kinds of XML documents. \
     7.7 -    Looks for certain attributes or element names to decide what are interesting items to show in the index. \
     7.8 -    Displays elements in document order, so appropriate as an outline for big documents of various kinds. \
     7.9 -    More or less works on XHTML; DocBook (including DocBook Slides); XSLT; XML Schema; XML Catalog; and miscellaneous other XML formats.
    7.10 -OpenIDE-Module-Name=XML Navigation
    7.11 -OpenIDE-Module-Short-Description=Provides a Navigator view for XML documents.
     8.1 --- a/xmlnavigation/src/org/netbeans/modules/xmlnavigation/XMLNavigatorPanel.java	Thu Jun 29 16:15:32 2006 -0400
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,354 +0,0 @@
     8.4 -/*
     8.5 - * The contents of this file are subject to the terms of the Common Development
     8.6 - * and Distribution License (the License). You may not use this file except in
     8.7 - * compliance with the License.
     8.8 - *
     8.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    8.10 - * or http://www.netbeans.org/cddl.txt.
    8.11 - *
    8.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
    8.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
    8.14 - * If applicable, add the following below the CDDL Header, with the fields
    8.15 - * enclosed by brackets [] replaced by your own identifying information:
    8.16 - * "Portions Copyrighted [year] [name of copyright owner]"
    8.17 - *
    8.18 - * The Original Software is NetBeans. The Initial Developer of the Original
    8.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
    8.20 - * Microsystems, Inc. All Rights Reserved.
    8.21 - */
    8.22 -
    8.23 -package org.netbeans.modules.xmlnavigation;
    8.24 -
    8.25 -import java.awt.Component;
    8.26 -import java.awt.EventQueue;
    8.27 -import java.awt.Toolkit;
    8.28 -import java.awt.event.ActionEvent;
    8.29 -import java.awt.event.KeyEvent;
    8.30 -import java.awt.event.MouseAdapter;
    8.31 -import java.awt.event.MouseEvent;
    8.32 -import java.io.IOException;
    8.33 -import java.io.StringReader;
    8.34 -import java.util.ArrayList;
    8.35 -import java.util.Arrays;
    8.36 -import java.util.Collection;
    8.37 -import java.util.List;
    8.38 -import java.util.Locale;
    8.39 -import javax.swing.AbstractAction;
    8.40 -import javax.swing.DefaultListCellRenderer;
    8.41 -import javax.swing.DefaultListModel;
    8.42 -import javax.swing.DefaultListSelectionModel;
    8.43 -import javax.swing.JComponent;
    8.44 -import javax.swing.JList;
    8.45 -import javax.swing.JScrollPane;
    8.46 -import javax.swing.KeyStroke;
    8.47 -import javax.swing.ListSelectionModel;
    8.48 -import javax.xml.parsers.ParserConfigurationException;
    8.49 -import javax.xml.parsers.SAXParser;
    8.50 -import javax.xml.parsers.SAXParserFactory;
    8.51 -import org.netbeans.api.xml.services.UserCatalog;
    8.52 -import org.netbeans.spi.navigator.NavigatorPanel;
    8.53 -import org.netbeans.spi.xml.cookies.DataObjectAdapters;
    8.54 -import org.openide.ErrorManager;
    8.55 -import org.openide.awt.MouseUtils;
    8.56 -import org.openide.cookies.LineCookie;
    8.57 -import org.openide.filesystems.FileUtil;
    8.58 -import org.openide.loaders.DataObject;
    8.59 -import org.openide.text.Line;
    8.60 -import org.openide.util.Lookup;
    8.61 -import org.openide.util.LookupEvent;
    8.62 -import org.openide.util.LookupListener;
    8.63 -import org.openide.util.RequestProcessor;
    8.64 -import org.xml.sax.Attributes;
    8.65 -import org.xml.sax.InputSource;
    8.66 -import org.xml.sax.Locator;
    8.67 -import org.xml.sax.SAXException;
    8.68 -import org.xml.sax.helpers.DefaultHandler;
    8.69 -
    8.70 -/**
    8.71 - * Displays an outline of an XML document.
    8.72 - * @author Jesse Glick
    8.73 - */
    8.74 -public final class XMLNavigatorPanel implements NavigatorPanel {
    8.75 -    
    8.76 -    private Lookup.Result selection;
    8.77 -    private final LookupListener selectionListener = new LookupListener() {
    8.78 -        public void resultChanged(LookupEvent ev) {
    8.79 -            display(selection.allInstances());
    8.80 -        }
    8.81 -    };
    8.82 -    private JComponent panel;
    8.83 -    private final DefaultListModel/*<Item>*/ listModel = new DefaultListModel();
    8.84 -    private ListSelectionModel/*<Item>*/ listSelectionModel;
    8.85 -    
    8.86 -    /**
    8.87 -     * Default constructor for layer.
    8.88 -     */
    8.89 -    public XMLNavigatorPanel() {}
    8.90 -    
    8.91 -    public String getDisplayName() {
    8.92 -        return "XML Outline"; // XXX I18N
    8.93 -    }
    8.94 -    
    8.95 -    public String getDisplayHint() {
    8.96 -        return "Displays an outline of interesting XML elements."; // XXX I18N
    8.97 -    }
    8.98 -    
    8.99 -    public JComponent getComponent() {
   8.100 -        if (panel == null) {
   8.101 -            listSelectionModel = new DefaultListSelectionModel();
   8.102 -            final JList/*<Item>*/ view = new JList(listModel);
   8.103 -            view.setSelectionModel(listSelectionModel);
   8.104 -            view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   8.105 -            view.addMouseListener(new MouseAdapter() {
   8.106 -                public void mouseClicked(MouseEvent e) {
   8.107 -                    if (MouseUtils.isDoubleClick(e)) {
   8.108 -                        int index = view.locationToIndex(e.getPoint());
   8.109 -                        open(index);
   8.110 -                    }
   8.111 -                }
   8.112 -            });
   8.113 -            view.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "open"); // NOI18N
   8.114 -            view.getActionMap().put("open", new AbstractAction() { // NOI18N
   8.115 -                public void actionPerformed(ActionEvent e) {
   8.116 -                    open(listSelectionModel.getLeadSelectionIndex());
   8.117 -                }
   8.118 -            });
   8.119 -            view.setCellRenderer(new ItemCellRenderer());
   8.120 -            panel = new JScrollPane(view) {
   8.121 -                public boolean requestFocusInWindow() {
   8.122 -                    boolean b = view.requestFocusInWindow();
   8.123 -                    if (!listModel.isEmpty() && listSelectionModel.isSelectionEmpty()) {
   8.124 -                        listSelectionModel.setSelectionInterval(0, 0);
   8.125 -                    }
   8.126 -                    return b;
   8.127 -                }
   8.128 -            };
   8.129 -        }
   8.130 -        return panel;
   8.131 -    }
   8.132 -    
   8.133 -    public void panelActivated(Lookup context) {
   8.134 -        selection = context.lookup(new Lookup.Template(DataObject.class));
   8.135 -        selection.addLookupListener(selectionListener);
   8.136 -        selectionListener.resultChanged(null);
   8.137 -        // XXX should also listen to changes in active Document and reparse after a short delay...
   8.138 -        // workaround: just switch tabs and back
   8.139 -    }
   8.140 -    
   8.141 -    public void panelDeactivated() {
   8.142 -        selection.removeLookupListener(selectionListener);
   8.143 -        selection = null;
   8.144 -    }
   8.145 -    
   8.146 -    public Lookup getLookup() {
   8.147 -        return null;
   8.148 -    }
   8.149 -    
   8.150 -    private void display(Collection/*<DataObject>*/ selectedFiles) {
   8.151 -        listModel.clear();
   8.152 -        // Show list of targets for selected file:
   8.153 -        if (selectedFiles.size() == 1) {
   8.154 -            final DataObject d = (DataObject) selectedFiles.iterator().next();
   8.155 -            final InputSource src = DataObjectAdapters.inputSource(d);
   8.156 -            // Parse asynch, since it can take a second or two for a big file.
   8.157 -            RequestProcessor.getDefault().post(new Runnable() {
   8.158 -                public void run() {
   8.159 -                    try {
   8.160 -                        final Item[] items = parse(src, d);
   8.161 -                        EventQueue.invokeLater(new Runnable() {
   8.162 -                            public void run() {
   8.163 -                                for (int i = 0; i < items.length; i++) {
   8.164 -                                    listModel.addElement(items[i]);
   8.165 -                                }
   8.166 -                            }
   8.167 -                        });
   8.168 -                    } catch (Exception e) { // IOException, SAXParseException
   8.169 -                        ErrorManager.getDefault().log(ErrorManager.WARNING,
   8.170 -                            "Could not parse " + FileUtil.getFileDisplayName(d.getPrimaryFile()) + ": " + e.toString());
   8.171 -                    }
   8.172 -                }
   8.173 -            });
   8.174 -        }
   8.175 -    }
   8.176 -    
   8.177 -    private void open(int listIndex) {
   8.178 -        if (listIndex < 0 || listIndex >= listModel.size()) {
   8.179 -            Toolkit.getDefaultToolkit().beep();
   8.180 -            return;
   8.181 -        }
   8.182 -        Item item = (Item) listModel.get(listIndex);
   8.183 -        item.open();
   8.184 -    }
   8.185 -
   8.186 -    /**
   8.187 -     * Names of elements which should be considered headers.
   8.188 -     */
   8.189 -    private static final List/*<String>*/ HEADERS = Arrays.asList(new String[] {
   8.190 -        "h1", // NOI18N
   8.191 -        "h2", // NOI18N
   8.192 -        "h3", // NOI18N
   8.193 -        "h4", // NOI18N
   8.194 -        "h5", // NOI18N
   8.195 -        "h6", // NOI18N
   8.196 -    });
   8.197 -    /**
   8.198 -     * Names of elements whose parent elements should be considered headers.
   8.199 -     */
   8.200 -    private static final List/*<String>*/ TITLES = Arrays.asList(new String[] {
   8.201 -        "title", // NOI18N
   8.202 -    });
   8.203 -    /**
   8.204 -     * Names of attributes which if on elements should be considered headers.
   8.205 -     */
   8.206 -    private static final List/*<String>*/ NAMES = Arrays.asList(new String[] {
   8.207 -        "name", // NOI18N
   8.208 -        "id", // NOI18N
   8.209 -        // For XSL:
   8.210 -        "match", // NOI18N
   8.211 -    });
   8.212 -    
   8.213 -    static Item[] parse(InputSource src, final DataObject d) throws IOException, SAXException, ParserConfigurationException {
   8.214 -        final List/*<Item>*/ items = new ArrayList();
   8.215 -        SAXParserFactory factory = SAXParserFactory.newInstance();
   8.216 -        SAXParser parser = factory.newSAXParser();
   8.217 -        class Handler extends DefaultHandler {
   8.218 -            private Locator locator;
   8.219 -            // XXX besides line, need to know file: if a complex doc includes others w/
   8.220 -            // entity refs, need to jump to subfiles!
   8.221 -            private int line = -1;
   8.222 -            private String element = null;
   8.223 -            private StringBuffer text = null;
   8.224 -            public void setDocumentLocator(Locator l) {
   8.225 -                locator = l;
   8.226 -            }
   8.227 -            // XXX do not match <xsl:call-template name="..."/>!
   8.228 -            // Better style would perhaps be to have include/exclude lists
   8.229 -            // which would be pairs of NS-qualified element name plus attr name... TBD.
   8.230 -            public void startElement(String uri, String localname, String qname, Attributes attr) throws SAXException {
   8.231 -                text = null;
   8.232 -                if (HEADERS.contains(qname.toLowerCase(Locale.ENGLISH))) {
   8.233 -                    text = new StringBuffer();
   8.234 -                    line = locator.getLineNumber();
   8.235 -                    element = null;
   8.236 -                    //System.err.println("HEADERS match on " + qname + " at " + line);
   8.237 -                } else if (TITLES.contains(qname.toLowerCase(Locale.ENGLISH))) {
   8.238 -                    if (element != null) {
   8.239 -                        text = new StringBuffer();
   8.240 -                        //System.err.println("TITLES match on " + qname + " inside " + element + " at line " + line);
   8.241 -                    }
   8.242 -                } else {
   8.243 -                    line = locator.getLineNumber();
   8.244 -                    element = qname;
   8.245 -                    //System.err.println("plain element " + element + " at " + line);
   8.246 -                    for (int i = 0; i < attr.getLength(); i++) {
   8.247 -                        String name = attr.getQName(i);
   8.248 -                        if (NAMES.contains(name.toLowerCase(Locale.ENGLISH))) {
   8.249 -                            //System.err.println("NAMES match on " + name + " in " + element + " at " + line);
   8.250 -                            items.add(new Item(attr.getValue(i), element, name, line, d));
   8.251 -                            break;
   8.252 -                        }
   8.253 -                    }
   8.254 -                }
   8.255 -            }
   8.256 -            public void endElement(String uri, String localname, String qname) throws SAXException {
   8.257 -                if (text != null) {
   8.258 -                    //System.err.println("ending " + qname + " in " + element + " with " + text + " at " + line);
   8.259 -                    assert line != -1;
   8.260 -                    if (element == null) {
   8.261 -                        element = qname;
   8.262 -                    }
   8.263 -                    items.add(new Item(text.toString(), element, qname, line, d));
   8.264 -                    text = null;
   8.265 -                    element = null;
   8.266 -                    line = -1;
   8.267 -                }
   8.268 -            }
   8.269 -            public void characters(char[] ch, int start, int length) throws SAXException {
   8.270 -                if (text != null) {
   8.271 -                    text.append(ch, start, length);
   8.272 -                }
   8.273 -            }
   8.274 -            public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
   8.275 -                InputSource known;
   8.276 -                try {
   8.277 -                    known = UserCatalog.getDefault().getEntityResolver().resolveEntity(publicId, systemId);
   8.278 -                } catch (IOException e) {
   8.279 -                    throw new SAXException(e);
   8.280 -                }
   8.281 -                if (known != null) {
   8.282 -                    // In our IDE catalog, cool.
   8.283 -                    //System.err.println("known match on " + publicId + " / " + systemId + ": " + known.getSystemId());
   8.284 -                    return known;
   8.285 -                } else if (systemId.startsWith("http")) { // NOI18N
   8.286 -                    // Do not load any remote entities or DTDs, too slow.
   8.287 -                    //System.err.println("No known match for remote " + publicId + " / " + systemId);
   8.288 -                    return new InputSource(new StringReader(""));
   8.289 -                } else {
   8.290 -                    // Maybe a local file: URL or similar.
   8.291 -                    return null;
   8.292 -                }
   8.293 -            }
   8.294 -            /*
   8.295 -            public void skippedEntity(String name) throws SAXException {
   8.296 -                System.err.println("skipped: " + name);
   8.297 -            }
   8.298 -             */
   8.299 -        }
   8.300 -        parser.parse(src, new Handler());
   8.301 -        return (Item[]) items.toArray(new Item[items.size()]);
   8.302 -    }
   8.303 -    
   8.304 -    static final class Item {
   8.305 -        private final String label;
   8.306 -        private final String element;
   8.307 -        private final String header;
   8.308 -        private final int line;
   8.309 -        private final DataObject d;
   8.310 -        public Item(String label, String element, String header, int line, DataObject d) {
   8.311 -            this.label = label;
   8.312 -            this.element = element;
   8.313 -            this.header = header;
   8.314 -            this.line = line /* SAX is 1-based */ - 1;
   8.315 -            this.d = d;
   8.316 -        }
   8.317 -        public String getLabel() {
   8.318 -            return label;
   8.319 -        }
   8.320 -        public String getElement() {
   8.321 -            return element;
   8.322 -        }
   8.323 -        public String getHeader() {
   8.324 -            return header;
   8.325 -        }
   8.326 -        int getLine() {
   8.327 -            return line;
   8.328 -        }
   8.329 -        public void open() {
   8.330 -            LineCookie cookie = (LineCookie) d.getCookie(LineCookie.class);
   8.331 -            if (cookie == null) {
   8.332 -                Toolkit.getDefaultToolkit().beep();
   8.333 -                return;
   8.334 -            }
   8.335 -            Line l;
   8.336 -            try {
   8.337 -                l = cookie.getLineSet().getCurrent(line);
   8.338 -            } catch (IndexOutOfBoundsException ex) {
   8.339 -                Toolkit.getDefaultToolkit().beep();
   8.340 -                return;
   8.341 -            }
   8.342 -            l.show(Line.SHOW_TOFRONT);
   8.343 -        }
   8.344 -    }
   8.345 -    
   8.346 -    private static final class ItemCellRenderer extends DefaultListCellRenderer {
   8.347 -        
   8.348 -        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   8.349 -            Item item = (Item) value;
   8.350 -            // XXX could also display element and/or header in a different color (use HTMLRenderer)
   8.351 -            String text = item.getLabel();
   8.352 -            return super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus);
   8.353 -        }
   8.354 -        
   8.355 -    }
   8.356 -    
   8.357 -}
     9.1 --- a/xmlnavigation/src/org/netbeans/modules/xmlnavigation/layer.xml	Thu Jun 29 16:15:32 2006 -0400
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,36 +0,0 @@
     9.4 -<?xml version="1.0" encoding="UTF-8"?>
     9.5 -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
     9.6 -<filesystem>
     9.7 -    <folder name="Navigator">
     9.8 -        <folder name="Panels">
     9.9 -            <file name="org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.instance"/>
    9.10 -            <folder name="text">
    9.11 -                <folder name="xml">
    9.12 -                    <file name="org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.shadow">
    9.13 -                        <attr name="originalFile" stringvalue="Navigator/Panels/org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.instance"/>
    9.14 -                    </file>
    9.15 -                </folder>
    9.16 -            </folder>
    9.17 -            <folder name="application">
    9.18 -                <folder name="xhtml+xml">
    9.19 -                    <file name="org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.shadow">
    9.20 -                        <attr name="originalFile" stringvalue="Navigator/Panels/org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.instance"/>
    9.21 -                    </file>
    9.22 -                </folder>
    9.23 -                <!-- Poor behavior with these currently, "XML View" does better (though not ideal):
    9.24 -                <folder name="x-schema+xml">
    9.25 -                    <file name="org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.shadow">
    9.26 -                        <attr name="originalFile" stringvalue="Navigator/Panels/org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.instance"/>
    9.27 -                    </file>
    9.28 -                </folder>
    9.29 -                <folder name="xslt+xml">
    9.30 -                    <file name="org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.shadow">
    9.31 -                        <attr name="originalFile" stringvalue="Navigator/Panels/org-netbeans-modules-xmlnavigation-XMLNavigatorPanel.instance"/>
    9.32 -                    </file>
    9.33 -                </folder>
    9.34 -                -->
    9.35 -            </folder>
    9.36 -        </folder>
    9.37 -    </folder>
    9.38 -</filesystem>
    9.39 -
    10.1 --- a/xmlnavigation/test/unit/src/org/netbeans/modules/xmlnavigation/XMLNavigatorPanelTest.java	Thu Jun 29 16:15:32 2006 -0400
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,144 +0,0 @@
    10.4 -/*
    10.5 - * The contents of this file are subject to the terms of the Common Development
    10.6 - * and Distribution License (the License). You may not use this file except in
    10.7 - * compliance with the License.
    10.8 - *
    10.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
   10.10 - * or http://www.netbeans.org/cddl.txt.
   10.11 - *
   10.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
   10.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
   10.14 - * If applicable, add the following below the CDDL Header, with the fields
   10.15 - * enclosed by brackets [] replaced by your own identifying information:
   10.16 - * "Portions Copyrighted [year] [name of copyright owner]"
   10.17 - *
   10.18 - * The Original Software is NetBeans. The Initial Developer of the Original
   10.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
   10.20 - * Microsystems, Inc. All Rights Reserved.
   10.21 - */
   10.22 -
   10.23 -package org.netbeans.modules.xmlnavigation;
   10.24 -
   10.25 -import java.io.IOException;
   10.26 -import java.io.StringReader;
   10.27 -import junit.framework.Assert;
   10.28 -import org.netbeans.api.xml.services.UserCatalog;
   10.29 -import org.netbeans.junit.MockServices;
   10.30 -import org.netbeans.junit.NbTestCase;
   10.31 -import org.xml.sax.EntityResolver;
   10.32 -import org.xml.sax.InputSource;
   10.33 -import org.xml.sax.SAXException;
   10.34 -
   10.35 -/**
   10.36 - * Test functionality of {@link XMLNavigatorPanel}.
   10.37 - * @author Jesse Glick
   10.38 - */
   10.39 -public class XMLNavigatorPanelTest extends NbTestCase {
   10.40 -
   10.41 -    public XMLNavigatorPanelTest(String name) {
   10.42 -       super(name);
   10.43 -    }
   10.44 -    
   10.45 -    protected void setUp() throws Exception {
   10.46 -        super.setUp();
   10.47 -        MockServices.setServices(new Class[] {TestCatalog.class});
   10.48 -    }
   10.49 -    
   10.50 -    public void testParseXHTML() throws Exception {
   10.51 -        assertEquals("correct parse of some XHTML sections",
   10.52 -            "1[h1/h1]Intro\n" +
   10.53 -            "6[h1/h1]Main Section\n" +
   10.54 -            "7[h2/h2]Subsection\n" +
   10.55 -            "10[h1/h1]Conclusion\n",
   10.56 -            itemsSummary(parse(
   10.57 -                "<body>\n" + // 0
   10.58 -                "<h1>Intro</h1>\n" + // 1
   10.59 -                "<p>\n" + // 2
   10.60 -                "Hello!\n" + // 3
   10.61 -                "</p>\n" + // 4
   10.62 -                "\n" + // 5
   10.63 -                "<h1>Main Section</h1>\n" + // 6
   10.64 -                "<h2>Subsection</h2>\n" + // 7
   10.65 -                "<p>More...</p>\n" + // 8
   10.66 -                "\n" + // 9
   10.67 -                "<h1>Conclusion</h1>\n" + // 10
   10.68 -                "\n" + // 11
   10.69 -                "</body>\n" // 12
   10.70 -                )));
   10.71 -        assertEquals("correct parse of some XHTML anchors",
   10.72 -            "1[a/name]here\n" +
   10.73 -            "6[a/id]there\n",
   10.74 -            itemsSummary(parse(
   10.75 -                "<body>\n" + // 0
   10.76 -                "<a name='here'>Stuff...</a>\n" + // 1
   10.77 -                "<p>\n" + // 2
   10.78 -                "Hello!\n" + // 3
   10.79 -                "</p>\n" + // 4
   10.80 -                "\n" + // 5
   10.81 -                "<a id='there'>More stuff...</a>\n" + // 6
   10.82 -                "</body>\n" // 7
   10.83 -                )));
   10.84 -        // XXX should try to also parse e.g. <h3><a name="section">Title here...</a></h3>
   10.85 -    }
   10.86 -    
   10.87 -    public void testParseWithUnresolvedEntityRefs() throws Exception {
   10.88 -        assertEquals("handles unref'd entities when we have a DOCTYPE",
   10.89 -            "1[section/title]First\n" +
   10.90 -            "4[section/title]Second\n",
   10.91 -            itemsSummary(parse(
   10.92 -                "<!DOCTYPE article PUBLIC 'whatever' 'http://wherever/'> <article>\n" + // 0
   10.93 -                " <section><title>First</title>\n" + // 1
   10.94 -                "  <para>&whatever;</para>\n" + // 2
   10.95 -                " </section>\n" + // 3
   10.96 -                " <section><title>Second</title>\n" + // 4
   10.97 -                "  <para>Stuff...</para>\n" + // 5
   10.98 -                " </section>\n" + // 6
   10.99 -                "</article>\n" // 17
  10.100 -                )));
  10.101 -        /*XXX cannot figure out how to make this pass; even http://apache.org/xml/features/continue-after-fatal-error does not work!
  10.102 -        assertEquals("handles unref'd entities when we have no DOCTYPE",
  10.103 -            "1[section/title]First\n" +
  10.104 -            "4[section/title]Second\n",
  10.105 -            itemsSummary(parse(
  10.106 -                "<article>\n" + // 0
  10.107 -                " <section><title>First</title>\n" + // 1
  10.108 -                "  <para>&whatever;</para>\n" + // 2
  10.109 -                " </section>\n" + // 3
  10.110 -                " <section><title>Second</title>\n" + // 4
  10.111 -                "  <para>Stuff...</para>\n" + // 5
  10.112 -                " </section>\n" + // 6
  10.113 -                "</article>\n" // 17
  10.114 -                )));
  10.115 -         */
  10.116 -    }
  10.117 -    
  10.118 -    private static XMLNavigatorPanel.Item[] parse(String xml) throws Exception {
  10.119 -        return XMLNavigatorPanel.parse(new InputSource(new StringReader(xml)), null);
  10.120 -    }
  10.121 -    
  10.122 -    private static String itemsSummary(XMLNavigatorPanel.Item[] items) {
  10.123 -        StringBuffer b = new StringBuffer();
  10.124 -        for (int i = 0; i < items.length; i++) {
  10.125 -            b.append(items[i].getLine());
  10.126 -            b.append('[');
  10.127 -            b.append(items[i].getElement());
  10.128 -            b.append('/');
  10.129 -            b.append(items[i].getHeader());
  10.130 -            b.append(']');
  10.131 -            b.append(items[i].getLabel());
  10.132 -            b.append('\n');
  10.133 -        }
  10.134 -        return b.toString();
  10.135 -    }
  10.136 -    
  10.137 -    public static final class TestCatalog extends UserCatalog implements EntityResolver {
  10.138 -        public TestCatalog() {}
  10.139 -        public EntityResolver getEntityResolver() {
  10.140 -            return this;
  10.141 -        }
  10.142 -        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
  10.143 -            return null;
  10.144 -        }
  10.145 -    }
  10.146 -    
  10.147 -}