Examples of insertString()


Examples of javax.swing.text.Document.insertString()

        int pos = xmlPane.getCaretPosition();
        String cursorChar = document.getText(pos, 1);
        boolean toAppendSpace = !">".equals(cursorChar) && !"".equals(cursorChar.trim()) && !"/".equals(cursorChar);
        String template = (name + "=\"\"" + (toAppendSpace ? " " : "")).substring(this.prefixLength);

        document.insertString(pos, template, null);
        xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 1 );
    }

    private void completeAttributeValue(String value) throws BadLocationException {
        Document document = xmlPane.getDocument();
View Full Code Here

Examples of javax.swing.text.Document.insertString()

        int startTagIndex = text.lastIndexOf("<");
        if (startTagIndex >= 0) {
            int quoteIndex = Math.max( text.lastIndexOf("\""), text.lastIndexOf("\'") );
            if (quoteIndex > 0 && quoteIndex > startTagIndex) {
                document.remove(quoteIndex + 1, pos - quoteIndex - 1);
                document.insertString(quoteIndex + 1, value, null);
            }
        }
    }

    private void completeTag(String name) throws BadLocationException {
View Full Code Here

Examples of javax.swing.text.Document.insertString()

    private void completeTag(String name) throws BadLocationException {
        Document document = xmlPane.getDocument();
        int pos = xmlPane.getCaretPosition();

        if ( CDATA_NAME.equals(name) ) {
            document.insertString(pos, "<![CDATA[  ]]>".substring(this.prefixLength), null);
            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else if ( XML_COMMENT_NAME.equals(name) ) {
            document.insertString(pos, "<!--  -->".substring(this.prefixLength), null);
            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else {
View Full Code Here

Examples of javax.swing.text.Document.insertString()

        if ( CDATA_NAME.equals(name) ) {
            document.insertString(pos, "<![CDATA[  ]]>".substring(this.prefixLength), null);
            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else if ( XML_COMMENT_NAME.equals(name) ) {
            document.insertString(pos, "<!--  -->".substring(this.prefixLength), null);
            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else {
            ElementInfo info = DefinitionResolver.getElementInfo(name);
            if (info != null) {
                String template = info.getTemplate(true).substring(this.prefixLength);
View Full Code Here

Examples of javax.swing.text.Document.insertString()

            xmlPane.setCaretPosition( xmlPane.getCaretPosition() - 4 );
        } else {
            ElementInfo info = DefinitionResolver.getElementInfo(name);
            if (info != null) {
                String template = info.getTemplate(true).substring(this.prefixLength);
                document.insertString(pos, template, null);
                int closingIndex = template.lastIndexOf("</");
                if (closingIndex >= 0) {
                    xmlPane.setCaretPosition( xmlPane.getCaretPosition() - template.length() + closingIndex );
                }
            }
View Full Code Here

Examples of javax.swing.text.Document.insertString()

                    if (code == MenuKeyEvent.VK_BACK_SPACE) {
                        if ( pos > 0 && document.getLength() > 0 ) {
                            document.remove(pos - 1, 1);
                        }
                    } else {
                        document.insertString(pos, String.valueOf(ch), null);
                    }
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
                popupMenu.setVisible(false);
View Full Code Here

Examples of javax.swing.text.Document.insertString()

   */
  protected void insertHeader(final String header) {
    final Document doc = textPane.getDocument();
    try {
      if (header.length() > 0) {
        doc.insertString(doc.getLength(), "<" + header + "> ",
            textPane.getStyle("header"));
      }
    } catch (final BadLocationException e) {
      logger.error("Couldn't insert initial text.", e);
    }
View Full Code Here

Examples of javax.swing.text.Document.insertString()

   */
  protected void insertTimestamp(final String header) {
    final Document doc = textPane.getDocument();
    try {
      if (header.length() > 0) {
        doc.insertString(doc.getLength(), header,
            textPane.getStyle("timestamp"));
      }
    } catch (final BadLocationException e) {
      logger.error("Couldn't insert initial text.", e);
    }
View Full Code Here

Examples of javax.swing.text.Document.insertString()

    try {
      final FormatTextParser parser =  new FormatTextParser() {
        @Override
        public void normalText(final String txt) throws BadLocationException {
          doc.insertString(doc.getLength(), txt, getStyle(color,styleDescription));
        }

        @Override
        public void colorText(final String txt) throws BadLocationException {
          doc.insertString(doc.getLength(), txt, textPane.getStyle("bold"));
View Full Code Here

Examples of javax.swing.text.Document.insertString()

          doc.insertString(doc.getLength(), txt, getStyle(color,styleDescription));
        }

        @Override
        public void colorText(final String txt) throws BadLocationException {
          doc.insertString(doc.getLength(), txt, textPane.getStyle("bold"));
        }
      };
      parser.format(text);
    } catch (final Exception e) {
      // BadLocationException
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.