use of com.google.gwt.user.client.Window.ClosingEvent in project gerrit by GerritCodeReview.
the class EditScreen method onShowView.
@Override
public void onShowView() {
super.onShowView();
Window.enableScrolling(false);
JumpKeys.enable(false);
if (prefs.hideTopMenu()) {
Gerrit.setHeaderVisible(false);
}
resizeHandler = Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
adjustHeight();
}
});
closeHandler = Window.addWindowClosingHandler(new ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent event) {
if (!cmEdit.isClean(generation)) {
event.setMessage(EditConstants.I.closeUnsavedChanges());
}
}
});
generation = cmEdit.changeGeneration(true);
setClean(true);
cmEdit.on(new ChangesHandler() {
@Override
public void handle(CodeMirror cm) {
setClean(cm.isClean(generation));
}
});
adjustHeight();
cmEdit.on("cursorActivity", updateCursorPosition());
setShowTabs(prefs.showTabs());
setLineLength(prefs.lineLength());
cmEdit.refresh();
cmEdit.focus();
if (startLine > 0) {
cmEdit.scrollToLine(startLine);
}
updateActiveLine();
editPrefsAction = new EditPreferencesAction(this, prefs);
}
use of com.google.gwt.user.client.Window.ClosingEvent in project rstudio by rstudio.
the class ChunkSatelliteWindow method onInitialize.
@Override
protected void onInitialize(LayoutPanel mainPanel, JavaScriptObject params) {
chunkWindowParams_ = params.cast();
String title = "RStudio: Notebook Output";
Window.setTitle(title);
ChunkOutputHost chunkOutputHost = new ChunkOutputHost() {
@Override
public void onOutputRemoved(final ChunkOutputWidget widget) {
}
@Override
public void onOutputHeightChanged(ChunkOutputWidget widget, int height, boolean ensureVisible) {
}
};
chunkOutputWidget_ = new ChunkOutputWidget(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId(), RmdChunkOptions.create(), ChunkOutputWidget.EXPANDED, // can close
false, chunkOutputHost, ChunkOutputSize.Full);
Element ele = chunkOutputWidget_.getElement();
ele.addClassName(ThemeStyles.INSTANCE.selectableText());
// Append the chunkOutputWidget as an HTML element, not as a widget.
// Why? Chunks are widgets that are attached to the ACE editor as HTML
// elements, not as widgets. The reason being that GWT does not support
// triggering events for widgets that are not attached to their hierarchy.
// Therefore, if we attach this element as a widget, GWT will remove
// events in some cases which will cause functionality to be lost.
mainPanel.getElement().appendChild(chunkOutputWidget_.getElement());
chunkOutputWidget_.getElement().getStyle().setHeight(100, Unit.PCT);
mainPanel.addStyleName("ace_editor");
pEventBus_.get().addHandler(ChunkSatelliteCodeExecutingEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkSatelliteCacheEditorStyleEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkPlotRefreshedEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkPlotRefreshFinishedEvent.TYPE, this);
pEventBus_.get().addHandler(ChunkChangeEvent.TYPE, this);
pEventBus_.get().addHandler(RmdChunkOutputFinishedEvent.TYPE, this);
pEventBus_.get().addHandler(RmdChunkOutputEvent.TYPE, this);
Window.addWindowClosingHandler(new ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent arg0) {
server_.cleanReplayNotebookChunkPlots(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId(), new ServerRequestCallback<Void>() {
@Override
public void onError(ServerError error) {
}
});
}
});
pEventBus_.get().fireEventToMainWindow(new ChunkSatelliteWindowOpenedEvent(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId()));
}
use of com.google.gwt.user.client.Window.ClosingEvent in project rstudio by rstudio.
the class Satellite method initialize.
public void initialize(String name, CommandWithArg<JavaScriptObject> onReactivated) {
onReactivated_ = onReactivated;
initializeNative(name);
// to notifyRStudioSatelliteClosing
if (!Desktop.isDesktop()) {
Window.addWindowClosingHandler(new ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent event) {
fireCloseEvent();
}
});
}
// let main window know when we get focus
WindowEx.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent arg0) {
events_.fireEvent(new SatelliteFocusedEvent(getSatelliteName()));
}
});
}
Aggregations