tidy integration (tidy.jar itself is NOT included - waiting BLD200301310100
authortor@netbeans.org
Thu, 30 Jan 2003 18:52:12 +0000
changeset 30607791edd9da5f
parent 3059 75a9dd2efa80
child 3061 b1f9214b68b7
tidy integration (tidy.jar itself is NOT included - waiting
for approval. Apparently it may take a while, so I'm committing
the rest of the code.)
tasklist.html/build.xml
tasklist.html/manifest.mf
tasklist.html/src/org/netbeans/modules/tasklist/html/Bundle.properties
tasklist.html/src/org/netbeans/modules/tasklist/html/RewriteAction.java
tasklist.html/src/org/netbeans/modules/tasklist/html/RewritePanel.form
tasklist.html/src/org/netbeans/modules/tasklist/html/RewritePanel.java
tasklist.html/src/org/netbeans/modules/tasklist/html/TidySuggester.java
tasklist.html/src/org/netbeans/modules/tasklist/html/docerror.xml
tasklist.html/src/org/netbeans/modules/tasklist/html/mf-layer.xml
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tasklist.html/build.xml	Thu Jan 30 18:52:12 2003 +0000
     1.3 @@ -0,0 +1,114 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!--
     1.6 +                Sun Public License Notice
     1.7 +
     1.8 +The contents of this file are subject to the Sun Public License
     1.9 +Version 1.0 (the "License"). You may not use this file except in
    1.10 +compliance with the License. A copy of the License is available at
    1.11 +http://www.sun.com/
    1.12 +
    1.13 +The Original Code is NetBeans. The Initial Developer of the Original
    1.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun
    1.15 +Microsystems, Inc. All Rights Reserved.
    1.16 +-->
    1.17 +
    1.18 +<project name="tasklist/html" default="netbeans" basedir=".">
    1.19 +
    1.20 +    <property name="nb_all" value="../.."/>
    1.21 +
    1.22 +    <taskdef name="makenbm" classname="org.netbeans.nbbuild.MakeNBM" classpath="${nb_all}/nbbuild/nbantext.jar"/>
    1.23 +    <taskdef name="genlist" classname="org.netbeans.nbbuild.MakeListOfNBM" classpath="${nb_all}/nbbuild/nbantext.jar"/>
    1.24 +    <taskdef name="locjar" classname="org.netbeans.nbbuild.LocalizedJar" classpath="${nb_all}/nbbuild/nbantext.jar"/>
    1.25 +
    1.26 +    <property name="nbm_alias" value="nb_ide"/>
    1.27 +    <property name="homepage.base" value="netbeans.org"/>
    1.28 +    <property name="dist.base" value="www.netbeans.org/download/nbms/40"/>
    1.29 +    <property name="license.file" value="${nb_all}/nbbuild/standard-nbm-license.txt"/>
    1.30 +
    1.31 +    <!-- TODO Remove this when the module is part of the full tasklist build -->
    1.32 +    <property name="build.compiler.debug" value="on"/>
    1.33 +  
    1.34 +    <target name="init">
    1.35 +       <ant dir="external" target="unscramble"/>
    1.36 +    </target>
    1.37 +
    1.38 +    <target name="compile" depends="init">
    1.39 +        <javac srcdir="src" destdir="src" deprecation="${build.compiler.deprecation}" debug="${build.compiler.debug}">
    1.40 +            <classpath>
    1.41 +                <pathelement location="${nb_all}/openide/openide-13javac-workaround.jar"/>
    1.42 +                <fileset dir="${nb_all}/openide/netbeans/lib">
    1.43 +                    <include name="openide*.jar" />
    1.44 +                </fileset>
    1.45 +                <!-- tasklist api -->
    1.46 +                <pathelement path="../api/src"/>
    1.47 +                <!-- html -->
    1.48 +                <pathelement path="../../html/netbeans/modules/html.jar"/>
    1.49 +                <!-- diff -->
    1.50 +                <pathelement path="../../diff/netbeans/modules/diff.jar"/>
    1.51 +                <!-- Tidy library -->
    1.52 +                <fileset dir="external">
    1.53 +                    <include name="Tidy*.jar"/>
    1.54 +                </fileset>
    1.55 +                <!-- tasklist core -->
    1.56 +                <pathelement path="../core/src"/>
    1.57 +                <pathelement path="../../openide/deprecated/netbeans/modules/autoload/openide-deprecated.jar"/> <!-- XXX -->
    1.58 +            </classpath>
    1.59 +        </javac>
    1.60 +    </target>
    1.61 +
    1.62 +    <target name="jars" depends="compile">
    1.63 +        <mkdir dir="netbeans/modules"/>
    1.64 +        <filter token="BUILD_NUMBER_SUBST" value="${buildnumber}"/>
    1.65 +        <copy file="manifest.mf" tofile="manifest-subst.mf" filtering="on"/>
    1.66 +        <locjar jarfile="netbeans/modules/tasklist-html.jar"
    1.67 +                manifest="manifest-subst.mf"
    1.68 +                basedir="src"
    1.69 +	        excludesfile="${nb_all}/nbbuild/standard-jar-excludes.txt"
    1.70 +	        compress="false">
    1.71 +            <locale name="ja"/>
    1.72 +        </locjar>
    1.73 +    </target>
    1.74 +
    1.75 +    <target name="netbeans" depends="jars">
    1.76 +        <genlist targetname="nbm" outputfiledir="netbeans"/>
    1.77 +    </target>
    1.78 +
    1.79 +    <target name="nbm" depends="netbeans">
    1.80 +        <makenbm file="../tasklist-html.nbm"
    1.81 +                 topdir="."
    1.82 +                 module="netbeans/modules/tasklist-html.jar"
    1.83 +                 homepage="http://tasklist.${homepage.base}/"
    1.84 +                 distribution="http://${dist.base}/tasklist-html.nbm"
    1.85 +                 needsrestart="false">
    1.86 +            <license file="${license.file}"/>
    1.87 +            <notification file="module-updates.txt"/>
    1.88 +            <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
    1.89 +        </makenbm>
    1.90 +    </target>
    1.91 +  
    1.92 +    <target name="clean">
    1.93 +        <delete>
    1.94 +            <fileset dir="src">
    1.95 +                <include name="**/*.class"/>
    1.96 +            </fileset>
    1.97 +        </delete>
    1.98 +        <delete file="manifest-subst.mf"/>
    1.99 +        <delete file="../tasklist-html.nbm"/>
   1.100 +        <delete dir="netbeans"/>
   1.101 +        <delete dir="Info"/>
   1.102 +        <delete dir="javadoc"/>
   1.103 +    </target>
   1.104 +
   1.105 +    <target name="release" depends="init">
   1.106 +       <mkdir dir="netbeans/modules/ext"/>
   1.107 +       <copy todir="netbeans/modules/ext">
   1.108 +         <fileset dir="external">
   1.109 +           <include name="Tidy*.jar"/>
   1.110 +         </fileset>
   1.111 +       </copy>
   1.112 +    </target>
   1.113 +
   1.114 +    <target name="javahelp">
   1.115 +    </target>
   1.116 +
   1.117 +</project>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tasklist.html/manifest.mf	Thu Jan 30 18:52:12 2003 +0000
     2.3 @@ -0,0 +1,10 @@
     2.4 +OpenIDE-Module-Specification-Version: 0.6
     2.5 +OpenIDE-Module: org.netbeans.modules.tasklist.html/1
     2.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/tasklist/html/Bundle.properties
     2.7 +OpenIDE-Module-Layer: org/netbeans/modules/tasklist/html/mf-layer.xml
     2.8 +OpenIDE-Module-IDE-Dependencies: IDE/1 > 3.14
     2.9 +OpenIDE-Module-Module-Dependencies: org.openide.src > 1.0, org.netbeans.modules.html/1 > 1.11, org.netbeans.api.tasklist/1 > 0.8.25, org.netbeans.modules.tasklist.core/1 > 0.8.22, org.netbeans.modules.diff/1 > 1.6
    2.10 +OpenIDE-Module-Implementation-Version: @BUILD_NUMBER_SUBST@
    2.11 +Class-Path: ext/Tidy-r7.jar
    2.12 +
    2.13 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tasklist.html/src/org/netbeans/modules/tasklist/html/Bundle.properties	Thu Jan 30 18:52:12 2003 +0000
     3.3 @@ -0,0 +1,36 @@
     3.4 +#                 Sun Public License Notice
     3.5 +# 
     3.6 +# The contents of this file are subject to the Sun Public License
     3.7 +# Version 1.0 (the "License"). You may not use this file except in
     3.8 +# compliance with the License. A copy of the License is available at
     3.9 +# http://www.sun.com/
    3.10 +# 
    3.11 +# The Original Code is NetBeans. The Initial Developer of the Original
    3.12 +# Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
    3.13 +# Microsystems, Inc. All Rights Reserved.
    3.14 +
    3.15 +# Localizable strings from module's manifest
    3.16 +OpenIDE-Module-Name=HTML Suggestion Provider
    3.17 +OpenIDE-Module-Display-Category=Task List
    3.18 +OpenIDE-Module-Short-Description=Provides HTML error suggestions
    3.19 +OpenIDE-Module-Long-Description=\
    3.20 +This module lists problems in HTML documents as identified by the \
    3.21 +"tidy" utility from W3C.
    3.22 +
    3.23 +HINT_doc_error=HTML Problems
    3.24 +Rewrite=Rewrite...
    3.25 +Preview=Preview...
    3.26 +
    3.27 +TITLE_diff=Rewrite Diff
    3.28 +DiffBefore=Before
    3.29 +DiffAfter=After
    3.30 +
    3.31 +ConvertXHTML=Convert HTML to xHTML
    3.32 +ReplaceFont=Replace font, nobr and center tags by CSS
    3.33 +Lowercase=Lower case tags
    3.34 +Uppercase=Upper case tags
    3.35 +OmitOptional=Omit optional end tags
    3.36 +Indent=Indent element content
    3.37 +WrapCol=Wrap at column:
    3.38 +RewriteSettings=Select Rewrite Document Settings:
    3.39 +TITLE_rewrite=Rewrite Document Settings
    3.40 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tasklist.html/src/org/netbeans/modules/tasklist/html/RewriteAction.java	Thu Jan 30 18:52:12 2003 +0000
     4.3 @@ -0,0 +1,281 @@
     4.4 +/*
     4.5 + *                 Sun Public License Notice
     4.6 + *
     4.7 + * The contents of this file are subject to the Sun Public License
     4.8 + * Version 1.0 (the "License"). You may not use this file except in
     4.9 + * compliance with the License. A copy of the License is available at
    4.10 + * http://www.sun.com/
    4.11 + *
    4.12 + * The Original Code is NetBeans. The Initial Developer of the Original
    4.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
    4.14 + * Microsystems, Inc. All Rights Reserved.
    4.15 + */
    4.16 +
    4.17 +package org.netbeans.modules.tasklist.html;
    4.18 +
    4.19 +import java.awt.Component;
    4.20 +import java.awt.Dialog;
    4.21 +import java.util.List;
    4.22 +import java.util.ArrayList;
    4.23 +import javax.swing.JButton;
    4.24 +import javax.swing.JCheckBox;
    4.25 +import org.openide.text.Line;
    4.26 +import org.openide.loaders.DataObject;
    4.27 +import java.io.*;
    4.28 +import org.openide.ErrorManager;
    4.29 +
    4.30 +import javax.swing.text.*;
    4.31 +import org.openide.DialogDescriptor;
    4.32 +import org.openide.DialogDisplayer;
    4.33 +import org.openide.NotifyDescriptor;
    4.34 +import org.openide.awt.Actions;
    4.35 +import org.openide.nodes.Node;
    4.36 +import org.openide.util.HelpCtx;
    4.37 +import org.openide.util.NbBundle;
    4.38 +import org.openide.util.actions.NodeAction;
    4.39 +import org.openide.util.actions.CallableSystemAction;
    4.40 +
    4.41 +import org.netbeans.modules.html.*;
    4.42 +import org.netbeans.api.diff.*;
    4.43 +
    4.44 +import org.netbeans.modules.tasklist.core.*;
    4.45 +import org.netbeans.api.tasklist.*;
    4.46 +
    4.47 +import org.w3c.tidy.*;
    4.48 +
    4.49 +/**
    4.50 + * Rewrite the document
    4.51 + * <p>
    4.52 + *
    4.53 + * @author Tor Norbye
    4.54 + */
    4.55 +
    4.56 +public class RewriteAction extends NodeAction 
    4.57 +     implements Report.ErrorReporter  {
    4.58 +
    4.59 +    public void reportError(int line, int col, boolean error, String message) {
    4.60 +        //System.err.println("reportError(" + line + ", " + col + ", " + error + ", " + message + ")");
    4.61 +    }
    4.62 +
    4.63 +    protected boolean enable(Node[] node) {
    4.64 +        if ((node == null) || (node.length != 1)) {
    4.65 +            return false;
    4.66 +        }
    4.67 +        Suggestion item = (Suggestion)TaskNode.getTask(node[0]);
    4.68 +        if (item == null) {
    4.69 +            return false;
    4.70 +        }
    4.71 +        Line l = item.getLine();
    4.72 +        if (l == null) {
    4.73 +            return false;
    4.74 +        }        
    4.75 +        return true;
    4.76 +    }
    4.77 +
    4.78 +    private TidyRunner tidy = null;
    4.79 +
    4.80 +    protected void performAction(Node[] node) {
    4.81 +        // Figure out which data object the node is associated
    4.82 +        // with.
    4.83 +               // XXX Later I could store this in the Suggestion
    4.84 +               // rather than relying on the Line object (since
    4.85 +               // for example category nodes don't have Line objects)
    4.86 +               // (e.g. the suggestion manager would associate the
    4.87 +               // data object with the node)
    4.88 +        SuggestionManager manager =  SuggestionManager.getDefault();
    4.89 +        Suggestion item = (Suggestion)TaskNode.getTask(node[0]);
    4.90 +        Line l = item.getLine();
    4.91 +        Document doc = TLUtils.getDocument(l);
    4.92 +        if (doc == null) {
    4.93 +            return; // XXX signal error?
    4.94 +        }
    4.95 +
    4.96 +        DataObject dobj = l.getDataObject();
    4.97 +        boolean isHTML = TidySuggester.isHTML(dobj);
    4.98 +        boolean isJSP = false;
    4.99 +        boolean isXML = false;
   4.100 +        if (!isHTML) {
   4.101 +            isJSP = TidySuggester.isJSP(dobj);
   4.102 +            if (!isJSP) {
   4.103 +                isXML = TidySuggester.isXML(dobj);
   4.104 +            }
   4.105 +        }
   4.106 +        if (!(isHTML || isJSP || isXML)) {
   4.107 +            return;
   4.108 +        }
   4.109 +
   4.110 +        // Set configuration settings
   4.111 +        if (tidy == null) {
   4.112 +            tidy = new TidyRunner();
   4.113 +        }
   4.114 +        Configuration config = tidy.getConfiguration();
   4.115 +        config.XmlTags = isXML;
   4.116 +
   4.117 +        RewritePanel panel = new RewritePanel(this, doc, dobj);
   4.118 +        panel.setXHTML(config.xHTML);
   4.119 +        panel.setWrapCol(config.wraplen);
   4.120 +        panel.setOmit(config.HideEndTags);
   4.121 +        panel.setUpper(config.UpperCaseTags);
   4.122 +        panel.setIndent(config.IndentContent);
   4.123 +        panel.setReplace(config.MakeClean);
   4.124 +        panel.setXML(config.XmlTags);
   4.125 +        DialogDescriptor d = new DialogDescriptor(panel,
   4.126 +                    NbBundle.getMessage(RewriteAction.class,
   4.127 +                    "TITLE_rewrite")); // NOI18N
   4.128 +        d.setModal(true);
   4.129 +        d.setMessageType(NotifyDescriptor.PLAIN_MESSAGE);
   4.130 +        d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
   4.131 +        Dialog dlg = DialogDisplayer.getDefault().createDialog(d);
   4.132 +        dlg.pack();
   4.133 +        dlg.show();
   4.134 +        if (d.getValue() != NotifyDescriptor.OK_OPTION) {
   4.135 +            return;
   4.136 +        }
   4.137 +
   4.138 +        config.xHTML = panel.getXHTML();
   4.139 +        config.MakeClean = panel.getReplace();
   4.140 +        config.IndentContent = panel.getIndent();
   4.141 +        config.SmartIndent = panel.getIndent();
   4.142 +        config.UpperCaseTags = panel.getUpper();
   4.143 +        config.HideEndTags = panel.getOmit();
   4.144 +        config.wraplen = panel.getWrapCol();
   4.145 +
   4.146 +        String rewritten = rewrite(doc);
   4.147 +
   4.148 +        try {
   4.149 +            // TODO Instead of a two-step process, use replaceSelection
   4.150 +            // to perform a single step replacement
   4.151 +            doc.remove(0, doc.getLength());
   4.152 +            doc.insertString(0, rewritten, null);
   4.153 +        } catch (BadLocationException e) {
   4.154 +            ErrorManager.getDefault().notify(e);
   4.155 +        }
   4.156 +        Suggestion s = (Suggestion)node[0].getCookie(Suggestion.class);
   4.157 +        if (s != null) {
   4.158 +            SuggestionProvider provider = s.getProvider();
   4.159 +            if ((provider != null) && (provider instanceof TidySuggester)) {
   4.160 +                ((TidySuggester)provider).rescan();
   4.161 +            }
   4.162 +        }
   4.163 +    }
   4.164 +    
   4.165 +    private String rewrite(Document doc) {
   4.166 +        InputStream input = null;
   4.167 +        try {
   4.168 +            String text = doc.getText(0, doc.getLength());
   4.169 +            input = new StringBufferInputStream(text);
   4.170 +        } catch (BadLocationException e) {
   4.171 +            ErrorManager.getDefault().
   4.172 +                notify(ErrorManager.WARNING, e);
   4.173 +            return "";
   4.174 +        }
   4.175 +        StringBuffer sb = new StringBuffer(doc.getLength()+500);
   4.176 +        OutputStream output = new StringBufferOutputStream(sb);
   4.177 +            
   4.178 +        try {
   4.179 +            tidy.parse(input, output, this, true);
   4.180 +        } catch (FileNotFoundException fnfe) {
   4.181 +            ErrorManager.getDefault().notify(fnfe);
   4.182 +        } catch (IOException ioe) {
   4.183 +            ErrorManager.getDefault().notify(ioe);
   4.184 +        }
   4.185 +        return sb.toString();
   4.186 +    }
   4.187 +
   4.188 +    void preview(RewritePanel panel, Document doc, DataObject dobj) {
   4.189 +        Configuration config = tidy.getConfiguration();
   4.190 +        config.xHTML = panel.getXHTML();
   4.191 +        config.MakeClean = panel.getReplace();
   4.192 +        config.IndentContent = panel.getIndent();
   4.193 +        config.SmartIndent = panel.getIndent();
   4.194 +        config.UpperCaseTags = panel.getUpper();
   4.195 +        config.HideEndTags = panel.getOmit();
   4.196 +        config.wraplen = panel.getWrapCol();
   4.197 +
   4.198 +        String before;
   4.199 +        try {
   4.200 +            before = doc.getText(0, doc.getLength());
   4.201 +        } catch (BadLocationException e) {
   4.202 +            ErrorManager.getDefault().
   4.203 +                notify(ErrorManager.WARNING, e);
   4.204 +            return;
   4.205 +        }
   4.206 +        String rewritten = rewrite(doc);
   4.207 +        String mime = dobj.getPrimaryFile().getMIMEType();
   4.208 +        diff(before, rewritten, mime);
   4.209 +
   4.210 +    }
   4.211 +
   4.212 +    void diff(String before, String after, String mime) {
   4.213 +        Diff diff = Diff.getDefault();
   4.214 +        if (diff == null) {
   4.215 +            // TODO Check for this condition and hide the Diff button
   4.216 +            // if this is the case
   4.217 +            return ;
   4.218 +        }
   4.219 +
   4.220 +        String beforeDesc = NbBundle.getMessage(RewriteAction.class,
   4.221 +                            "DiffBefore"); // NOI18N
   4.222 +        String afterDesc = NbBundle.getMessage(RewriteAction.class,
   4.223 +                            "DiffAfter"); // NOI18N
   4.224 +        String beforeTitle = beforeDesc; 
   4.225 +        String afterTitle = afterDesc; 
   4.226 +
   4.227 +        Component tp = null;
   4.228 +        try {
   4.229 +            tp = diff.createDiff(beforeDesc, beforeTitle,
   4.230 +                                 new StringReader(before),
   4.231 +                                 afterDesc, afterTitle,
   4.232 +                                 new StringReader(after),
   4.233 +                                 mime);
   4.234 +        } catch (IOException ioex) {
   4.235 +            ErrorManager.getDefault().notify(ioex);
   4.236 +            return ;
   4.237 +        }
   4.238 +        if (tp == null) {
   4.239 +            return;
   4.240 +        }
   4.241 +
   4.242 +        DialogDescriptor d = new DialogDescriptor(tp,
   4.243 +                    NbBundle.getMessage(RewriteAction.class,
   4.244 +                    "TITLE_diff")); // NOI18N
   4.245 +        d.setModal(true);
   4.246 +        d.setMessageType(NotifyDescriptor.PLAIN_MESSAGE);
   4.247 +        d.setOptionType(NotifyDescriptor.DEFAULT_OPTION);
   4.248 +        Dialog dlg = DialogDisplayer.getDefault().createDialog(d);
   4.249 +        dlg.pack();
   4.250 +        dlg.show();
   4.251 +    }
   4.252 +
   4.253 +
   4.254 +    public String getName() {
   4.255 +        return NbBundle.getMessage(RewriteAction.class,
   4.256 +                                   "Rewrite"); // NOI18N
   4.257 +    }
   4.258 +
   4.259 +    /*
   4.260 +    protected String iconResource() {
   4.261 +        return "org/netbeans/modules/tasklist/html/rewrite.gif"; // NOI18N
   4.262 +    }
   4.263 +    */
   4.264 +    
   4.265 +    public HelpCtx getHelpCtx() {
   4.266 +        return HelpCtx.DEFAULT_HELP;
   4.267 +        // If you will provide context help then use:
   4.268 +        // return new HelpCtx (NewTodoItemAction.class);
   4.269 +    }
   4.270 +
   4.271 +    // Grr... tidy uses input/output stream instead of input/output writer
   4.272 +    private class StringBufferOutputStream extends OutputStream {
   4.273 +        private StringBuffer sb;
   4.274 +        StringBufferOutputStream(StringBuffer sb) {
   4.275 +            this.sb = sb;
   4.276 +        }
   4.277 +
   4.278 +        public void write(int b) {
   4.279 +            sb.append((char)b);
   4.280 +        }
   4.281 +    }
   4.282 +
   4.283 +    
   4.284 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tasklist.html/src/org/netbeans/modules/tasklist/html/RewritePanel.form	Thu Jan 30 18:52:12 2003 +0000
     5.3 @@ -0,0 +1,146 @@
     5.4 +<?xml version="1.0" encoding="UTF-8" ?>
     5.5 +
     5.6 +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
     5.7 +  <NonVisualComponents>
     5.8 +    <Component class="javax.swing.ButtonGroup" name="caseButtonGroup">
     5.9 +    </Component>
    5.10 +  </NonVisualComponents>
    5.11 +  <Properties>
    5.12 +    <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
    5.13 +      <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
    5.14 +        <EmptyBorder bottom="11" left="12" right="11" top="12"/>
    5.15 +      </Border>
    5.16 +    </Property>
    5.17 +  </Properties>
    5.18 +
    5.19 +  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
    5.20 +  <SubComponents>
    5.21 +    <Component class="javax.swing.JLabel" name="jLabel1">
    5.22 +      <Properties>
    5.23 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.24 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="RewriteSettings" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
    5.25 +        </Property>
    5.26 +      </Properties>
    5.27 +      <Constraints>
    5.28 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
    5.29 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
    5.30 +        </Constraint>
    5.31 +      </Constraints>
    5.32 +    </Component>
    5.33 +    <Component class="javax.swing.JCheckBox" name="xhtmlCB">
    5.34 +      <Properties>
    5.35 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.36 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="ConvertXHTML" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
    5.37 +        </Property>
    5.38 +      </Properties>
    5.39 +      <Constraints>
    5.40 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
    5.41 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
    5.42 +        </Constraint>
    5.43 +      </Constraints>
    5.44 +    </Component>
    5.45 +    <Component class="javax.swing.JCheckBox" name="replaceCB">
    5.46 +      <Properties>
    5.47 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.48 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="ReplaceFont" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
    5.49 +        </Property>
    5.50 +      </Properties>
    5.51 +      <Constraints>
    5.52 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
    5.53 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
    5.54 +        </Constraint>
    5.55 +      </Constraints>
    5.56 +    </Component>
    5.57 +    <Component class="javax.swing.JRadioButton" name="lowerRB">
    5.58 +      <Properties>
    5.59 +        <Property name="selected" type="boolean" value="true"/>
    5.60 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.61 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="Lowercase" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
    5.62 +        </Property>
    5.63 +        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
    5.64 +          <ComponentRef name="caseButtonGroup"/>
    5.65 +        </Property>
    5.66 +      </Properties>
    5.67 +      <Constraints>
    5.68 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
    5.69 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
    5.70 +        </Constraint>
    5.71 +      </Constraints>
    5.72 +    </Component>
    5.73 +    <Component class="javax.swing.JRadioButton" name="upperRB">
    5.74 +      <Properties>
    5.75 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.76 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="Uppercase" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
    5.77 +        </Property>
    5.78 +        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
    5.79 +          <ComponentRef name="caseButtonGroup"/>
    5.80 +        </Property>
    5.81 +      </Properties>
    5.82 +      <Constraints>
    5.83 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
    5.84 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
    5.85 +        </Constraint>
    5.86 +      </Constraints>
    5.87 +    </Component>
    5.88 +    <Component class="javax.swing.JCheckBox" name="omitCB">
    5.89 +      <Properties>
    5.90 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
    5.91 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="OmitOptional" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
    5.92 +        </Property>
    5.93 +      </Properties>
    5.94 +      <Constraints>
    5.95 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
    5.96 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
    5.97 +        </Constraint>
    5.98 +      </Constraints>
    5.99 +    </Component>
   5.100 +    <Component class="javax.swing.JCheckBox" name="indentCB">
   5.101 +      <Properties>
   5.102 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   5.103 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="Indent" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
   5.104 +        </Property>
   5.105 +      </Properties>
   5.106 +      <Constraints>
   5.107 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
   5.108 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
   5.109 +        </Constraint>
   5.110 +      </Constraints>
   5.111 +    </Component>
   5.112 +    <Component class="javax.swing.JCheckBox" name="wrapCB">
   5.113 +      <Properties>
   5.114 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   5.115 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="WrapCol" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
   5.116 +        </Property>
   5.117 +      </Properties>
   5.118 +      <Constraints>
   5.119 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
   5.120 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
   5.121 +        </Constraint>
   5.122 +      </Constraints>
   5.123 +    </Component>
   5.124 +    <Component class="javax.swing.JTextField" name="wrapText">
   5.125 +      <Properties>
   5.126 +        <Property name="columns" type="int" value="3"/>
   5.127 +        <Property name="text" type="java.lang.String" value="68"/>
   5.128 +        <Property name="horizontalAlignment" type="int" value="11"/>
   5.129 +      </Properties>
   5.130 +      <Constraints>
   5.131 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
   5.132 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
   5.133 +        </Constraint>
   5.134 +      </Constraints>
   5.135 +    </Component>
   5.136 +    <Component class="javax.swing.JButton" name="previewButton">
   5.137 +      <Properties>
   5.138 +        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
   5.139 +          <ResourceString bundle="org/netbeans/modules/tasklist/html/Bundle.properties" key="Preview" replaceFormat="NbBundle.getMessage(RewritePanel.class, &quot;{key}&quot;)); // NOI18N("/>
   5.140 +        </Property>
   5.141 +      </Properties>
   5.142 +      <Constraints>
   5.143 +        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
   5.144 +          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
   5.145 +        </Constraint>
   5.146 +      </Constraints>
   5.147 +    </Component>
   5.148 +  </SubComponents>
   5.149 +</Form>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tasklist.html/src/org/netbeans/modules/tasklist/html/RewritePanel.java	Thu Jan 30 18:52:12 2003 +0000
     6.3 @@ -0,0 +1,253 @@
     6.4 +/*
     6.5 + *                 Sun Public License Notice
     6.6 + * 
     6.7 + * The contents of this file are subject to the Sun Public License
     6.8 + * Version 1.0 (the "License"). You may not use this file except in
     6.9 + * compliance with the License. A copy of the License is available at
    6.10 + * http://www.sun.com/
    6.11 + * 
    6.12 + * The Original Code is NetBeans. The Initial Developer of the Original
    6.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun
    6.14 + * Microsystems, Inc. All Rights Reserved.
    6.15 + */
    6.16 +
    6.17 +package org.netbeans.modules.tasklist.html;
    6.18 +
    6.19 +import java.awt.*;
    6.20 +import javax.swing.*;
    6.21 +import javax.swing.text.*;
    6.22 +import javax.swing.event.*;
    6.23 +import java.awt.event.*;
    6.24 +import org.openide.loaders.DataObject;
    6.25 +
    6.26 +import org.openide.util.NbBundle;
    6.27 +
    6.28 +/**
    6.29 + * Confirmation panel before launching an HTML rewrite;
    6.30 + * provide the user the capability to set some of jtidy's
    6.31 + * options
    6.32 + * <p>
    6.33 + * @todo Add option to show the new file in a merge dialog?
    6.34 + *
    6.35 + * @author  Tor Norbye
    6.36 + */
    6.37 +public class RewritePanel extends javax.swing.JPanel 
    6.38 +     implements ActionListener {
    6.39 +    
    6.40 +    private RewriteAction action;
    6.41 +    private Document doc;
    6.42 +    private DataObject dobj;
    6.43 +
    6.44 +    /** Creates new form RewritePanel */
    6.45 +    public RewritePanel(RewriteAction action, Document doc, DataObject dobj) {
    6.46 +        this.action = action;
    6.47 +        this.doc = doc;
    6.48 +        this.dobj = dobj;
    6.49 +        initComponents();
    6.50 +        xhtmlCB.addActionListener(this);
    6.51 +        previewButton.addActionListener(this);
    6.52 +    }
    6.53 +
    6.54 +    public void actionPerformed(ActionEvent evt) {
    6.55 +        if (evt.getSource() == xhtmlCB) {
    6.56 +            // Cannot choose uppercase tags or strip-end-tags
    6.57 +            // on XML mode
    6.58 +            boolean xml = xhtmlCB.isSelected();
    6.59 +            if (upperRB.isSelected()) {
    6.60 +                upperRB.setSelected(false);
    6.61 +                lowerRB.setSelected(true);
    6.62 +            }
    6.63 +            upperRB.setEnabled(!xml);
    6.64 +            if (omitCB.isSelected()) {
    6.65 +                omitCB.setSelected(false);
    6.66 +            }
    6.67 +            omitCB.setEnabled(!xml);
    6.68 +        } else if (evt.getSource() == previewButton) {
    6.69 +            action.preview(this, doc, dobj);
    6.70 +        }
    6.71 +    }
    6.72 +    
    6.73 +    /** This method is called from within the constructor to
    6.74 +     * initialize the form.
    6.75 +     * WARNING: Do NOT modify this code. The content of this method is
    6.76 +     * always regenerated by the Form Editor.
    6.77 +     */
    6.78 +    private void initComponents() {//GEN-BEGIN:initComponents
    6.79 +        java.awt.GridBagConstraints gridBagConstraints;
    6.80 +
    6.81 +        caseButtonGroup = new javax.swing.ButtonGroup();
    6.82 +        jLabel1 = new javax.swing.JLabel();
    6.83 +        xhtmlCB = new javax.swing.JCheckBox();
    6.84 +        replaceCB = new javax.swing.JCheckBox();
    6.85 +        lowerRB = new javax.swing.JRadioButton();
    6.86 +        upperRB = new javax.swing.JRadioButton();
    6.87 +        omitCB = new javax.swing.JCheckBox();
    6.88 +        indentCB = new javax.swing.JCheckBox();
    6.89 +        wrapCB = new javax.swing.JCheckBox();
    6.90 +        wrapText = new javax.swing.JTextField();
    6.91 +        previewButton = new javax.swing.JButton();
    6.92 +
    6.93 +        setLayout(new java.awt.GridBagLayout());
    6.94 +
    6.95 +        setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(12, 12, 11, 11)));
    6.96 +        jLabel1.setText(NbBundle.getMessage(RewritePanel.class, "RewriteSettings")); // NOI18N();
    6.97 +        gridBagConstraints = new java.awt.GridBagConstraints();
    6.98 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    6.99 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.100 +        add(jLabel1, gridBagConstraints);
   6.101 +
   6.102 +        xhtmlCB.setText(NbBundle.getMessage(RewritePanel.class, "ConvertXHTML")); // NOI18N();
   6.103 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.104 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.105 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.106 +        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
   6.107 +        add(xhtmlCB, gridBagConstraints);
   6.108 +
   6.109 +        replaceCB.setText(NbBundle.getMessage(RewritePanel.class, "ReplaceFont")); // NOI18N();
   6.110 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.111 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.112 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.113 +        add(replaceCB, gridBagConstraints);
   6.114 +
   6.115 +        lowerRB.setSelected(true);
   6.116 +        lowerRB.setText(NbBundle.getMessage(RewritePanel.class, "Lowercase")); // NOI18N();
   6.117 +        caseButtonGroup.add(lowerRB);
   6.118 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.119 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.120 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.121 +        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
   6.122 +        add(lowerRB, gridBagConstraints);
   6.123 +
   6.124 +        upperRB.setText(NbBundle.getMessage(RewritePanel.class, "Uppercase")); // NOI18N();
   6.125 +        caseButtonGroup.add(upperRB);
   6.126 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.127 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.128 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.129 +        add(upperRB, gridBagConstraints);
   6.130 +
   6.131 +        omitCB.setText(NbBundle.getMessage(RewritePanel.class, "OmitOptional")); // NOI18N();
   6.132 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.133 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.134 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.135 +        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
   6.136 +        add(omitCB, gridBagConstraints);
   6.137 +
   6.138 +        indentCB.setText(NbBundle.getMessage(RewritePanel.class, "Indent")); // NOI18N();
   6.139 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.140 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.141 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.142 +        add(indentCB, gridBagConstraints);
   6.143 +
   6.144 +        wrapCB.setText(NbBundle.getMessage(RewritePanel.class, "WrapCol")); // NOI18N();
   6.145 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.146 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.147 +        add(wrapCB, gridBagConstraints);
   6.148 +
   6.149 +        wrapText.setColumns(3);
   6.150 +        wrapText.setText("68");
   6.151 +        wrapText.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
   6.152 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.153 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.154 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.155 +        add(wrapText, gridBagConstraints);
   6.156 +
   6.157 +        previewButton.setText(NbBundle.getMessage(RewritePanel.class, "Preview")); // NOI18N();
   6.158 +        gridBagConstraints = new java.awt.GridBagConstraints();
   6.159 +        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
   6.160 +        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
   6.161 +        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
   6.162 +        add(previewButton, gridBagConstraints);
   6.163 +
   6.164 +    }//GEN-END:initComponents
   6.165 +
   6.166 +    
   6.167 +    // Variables declaration - do not modify//GEN-BEGIN:variables
   6.168 +    private javax.swing.JCheckBox indentCB;
   6.169 +    private javax.swing.JCheckBox replaceCB;
   6.170 +    private javax.swing.JRadioButton upperRB;
   6.171 +    private javax.swing.JTextField wrapText;
   6.172 +    private javax.swing.JButton previewButton;
   6.173 +    private javax.swing.JCheckBox omitCB;
   6.174 +    private javax.swing.JCheckBox wrapCB;
   6.175 +    private javax.swing.JLabel jLabel1;
   6.176 +    private javax.swing.JCheckBox xhtmlCB;
   6.177 +    private javax.swing.ButtonGroup caseButtonGroup;
   6.178 +    private javax.swing.JRadioButton lowerRB;
   6.179 +    // End of variables declaration//GEN-END:variables
   6.180 +
   6.181 +   boolean getXHTML() {    
   6.182 +        return xhtmlCB.isSelected();
   6.183 +   }
   6.184 +
   6.185 +   boolean getIndent() {    
   6.186 +        return indentCB.isSelected();
   6.187 +   }
   6.188 +
   6.189 +   boolean getReplace() {
   6.190 +        return replaceCB.isSelected();
   6.191 +   }
   6.192 +
   6.193 +   boolean getOmit() {
   6.194 +        return omitCB.isSelected();
   6.195 +   }
   6.196 +
   6.197 +   boolean getUpper() {
   6.198 +        return upperRB.isSelected();
   6.199 +   }
   6.200 +
   6.201 +   int getWrapCol() {
   6.202 +       if (!wrapCB.isSelected()) {
   6.203 +           return 0;
   6.204 +       }
   6.205 +       String str = wrapText.getText().trim();
   6.206 +       int col = 68;
   6.207 +       try {
   6.208 +           col = Integer.parseInt(str);
   6.209 +       } catch (Exception e) {
   6.210 +       }
   6.211 +       return col;
   6.212 +   }
   6.213 +
   6.214 +    void setXHTML(boolean on) {    
   6.215 +        xhtmlCB.setSelected(on);
   6.216 +   }
   6.217 +
   6.218 +   void setIndent(boolean on) {    
   6.219 +        indentCB.setSelected(on);
   6.220 +   }
   6.221 +
   6.222 +   void setReplace(boolean on) {
   6.223 +        replaceCB.setSelected(on);
   6.224 +   }
   6.225 +
   6.226 +   void setOmit(boolean on) {
   6.227 +        omitCB.setSelected(on);
   6.228 +   }
   6.229 +
   6.230 +   void setUpper(boolean on) {
   6.231 +        upperRB.setSelected(on);
   6.232 +        lowerRB.setSelected(!on);
   6.233 +   }
   6.234 +
   6.235 +   void setWrapCol(int col) {
   6.236 +       if (col == 0) {
   6.237 +           wrapCB.setSelected(false);
   6.238 +       } else {
   6.239 +           wrapText.setText(Integer.toString(col));
   6.240 +           wrapCB.setSelected(true);
   6.241 +       }
   6.242 +   }
   6.243 +
   6.244 +   void setXML(boolean on) {
   6.245 +       // Document is XML - cannot "convert to" XML
   6.246 +       xhtmlCB.setEnabled(!on);
   6.247 +       if (on) {
   6.248 +           upperRB.setSelected(false);
   6.249 +           lowerRB.setSelected(true);
   6.250 +           omitCB.setSelected(false);
   6.251 +           omitCB.setEnabled(false);
   6.252 +           replaceCB.setSelected(false);
   6.253 +           replaceCB.setEnabled(false);
   6.254 +       }
   6.255 +   }
   6.256 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tasklist.html/src/org/netbeans/modules/tasklist/html/TidySuggester.java	Thu Jan 30 18:52:12 2003 +0000
     7.3 @@ -0,0 +1,219 @@
     7.4 +/*
     7.5 + *                 Sun Public License Notice
     7.6 + *
     7.7 + * The contents of this file are subject to the Sun Public License
     7.8 + * Version 1.0 (the "License"). You may not use this file except in
     7.9 + * compliance with the License. A copy of the License is available at
    7.10 + * http://www.sun.com/
    7.11 + *
    7.12 + * The Original Code is NetBeans. The Initial Developer of the Original
    7.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
    7.14 + * Microsystems, Inc. All Rights Reserved.
    7.15 + */
    7.16 +
    7.17 +package org.netbeans.modules.tasklist.html;
    7.18 +
    7.19 +import org.netbeans.api.tasklist.*;
    7.20 +
    7.21 +import javax.swing.text.*;
    7.22 +import javax.swing.event.*;
    7.23 +import java.awt.*;
    7.24 +import java.awt.event.*;
    7.25 +import javax.swing.*;
    7.26 +import java.io.*;
    7.27 +import java.util.List;
    7.28 +import java.util.ArrayList;
    7.29 +import org.openide.ErrorManager;
    7.30 +import org.openide.explorer.view.*;
    7.31 +
    7.32 +
    7.33 +import org.openide.filesystems.FileObject;
    7.34 +import org.openide.loaders.DataObject;
    7.35 +import org.openide.text.Line;
    7.36 +import org.openide.TopManager;
    7.37 +
    7.38 +import org.netbeans.modules.html.*;
    7.39 +
    7.40 +import org.w3c.tidy.*;
    7.41 +
    7.42 +import org.netbeans.modules.tasklist.core.TLUtils;
    7.43 +
    7.44 +
    7.45 +/**
    7.46 + * This class lists problems in HTML documents (based on a
    7.47 + * doc scan by the Tidy utility)
    7.48 + * <p>
    7.49 + *
    7.50 + * @author Tor Norbye
    7.51 + */
    7.52 +public class TidySuggester extends DocumentSuggestionProvider 
    7.53 +    implements Report.ErrorReporter  {
    7.54 +
    7.55 +    final private static String TYPE = "nb-html-errors"; // NOI18N
    7.56 +
    7.57 +    /**
    7.58 +     * Return the typenames of the suggestions that this provider
    7.59 +     * will create.
    7.60 +     * @return An array of string names. Should never be null. Most
    7.61 +     *  providers will create Suggestions of a single type, so it will
    7.62 +     *  be an array with one element.
    7.63 +     */
    7.64 +    public String[] getTypes() {
    7.65 +        return new String[] { TYPE };
    7.66 +    }
    7.67 +    
    7.68 +    /** Rescan the given document for suggestions. Typically called
    7.69 +     * when a document is shown or when a document is edited, but
    7.70 +     * could also be called for example when the document is
    7.71 +     * saved.
    7.72 +     * <p>
    7.73 +     * This method should register the suggestions with the
    7.74 +     * suggestion manager.
    7.75 +     * <p>
    7.76 +     * @param doc The document being scanned
    7.77 +     * @param dobj The Data Object for the file being scanned
    7.78 +     */
    7.79 +    public void rescan(Document doc, DataObject dobj) {
    7.80 +        dataobject = dobj;
    7.81 +        document = doc;
    7.82 +        List newTasks = scan(doc, dobj);
    7.83 +        SuggestionManager manager = SuggestionManager.getDefault();
    7.84 +
    7.85 +        if ((newTasks == null) && (showingTasks == null)) {
    7.86 +            return;
    7.87 +        }
    7.88 +        manager.register(TYPE, newTasks, showingTasks);
    7.89 +        showingTasks = newTasks;
    7.90 +    }
    7.91 +
    7.92 +    /** Package private rescan: called when you've rewritten
    7.93 +        the HTML for example */
    7.94 +    void rescan() {
    7.95 +        rescan(document, dataobject);
    7.96 +    }
    7.97 +
    7.98 +    static boolean isHTML(DataObject dobj) {
    7.99 +         // XXX instanceof not good - I've heard data object
   7.100 +         // instancing like this is going away. Look for
   7.101 +         // some kind of HTML related cookie instead?
   7.102 +         return dobj instanceof HtmlDataObject;
   7.103 +    }
   7.104 +
   7.105 +    static boolean isJSP(DataObject dobj) {
   7.106 +        String file = dobj.getPrimaryFile().getName();
   7.107 +        return file.endsWith(".jsp") || // NOI18N
   7.108 +            file.endsWith(".JSP") || // NOI18N
   7.109 +            // There are several data objects in web/core/.../jsploader
   7.110 +            // so just look for the jsploader package instead of
   7.111 +            // and actual classname
   7.112 +            (dobj.getClass().getName().indexOf("jsploader") != -1); // NOI18N
   7.113 +    }
   7.114 +
   7.115 +    static boolean isXML(DataObject dobj) {
   7.116 +        String file = dobj.getPrimaryFile().getName();
   7.117 +        return file.endsWith(".xml") || // NOI18N
   7.118 +            file.endsWith(".XML") || // NOI18N
   7.119 +            (dobj.getClass().getName().indexOf("XMLDataObject") != -1); // NOI18N
   7.120 +    }
   7.121 +                         
   7.122 +    
   7.123 +    /** Scan the given document for suggestions. Typically called
   7.124 +     * when a document is shown or when a document is edited, but
   7.125 +     * could also be called for example as part of a directory
   7.126 +     * scan for suggestions.
   7.127 +     * <p>
   7.128 +     * @param doc The document being hidden
   7.129 +     * @param dobj The Data Object for the file being opened
   7.130 +     * @return List of suggestions scanned for this document type
   7.131 +     *
   7.132 +     */
   7.133 +    public List scan(Document doc, final DataObject dobj) {
   7.134 +         // XXX instanceof not good - I've heard data object
   7.135 +         // instancing like this is going away. Look for
   7.136 +         // some kind of HTML related cookie instead?
   7.137 +         boolean isHTML = isHTML(dobj);
   7.138 +         boolean isJSP = false;
   7.139 +         boolean isXML = false;
   7.140 +         if (!isHTML) {
   7.141 +             isJSP = isJSP(dobj);
   7.142 +             if (!isJSP) {
   7.143 +                 isXML = isXML(dobj);
   7.144 +             }
   7.145 +         }
   7.146 +         if (!(isHTML || isJSP || isXML)) {
   7.147 +             return null;
   7.148 +         }
   7.149 +        SuggestionManager manager = SuggestionManager.getDefault();
   7.150 +        
   7.151 +        parseTasks = null;
   7.152 +        parseObject = dobj;
   7.153 +        if (manager.isEnabled(TYPE)) {
   7.154 +            InputStream input = null;
   7.155 +            try {
   7.156 +                String text = doc.getText(0, doc.getLength());
   7.157 +                input = new StringBufferInputStream(text);
   7.158 +            } catch (BadLocationException e) {
   7.159 +                ErrorManager.getDefault().
   7.160 +                    notify(ErrorManager.WARNING, e);
   7.161 +                return null;
   7.162 +            }
   7.163 +            
   7.164 +            if (tidy == null) {
   7.165 +                tidy = new TidyRunner();
   7.166 +            }
   7.167 +            Configuration config = tidy.getConfiguration();
   7.168 +            config.XmlTags = isXML;
   7.169 +
   7.170 +            try {
   7.171 +                tidy.parse(input, System.out, this, false);
   7.172 +            } catch (FileNotFoundException fnfe) {
   7.173 +                ErrorManager.getDefault().notify(fnfe);
   7.174 +            } catch (IOException ioe) {
   7.175 +                ErrorManager.getDefault().notify(ioe);
   7.176 +            }
   7.177 +        }
   7.178 +        return parseTasks;
   7.179 +    }
   7.180 +    /**
   7.181 +      * Remove items added by {@link rescan}.
   7.182 +     * <p>
   7.183 +     * @param document The document previously scanned
   7.184 +     * @param dataobject The Data Object for the file previously scanned
   7.185 +      */
   7.186 +     public void clear(Document document, DataObject dataobject) {
   7.187 +        // Remove existing items
   7.188 +        if (showingTasks != null) {
   7.189 +            SuggestionManager manager = SuggestionManager.getDefault();
   7.190 +            manager.register(TYPE, null, showingTasks);
   7.191 +            showingTasks = null;
   7.192 +        }
   7.193 +     }
   7.194 +
   7.195 +    /** The list of tasks we're currently showing in the tasklist */
   7.196 +    private List showingTasks = null;
   7.197 +
   7.198 +    /** List being built during a scan */
   7.199 +    private List parseTasks = null;
   7.200 +    private DataObject parseObject = null;
   7.201 +
   7.202 +    public void reportError(int line, int col, boolean error, String message) {
   7.203 +        //System.err.println("reportError(" + line + ", " + col + ", " + error + ", " + message + ")");
   7.204 +        
   7.205 +        SuggestionManager manager = SuggestionManager.getDefault();
   7.206 +        Suggestion s = manager.createSuggestion(TYPE,
   7.207 +                                                message,
   7.208 +                                                null,
   7.209 +                                                this);
   7.210 +        Line l = TLUtils.getLineByNumber(parseObject, line);
   7.211 +        s.setLine(l);
   7.212 +        s.setPriority(SuggestionPriority.NORMAL);
   7.213 +        if (parseTasks == null) {
   7.214 +            parseTasks = new ArrayList(30);
   7.215 +        }
   7.216 +        parseTasks.add(s);
   7.217 +    }
   7.218 +
   7.219 +    private DataObject dataobject = null;
   7.220 +    private Document document = null;
   7.221 +    private TidyRunner tidy = null;
   7.222 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/tasklist.html/src/org/netbeans/modules/tasklist/html/docerror.xml	Thu Jan 30 18:52:12 2003 +0000
     8.3 @@ -0,0 +1,25 @@
     8.4 +<?xml version="1.0"?>
     8.5 +<!--
     8.6 +                Sun Public License Notice
     8.7 +
     8.8 +The contents of this file are subject to the Sun Public License
     8.9 +Version 1.0 (the "License"). You may not use this file except in
    8.10 +compliance with the License. A copy of the License is available at
    8.11 +http://www.sun.com/
    8.12 +
    8.13 +The Original Code is NetBeans. The Initial Developer of the Original
    8.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
    8.15 +Microsystems, Inc. All Rights Reserved.
    8.16 +-->
    8.17 +
    8.18 +<!DOCTYPE type PUBLIC "-//NetBeans//DTD suggestion type 1.0//EN" "http://www.netbeans.org/dtds/suggestion-type-1_0.dtd">
    8.19 +<type
    8.20 +    name="nb-html-errors"
    8.21 +    description_key="HINT_doc_error"
    8.22 +    localizing_bundle="org.netbeans.modules.tasklist.html.Bundle"
    8.23 +    icon="nbresloc:org/netbeans/modules/tasklist/html/error.gif"
    8.24 +>
    8.25 +   <actions>
    8.26 +       <action class="org.netbeans.modules.tasklist.html.RewriteAction"/>
    8.27 +   </actions>
    8.28 +</type>
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/tasklist.html/src/org/netbeans/modules/tasklist/html/mf-layer.xml	Thu Jan 30 18:52:12 2003 +0000
     9.3 @@ -0,0 +1,31 @@
     9.4 +<?xml version="1.0"?>
     9.5 +<!--
     9.6 +                Sun Public License Notice
     9.7 +
     9.8 +The contents of this file are subject to the Sun Public License
     9.9 +Version 1.0 (the "License"). You may not use this file except in
    9.10 +compliance with the License. A copy of the License is available at
    9.11 +http://www.sun.com/
    9.12 +
    9.13 +The Original Code is NetBeans. The Initial Developer of the Original
    9.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
    9.15 +Microsystems, Inc. All Rights Reserved.
    9.16 +-->
    9.17 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.0//EN" "http://www.netbeans.org/dtds/filesystem-1_0.dtd">
    9.18 +
    9.19 +<filesystem>
    9.20 +    <folder name="Suggestions">
    9.21 +      <folder name="Types">
    9.22 +        <file name="org-netbeans-modules-tasklist-html-docerror.xml" url="docerror.xml"/>
    9.23 +      </folder>
    9.24 +    </folder>
    9.25 +
    9.26 +    <folder name="Services">
    9.27 +       <folder name="SuggestionProviders">
    9.28 +          <file name="org-netbeans-modules-tasklist-html-TidySuggester.instance">
    9.29 +             <attr name="instanceOf" stringvalue="org.netbeans.api.tasklist.SuggestionProvider"/>
    9.30 +             <attr name="instanceClass" stringvalue="org.netbeans.modules.tasklist.html.TidySuggester"/>
    9.31 +          </file>
    9.32 +       </folder>
    9.33 +   </folder>
    9.34 +</filesystem>