use of org.rstudio.studio.client.workbench.views.files.model.FileChange in project rstudio by rstudio.
the class ClientEventDispatcher method dispatchEvent.
private void dispatchEvent(ClientEvent event) {
String type = event.getType();
try {
if (type.equals(ClientEvent.Busy)) {
boolean busy = event.<Bool>getData().getValue();
eventBus_.fireEvent(new BusyEvent(busy));
} else if (type.equals(ClientEvent.ConsoleOutput)) {
ConsoleText output = event.getData();
eventBus_.fireEvent(new ConsoleWriteOutputEvent(output));
} else if (type.equals(ClientEvent.ConsoleError)) {
ConsoleText error = event.getData();
eventBus_.fireEvent(new ConsoleWriteErrorEvent(error));
} else if (type.equals(ClientEvent.ConsoleWritePrompt)) {
String prompt = event.getData();
eventBus_.fireEvent(new ConsoleWritePromptEvent(prompt));
} else if (type.equals(ClientEvent.ConsoleWriteInput)) {
ConsoleText input = event.getData();
eventBus_.fireEvent(new ConsoleWriteInputEvent(input));
} else if (type.equals(ClientEvent.ConsolePrompt)) {
ConsolePrompt prompt = event.getData();
eventBus_.fireEvent(new ConsolePromptEvent(prompt));
} else if (type.equals(ClientEvent.ShowEditor)) {
ShowEditorData data = event.getData();
eventBus_.fireEvent(new ShowEditorEvent(data));
} else if (type.equals(ClientEvent.FileChanged)) {
FileChange fileChange = event.getData();
eventBus_.fireEvent(new FileChangeEvent(fileChange));
} else if (type.equals(ClientEvent.WorkingDirChanged)) {
String path = event.getData();
eventBus_.fireEvent(new WorkingDirChangedEvent(path));
} else if (type.equals(ClientEvent.ShowHelp)) {
String helpUrl = event.getData();
eventBus_.fireEvent(new ShowHelpEvent(helpUrl));
} else if (type.equals(ClientEvent.ShowErrorMessage)) {
ErrorMessage errorMessage = event.getData();
eventBus_.fireEvent(new ShowErrorMessageEvent(errorMessage));
} else if (type.equals(ClientEvent.ChooseFile)) {
boolean newFile = event.<Bool>getData().getValue();
eventBus_.fireEvent(new ChooseFileEvent(newFile));
} else if (type.equals(ClientEvent.BrowseUrl)) {
BrowseUrlInfo urlInfo = event.getData();
eventBus_.fireEvent(new BrowseUrlEvent(urlInfo));
} else if (type.equals(ClientEvent.PlotsStateChanged)) {
PlotsState plotsState = event.getData();
eventBus_.fireEvent(new PlotsChangedEvent(plotsState));
} else if (type.equals(ClientEvent.ViewData)) {
DataView dataView = event.getData();
eventBus_.fireEvent(new ViewDataEvent(dataView));
} else if (type.equals(ClientEvent.PackageStateChanged)) {
PackageState newState = event.getData();
eventBus_.fireEvent(new PackageStateChangedEvent(newState));
} else if (type.equals(ClientEvent.PackageStatusChanged)) {
PackageStatus status = event.getData();
eventBus_.fireEvent(new PackageStatusChangedEvent(status));
} else if (type.equals(ClientEvent.Locator)) {
eventBus_.fireEvent(new LocatorEvent());
} else if (type.equals(ClientEvent.ConsoleResetHistory)) {
ConsoleResetHistory reset = event.getData();
eventBus_.fireEvent(new ConsoleResetHistoryEvent(reset));
} else if (type.equals(ClientEvent.SessionSerialization)) {
SessionSerializationAction action = event.getData();
eventBus_.fireEvent(new SessionSerializationEvent(action));
} else if (type.equals(ClientEvent.HistoryEntriesAdded)) {
RpcObjectList<HistoryEntry> entries = event.getData();
eventBus_.fireEvent(new HistoryEntriesAddedEvent(entries));
} else if (type.equals(ClientEvent.QuotaStatus)) {
QuotaStatus quotaStatus = event.getData();
eventBus_.fireEvent(new QuotaStatusEvent(quotaStatus));
} else if (type.equals(ClientEvent.FileEdit)) {
FileSystemItem file = event.getData();
eventBus_.fireEvent(new FileEditEvent(file));
} else if (type.equals(ClientEvent.ShowContent)) {
ContentItem content = event.getData();
eventBus_.fireEvent(new ShowContentEvent(content));
} else if (type.equals(ClientEvent.ShowData)) {
DataItem data = event.getData();
eventBus_.fireEvent(new ShowDataEvent(data));
} else if (type.equals(ClientEvent.AbendWarning)) {
eventBus_.fireEvent(new SessionAbendWarningEvent());
} else if (type.equals(ClientEvent.ShowWarningBar)) {
WarningBarMessage message = event.getData();
eventBus_.fireEvent(new ShowWarningBarEvent(message));
} else if (type.equals(ClientEvent.OpenProjectError)) {
OpenProjectError error = event.getData();
eventBus_.fireEvent(new OpenProjectErrorEvent(error));
} else if (type.equals(ClientEvent.VcsRefresh)) {
JsObject data = event.getData();
eventBus_.fireEvent(new VcsRefreshEvent(Reason.NA, data.getInteger("delay")));
} else if (type.equals(ClientEvent.AskPass)) {
AskPassEvent.Data data = event.getData();
eventBus_.fireEvent(new AskPassEvent(data));
} else if (type.equals(ClientEvent.ConsoleProcessOutput)) {
ServerConsoleOutputEvent.Data data = event.getData();
eventBus_.fireEvent(new ServerConsoleOutputEvent(data.getHandle(), data.getOutput(), data.isError()));
} else if (type.equals(ClientEvent.ConsoleProcessPrompt)) {
ServerConsolePromptEvent.Data data = event.getData();
eventBus_.fireEvent(new ServerConsolePromptEvent(data.getHandle(), data.getPrompt()));
} else if (type.equals(ClientEvent.ConsoleProcessCreated)) {
ConsoleProcessCreatedEvent.Data data = event.getData();
eventBus_.fireEvent(new ConsoleProcessCreatedEvent(data));
} else if (type.equals(ClientEvent.ConsoleProcessExit)) {
ServerProcessExitEvent.Data data = event.getData();
eventBus_.fireEvent(new ServerProcessExitEvent(data.getHandle(), data.getExitCode()));
} else if (type.equals(ClientEvent.HTMLPreviewStartedEvent)) {
HTMLPreviewStartedEvent.Data data = event.getData();
eventBus_.fireEvent(new HTMLPreviewStartedEvent(data));
} else if (type.equals(ClientEvent.HTMLPreviewOutputEvent)) {
String output = event.getData();
eventBus_.fireEvent(new HTMLPreviewOutputEvent(output));
} else if (type.equals(ClientEvent.HTMLPreviewCompletedEvent)) {
HTMLPreviewResult result = event.getData();
eventBus_.fireEvent(new HTMLPreviewCompletedEvent(result));
} else if (type.equals(ClientEvent.CompilePdfStartedEvent)) {
CompilePdfStartedEvent.Data data = event.getData();
eventBus_.fireEvent(new CompilePdfStartedEvent(data));
} else if (type.equals(ClientEvent.CompilePdfOutputEvent)) {
CompileOutput output = event.getData();
eventBus_.fireEvent(new CompilePdfOutputEvent(output));
} else if (type.equals(ClientEvent.CompilePdfErrorsEvent)) {
JsArray<SourceMarker> data = event.getData();
eventBus_.fireEvent(new CompilePdfErrorsEvent(data));
} else if (type.equals(ClientEvent.CompilePdfCompletedEvent)) {
CompilePdfResult result = event.getData();
eventBus_.fireEvent(new CompilePdfCompletedEvent(result));
} else if (type.equals(ClientEvent.SynctexEditFile)) {
SourceLocation sourceLocation = event.getData();
eventBus_.fireEvent(new SynctexEditFileEvent(sourceLocation));
} else if (type.equals(ClientEvent.FindResult)) {
FindResultEvent.Data data = event.getData();
eventBus_.fireEvent(new FindResultEvent(data.getHandle(), data.getResults().toArrayList()));
} else if (type.equals(ClientEvent.FindOperationEnded)) {
String data = event.getData();
eventBus_.fireEvent(new FindOperationEndedEvent(data));
} else if (type.equals(ClientEvent.RPubsUploadStatus)) {
RPubsUploadStatusEvent.Status status = event.getData();
eventBus_.fireEvent(new RPubsUploadStatusEvent(status));
} else if (type.equals(ClientEvent.BuildStarted)) {
eventBus_.fireEvent(new BuildStartedEvent());
} else if (type.equals(ClientEvent.BuildOutput)) {
CompileOutput data = event.getData();
eventBus_.fireEvent(new BuildOutputEvent(data));
} else if (type.equals(ClientEvent.BuildCompleted)) {
BuildCompletedEvent.Data data = event.getData();
eventBus_.fireEvent(new BuildCompletedEvent(data));
} else if (type.equals(ClientEvent.BuildErrors)) {
BuildErrorsEvent.Data data = event.getData();
eventBus_.fireEvent(new BuildErrorsEvent(data));
} else if (type.equals(ClientEvent.DirectoryNavigate)) {
DirectoryNavigateEvent.Data data = event.getData();
eventBus_.fireEvent(new DirectoryNavigateEvent(data));
} else if (type.equals(ClientEvent.DeferredInitCompleted)) {
eventBus_.fireEvent(new DeferredInitCompletedEvent());
} else if (type.equals(ClientEvent.PlotsZoomSizeChanged)) {
PlotsZoomSizeChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new PlotsZoomSizeChangedEvent(data));
} else if (type.equals(ClientEvent.SourceCppStarted)) {
eventBus_.fireEvent(new SourceCppStartedEvent());
} else if (type.equals(ClientEvent.SourceCppCompleted)) {
SourceCppState state = event.getData();
eventBus_.fireEvent(new SourceCppCompletedEvent(state));
} else if (type.equals(ClientEvent.LoadedPackageUpdates)) {
String installCmd = event.getData();
eventBus_.fireEvent(new LoadedPackageUpdatesEvent(installCmd));
} else if (type.equals(ClientEvent.ActivatePane)) {
String pane = event.getData();
eventBus_.fireEvent(new ActivatePaneEvent(pane));
} else if (type.equals(ClientEvent.ShowPresentationPane)) {
PresentationState state = event.getData();
eventBus_.fireEvent(new ShowPresentationPaneEvent(state));
} else if (type.equals(ClientEvent.EnvironmentRefresh)) {
eventBus_.fireEvent(new EnvironmentRefreshEvent());
} else if (type.equals(ClientEvent.ListChanged)) {
eventBus_.fireEvent(new ListChangedEvent(event.<JsObject>getData()));
} else if (type.equals(ClientEvent.UiPrefsChanged)) {
UiPrefsChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new UiPrefsChangedEvent(data));
} else if (type.equals(ClientEvent.ContextDepthChanged)) {
EnvironmentContextData data = event.getData();
eventBus_.fireEvent(new ContextDepthChangedEvent(data, true));
} else if (type.equals(ClientEvent.HandleUnsavedChanges)) {
eventBus_.fireEvent(new HandleUnsavedChangesEvent());
} else if (type.equals(ClientEvent.Quit)) {
QuitEvent.Data data = event.getData();
eventBus_.fireEvent(new QuitEvent(data));
} else if (type.equals(ClientEvent.Suicide)) {
// NOTE: we don't explicitly stop listening for events here
// for the reasons cited above in ClientEvent.Quit
// fire event
String message = event.getData();
eventBus_.fireEvent(new SuicideEvent(message));
} else if (type.equals(ClientEvent.SaveActionChanged)) {
SaveAction action = event.getData();
eventBus_.fireEvent(new SaveActionChangedEvent(action));
} else if (type.equals(ClientEvent.EnvironmentAssigned)) {
RObject objectInfo = event.getData();
eventBus_.fireEvent(new EnvironmentObjectAssignedEvent(objectInfo));
} else if (type.equals(ClientEvent.EnvironmentRemoved)) {
String objectName = event.getData();
eventBus_.fireEvent(new EnvironmentObjectRemovedEvent(objectName));
} else if (type.equals(ClientEvent.BrowserLineChanged)) {
LineData lineData = event.getData();
eventBus_.fireEvent(new BrowserLineChangedEvent(lineData));
} else if (type.equals(ClientEvent.PackageLoaded)) {
eventBus_.fireEvent(new PackageLoadedEvent((String) event.getData()));
} else if (type.equals(ClientEvent.PackageUnloaded)) {
eventBus_.fireEvent(new PackageUnloadedEvent((String) event.getData()));
} else if (type.equals(ClientEvent.PresentationPaneRequestCompleted)) {
eventBus_.fireEvent(new PresentationPaneRequestCompletedEvent());
} else if (type.equals(ClientEvent.UnhandledError)) {
UnhandledError err = event.getData();
eventBus_.fireEvent(new UnhandledErrorEvent(err));
} else if (type.equals(ClientEvent.ErrorHandlerChanged)) {
ErrorHandlerType handlerType = event.getData();
eventBus_.fireEvent(new ErrorHandlerChangedEvent(handlerType));
} else if (type.equals(ClientEvent.ViewerNavigate)) {
ViewerNavigateEvent.Data data = event.getData();
eventBus_.fireEvent(new ViewerNavigateEvent(data));
} else if (type.equals(ClientEvent.SourceExtendedTypeDetected)) {
SourceExtendedTypeDetectedEvent.Data data = event.getData();
eventBus_.fireEvent(new SourceExtendedTypeDetectedEvent(data));
} else if (type.equals(ClientEvent.ShinyViewer)) {
ShinyApplicationParams data = event.getData();
eventBus_.fireEvent(new ShinyApplicationStatusEvent(data, true));
} else if (type.equals(ClientEvent.DebugSourceCompleted)) {
DebugSourceResult result = (DebugSourceResult) event.getData();
eventBus_.fireEvent(new DebugSourceCompletedEvent(result));
} else if (type.equals(ClientEvent.RmdRenderStarted)) {
RmdRenderStartedEvent.Data data = event.getData();
eventBus_.fireEvent(new RmdRenderStartedEvent(data));
} else if (type.equals(ClientEvent.RmdRenderOutput)) {
CompileOutput data = event.getData();
eventBus_.fireEvent(new RmdRenderOutputEvent(data));
} else if (type.equals(ClientEvent.RmdRenderCompleted)) {
RmdRenderResult result = event.getData();
eventBus_.fireEvent(new RmdRenderCompletedEvent(result));
} else if (type.equals(ClientEvent.RmdShinyDocStarted)) {
RmdShinyDocInfo docInfo = event.getData();
eventBus_.fireEvent(new RmdShinyDocStartedEvent(docInfo));
} else if (type.equals(ClientEvent.RSConnectDeploymentOutput)) {
CompileOutput output = event.getData();
eventBus_.fireEvent(new RSConnectDeploymentOutputEvent(output));
} else if (type.equals(ClientEvent.RSConnectDeploymentCompleted)) {
String url = event.getData();
eventBus_.fireEvent(new RSConnectDeploymentCompletedEvent(url));
} else if (type.equals(ClientEvent.RSConnectDeploymentFailed)) {
RSConnectDeploymentFailedEvent.Data data = event.getData();
eventBus_.fireEvent(new RSConnectDeploymentFailedEvent(data));
} else if (type.equals(ClientEvent.UserPrompt)) {
UserPrompt prompt = event.getData();
eventBus_.fireEvent(new UserPromptEvent(prompt));
} else if (type.equals(ClientEvent.InstallRtools)) {
InstallRtoolsEvent.Data data = event.getData();
eventBus_.fireEvent(new InstallRtoolsEvent(data));
} else if (type.equals(ClientEvent.InstallShiny)) {
String userAction = event.getData();
eventBus_.fireEvent(new InstallShinyEvent(userAction));
} else if (type.equals(ClientEvent.SuspendAndRestart)) {
SuspendAndRestartEvent.Data data = event.getData();
eventBus_.fireEvent(new SuspendAndRestartEvent(data));
} else if (type.equals(ClientEvent.DataViewChanged)) {
DataViewChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new DataViewChangedEvent(data));
} else if (type.equals(ClientEvent.ViewFunction)) {
SearchPathFunctionDefinition data = event.getData();
eventBus_.fireEvent(new CodeBrowserNavigationEvent(data, null, false, true));
} else if (type.equals(ClientEvent.MarkersChanged)) {
MarkersChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new MarkersChangedEvent(data));
} else if (type.equals(ClientEvent.EnableRStudioConnect)) {
EnableRStudioConnectUIEvent.Data data = event.getData();
eventBus_.fireEvent(new EnableRStudioConnectUIEvent(data));
} else if (type.equals(ClientEvent.UpdateGutterMarkers)) {
LintEvent.Data data = event.getData();
eventBus_.fireEvent(new LintEvent(data));
} else if (type.equals(ClientEvent.SnippetsChanged)) {
SnippetsChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new SnippetsChangedEvent(data));
} else if (type.equals(ClientEvent.JumpToFunction)) {
JumpToFunctionEvent.Data data = event.getData();
eventBus_.fireEvent(new JumpToFunctionEvent(data));
} else if (type.equals(ClientEvent.CollabEditStarted)) {
CollabEditStartParams params = event.getData();
eventBus_.fireEvent(new CollabEditStartedEvent(params));
} else if (type.equals(ClientEvent.SessionCountChanged)) {
SessionCountChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new SessionCountChangedEvent(data));
} else if (type.equals(ClientEvent.CollabEditEnded)) {
CollabEditEndedEvent.Data data = event.getData();
eventBus_.fireEvent(new CollabEditEndedEvent(data));
} else if (type.equals(ClientEvent.ProjectUsersChanged)) {
ProjectUserChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new ProjectUserChangedEvent(data));
} else if (type.equals(ClientEvent.RVersionsChanged)) {
RVersionsInfo versions = event.getData();
eventBus_.fireEvent(new RVersionsChangedEvent(versions));
} else if (type.equals(ClientEvent.ShinyGadgetDialog)) {
ShinyGadgetDialogEvent.Data data = event.getData();
eventBus_.fireEvent(new ShinyGadgetDialogEvent(data));
} else if (type.equals(ClientEvent.RmdParamsReady)) {
String paramsFile = event.getData();
eventBus_.fireEvent(new RmdParamsReadyEvent(paramsFile));
} else if (type.equals(ClientEvent.RegisterUserCommand)) {
RegisterUserCommandEvent.Data data = event.getData();
eventBus_.fireEvent(new RegisterUserCommandEvent(data));
} else if (type.equals(ClientEvent.SendToConsole)) {
SendToConsoleEvent.Data data = event.getData();
eventBus_.fireEvent(new SendToConsoleEvent(data));
} else if (type.equals(ClientEvent.UserFollowStarted)) {
ProjectUser user = event.getData();
eventBus_.fireEvent(new FollowUserEvent(user, true));
} else if (type.equals(ClientEvent.UserFollowEnded)) {
ProjectUser user = event.getData();
eventBus_.fireEvent(new FollowUserEvent(user, false));
} else if (type.equals(ClientEvent.ProjectAccessRevoked)) {
eventBus_.fireEvent(new ProjectAccessRevokedEvent());
} else if (type.equals(ClientEvent.CollabEditSaved)) {
CollabEditSavedEvent.Data data = event.getData();
eventBus_.fireEvent(new CollabEditSavedEvent(data));
} else if (type.equals(ClientEvent.AddinRegistryUpdated)) {
RAddins data = event.getData();
eventBus_.fireEvent(new AddinRegistryUpdatedEvent(data));
} else if (type.equals(ClientEvent.ChunkOutput)) {
RmdChunkOutput data = event.getData();
eventBus_.fireEvent(new RmdChunkOutputEvent(data));
} else if (type.equals(ClientEvent.ChunkOutputFinished)) {
RmdChunkOutputFinishedEvent.Data data = event.getData();
eventBus_.fireEvent(new RmdChunkOutputFinishedEvent(data));
} else if (type.equals(ClientEvent.RprofStarted)) {
eventBus_.fireEvent(new RprofEvent(RprofEvent.RprofEventType.START, null));
} else if (type.equals(ClientEvent.RprofStopped)) {
eventBus_.fireEvent(new RprofEvent(RprofEvent.RprofEventType.STOP, null));
} else if (type.equals(ClientEvent.RprofCreated)) {
RprofEvent.Data data = event.getData();
eventBus_.fireEvent(new RprofEvent(RprofEvent.RprofEventType.CREATE, data));
} else if (type.equals(ClientEvent.EditorCommand)) {
EditorCommandEvent.Data data = event.getData();
EditorCommandEvent payload = new EditorCommandEvent(data);
eventBus_.fireEvent(new EditorCommandDispatchEvent(payload));
} else if (type.equals(ClientEvent.PreviewRmd)) {
PreviewRmdEvent.Data data = event.getData();
eventBus_.fireEvent(new PreviewRmdEvent(data));
} else if (type.equals(ClientEvent.WebsiteFileSaved)) {
FileSystemItem fsi = event.getData();
eventBus_.fireEvent(new WebsiteFileSavedEvent(fsi));
} else if (type.equals(ClientEvent.ChunkPlotRefreshed)) {
ChunkPlotRefreshedEvent.Data data = event.getData();
eventBus_.fireEvent(new ChunkPlotRefreshedEvent(data));
} else if (type.equals(ClientEvent.ChunkPlotRefreshFinished)) {
ChunkPlotRefreshFinishedEvent.Data data = event.getData();
eventBus_.fireEvent(new ChunkPlotRefreshFinishedEvent(data));
} else if (type.equals(ClientEvent.ReloadWithLastChanceSave)) {
eventBus_.fireEvent(new ReloadWithLastChanceSaveEvent());
} else if (type.equals(ClientEvent.ConnectionUpdated)) {
ConnectionUpdatedEvent.Data data = event.getData();
eventBus_.fireEvent(new ConnectionUpdatedEvent(data));
} else if (type.equals(ClientEvent.EnableConnections)) {
eventBus_.fireEvent(new EnableConnectionsEvent());
} else if (type.equals(ClientEvent.ConnectionListChanged)) {
JsArray<Connection> connections = event.getData();
eventBus_.fireEvent(new ConnectionListChangedEvent(connections));
} else if (type.equals(ClientEvent.ActiveConnectionsChanged)) {
JsArray<ConnectionId> connections = event.getData();
eventBus_.fireEvent(new ActiveConnectionsChangedEvent(connections));
} else if (type.equals(ClientEvent.ConnectionOpened)) {
Connection connection = event.getData();
eventBus_.fireEvent(new ConnectionOpenedEvent(connection));
} else if (type.equals(ClientEvent.NotebookRangeExecuted)) {
NotebookRangeExecutedEvent.Data data = event.getData();
eventBus_.fireEvent(new NotebookRangeExecutedEvent(data));
} else if (type.equals(ClientEvent.ChunkExecStateChanged)) {
ChunkExecStateChangedEvent.Data data = event.getData();
eventBus_.fireEvent(new ChunkExecStateChangedEvent(data));
} else if (type.equals(ClientEvent.NavigateShinyFrame)) {
ShinyFrameNavigatedEvent.Data data = event.getData();
eventBus_.fireEvent(new ShinyFrameNavigatedEvent(data));
} else if (type.equals(ClientEvent.UpdateNewConnectionDialog)) {
NewConnectionDialogUpdatedEvent.Data data = event.getData();
eventBus_.fireEvent(new NewConnectionDialogUpdatedEvent(data));
} else if (type.equals(ClientEvent.ProjectTemplateRegistryUpdated)) {
ProjectTemplateRegistry data = event.getData();
eventBus_.fireEvent(new ProjectTemplateRegistryUpdatedEvent(data));
} else if (type.equals(ClientEvent.TerminalSubProcs)) {
TerminalSubprocEvent.Data data = event.getData();
eventBus_.fireEvent(new TerminalSubprocEvent(data));
} else if (type.equals(ClientEvent.PackageExtensionIndexingCompleted)) {
PackageProvidedExtensions.Data data = event.getData();
eventBus_.fireEvent(new PackageExtensionIndexingCompletedEvent(data));
} else if (type.equals(ClientEvent.RStudioAPIShowDialog)) {
RStudioAPIShowDialogEvent.Data data = event.getData();
eventBus_.fireEvent(new RStudioAPIShowDialogEvent(data));
} else {
GWT.log("WARNING: Server event not dispatched: " + type, null);
}
} catch (Throwable e) {
GWT.log("WARNING: Exception occured dispatching event: " + type, e);
}
}
use of org.rstudio.studio.client.workbench.views.files.model.FileChange in project rstudio by rstudio.
the class TextEditingTarget method initialize.
public void initialize(final SourceDocument document, FileSystemContext fileContext, FileType type, Provider<String> defaultNameProvider) {
id_ = document.getId();
fileContext_ = fileContext;
fileType_ = (TextFileType) type;
codeExecution_ = new EditingTargetCodeExecution(this, docDisplay_, getId(), this);
extendedType_ = document.getExtendedType();
extendedType_ = rmarkdownHelper_.detectExtendedType(document.getContents(), extendedType_, fileType_);
themeHelper_ = new TextEditingTargetThemeHelper(this, events_);
docUpdateSentinel_ = new DocUpdateSentinel(server_, docDisplay_, document, globalDisplay_.getProgressIndicator("Save File"), dirtyState_, events_);
view_ = new TextEditingTargetWidget(this, docUpdateSentinel_, commands_, prefs_, fileTypeRegistry_, docDisplay_, fileType_, extendedType_, events_, session_);
roxygenHelper_ = new RoxygenHelper(docDisplay_, view_);
// create notebook and forward resize events
chunks_ = new TextEditingTargetChunks(this);
notebook_ = new TextEditingTargetNotebook(this, chunks_, view_, docDisplay_, dirtyState_, docUpdateSentinel_, document, releaseOnDismiss_, dependencyManager_);
view_.addResizeHandler(notebook_);
// ensure that Makefile and Makevars always use tabs
name_.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
if ("Makefile".equals(event.getValue()) || "Makefile.in".equals(event.getValue()) || "Makefile.win".equals(event.getValue()) || "Makevars".equals(event.getValue()) || "Makevars.in".equals(event.getValue()) || "Makevars.win".equals(event.getValue())) {
docDisplay_.setUseSoftTabs(false);
}
}
});
name_.setValue(getNameFromDocument(document, defaultNameProvider), true);
String contents = document.getContents();
docDisplay_.setCode(contents, false);
// Load and apply folds.
final ArrayList<Fold> folds = Fold.decode(document.getFoldSpec());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
for (Fold fold : folds) docDisplay_.addFold(fold.getRange());
}
});
// Load and apply Vim marks (if they exist).
if (document.getProperties().hasKey("marks")) {
final String marksSpec = document.getProperties().getString("marks");
final JsMap<Position> marks = VimMarks.decode(marksSpec);
// Time out the marks setting just to avoid conflict with other
// mutations of the editor.
new Timer() {
@Override
public void run() {
docDisplay_.setMarks(marks);
}
}.schedule(100);
}
registerPrefs(releaseOnDismiss_, prefs_, docDisplay_, document);
// Initialize sourceOnSave, and keep it in sync
view_.getSourceOnSave().setValue(document.sourceOnSave(), false);
view_.getSourceOnSave().addValueChangeHandler(new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> event) {
docUpdateSentinel_.setSourceOnSave(event.getValue(), globalDisplay_.getProgressIndicator("Error Saving Setting"));
}
});
if (document.isDirty())
dirtyState_.markDirty(false);
else
dirtyState_.markClean();
docDisplay_.addValueChangeHandler(new ValueChangeHandler<Void>() {
public void onValueChange(ValueChangeEvent<Void> event) {
dirtyState_.markDirty(true);
docDisplay_.clearSelectionHistory();
}
});
docDisplay_.addFocusHandler(new FocusHandler() {
public void onFocus(FocusEvent event) {
// let anyone listening know this doc just got focus
events_.fireEvent(new DocFocusedEvent(getPath(), getId()));
if (queuedCollabParams_ != null) {
// of one
if (docDisplay_ != null && !docDisplay_.hasActiveCollabSession()) {
beginQueuedCollabSession();
}
}
// check to see if the file's been saved externally--we do this even
// in a collaborative editing session so we can get delete
// notifications
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
public boolean execute() {
if (view_.isAttached())
checkForExternalEdit();
return false;
}
}, 500);
}
});
if (fileType_.isR()) {
docDisplay_.addBreakpointSetHandler(new BreakpointSetEvent.Handler() {
@Override
public void onBreakpointSet(BreakpointSetEvent event) {
if (event.isSet()) {
Breakpoint breakpoint = null;
// don't try to set breakpoints in unsaved code
if (isNewDoc()) {
view_.showWarningBar("Breakpoints cannot be set until " + "the file is saved.");
return;
}
// don't try to set breakpoints if the R version is too old
if (!session_.getSessionInfo().getHaveSrcrefAttribute()) {
view_.showWarningBar("Editor breakpoints require R 2.14 " + "or newer.");
return;
}
Position breakpointPosition = Position.create(event.getLineNumber() - 1, 1);
// if we're not in function scope, or this is a Shiny file,
// set a top-level (aka. Shiny-deferred) breakpoint
ScopeFunction innerFunction = null;
if (extendedType_ == null || !extendedType_.startsWith(SourceDocument.XT_SHINY_PREFIX))
innerFunction = docDisplay_.getFunctionAtPosition(breakpointPosition, false);
if (innerFunction == null || !innerFunction.isFunction() || StringUtil.isNullOrEmpty(innerFunction.getFunctionName())) {
breakpoint = breakpointManager_.setTopLevelBreakpoint(getPath(), event.getLineNumber());
} else // the scope tree will find nested functions, but in R these
// are addressable only as substeps of the parent function.
// keep walking up the scope tree until we've reached the top
// level function.
{
while (innerFunction.getParentScope() != null && innerFunction.getParentScope().isFunction()) {
innerFunction = (ScopeFunction) innerFunction.getParentScope();
}
String functionName = innerFunction.getFunctionName();
breakpoint = breakpointManager_.setBreakpoint(getPath(), functionName, event.getLineNumber(), dirtyState().getValue() == false);
}
docDisplay_.addOrUpdateBreakpoint(breakpoint);
} else {
breakpointManager_.removeBreakpoint(event.getBreakpointId());
}
updateBreakpointWarningBar();
}
});
docDisplay_.addBreakpointMoveHandler(new BreakpointMoveEvent.Handler() {
@Override
public void onBreakpointMove(BreakpointMoveEvent event) {
breakpointManager_.moveBreakpoint(event.getBreakpointId());
}
});
}
// validate required components (e.g. Tex, knitr, C++ etc.)
checkCompilePdfDependencies();
rmarkdownHelper_.verifyPrerequisites(view_, fileType_);
syncFontSize(releaseOnDismiss_, events_, view_, fontSizeManager_);
final String rTypeId = FileTypeRegistry.R.getTypeId();
releaseOnDismiss_.add(prefs_.softWrapRFiles().addValueChangeHandler(new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> evt) {
if (fileType_.getTypeId().equals(rTypeId))
view_.adaptToFileType(fileType_);
}
}));
releaseOnDismiss_.add(events_.addHandler(FileChangeEvent.TYPE, new FileChangeHandler() {
@Override
public void onFileChange(FileChangeEvent event) {
// screen out adds and events that aren't for our path
FileChange fileChange = event.getFileChange();
if (fileChange.getType() == FileChange.ADD)
return;
else if (!fileChange.getFile().getPath().equals(getPath()))
return;
// always check for changes if this is the active editor
if (commandHandlerReg_ != null) {
checkForExternalEdit();
} else // this will show a confirmation dialog
if (event.getFileChange().getType() == FileChange.MODIFIED && dirtyState().getValue() == false) {
checkForExternalEdit();
}
}
}));
spelling_ = new TextEditingTargetSpelling(docDisplay_, docUpdateSentinel_);
// show/hide the debug toolbar when the dirty state changes. (note:
// this doesn't yet handle the case where the user saves the document,
// in which case we should still show some sort of warning.)
dirtyState().addValueChangeHandler(new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> evt) {
updateDebugWarningBar();
}
});
// find all of the debug breakpoints set in this document and replay them
// onto the edit surface
ArrayList<Breakpoint> breakpoints = breakpointManager_.getBreakpointsInFile(getPath());
for (Breakpoint breakpoint : breakpoints) {
docDisplay_.addOrUpdateBreakpoint(breakpoint);
}
if (extendedType_.equals(SourceDocument.XT_RMARKDOWN)) {
// populate the popup menu with a list of available formats
updateRmdFormatList();
setRMarkdownBehaviorEnabled(true);
}
view_.addRmdFormatChangedHandler(new RmdOutputFormatChangedEvent.Handler() {
@Override
public void onRmdOutputFormatChanged(RmdOutputFormatChangedEvent event) {
setRmdFormat(event.getFormat());
}
});
syncPublishPath(document.getPath());
initStatusBar();
}
Aggregations