Search in sources :

Example 11 with RTextScrollPane

use of org.fife.ui.rtextarea.RTextScrollPane in project knime-core by knime.

the class RuleMainPanel method createEditorComponent.

/**
 * {@inheritDoc}
 */
@Override
protected JComponent createEditorComponent() {
    m_textEditor = new KnimeSyntaxTextArea(20, 60);
    final RSyntaxTextArea textArea = m_textEditor;
    // An AutoCompletion acts as a "middle-man" between a text component
    // and a CompletionProvider. It manages any options associated with
    // the auto-completion (the popup trigger key, whether to display a
    // documentation window along with completion choices, etc.). Unlike
    // CompletionProviders, instances of AutoCompletion cannot be shared
    // among multiple text components.
    AutoCompletion ac = new AutoCompletion(getCompletionProvider());
    ac.setShowDescWindow(true);
    ac.install(textArea);
    setExpEdit(textArea);
    textArea.setSyntaxEditingStyle(m_syntaxStyle);
    textArea.getPopupMenu().add(new ToggleRuleAction("Toggle comment", textArea));
    RTextScrollPane textScrollPane = new RTextScrollPane(textArea);
    textScrollPane.setLineNumbersEnabled(true);
    textScrollPane.setIconRowHeaderEnabled(true);
    m_gutter = textScrollPane.getGutter();
    addRowHeaderMouseListener(new MouseAdapter() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                try {
                    new ToggleRuleAction(textArea).actionPerformed(new ToggleRuleAction.LinePosition(textArea, (int) (new Date().getTime() & 0x7fffffff), "toggle comment", e.getModifiers(), textArea.getLineOfOffset(textArea.viewToModel(e.getPoint()))));
                } catch (BadLocationException e1) {
                    LOGGER.debug(e1.getMessage(), e1);
                }
            }
        }
    });
    return textScrollPane;
}
Also used : AutoCompletion(org.fife.ui.autocomplete.AutoCompletion) MouseEvent(java.awt.event.MouseEvent) RSyntaxTextArea(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea) MouseAdapter(java.awt.event.MouseAdapter) KnimeSyntaxTextArea(org.knime.base.node.util.KnimeSyntaxTextArea) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane) Date(java.util.Date) BadLocationException(javax.swing.text.BadLocationException)

Example 12 with RTextScrollPane

use of org.fife.ui.rtextarea.RTextScrollPane in project knime-core by knime.

the class JavaSnippetNodeDialog method createSnippetPanel.

/**
 * Create the panel with the snippet.
 */
private JComponent createSnippetPanel() {
    m_snippetTextArea = new JSnippetTextArea(m_snippet);
    // reset style which causes a recreation of the folds
    // this code is also executed in "onOpen" but that is not called for the template viewer tab
    m_snippetTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
    m_snippetTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
    collapseAllFolds();
    final JScrollPane snippetScroller = new RTextScrollPane(m_snippetTextArea);
    final JPanel snippet = new JPanel(new BorderLayout());
    snippet.add(snippetScroller, BorderLayout.CENTER);
    final ErrorStrip es = new ErrorStrip(m_snippetTextArea);
    snippet.add(es, BorderLayout.LINE_END);
    return snippet;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JSnippetTextArea(org.knime.base.node.jsnippet.ui.JSnippetTextArea) BorderLayout(java.awt.BorderLayout) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane) ErrorStrip(org.fife.ui.rsyntaxtextarea.ErrorStrip)

Example 13 with RTextScrollPane

use of org.fife.ui.rtextarea.RTextScrollPane in project knime-core by knime.

the class ParameterizedDBQueryPanel method createEditorPanel.

private JPanel createEditorPanel() {
    final JPanel panel = new JPanel(new BorderLayout());
    final JLabel editorLabel = new JLabel("SQL Statement");
    editorLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
    final RTextScrollPane editorScrollPane = new RTextScrollPane(m_editor);
    editorScrollPane.setPreferredSize(new Dimension(850, 400));
    editorScrollPane.setFoldIndicatorEnabled(true);
    panel.add(editorLabel, BorderLayout.NORTH);
    panel.add(editorScrollPane, BorderLayout.CENTER);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) EmptyBorder(javax.swing.border.EmptyBorder) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane)

Example 14 with RTextScrollPane

use of org.fife.ui.rtextarea.RTextScrollPane in project cuba by cuba-platform.

the class DesktopSourceCodeEditor method createTextComponentImpl.

@Override
protected RSyntaxTextArea createTextComponentImpl() {
    RSyntaxTextArea impl = new RSyntaxTextArea();
    int height = (int) impl.getPreferredSize().getHeight();
    impl.setMinimumSize(new Dimension(0, height));
    RTextScrollPane scrollPane = new RTextScrollPane(impl);
    scrollPane.setLineNumbersEnabled(showGutter);
    composition = scrollPane;
    composition.setPreferredSize(new Dimension(150, height));
    composition.setMinimumSize(new Dimension(0, height));
    doc.putProperty("filterNewlines", false);
    return impl;
}
Also used : RSyntaxTextArea(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane)

Aggregations

RTextScrollPane (org.fife.ui.rtextarea.RTextScrollPane)14 RSyntaxTextArea (org.fife.ui.rsyntaxtextarea.RSyntaxTextArea)7 JPanel (javax.swing.JPanel)4 BorderLayout (java.awt.BorderLayout)3 Component (java.awt.Component)3 Dimension (java.awt.Dimension)3 JViewport (javax.swing.JViewport)3 JHexEditor (com.jhe.hexed.JHexEditor)2 JScrollPane (javax.swing.JScrollPane)2 JTextComponent (javax.swing.text.JTextComponent)2 AutoCompletion (org.fife.ui.autocomplete.AutoCompletion)2 Container (java.awt.Container)1 Font (java.awt.Font)1 Frame (java.awt.Frame)1 Panel (java.awt.Panel)1 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1