Search in sources :

Example 1 with JRestrictedSizeScrollPane

use of org.freeplane.core.ui.components.JRestrictedSizeScrollPane in project freeplane by freeplane.

the class FormulaTextTransformer method createEditor.

public EditNodeBase createEditor(final NodeModel node, final EditNodeBase.IEditControl editControl, String text, final boolean editLong) {
    MTextController textController = MTextController.getController();
    if (textController.isTextFormattingDisabled(node))
        return null;
    final KeyEvent firstKeyEvent = textController.getEventQueue().getFirstEvent();
    if (firstKeyEvent != null) {
        if (firstKeyEvent.getKeyChar() == '=') {
            text = "=";
        } else {
            return null;
        }
    }
    if (text.startsWith("=")) {
        JEditorPane textEditor = new JEditorPane();
        textEditor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
        final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(textEditor);
        scrollPane.setMinimumSize(new Dimension(0, 60));
        final EditNodeDialog editNodeDialog = new FormulaEditor(node, text, firstKeyEvent, editControl, false, textEditor);
        editNodeDialog.setTitle(TextUtils.getText("formula_editor"));
        textEditor.setContentType("text/groovy");
        final String fontName = ResourceController.getResourceController().getProperty(FormulaEditor.GROOVY_EDITOR_FONT);
        final int fontSize = ResourceController.getResourceController().getIntProperty(FormulaEditor.GROOVY_EDITOR_FONT_SIZE);
        textEditor.setFont(new Font(fontName, Font.PLAIN, fontSize));
        return editNodeDialog;
    }
    return null;
}
Also used : KeyEvent(java.awt.event.KeyEvent) JRestrictedSizeScrollPane(org.freeplane.core.ui.components.JRestrictedSizeScrollPane) JEditorPane(javax.swing.JEditorPane) MTextController(org.freeplane.features.text.mindmapmode.MTextController) Dimension(java.awt.Dimension) EditNodeDialog(org.freeplane.features.text.mindmapmode.EditNodeDialog) Font(java.awt.Font)

Example 2 with JRestrictedSizeScrollPane

use of org.freeplane.core.ui.components.JRestrictedSizeScrollPane in project freeplane by freeplane.

the class MEdgeController method editEdgeColorConfiguration.

