Java 类javax.swing.text.html.HTML 实例源码

项目:Neukoelln_SER316    文件:HTMLEditor.java   
public void actionPerformed(ActionEvent e) {
    String elName =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getName();
    /*
     * if ((elName.toUpperCase().equals("PRE")) ||
     * (elName.toUpperCase().equals("P-IMPLIED"))) {
     * editor.replaceSelection("\r"); return;
     */
    HTML.Tag tag = HTML.getTag(elName);
    if (elName.toUpperCase().equals("P-IMPLIED"))
        tag = HTML.Tag.IMPLIED;

    HTMLEditorKit.InsertHTMLTextAction hta =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertBR",
            "<br>",
            tag,
            HTML.Tag.BR);
    hta.actionPerformed(e);

    //insertHTML("<br>",editor.getCaretPosition());

}
项目:Wilmersdorf_SER316    文件:AltHTMLWriter.java   
/**
 * Writes out an end tag for the element.
 *
 * @param elem    an Element
 * @exception IOException on any I/O error
 */
protected void endTag(Element elem) throws IOException {
    if (synthesizedElement(elem)) {
        return;
    }
    if (matchNameAttribute(elem.getAttributes(), HTML.Tag.PRE)) {
        inPre = false;
    }

    // write out end tags for item on stack
    closeOutUnwantedEmbeddedTags(elem.getAttributes());
    if (inContent) {
        if (!newlineOutputed) {
            writeLineSeparator();
        }
        newlineOutputed = false;
        inContent = false;
    }
    indent();
    write('<');
    write('/');
    write(elem.getName());
    write('>');
    writeLineSeparator();
}
项目:Wilmersdorf_SER316    文件:AltHTMLWriter.java   
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
项目:SER316-Ingolstadt    文件:AltHTMLWriter.java   
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
项目:SER316-Aachen    文件:AltHTMLWriter.java   
/**
 * Writes out an end tag for the element.
 *
 * @param elem    an Element
 * @exception IOException on any I/O error
 */
