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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations