use of org.fife.ui.autocomplete.AutoCompletion in project unethicalite by unethicalite.
the class ShellPanel method switchContext.
public void switchContext(Injector injector) {
freeContext();
this.injector = injector;
exec = new RLShellExecutionControl() {
@Override
protected String invoke(Method doitMethod) throws Exception {
var result = new AtomicReference<>();
var sema = new Semaphore(0);
invokeOnClientThread(() -> {
try {
result.set(super.invoke(doitMethod));
} catch (Exception e) {
result.set(e);
} finally {
sema.release();
}
});
sema.acquire();
if (result.get() instanceof String) {
return (String) result.get();
}
throw (Exception) result.get();
}
};
shell = JShell.builder().executionEngine(exec, null).build();
String preludeStr;
try (var is = ShellPanel.class.getResourceAsStream("prelude.jsh")) {
preludeStr = new String(is.readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
prelude = ImmutableSet.copyOf(eval(preludeStr, false));
var cp = new JShellAutocompleteProvider(shell);
autoCompletion = new AutoCompletion(cp);
autoCompletion.setAutoActivationDelay(200);
autoCompletion.setAutoActivationEnabled(true);
autoCompletion.setAutoCompleteSingleChoices(false);
autoCompletion.install(this.textArea);
}
use of org.fife.ui.autocomplete.AutoCompletion in project omegaide by omegaui.
the class RegexAwareComboBox method setAutoCompleteEnabled.
/**
* Toggles whether regex auto-complete is enabled. This method will fire
* a property change event of type
* {@link ContentAssistable#ASSISTANCE_IMAGE}.
*
* @param enabled Whether regex auto complete should be enabled.
* @see #isAutoCompleteEnabled()
*/
public void setAutoCompleteEnabled(boolean enabled) {
if (this.enabled != enabled) {
this.enabled = enabled;
if (enabled) {
AutoCompletion ac = getAutoCompletion();
JTextComponent tc = (JTextComponent) getEditor().getEditorComponent();
ac.install(tc);
} else {
ac.uninstall();
}
String prop = ContentAssistable.ASSISTANCE_IMAGE;
// both non-null and old.equals(new).
if (enabled) {
firePropertyChange(prop, null, getContentAssistImage());
} else {
firePropertyChange(prop, null, null);
}
}
}
use of org.fife.ui.autocomplete.AutoCompletion in project runelite by open-osrs.
the class ShellPanel method switchContext.
public void switchContext(Injector injector) {
freeContext();
this.injector = injector;
exec = new RLShellExecutionControl() {
@Override
protected String invoke(Method doitMethod) throws Exception {
var result = new AtomicReference<>();
var sema = new Semaphore(0);
invokeOnClientThread(() -> {
try {
result.set(super.invoke(doitMethod));
} catch (Exception e) {
result.set(e);
} finally {
sema.release();
}
});
sema.acquire();
if (result.get() instanceof String) {
return (String) result.get();
}
throw (Exception) result.get();
}
};
shell = JShell.builder().executionEngine(exec, null).build();
String preludeStr;
try (var is = ShellPanel.class.getResourceAsStream("prelude.jsh")) {
preludeStr = new String(is.readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
prelude = ImmutableSet.copyOf(eval(preludeStr, false));
var cp = new JShellAutocompleteProvider(shell);
autoCompletion = new AutoCompletion(cp);
autoCompletion.setAutoActivationDelay(200);
autoCompletion.setAutoActivationEnabled(true);
autoCompletion.setAutoCompleteSingleChoices(false);
autoCompletion.install(this.textArea);
}
use of org.fife.ui.autocomplete.AutoCompletion in project MeteoInfo by meteoinfo.
the class JythonLanguageSupport method install.
/**
* {@inheritDoc}
*/
@Override
public void install(RSyntaxTextArea textArea) {
JythonCompletionProvider prov = getProvider();
AutoCompletion ac = new JythonAutoCompletion(prov);
ac.setAutoCompleteEnabled(true);
ac.setAutoActivationEnabled(true);
ac.setParameterAssistanceEnabled(isParameterAssistanceEnabled());
ac.install(textArea);
installImpl(textArea, ac);
textArea.setToolTipSupplier(prov);
}
use of org.fife.ui.autocomplete.AutoCompletion in project MeteoInfo by meteoinfo.
the class AbstractLanguageSupport method uninstallImpl.
/**
* Unregisters an textArea. This should be called by subclasses in their
* {@link #uninstall(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea)} methods.
* This method will also call the <code>uninstall</code> method on the
* <code>AutoCompletion</code>.
*
* @param textArea The text area.
* @see #installImpl(RSyntaxTextArea, AutoCompletion)
*/
protected void uninstallImpl(RSyntaxTextArea textArea) {
AutoCompletion ac = getAutoCompletionFor(textArea);
if (ac != null) {
ac.uninstall();
}
textAreaToAutoCompletion.remove(textArea);
}
Aggregations