protected void endTag(Element elem) throws IOException {
    if (synthesizedElement(elem)) {
        return;
    }
    if (matchNameAttribute(elem.getAttributes(), HTML.Tag.PRE)) {
        inPre = false;
    }

    // write out end tags for item on stack
    closeOutUnwantedEmbeddedTags(elem.getAttributes());
    if (inContent) {
        if (!newlineOutputed) {
            writeLineSeparator();
        }
        newlineOutputed = false;
        inContent = false;
    }
    indent();
    write('<');
    write('/');
    write(elem.getName());
    write('>');
    writeLineSeparator();
}
项目:SER316-Aachen    文件:HTMLEditor.java   
public void actionPerformed(ActionEvent e) {
    /*
     * String elName =
     * document.getParagraphElement(editor.getCaretPosition()).getName();
     * HTML.Tag tag = HTML.getTag(elName); if
     * (elName.toUpperCase().equals("P-IMPLIED")) tag =
     * HTML.Tag.IMPLIED; HTMLEditorKit.InsertHTMLTextAction hta = new
     * HTMLEditorKit.InsertHTMLTextAction("insertHR", " <hr> ", tag,
     * HTML.Tag.HR);
     */
    try {
        editorKit.insertHTML(
            document,
            editor.getCaretPosition(),
            "<hr>",
            0,
            0,
            HTML.Tag.HR);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
项目:incubator-netbeans    文件:SearchThreadJdk12.java   
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {

            if ( t == HTML.Tag.DT ) {
                where = IN_DT;
                currentDii = null;
            }
            else if ( t == HTML.Tag.A && where == IN_DT ) {
                where = IN_AREF;
                Object val = a.getAttribute( HTML.Attribute.HREF );
                if ( val != null ) {
                    hrefVal = val.toString();
                    currentDii = new DocIndexItem( null, null, contextURL, hrefVal );
                }
            }
            else if ( t == HTML.Tag.A && (where == IN_DESCRIPTION_SUFFIX || where == IN_DESCRIPTION) ) {
                // Just ignore
            }
            else if ( (t == HTML.Tag.B || t == HTML.Tag.SPAN)/* && where == IN_AREF */) {
                /*where = IN_AREF;*/
                // Ignore formatting
            }
            else {
                where = IN_BALAST;
            }
        }
项目:incubator-netbeans    文件:SearchThreadJdk12_japan.java   
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {

            if ( t == HTML.Tag.DT ) {
                where = IN_DT;
                currentDii = null;
            }
            else if ( t == HTML.Tag.A && where == IN_DT ) {
                where = IN_AREF;
                Object val = a.getAttribute( HTML.Attribute.HREF );
                if ( val != null ) {
                    hrefVal = val.toString();
                    currentDii = new DocIndexItem( null, null, contextURL, hrefVal );
                }
            }
            else if ( t == HTML.Tag.A && (where == IN_DESCRIPTION_SUFFIX || where == IN_DESCRIPTION) ) {
                // Just ignore
            }
            else if ( (t == HTML.Tag.B || t == HTML.Tag.SPAN) && where == IN_AREF ) {
                where = IN_AREF;
            }
            else {
                where = IN_BALAST;
            }
        }
项目:Dahlem_SER316    文件:AltHTMLWriter.java   
/**
 * Writes out an end tag for the element.
 *
 * @param elem    an Element
 * @exception IOException on any I/O error
 */
protected void endTag(Element elem) throws IOException {
    if (synthesizedElement(elem)) {
        return;
    }
    if (matchNameAttribute(elem.getAttributes(), HTML.Tag.PRE)) {
        inPre = false;
    }

    // write out end tags for item on stack
    closeOutUnwantedEmbeddedTags(elem.getAttributes());
    if (inContent) {
        if (!newlineOutputed) {
            writeLineSeparator();
        }
        newlineOutputed = false;
        inContent = false;
    }
    indent();
    write('<');
    write('/');
    write(elem.getName());
    write('>');
    writeLineSeparator();
}
项目:marathonv5    文件:REditorPane.java   
public void setHRef(int pos, Document doc) {
    hRef = null;
    text = null;
    if (!(doc instanceof HTMLDocument)) {
        return;
    }
    HTMLDocument hdoc = (HTMLDocument) doc;
    Iterator iterator = hdoc.getIterator(HTML.Tag.A);
    while (iterator.isValid()) {
        if (pos >= iterator.getStartOffset() && pos < iterator.getEndOffset()) {
            AttributeSet attributes = iterator.getAttributes();
            if (attributes != null && attributes.getAttribute(HTML.Attribute.HREF) != null) {
                try {
                    text = hdoc.getText(iterator.getStartOffset(), iterator.getEndOffset() - iterator.getStartOffset()).trim();
                    hRef = attributes.getAttribute(HTML.Attribute.HREF).toString();
                    setIndexOfHrefAndText(hdoc, pos, text, hRef);
                } catch (BadLocationException e) {
                    e.printStackTrace();
                }
                return;
            }
        }
        iterator.next();
    }
}
项目:SER316-Aachen    文件:AltHTMLWriter.java   
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
项目:SER316-Dresden    文件:HTMLEditor.java   
public void olActionB_actionPerformed(ActionEvent e) {
    String parentname =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getParentElement()
            .getName();
    HTML.Tag parentTag = HTML.getTag(parentname);
    HTMLEditorKit.InsertHTMLTextAction olAction =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertOL",
            "<ol><li></li></ol>",
            parentTag,
            HTML.Tag.OL);
    olAction.actionPerformed(e);
    //removeIfEmpty(document.getParagraphElement(editor.getCaretPosition()-1));
    list = true;
}
项目:SER316-Dresden    文件:HTMLEditor.java   
public void actionPerformed(ActionEvent e) {
    String elName =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getName();
    /*
     * if ((elName.toUpperCase().equals("PRE")) ||
     * (elName.toUpperCase().equals("P-IMPLIED"))) {
     * editor.replaceSelection("\r"); return;
     */
    HTML.Tag tag = HTML.getTag(elName);
    if (elName.toUpperCase().equals("P-IMPLIED"))
        tag = HTML.Tag.IMPLIED;

    HTMLEditorKit.InsertHTMLTextAction hta =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertBR",
            "<br>",
            tag,
            HTML.Tag.BR);
    hta.actionPerformed(e);

    //insertHTML("<br>",editor.getCaretPosition());

}
项目:Dahlem_SER316    文件:AltHTMLWriter.java   
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
项目:SER316-Ingolstadt    文件:AltHTMLWriter.java   
public RectangleRegionContainment(AttributeSet as) {
    int[] coords = extractCoords(as.getAttribute(HTML.Attribute.COORDS));

    percents = null;
    if (coords == null || coords.length != 4) {
        throw new RuntimeException("Unable to parse rectangular area");
    }
    else {
        x0 = coords[0];
        y0 = coords[1];
        x1 = coords[2];
        y1 = coords[3];
        if (x0 < 0 || y0 < 0 || x1 < 0 || y1 < 0) {
            percents = new float[4];
            lastWidth = lastHeight = -1;
            for (int counter = 0; counter < 4; counter++) {
                if (coords[counter] < 0) {
                    percents[counter] = Math.abs(coords[counter]) / 100.0f;
                }
                else {
                    percents[counter] = -1.0f;
                }
            }
        }
    }
}
项目:SER316-Dresden    文件:AltHTMLWriter.java   
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
项目:jdk8u-jdk    文件:TableView.java   
/**
 * Determines the number of columns occupied by
 * the table cell represented by given element.
 */