public void editEdgeColorConfiguration(MapModel map) {
    final List<Color> oldColors = edgeColorsConfigurationFactory.create(map).colors;
    final ColorListEditorPanelBuilder colorListEditorPanelBuilder = new ColorListEditorPanelBuilder(oldColors);
    final JComponent panel = colorListEditorPanelBuilder.getPanel();
    JScrollPane jscrollpane = new JRestrictedSizeScrollPane(panel);
    UITools.setScrollbarIncrement(jscrollpane);
    jscrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jscrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jscrollpane.setMaximumSize(new Dimension(Integer.MAX_VALUE, 600));
    String title = TextUtils.getText("editEdgeColors");
    final int status = JOptionPane.showConfirmDialog(UITools.getCurrentFrame(), jscrollpane, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    switch(status) {
        case JOptionPane.OK_OPTION:
            final List<Color> newColors = colorListEditorPanelBuilder.getColors();
            edgeColorsConfigurationFactory.setConfiguration(map, new EdgeColorConfiguration(newColors));
            break;
        default:
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JRestrictedSizeScrollPane(org.freeplane.core.ui.components.JRestrictedSizeScrollPane) Color(java.awt.Color) JComponent(javax.swing.JComponent) EdgeColorConfiguration(org.freeplane.features.edge.EdgeColorConfiguration) Dimension(java.awt.Dimension)

Example 3 with JRestrictedSizeScrollPane

use of org.freeplane.core.ui.components.JRestrictedSizeScrollPane in project freeplane by freeplane.

the class ScriptComboBoxEditor method editScript.

protected void editScript(boolean selectAll) {
    JEditorPane textEditor = new JEditorPane();
    textEditor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(textEditor);
    scrollPane.setMinimumSize(minimumSize);
    textEditor.setContentType("text/groovy");
    final String fontName = ResourceController.getResourceController().getProperty(ScriptEditorPanel.GROOVY_EDITOR_FONT);
    final int fontSize = ResourceController.getResourceController().getIntProperty(ScriptEditorPanel.GROOVY_EDITOR_FONT_SIZE);
    textEditor.setFont(new Font(fontName, Font.PLAIN, fontSize));
    textEditor.setText(script);
    if (selectAll) {
        textEditor.selectAll();
    }
    String title = TextUtils.getText("plugins/ScriptEditor/window.title");
    final JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    final JDialog dialog = optionPane.createDialog(showEditorBtn, title);
    dialog.setResizable(true);
    if (bounds != null)
        dialog.setBounds(bounds);
    dialog.setVisible(true);
    bounds = dialog.getBounds();
    final Integer result = ((Integer) optionPane.getValue());
    if (result == null || result != JOptionPane.OK_OPTION)
        return;
    script = textEditor.getText();
    setButtonText();
    final ActionEvent actionEvent = new ActionEvent(this, 0, null);
    for (final ActionListener l : actionListeners) {
        l.actionPerformed(actionEvent);
    }
}
Also used : ActionListener(java.awt.event.ActionListener) JRestrictedSizeScrollPane(org.freeplane.core.ui.components.JRestrictedSizeScrollPane) ActionEvent(java.awt.event.ActionEvent) JEditorPane(javax.swing.JEditorPane) JOptionPane(javax.swing.JOptionPane) Font(java.awt.Font) JDialog(javax.swing.JDialog)

Example 4 with JRestrictedSizeScrollPane

use of org.freeplane.core.ui.components.JRestrictedSizeScrollPane in project freeplane by freeplane.

the class LatexRenderer method createEditor.

public EditNodeBase createEditor(NodeModel node, IEditControl editControl, String text, boolean editLong) {
    MTextController textController = MTextController.getController();
    if (// Format=Text!
    textController.isTextFormattingDisabled(node))
        return null;
    final KeyEvent firstKeyEvent = textController.getEventQueue().getFirstEvent();
    String nodeFormat = textController.getNodeFormat(node);
    final String latexText = getLatexNode(text, nodeFormat, TargetMode.FOR_EDITOR);
    // this option has been added to work around bugs in JSyntaxPane with Chinese characters
    if (ResourceController.getResourceController().getBooleanProperty(LATEX_EDITOR_DISABLE))
        return null;
    if (latexText != null) {
        JEditorPane textEditor = new JEditorPane();
        textEditor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
        final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(textEditor);
        scrollPane.setMinimumSize(new Dimension(0, 60));
        final EditNodeDialog editNodeDialog = new LatexEditor(node, latexText, firstKeyEvent, editControl, false, textEditor);
        editNodeDialog.setTitle(TextUtils.getText("latex_editor"));
        textEditor.setContentType("text/latex");
        final String fontName = ResourceController.getResourceController().getProperty(LATEX_EDITOR_FONT);
        final int fontSize = ResourceController.getResourceController().getIntProperty(LATEX_EDITOR_FONT_SIZE);
        textEditor.setFont(new Font(fontName, Font.PLAIN, fontSize));
        return editNodeDialog;
    }
    return null;
}
Also used : KeyEvent(java.awt.event.KeyEvent) JRestrictedSizeScrollPane(org.freeplane.core.ui.components.JRestrictedSizeScrollPane) JEditorPane(javax.swing.JEditorPane) MTextController(org.freeplane.features.text.mindmapmode.MTextController) Dimension(java.awt.Dimension) EditNodeDialog(org.freeplane.features.text.mindmapmode.EditNodeDialog) Font(java.awt.Font)

Example 5 with JRestrictedSizeScrollPane

use of org.freeplane.core.ui.components.JRestrictedSizeScrollPane in project freeplane by freeplane.

the class ColorListEditorPanelBuilder method main.

/**
 * Main method for panel
 */
public static void main(String[] args) {
    final List<Color> colorList = new ArrayList<>(100);
    for (int i = 0; i < 100; i++) colorList.add(Color.WHITE);
    final JComponent panel = new ColorListEditorPanelBuilder(colorList).getPanel();
    JScrollPane jscrollpane = new JRestrictedSizeScrollPane(panel);
    jscrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jscrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jscrollpane.setMaximumSize(new Dimension(Integer.MAX_VALUE, 600));
    JOptionPane.showConfirmDialog(null, jscrollpane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JRestrictedSizeScrollPane(org.freeplane.core.ui.components.JRestrictedSizeScrollPane) Color(java.awt.Color) ArrayList(java.util.ArrayList) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension)

Aggregations

JRestrictedSizeScrollPane (org.freeplane.core.ui.components.JRestrictedSizeScrollPane)5 Dimension (java.awt.Dimension)4 Font (java.awt.Font)3 JEditorPane (javax.swing.JEditorPane)3 Color (java.awt.Color)2 KeyEvent (java.awt.event.KeyEvent)2 JComponent (javax.swing.JComponent)2 JScrollPane (javax.swing.JScrollPane)2 EditNodeDialog (org.freeplane.features.text.mindmapmode.EditNodeDialog)2 MTextController (org.freeplane.features.text.mindmapmode.MTextController)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 JDialog (javax.swing.JDialog)1 JOptionPane (javax.swing.JOptionPane)1 EdgeColorConfiguration (org.freeplane.features.edge.EdgeColorConfiguration)1