use of org.erlide.ui.console.IErlangConsolePage in project erlide_eclipse by erlang.
the class SendToConsoleAction method run.
@Override
public void run(final ITextSelection selection0) {
ITextSelection selection = selection0;
IErlangConsole console = null;
if (project != null) {
console = getConsole(project);
if (console == null) {
final String message = "There is no runtime launched for this backend. Please start a runtime to send commands to.";
final Exception x = new Exception("No runtime started");
ErrorDialog.openError(getShell(), "No runtime", message, new Status(IStatus.ERROR, ErlideUIPlugin.PLUGIN_ID, 0, x.getMessage(), x));
return;
}
console.getShell().removeListener(consoleBackendShellListener);
// if selection is empty, grab the whole line
selection = getLineSelection(selection, false);
// try to make the text a full erlang expression, ending with dot
String text = selection.getText().trim();
if (text.endsWith(",") || text.endsWith(";")) {
// $NON-NLS-1$ //$NON-NLS-2$
text = text.substring(0, text.length() - 1);
}
if (!text.endsWith(".")) {
// $NON-NLS-1$
// $NON-NLS-1$
text += ".";
}
// $NON-NLS-1$
text += "\n";
// send it off to the console
if (getOutput) {
consoleBackendShellListener = new ConsoleBackendShellListener(console.getShell(), getLineSelection(selection, true).getOffset());
console.getShell().addListener(consoleBackendShellListener);
}
final IErlangConsolePage consolePage = ErlideUIPlugin.getDefault().getErlConsoleManager().getPage(console);
consolePage.input(text);
super.run(selection);
}
}
Aggregations