Search in sources :

Example 51 with JEditorPane

use of javax.swing.JEditorPane in project tika by apache.

the class TikaGUI method textDialog.

private void textDialog(String title, URL resource) {
    try {
        JDialog dialog = new JDialog(this, title);
        JEditorPane editor = new JEditorPane(resource);
        editor.setContentType("text/html");
        editor.setEditable(false);
        editor.setBackground(Color.WHITE);
        editor.setPreferredSize(new Dimension(400, 250));
        editor.addHyperlinkListener(this);
        dialog.add(editor);
        dialog.pack();
        dialog.setVisible(true);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension) IOException(java.io.IOException) JDialog(javax.swing.JDialog)

Example 52 with JEditorPane

use of javax.swing.JEditorPane in project tika by apache.

the class TikaGUI method handleError.

private void handleError(String name, Throwable t) {
    StringWriter writer = new StringWriter();
    writer.append("Apache Tika was unable to parse the document\n");
    writer.append("at " + name + ".\n\n");
    writer.append("The full exception stack trace is included below:\n\n");
    t.printStackTrace(new PrintWriter(writer));
    JEditorPane editor = new JEditorPane("text/plain", writer.toString());
    editor.setEditable(false);
    editor.setBackground(Color.WHITE);
    editor.setCaretPosition(0);
    editor.setPreferredSize(new Dimension(600, 400));
    JDialog dialog = new JDialog(this, "Apache Tika error");
    dialog.add(new JScrollPane(editor));
    dialog.pack();
    dialog.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) StringWriter(java.io.StringWriter) JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension) JDialog(javax.swing.JDialog) PrintWriter(java.io.PrintWriter)

Example 53 with JEditorPane

use of javax.swing.JEditorPane in project tika by apache.

the class TikaGUI method addCard.

private JEditorPane addCard(JPanel panel, String type, String name) {
    JEditorPane editor = new JTextPane();
    editor.setBackground(Color.WHITE);
    editor.setContentType(type);
    editor.setTransferHandler(new ParsingTransferHandler(editor.getTransferHandler(), this));
    panel.add(new JScrollPane(editor), name);
    return editor;
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextPane(javax.swing.JTextPane) JEditorPane(javax.swing.JEditorPane)

Example 54 with JEditorPane

use of javax.swing.JEditorPane in project enclojure by EricThorsen.

the class ClojureToolTipAnnotation method run.

public void run() {
    LOG.log(Level.FINEST, "ClojureTooltip: run");
    // 1) get tooltip text
    Line.Part lp = (Line.Part) getAttachedAnnotatable();
    JEditorPane ep = Utils.getCurrentEditor();
    String textForTooltip = "";
    if ((lp == null) || (ep == null)) {
        return;
    }
    // first try EL
    String text = Utils.getELIdentifier(doc, ep, NbDocument.findLineOffset(doc, lp.getLine().getLineNumber()) + lp.getColumn());
    LOG.log(Level.FINEST, "JspToClojureTooltipoltip: ELIdentifier = " + text);
    boolean isScriptlet = Utils.isScriptlet(doc, ep, NbDocument.findLineOffset(doc, lp.getLine().getLineNumber()) + lp.getColumn());
    LOG.log(Level.FINEST, "isScriptlet: " + isScriptlet);
    // if not, try Java
    if ((text == null) && (isScriptlet)) {
        text = Utils.getJavaIdentifier(doc, ep, NbDocument.findLineOffset(doc, lp.getLine().getLineNumber()) + lp.getColumn());
        textForTooltip = text;
        LOG.log(Level.FINEST, "ClojureTooltip: javaIdentifier = " + text);
        if (text == null) {
            return;
        }
    } else {
        if (text == null) {
            return;
        }
        textForTooltip = text;
        String textEscaped = org.openide.util.Utilities.replaceString(text, "\"", "\\\"");
        text = "pageContext.getExpressionEvaluator().evaluate(\"" + textEscaped + "\", java.lang.String.class, (javax.servlet.jsp.PageContext)pageContext, null)";
    }
    LOG.log(Level.FINEST, "JspTooltip: fullWatch = " + text);
    // 3) obtain text representation of value of watch
    String old = toolTipText;
    toolTipText = null;
    DebuggerEngine currentEngine = DebuggerManager.getDebuggerManager().getCurrentEngine();
    if (currentEngine == null)
        return;
    JPDADebugger d = (JPDADebugger) currentEngine.lookupFirst(null, JPDADebugger.class);
    if (d == null)
        return;
    try {
        Variable v = d.evaluate(text);
        if (v instanceof ObjectVariable) {
            toolTipText = textForTooltip + " = (" + v.getType() + ")" + ((ObjectVariable) v).getToStringValue();
        } else {
            toolTipText = textForTooltip + " = (" + v.getType() + ")" + v.getValue();
        }
    } catch (InvalidExpressionException e) {
        toolTipText = text + " = >" + e.getMessage() + "<";
    }
    LOG.log(Level.FINEST, "ClojureTooltip: " + toolTipText);
    firePropertyChange(PROP_SHORT_DESCRIPTION, old, toolTipText);
}
Also used : JEditorPane(javax.swing.JEditorPane)

Example 55 with JEditorPane

use of javax.swing.JEditorPane in project vcell by virtualcell.

the class MathDebuggerPanel method getStatusEditorPane.

/**
 * This method initializes statusEditorPane
 *
 * @return javax.swing.JEditorPane
 */
private JEditorPane getStatusEditorPane() {
    if (statusEditorPane == null) {
        statusEditorPane = new JEditorPane();
        statusEditorPane.setMinimumSize(new Dimension(33, 100));
        statusEditorPane.setPreferredSize(new Dimension(1500, 100));
        statusEditorPane.setMaximumSize(new Dimension(2147483647, 100));
    }
    return statusEditorPane;
}
Also used : JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension)

Aggregations

JEditorPane (javax.swing.JEditorPane)60 JScrollPane (javax.swing.JScrollPane)22 Dimension (java.awt.Dimension)12 JPanel (javax.swing.JPanel)12 IOException (java.io.IOException)11 JButton (javax.swing.JButton)11 JLabel (javax.swing.JLabel)11 JFrame (javax.swing.JFrame)10 GridBagLayout (java.awt.GridBagLayout)9 GridBagConstraints (java.awt.GridBagConstraints)8 JDialog (javax.swing.JDialog)7 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 BorderLayout (java.awt.BorderLayout)5 JTextField (javax.swing.JTextField)5 HyperlinkListener (javax.swing.event.HyperlinkListener)5 StyledEditorKit (javax.swing.text.StyledEditorKit)5 JCheckBox (javax.swing.JCheckBox)4 JSplitPane (javax.swing.JSplitPane)4 JTree (javax.swing.JTree)4 Component (java.awt.Component)3