Example usage for javax.swing.text BadLocationException printStackTrace

List of usage examples for javax.swing.text BadLocationException printStackTrace

Introduction

In this page you can find the example usage for javax.swing.text BadLocationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.ayound.js.debug.ui.editor.AbstractEditor.java

private void updateBookMark() {
    gutter.removeAllTrackingIcons();//www. jav  a  2s  .com
    for (BreakPointModel model : BreakPointManager.getAllBreakPoints()) {
        if (filePath != null && filePath.equals(model.getResourcePath())) {
            try {
                gutter.addLineTrackingIcon(model.getLineNumber(), gutter.getBookmarkIcon());
            } catch (BadLocationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}

From source file:org.ayound.js.debug.ui.editor.AbstractEditor.java

public void focus(int line) {
    int offset;// ww w.  j  av  a 2 s  .c o m
    try {
        offset = textArea.getLineEndOffset(line - 2);
        if (offset > 0) {
            textArea.setCaretPosition(offset);
        }
    } catch (BadLocationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:org.drugis.addis.gui.wizard.AddStudyWizard.java

private static JComponent buildTip(String tip) {
    JTextPane area = new JTextPane();
    StyledDocument doc = area.getStyledDocument();
    addStylesToDoc(doc);/* w w  w  .  j av  a 2s .c  om*/

    area.setBackground(new Color(255, 180, 180));

    try {
        doc.insertString(0, "x", doc.getStyle("tip"));
        doc.insertString(doc.getLength(), " Tip: \n", doc.getStyle("bold"));
        doc.insertString(doc.getLength(), tip, doc.getStyle("regular"));
    } catch (BadLocationException e) {
        e.printStackTrace();
    }

    area.setEditable(false);

    JScrollPane pane = new JScrollPane(area);
    pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    pane.setPreferredSize(TextComponentFactory.textPaneDimension(area, 270, 70));

    pane.setWheelScrollingEnabled(true);
    pane.getVerticalScrollBar().setValue(0);

    return pane;
}

From source file:org.executequery.gui.editor.QueryEditorTextPane.java

public String getTextAtRow(int rowNumber) {

    Element line = getElementMap().getElement(rowNumber);

    int startOffset = line.getStartOffset();
    int endOffset = line.getEndOffset();
    try {//from  www  .j ava  2  s  .com

        return getText(startOffset, (endOffset - startOffset));

    } catch (BadLocationException e) {

        e.printStackTrace();
        return null;
    }
}

From source file:org.executequery.gui.editor.QueryEditorTextPane.java

private void checkForShortcutText() {

    int index = getCaretPosition();
    String word = getWordEndingAt(index).toUpperCase();

    word = removeBracesAtStart(word);//  ww w .ja  va  2 s  . c  o  m
    if (editorShortcuts.containsKey(word)) {

        String text = editorShortcuts.get(word).getQuery();
        try {
            document.replace(index - word.length(), word.length(), text, null);
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
    }

}

From source file:org.executequery.gui.editor.QueryEditorTextPanel.java

/**
 * Adds a comment tag to the beginning of the current line
 * or selected lines./*  ww  w  .  ja v a  2 s.  c o  m*/
 */
public void commentLines() {

    int selectionStart = queryPane.getSelectionStart();
    int selectionEnd = queryPane.getSelectionEnd();

    boolean singleRow = (selectionStart == selectionEnd);

    int startRow = queryPane.getRowAt(selectionStart);
    int endRow = queryPane.getRowAt(selectionEnd);

    int endRowStartIndex = queryPane.getRowStartOffset(endRow);
    if (!singleRow && selectionEnd == endRowStartIndex) {

        endRow--;
    }

    try {

        if (rowsHaveComments(startRow, endRow, true)) {

            removeCommentFromRows(startRow, endRow);

        } else if (rowsHaveComments(startRow, endRow, false)) {

            if (singleRow) {

                removeCommentFromRows(startRow, endRow);

            } else {

                // if any one row of a multi-row selection has
                // a comment, comment the rest also

                addCommentToRows(startRow, endRow);
            }

        } else {

            addCommentToRows(startRow, endRow);
        }

    } catch (BadLocationException e) {

        // nothing we can do here

        e.printStackTrace();
    }

    if (!singleRow) {

        queryPane.setSelectionStart(queryPane.getRowStartOffset(startRow));
        queryPane.setSelectionEnd(queryPane.getRowEndOffset(endRow));
    }

}

From source file:org.fife.ui.rtextarea.RTATextTransferHandler.java

/**
 * This method causes a transfer to a component from a clipboard or a 
 * DND drop operation.  The Transferable represents the data to be
 * imported into the component.  /*from w ww. ja  v a  2  s .c o  m*/
 *
 * @param comp  The component to receive the transfer.  This
 *  argument is provided to enable sharing of TransferHandlers by
 *  multiple components.
 * @param t The data to import
 * @return <code>true</code> iff the data was inserted into the component.
 */
@Override
public boolean importData(JComponent comp, Transferable t) {

    JTextComponent c = (JTextComponent) comp;
    withinSameComponent = c == exportComp;

    // if we are importing to the same component that we exported from
    // then don't actually do anything if the drop location is inside
    // the drag location and set shouldRemove to false so that exportDone
    // knows not to remove any data
    if (withinSameComponent && c.getCaretPosition() >= p0 && c.getCaretPosition() <= p1) {
        shouldRemove = false;
        return true;
    }

    boolean imported = false;
    DataFlavor importFlavor = getImportFlavor(t.getTransferDataFlavors(), c);
    if (importFlavor != null) {
        try {
            InputContext ic = c.getInputContext();
            if (ic != null)
                ic.endComposition();
            Reader r = importFlavor.getReaderForText(t);
            handleReaderImport(r, c);
            imported = true;
        } catch (UnsupportedFlavorException ufe) {
            ufe.printStackTrace();
        } catch (BadLocationException ble) {
            ble.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }

    return imported;

}

From source file:org.fit.cssbox.scriptbox.demo.tester.ConsoleInjector.java

private static void clearStyledDocumentImpl(final StyledDocument doc) {
    try {//w  w  w  . j a va  2 s.  c o m
        doc.remove(0, doc.getLength());
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}

From source file:org.languagetool.gui.LanguageToolSupport.java

private void updateHighlights() {
    removeHighlights();//ww  w . ja  v  a 2s. c o m

    Highlighter h = textComponent.getHighlighter();

    for (Span span : documentSpans) {
        if (span.start == span.end) {
            continue;
        }
        try {
            if (span.start < span.end) { //to avoid the BadLocationException
                ITSIssueType issueType = span.rule.getLocQualityIssueType();
                Color ulColor = config.getUnderlineColor(span.rule.getCategory().getName());
                Color colorForIssueType = getConfig().getErrorColors().get(issueType);
                Color bgColor = colorForIssueType != null ? colorForIssueType : null;
                Color underlineColor = ITSIssueType.Misspelling == span.rule.getLocQualityIssueType()
                        ? Color.red
                        : ulColor;
                HighlightPainter painter = new HighlightPainter(bgColor, underlineColor);
                h.addHighlight(span.start, span.end, painter);
            }
        } catch (BadLocationException ex) {
            ex.printStackTrace();
        }
    }
}

From source file:org.opendatakit.appengine.updater.UpdaterWindow.java

public synchronized void displayOutput(StreamType type, String actionName, String line) {
    Document doc = editorArea.getDocument();

    String str = actionName + ((type == StreamType.ERR) ? "!:  " : " :  ") + line + "\r\n";

    try {//from   w w  w. ja v a 2  s  . c  o m
        doc.insertString(doc.getLength(), str, null);
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}