/*protected*/ int getColumnsOccupied(View v) {
    // PENDING(prinz) this code should be in the html
    // paragraph, but we can't add api to enable it.
    AttributeSet a = v.getElement().getAttributes();
    String s = (String) a.getAttribute(HTML.Attribute.COLSPAN);
    if (s != null) {
        try {
            return Integer.parseInt(s);
        } catch (NumberFormatException nfe) {
            // fall through to one column
        }
    }

    return 1;
}
项目:Reinickendorf_SER316    文件:AltHTMLWriter.java   
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
项目:SER316-Munich    文件:HTMLEditor.java   
public void olActionB_actionPerformed(ActionEvent e) {
    String parentname =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getParentElement()
            .getName();
    HTML.Tag parentTag = HTML.getTag(parentname);
    HTMLEditorKit.InsertHTMLTextAction olAction =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertOL",
            "<ol><li></li></ol>",
            parentTag,
            HTML.Tag.OL);
    olAction.actionPerformed(e);
    //removeIfEmpty(document.getParagraphElement(editor.getCaretPosition()-1));
    list = true;
}
项目:SER316-Munich    文件:HTMLEditor.java   
public void actionPerformed(ActionEvent e) {
    String elName =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getName();
    /*
     * if ((elName.toUpperCase().equals("PRE")) ||
     * (elName.toUpperCase().equals("P-IMPLIED"))) {
     * editor.replaceSelection("\r"); return;
     */
    HTML.Tag tag = HTML.getTag(elName);
    if (elName.toUpperCase().equals("P-IMPLIED"))
        tag = HTML.Tag.IMPLIED;

    HTMLEditorKit.InsertHTMLTextAction hta =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertBR",
            "<br>",
            tag,
            HTML.Tag.BR);
    hta.actionPerformed(e);

    //insertHTML("<br>",editor.getCaretPosition());

}
项目:jdk8u-jdk    文件:TableView.java   
/**
 * Determines the number of rows occupied by
 * the table cell represented by given element.
 */
/*protected*/ int getRowsOccupied(View v) {
    // PENDING(prinz) this code should be in the html
    // paragraph, but we can't add api to enable it.
    AttributeSet a = v.getElement().getAttributes();
    String s = (String) a.getAttribute(HTML.Attribute.ROWSPAN);
    if (s != null) {
        try {
            return Integer.parseInt(s);
        } catch (NumberFormatException nfe) {
            // fall through to one row
        }
    }

    return 1;
}
项目:Wilmersdorf_SER316    文件:AltHTMLWriter.java   
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
项目:Dahlem_SER316    文件:AltHTMLWriter.java   
/**
 * Writes out the content of the Option form element.
 * @param option  an Option
 * @exception IOException on any I/O error
 *
 */
