Search in sources :

Example 11 with JEditorPane

use of javax.swing.JEditorPane in project jgnash by ccavanaugh.

the class NewFileTwo method initComponents.

private void initComponents() {
    helpPane = new JEditorPane();
    helpPane.setEditable(false);
    helpPane.setEditorKit(new StyledEditorKit());
    helpPane.setBackground(getBackground());
    helpPane.setText(TextResource.getString("NewFileTwo.txt"));
}
Also used : StyledEditorKit(javax.swing.text.StyledEditorKit) JEditorPane(javax.swing.JEditorPane)

Example 12 with JEditorPane

use of javax.swing.JEditorPane in project jabref by JabRef.

the class EntryEditorTabRelatedArticles method setHtmlText.

/**
     * Takes a List of HTML snippets stored in the field "html_representation" of a list of bibentries and sets it in the JEditorPane
     *
     * @param list of bib entries having a field html_representation
     */
public void setHtmlText(List<BibEntry> list) {
    StringBuilder htmlContent = new StringBuilder();
    URL url = IconTheme.getIconUrl("mdlListIcon");
    htmlContent.append("<html><head><title></title></head><body bgcolor='#ffffff'>");
    htmlContent.append("<ul style='list-style-image:(");
    htmlContent.append(url);
    htmlContent.append(")'>");
    list.stream().map(bibEntry -> bibEntry.getField("html_representation")).filter(Optional::isPresent).map(o -> "<li style='margin: 5px'>" + o.get() + "</li>").forEach(html -> htmlContent.append(html));
    htmlContent.append("</ul>");
    htmlContent.append("<br><div style='margin-left: 5px'>");
    htmlContent.append("<a href='http://mr-dlib.org/information-for-users/information-about-mr-dlib-for-jabref-users/#'>");
    htmlContent.append(Localization.lang("What_is_Mr._DLib?"));
    htmlContent.append("</a></div>");
    htmlContent.append("</body></html>");
    this.setText(htmlContent.toString());
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) FieldName(org.jabref.model.entry.FieldName) URL(java.net.URL) BibEntry(org.jabref.model.entry.BibEntry) JabRefDesktop(org.jabref.gui.desktop.JabRefDesktop) MrDLibFetcher(org.jabref.logic.importer.fetcher.MrDLibFetcher) IconTheme(org.jabref.gui.IconTheme) IOException(java.io.IOException) JabRefPreferences(org.jabref.preferences.JabRefPreferences) Globals(org.jabref.Globals) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) JEditorPane(javax.swing.JEditorPane) Optional(java.util.Optional) SwingWorker(javax.swing.SwingWorker) Localization(org.jabref.logic.l10n.Localization) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) Optional(java.util.Optional) URL(java.net.URL)

Example 13 with JEditorPane

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

the class TikaGUI method hyperlinkUpdate.

public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == EventType.ACTIVATED) {
        try {
            URL url = e.getURL();
            try (InputStream stream = url.openStream()) {
                JEditorPane editor = new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8));
                editor.setEditable(false);
                editor.setBackground(Color.WHITE);
                editor.setCaretPosition(0);
                editor.setPreferredSize(new Dimension(600, 400));
                String name = url.toString();
                name = name.substring(name.lastIndexOf('/') + 1);
                JDialog dialog = new JDialog(this, "Apache Tika: " + name);
                dialog.add(new JScrollPane(editor));
                dialog.pack();
                dialog.setVisible(true);
            }
        } catch (IOException exception) {
            exception.printStackTrace();
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) ProgressMonitorInputStream(javax.swing.ProgressMonitorInputStream) TikaInputStream(org.apache.tika.io.TikaInputStream) InputStream(java.io.InputStream) JEditorPane(javax.swing.JEditorPane) Dimension(java.awt.Dimension) IOException(java.io.IOException) URL(java.net.URL) JDialog(javax.swing.JDialog)

Example 14 with JEditorPane

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

the class TikaGUI method addWelcomeCard.

private void addWelcomeCard(JPanel panel, String name) {
    try {
        JEditorPane editor = new JEditorPane(TikaGUI.class.getResource("welcome.html"));
        editor.setContentType("text/html");
        editor.setEditable(false);
        editor.setBackground(Color.WHITE);
        editor.setTransferHandler(new ParsingTransferHandler(editor.getTransferHandler(), this));
        panel.add(new JScrollPane(editor), name);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JEditorPane(javax.swing.JEditorPane) IOException(java.io.IOException)

Example 15 with JEditorPane

use of javax.swing.JEditorPane in project processdash by dtuma.

the class AutoUpdateManager method displayUpdateMessage.

/** Display a message box, telling the user that various packages are
     *  now available for download.
     */
protected void displayUpdateMessage(Component parent, int numUpdatesFound) {
    HashSet urlsSeen = new HashSet();
    DashPackage pkg;
    StringBuffer html = new StringBuffer();
    html.append("<html><head><style>" + "UL { margin-top: 0pt; margin-bottom: 0pt }" + "</style></head><body>");
    for (int i = 0; i < packages.size(); i++) {
        pkg = (DashPackage) packages.get(i);
        if (!pkg.updateAvailable)
            continue;
        String userURL = pkg.userURL;
        if (userURL == null || urlsSeen.contains(userURL))
            continue;
        urlsSeen.add(userURL);
        ArrayList updates = new ArrayList();
        updates.add(pkg.name);
        for (int j = i + 1; j < packages.size(); j++) {
            pkg = (DashPackage) packages.get(j);
            if (pkg.updateAvailable && userURL.equals(pkg.userURL))
                updates.add(pkg.name);
        }
        Collections.sort(updates, String.CASE_INSENSITIVE_ORDER);
        html.append("<p>");
        String hyperlink = "<a href=\"" + userURL + "\">" + HTMLUtils.escapeEntities(userURL) + "</a>";
        html.append(resources.format("Updates_Available_Message_FMT", hyperlink, new Integer(updates.size())));
        html.append("<ul>");
        Iterator u = updates.iterator();
        while (u.hasNext()) {
            String updateName = Translator.translate((String) u.next());
            html.append("<li>").append(HTMLUtils.escapeEntities(updateName));
        }
        html.append("</ul>");
    }
    JEditorPane message = new JEditorPane();
    message.setContentType("text/html");
    message.setEditable(false);
    message.setBackground(null);
    message.setText(html.toString());
    message.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
                Browser.launch(e.getURL().toString());
        }
    });
    JCheckBox disable = new JCheckBox(resources.getString("Do_Not_Check_Label"));
    Object[] messageDisplay = new Object[2];
    messageDisplay[0] = message;
    messageDisplay[1] = disable;
    String[] updateOptions = { resources.getString("Remind_Label"), resources.getString("Close_Label") };
    int choice = JOptionPane.showOptionDialog(parent, messageDisplay, resources.getString("Updates_Available_Title"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, updateOptions, updateOptions[0]);
    if (choice == 0)
        InternalSettings.set(AUTO_UPDATE_SETTING + REMIND, "true");
    if (disable.isSelected())
        InternalSettings.set(AUTO_UPDATE_SETTING + DISABLED, "true");
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) ArrayList(java.util.ArrayList) JCheckBox(javax.swing.JCheckBox) HyperlinkListener(javax.swing.event.HyperlinkListener) Iterator(java.util.Iterator) JEditorPane(javax.swing.JEditorPane) HashSet(java.util.HashSet)

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