use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.
the class Source method onGetEditorContext.
@Override
public void onGetEditorContext(GetEditorContextEvent event) {
GetEditorContextEvent.Data data = event.getData();
int type = data.getType();
if (type == GetEditorContextEvent.TYPE_ACTIVE_EDITOR) {
if (consoleEditorHadFocusLast() || activeEditor_ == null)
type = GetEditorContextEvent.TYPE_CONSOLE_EDITOR;
else
type = GetEditorContextEvent.TYPE_SOURCE_EDITOR;
}
if (type == GetEditorContextEvent.TYPE_CONSOLE_EDITOR) {
InputEditorDisplay editor = consoleEditorProvider_.getConsoleEditor();
if (editor != null && editor instanceof DocDisplay) {
getEditorContext("#console", "", (DocDisplay) editor);
return;
}
} else if (type == GetEditorContextEvent.TYPE_SOURCE_EDITOR) {
EditingTarget target = activeEditor_;
if (target != null && target instanceof TextEditingTarget) {
getEditorContext(target.getId(), target.getPath(), ((TextEditingTarget) target).getDocDisplay());
return;
}
}
// We need to ensure a 'getEditorContext' event is always
// returned as we have a 'wait-for' event on the server side
server_.getEditorContextCompleted(GetEditorContextEvent.SelectionData.create(), new VoidServerRequestCallback());
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.
the class Source method saveActiveSourceDoc.
private void saveActiveSourceDoc() {
if (activeEditor_ != null && activeEditor_ instanceof TextEditingTarget) {
TextEditingTarget target = (TextEditingTarget) activeEditor_;
target.save();
}
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.
the class Source method onFindInFiles.
@Handler
public void onFindInFiles() {
String searchPattern = "";
if (activeEditor_ != null && activeEditor_ instanceof TextEditingTarget) {
TextEditingTarget textEditor = (TextEditingTarget) activeEditor_;
String selection = textEditor.getSelectedText();
boolean multiLineSelection = selection.indexOf('\n') != -1;
if ((selection.length() != 0) && !multiLineSelection)
searchPattern = selection;
}
events_.fireEvent(new FindInFilesEvent(searchPattern));
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.
the class Source method dispatchEditorEvent.
private void dispatchEditorEvent(final String id, final CommandWithArg<DocDisplay> command) {
InputEditorDisplay console = consoleEditorProvider_.getConsoleEditor();
boolean isConsoleEvent = false;
if (console != null) {
isConsoleEvent = (StringUtil.isNullOrEmpty(id) && console.isFocused()) || "#console".equals(id);
}
if (isConsoleEvent) {
command.execute((DocDisplay) console);
} else {
withTarget(id, new CommandWithArg<TextEditingTarget>() {
@Override
public void execute(TextEditingTarget target) {
command.execute(target.getDocDisplay());
}
});
}
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.
the class Source method reflowText.
private void reflowText() {
if (activeEditor_ != null && activeEditor_ instanceof TextEditingTarget) {
TextEditingTarget editor = (TextEditingTarget) activeEditor_;
editor.reflowText();
}
}
Aggregations