protected void writeOption(Option option) throws IOException {

    indent();
    write('<');
    write("option");
    // PENDING: should this be changed to check for null first?
    Object value = option.getAttributes().getAttribute(HTML.Attribute.VALUE);
    if (value != null) {
        write(" value=" + value);
    }
    if (option.isSelected()) {
        write(" selected");
    }
    write('>');
    if (option.getLabel() != null) {
        write(option.getLabel());
    }
    writeLineSeparator();
}
项目:Reinickendorf_SER316    文件:AltHTMLWriter.java   
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
项目:Reinickendorf_SER316    文件:AltHTMLWriter.java   
public RectangleRegionContainment(AttributeSet as) {
    int[] coords = extractCoords(as.getAttribute(HTML.Attribute.COORDS));

    percents = null;
    if (coords == null || coords.length != 4) {
        throw new RuntimeException("Unable to parse rectangular area");
    }
    else {
        x0 = coords[0];
        y0 = coords[1];
        x1 = coords[2];
        y1 = coords[3];
        if (x0 < 0 || y0 < 0 || x1 < 0 || y1 < 0) {
            percents = new float[4];
            lastWidth = lastHeight = -1;
            for (int counter = 0; counter < 4; counter++) {
                if (coords[counter] < 0) {
                    percents[counter] = Math.abs(coords[counter]) / 100.0f;
                }
                else {
                    percents[counter] = -1.0f;
                }
            }
        }
    }
}
项目:SER316-Munich    文件:AltHTMLWriter.java   
public RectangleRegionContainment(AttributeSet as) {
    int[] coords = extractCoords(as.getAttribute(HTML.Attribute.COORDS));

    percents = null;
    if (coords == null || coords.length != 4) {
        throw new RuntimeException("Unable to parse rectangular area");
    }
    else {
        x0 = coords[0];
        y0 = coords[1];
        x1 = coords[2];
        y1 = coords[3];
        if (x0 < 0 || y0 < 0 || x1 < 0 || y1 < 0) {
            percents = new float[4];
            lastWidth = lastHeight = -1;
            for (int counter = 0; counter < 4; counter++) {
                if (coords[counter] < 0) {
                    percents[counter] = Math.abs(coords[counter]) / 100.0f;
                }
                else {
                    percents[counter] = -1.0f;
                }
            }
        }
    }
}
项目:OpenJSharp    文件:TableView.java   
/**
 * Determines the number of columns occupied by
 * the table cell represented by given element.
 */
/*protected*/ int getColumnsOccupied(View v) {
    // PENDING(prinz) this code should be in the html
    // paragraph, but we can't add api to enable it.
    AttributeSet a = v.getElement().getAttributes();
    String s = (String) a.getAttribute(HTML.Attribute.COLSPAN);
    if (s != null) {
        try {
            return Integer.parseInt(s);
        } catch (NumberFormatException nfe) {
            // fall through to one column
        }
    }

    return 1;
}
项目:Dahlem_SER316    文件:AltHTMLWriter.java   
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
项目:jdk8u-jdk    文件:TextComponentPrintable.java   
/**
 * Checks whether the document has frames. Only HTMLDocument might
 * have frames.
 *
 * @param document the {@code Document} to check
 * @return {@code true} if the {@code document} has frames
 */
private static boolean isFrameSetDocument(final Document document) {
    boolean ret = false;
    if (document instanceof HTMLDocument) {
        HTMLDocument htmlDocument = (HTMLDocument)document;
        if (htmlDocument.getIterator(HTML.Tag.FRAME).isValid()) {
            ret = true;
        }
    }
    return ret;
}
项目:SER316-Ingolstadt    文件:AltHTMLWriter.java   
/**
 * Returns true if the element is a
 * synthesized element.  Currently we are only testing
 * for the p-implied tag.
 */
