Search in sources :

Example 1 with ActionBuilder

use of com.lightdev.app.shtm.ActionBuilder in project freeplane by freeplane.

the class MTextController method createSHTMLPanel.

/**
 * Note: when creating an SHTMLPanel using this method, you must make sure to attach
 * a FreeplaneToSHTMLPropertyChangeAdapter to the panel (see for example EditNodeWYSIWYG.HTMLDialog.createEditorPanel(String))
 * @param purpose
 * @return
 */
public SHTMLPanel createSHTMLPanel(String purpose) {
    SHTMLPanel.setResources(new TextResources() {

        public String getString(String pKey) {
            if (pKey.equals("approximate_search_threshold")) {
                return new Double(StringMatchingStrategy.APPROXIMATE_MATCHING_MINPROB).toString();
            }
            pKey = "simplyhtml." + pKey;
            String resourceString = ResourceController.getResourceController().getText(pKey, null);
            if (resourceString == null) {
                resourceString = ResourceController.getResourceController().getProperty(pKey);
            }
            return resourceString;
        }
    });
    com.lightdev.app.shtm.ScaledStyleSheet.FONT_SCALE_FACTOR = UITools.FONT_SCALE_FACTOR;
    SHTMLPanel.setActionBuilder(new ActionBuilder() {

        public void initActions(SHTMLPanel panel) {
            panel.addAction("editLink", new SHTMLEditLinkAction((SHTMLPanelImpl) panel));
            panel.addAction("setLinkByFileChooser", new SHTMLSetLinkByFileChooserAction((SHTMLPanelImpl) panel));
        }
    });
    final SHTMLPanel shtmlPanel = SHTMLPanel.createSHTMLPanel();
    shtmlPanel.setOpenHyperlinkHandler(new ActionListener() {

        public void actionPerformed(ActionEvent pE) {
            try {
                UrlManager.getController().loadURL(new URI(pE.getActionCommand()));
            } catch (Exception e) {
                LogUtils.warn(e);
            }
        }
    });
    final JEditorPane editorPane = shtmlPanel.getEditorPane();
    editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false);
    fireEditorPaneCreated(editorPane, purpose);
    return shtmlPanel;
}
Also used : SHTMLPanel(com.lightdev.app.shtm.SHTMLPanel) ActionBuilder(com.lightdev.app.shtm.ActionBuilder) ActionListener(java.awt.event.ActionListener) TextResources(com.lightdev.app.shtm.TextResources) ActionEvent(java.awt.event.ActionEvent) JEditorPane(javax.swing.JEditorPane) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) BadLocationException(javax.swing.text.BadLocationException) IOException(java.io.IOException)

Aggregations

ActionBuilder (com.lightdev.app.shtm.ActionBuilder)1 SHTMLPanel (com.lightdev.app.shtm.SHTMLPanel)1 TextResources (com.lightdev.app.shtm.TextResources)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 JEditorPane (javax.swing.JEditorPane)1 BadLocationException (javax.swing.text.BadLocationException)1