Search in sources :

Example 6 with AutoCompletion

use of org.fife.ui.autocomplete.AutoCompletion in project fql by CategoricalData.

the class OplCodeEditor method doTemplates.

@Override
protected void doTemplates() {
    CompletionProvider provider = createCompletionProvider();
    AutoCompletion ac = new AutoCompletion(provider);
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
    ac.setTriggerKey(key);
    ac.install(topArea);
}
Also used : CompletionProvider(org.fife.ui.autocomplete.CompletionProvider) DefaultCompletionProvider(org.fife.ui.autocomplete.DefaultCompletionProvider) AutoCompletion(org.fife.ui.autocomplete.AutoCompletion) KeyStroke(javax.swing.KeyStroke)

Example 7 with AutoCompletion

use of org.fife.ui.autocomplete.AutoCompletion in project MeteoInfo by meteoinfo.

the class AbstractLanguageSupport method createAutoCompletion.

/**
 * Creates an auto-completion instance pre-configured and usable by
 * most <code>LanguageSupport</code>s.
 *
 * @param p The completion provider.
 * @return The auto-completion instance.
 */
protected AutoCompletion createAutoCompletion(CompletionProvider p) {
    AutoCompletion ac = new AutoCompletion(p);
    ac.setListCellRenderer(getDefaultCompletionCellRenderer());
    ac.setAutoCompleteEnabled(isAutoCompleteEnabled());
    ac.setAutoActivationEnabled(isAutoActivationEnabled());
    ac.setAutoActivationDelay(getAutoActivationDelay());
    ac.setParameterAssistanceEnabled(isParameterAssistanceEnabled());
    ac.setShowDescWindow(getShowDescWindow());
    return ac;
}
Also used : AutoCompletion(org.fife.ui.autocomplete.AutoCompletion)

Example 8 with AutoCompletion

use of org.fife.ui.autocomplete.AutoCompletion in project ultimate-cube by G3G4X5X6.

the class EditTemplatePanel method createTextArea.

private RSyntaxTextArea createTextArea() {
    RSyntaxTextArea textArea = new RSyntaxTextArea();
    textArea.requestFocusInWindow();
    textArea.setCaretPosition(0);
    textArea.setMarkOccurrences(true);
    textArea.setCodeFoldingEnabled(true);
    textArea.setClearWhitespaceLinesEnabled(false);
    textArea.setCodeFoldingEnabled(true);
    textArea.setSyntaxEditingStyle("text/yaml");
    InputMap im = textArea.getInputMap();
    ActionMap am = textArea.getActionMap();
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), "decreaseFontSize");
    am.put("decreaseFontSize", new RSyntaxTextAreaEditorKit.DecreaseFontSizeAction());
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0), "increaseFontSize");
    am.put("increaseFontSize", new RSyntaxTextAreaEditorKit.IncreaseFontSizeAction());
    int ctrlShift = InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, ctrlShift), "copyAsStyledText");
    am.put("copyAsStyledText", new RSyntaxTextAreaEditorKit.CopyCutAsStyledTextAction(true));
    try {
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, ctrlShift), "copyAsStyledTextMonokai");
        am.put("copyAsStyledTextMonokai", createCopyAsStyledTextAction("monokai"));
        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_E, ctrlShift), "copyAsStyledTextEclipse");
        am.put("copyAsStyledTextEclipse", createCopyAsStyledTextAction("dark"));
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    // Since this demo allows the LookAndFeel and RSyntaxTextArea Theme to
    // be toggled independently of one another, we set this property to
    // true so matched bracket popups look good.  In an app where the
    // developer ensures the RSTA Theme always matches the LookAndFeel as
    // far as light/dark is concerned, this property can be omitted.
    System.setProperty(MatchedBracketPopup.PROPERTY_CONSIDER_TEXTAREA_BACKGROUND, "true");
    AutoCompletion ac = new AutoCompletion(new NucleiYamlCompletionProvider());
    ac.install(textArea);
    // TODO 快捷键与自动激活作为一个用户设置,二选一
    // ac.setAutoActivationEnabled(true);  // 找到唯一符合的关键字,将直接自动完成
    ac.setTriggerKey(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK));
    return textArea;
}
Also used : AutoCompletion(org.fife.ui.autocomplete.AutoCompletion) RSyntaxTextArea(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea) RSyntaxTextAreaEditorKit(org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit) IOException(java.io.IOException) NucleiYamlCompletionProvider(com.g3g4x5x6.nuclei.NucleiYamlCompletionProvider)

Example 9 with AutoCompletion

use of org.fife.ui.autocomplete.AutoCompletion 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 10 with AutoCompletion

use of org.fife.ui.autocomplete.AutoCompletion in project fql by CategoricalData.

the class MplCodeEditor method doTemplates.

@Override
protected void doTemplates() {
    CompletionProvider provider = createCompletionProvider();
    AutoCompletion ac = new AutoCompletion(provider);
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
    ac.setTriggerKey(key);
    ac.install(topArea);
}
Also used : DefaultCompletionProvider(org.fife.ui.autocomplete.DefaultCompletionProvider) CompletionProvider(org.fife.ui.autocomplete.CompletionProvider) AutoCompletion(org.fife.ui.autocomplete.AutoCompletion) KeyStroke(javax.swing.KeyStroke)

Aggregations

AutoCompletion (org.fife.ui.autocomplete.AutoCompletion)23 CompletionProvider (org.fife.ui.autocomplete.CompletionProvider)9 DefaultCompletionProvider (org.fife.ui.autocomplete.DefaultCompletionProvider)9 IOException (java.io.IOException)6 KeyStroke (javax.swing.KeyStroke)6 BadLocationException (javax.swing.text.BadLocationException)5 Method (java.lang.reflect.Method)4 Semaphore (java.util.concurrent.Semaphore)4 RSyntaxTextArea (org.fife.ui.rsyntaxtextarea.RSyntaxTextArea)4 RTextScrollPane (org.fife.ui.rtextarea.RTextScrollPane)3 JTextComponent (javax.swing.text.JTextComponent)2 CollapsibleSectionPanel (org.fife.rsta.ui.CollapsibleSectionPanel)2 FlatSVGIcon (com.formdev.flatlaf.extras.FlatSVGIcon)1 BashCompletionProvider (com.g3g4x5x6.editor.provider.BashCompletionProvider)1 JavaCompletionProvider (com.g3g4x5x6.editor.provider.JavaCompletionProvider)1 NucleiYamlCompletionProvider (com.g3g4x5x6.nuclei.NucleiYamlCompletionProvider)1 GridView (com.jeta.forms.gui.form.GridView)1 Font (java.awt.Font)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1