protected boolean synthesizedElement(Element elem) {
    if (matchNameAttribute(elem.getAttributes(), HTML.Tag.IMPLIED)) {
        return true;
    }
    return false;
}
项目:Neukoelln_SER316    文件:HTMLEditor.java   
public void olActionB_actionPerformed(ActionEvent e) {
    String parentname =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getParentElement()
            .getName();
    HTML.Tag parentTag = HTML.getTag(parentname);
    HTMLEditorKit.InsertHTMLTextAction olAction =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertOL",
            "<ol><li></li></ol>",
            parentTag,
            HTML.Tag.OL);
    olAction.actionPerformed(e);
}
项目:Neukoelln_SER316    文件:HTMLEditor.java   
public void linkActionB_actionPerformed(ActionEvent e) {
    LinkDialog dlg = new LinkDialog(null);
    //dlg.setLocation(linkActionB.getLocationOnScreen());
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = this.getSize();
    Point loc = this.getLocationOnScreen();
    dlg.setLocation(
        (frmSize.width - dlgSize.width) / 2 + loc.x,
        (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    if (editor.getSelectedText() != null)
        dlg.txtDesc.setText(editor.getSelectedText());
    dlg.setVisible(true);
    if (dlg.CANCELLED)
        return;
    String aTag = "<a";
    if (dlg.txtURL.getText().length() > 0)
        aTag += " href=\"" + dlg.txtURL.getText() + "\"";
    if (dlg.txtName.getText().length() > 0)
        aTag += " name=\"" + dlg.txtName.getText() + "\"";
    if (dlg.txtTitle.getText().length() > 0)
        aTag += " title=\"" + dlg.txtTitle.getText() + "\"";
    if (dlg.chkNewWin.isSelected())
        aTag += " target=\"_blank\"";
    aTag += ">" + dlg.txtDesc.getText() + "</a>";
    if (editor.getCaretPosition() == document.getLength())
        aTag += "&nbsp;";
    editor.replaceSelection("");
    try {
        editorKit.insertHTML(
            document,
            editor.getCaretPosition(),
            aTag,
            0,
            0,
            HTML.Tag.A);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:Neukoelln_SER316    文件:HTMLEditor.java   
void setElementProperties(Element el, String id, String cls, String sty) {
    ElementDialog dlg = new ElementDialog(null);
    //dlg.setLocation(linkActionB.getLocationOnScreen());
    Dimension dlgSize = dlg.getPreferredSize();
    Dimension frmSize = this.getSize();
    Point loc = this.getLocationOnScreen();
    dlg.setLocation(
        (frmSize.width - dlgSize.width) / 2 + loc.x,
        (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setModal(true);
    dlg.setTitle(Local.getString("Object properties"));
    dlg.idField.setText(id);
    dlg.classField.setText(cls);
    dlg.styleField.setText(sty);
    // Uncommented, returns a simple p into the header... fix needed ?
    //dlg.header.setText(el.getName());
    dlg.setVisible(true);
    if (dlg.CANCELLED)
        return;
    SimpleAttributeSet attrs = new SimpleAttributeSet(el.getAttributes());
    if (dlg.idField.getText().length() > 0)
        attrs.addAttribute(HTML.Attribute.ID, dlg.idField.getText());
    if (dlg.classField.getText().length() > 0)
        attrs.addAttribute(HTML.Attribute.CLASS, dlg.classField.getText());
    if (dlg.styleField.getText().length() > 0)
        attrs.addAttribute(HTML.Attribute.STYLE, dlg.styleField.getText());
    document.setParagraphAttributes(el.getStartOffset(), 0, attrs, true);
}
项目:Wilmersdorf_SER316    文件:AltHTMLWriter.java   
/**
 * Creates and returns an instance of RegionContainment that can be
 * used to test if a particular point lies inside a region.
 */
protected RegionContainment createRegionContainment(AttributeSet attributes) {
    Object shape = attributes.getAttribute(HTML.Attribute.SHAPE);

    if (shape == null) {
        shape = "rect";
    }
    if (shape instanceof String) {
        String shapeString = ((String) shape).toLowerCase();
        RegionContainment rc = null;

        try {
            if (shapeString.equals("rect")) {
                rc = new RectangleRegionContainment(attributes);
            }
            else if (shapeString.equals("circle")) {
                rc = new CircleRegionContainment(attributes);
            }
            else if (shapeString.equals("poly")) {
                rc = new PolygonRegionContainment(attributes);
            }
            else if (shapeString.equals("default")) {
                rc = DefaultRegionContainment.sharedInstance();
            }
        }
        catch (RuntimeException re) {
            // Something wrong with attributes.
            rc = null;
        }
        return rc;
    }
    return null;
}
项目:SER316-Aachen    文件:HTMLEditor.java   
public void ulActionB_actionPerformed(ActionEvent e) {
    String parentname =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getParentElement()
            .getName();
    HTML.Tag parentTag = HTML.getTag(parentname);
    HTMLEditorKit.InsertHTMLTextAction ulAction =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertUL",
            "<ul><li></li></ul>",
            parentTag,
            HTML.Tag.UL);
    ulAction.actionPerformed(e);
    //removeIfEmpty(document.getParagraphElement(editor.getCaretPosition()-1));
    list = true;
    /*
     * Element pEl =
     * document.getParagraphElement(editor.getCaretPosition());
     * StringWriter sw = new StringWriter(); try { editorKit.write(sw,
     * document, pEl.getStartOffset(),
     * pEl.getEndOffset()-pEl.getStartOffset()); String copy =
     * sw.toString(); String elName = pEl.getName(); copy =
     * copy.substring(copy.indexOf(" <"+elName)); copy =
     * copy.substring(0,copy.indexOf(" </"+elName)+elName.length()+3);
     * document.setOuterHTML(pEl, " <ul><li> "+copy+" </li></ul> ");
     * System.out.println(copy); } catch (Exception ex){
     * ex.printStackTrace();
     */

}
项目:Neukoelln_SER316    文件:AltHTMLWriter.java   
/**
 * Returns true if the element is a
 * synthesized element.  Currently we are only testing
 * for the p-implied tag.
 */
protected boolean synthesizedElement(Element elem) {
    if (matchNameAttribute(elem.getAttributes(), HTML.Tag.IMPLIED)) {
        return true;
    }
    return false;
}
项目:SER316-Ingolstadt    文件:AltHTMLWriter.java   
/**
 * Determines if the element associated with the attributeset
 * is a TEXTAREA or SELECT.  If true, returns true else
 * false
 */
private boolean isFormElementWithContent(AttributeSet attr) {
    if (matchNameAttribute(attr, HTML.Tag.TEXTAREA) || matchNameAttribute(attr, HTML.Tag.SELECT)) {
        return true;
    }
    return false;
}
项目:SER316-Aachen    文件:AltHTMLWriter.java   
/**
 * Returns true if the StyleConstants.NameAttribute is
 * equal to the tag that is passed in as a parameter.
 */
protected boolean matchNameAttribute(AttributeSet attr, HTML.Tag tag) {
    Object o = attr.getAttribute(StyleConstants.NameAttribute);
    if (o instanceof HTML.Tag) {
        HTML.Tag name = (HTML.Tag) o;
        if (name == tag) {
            return true;
        }
    }
    return false;
}
项目:jdk8u-jdk    文件:bug8058120.java   
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            createAndShowGUI();
        }
    });

    toolkit.realSync();

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                document.insertAfterEnd(document.getElement("ab"), textToInsert);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    });

    toolkit.realSync();

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Element parent = document.getElement("ab").getParentElement();
            int count = parent.getElementCount();
            if (count != 2) {
                throw new RuntimeException("Test Failed! Unexpected Element count = "+count);
            }
            Element insertedElement = parent.getElement(count - 1);
            if (!HTML.Tag.IMPLIED.toString().equals(insertedElement.getName())) {
                throw new RuntimeException("Test Failed! Inserted text is not wrapped by " + HTML.Tag.IMPLIED + " tag");
            }
        }
    });
}
项目:incubator-netbeans    文件:ReporterResultTopComponent.java   
@Override
public void hyperlinkUpdate(final HyperlinkEvent e) {
    if (!HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
        return;
    }
    BugTrackingAccessor accessor = Lookup.getDefault().lookup(BugTrackingAccessor.class);
    if (accessor != null){
        AttributeSet ats = e.getSourceElement().getAttributes();
        Object attribute = ats.getAttribute(HTML.getTag("a"));
        if (attribute instanceof SimpleAttributeSet) {
            SimpleAttributeSet attributeSet = (SimpleAttributeSet) attribute;
            Object bugId = attributeSet.getAttribute(HTML.getAttributeKey("id"));
            if (bugId != null){
                try{
                    Integer.parseInt(bugId.toString());
                    LOG.log(Level.FINE, "Open issue {0}", bugId);
                    accessor.openIssue(bugId.toString());
                    return;
                }catch(NumberFormatException nfe){
                    LOG.log(Level.INFO, "Invalid id attribute", nfe);
                }
            }
        }
    } else {
        LOG.log(Level.INFO, "Bugzilla Accessor not found");
    }
    RP.post(new Runnable(){

        @Override
        public void run() {
            HtmlBrowser.URLDisplayer.getDefault().showURL(e.getURL());
        }

    });
}