Search in sources :

Example 1 with ClosingEvent

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);
}
Also used : ChangesHandler(net.codemirror.lib.CodeMirror.ChangesHandler) ResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler) ClosingEvent(com.google.gwt.user.client.Window.ClosingEvent) ClosingHandler(com.google.gwt.user.client.Window.ClosingHandler) CodeMirror(net.codemirror.lib.CodeMirror) ResizeEvent(com.google.gwt.event.logical.shared.ResizeEvent)

Example 2 with ClosingEvent

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()));
}
Also used : ChunkSatelliteWindowOpenedEvent(org.rstudio.studio.client.workbench.views.source.editors.text.events.ChunkSatelliteWindowOpenedEvent) ChunkOutputHost(org.rstudio.studio.client.workbench.views.source.editors.text.rmd.ChunkOutputHost) ServerError(org.rstudio.studio.client.server.ServerError) Element(com.google.gwt.dom.client.Element) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) ClosingEvent(com.google.gwt.user.client.Window.ClosingEvent) ClosingHandler(com.google.gwt.user.client.Window.ClosingHandler)

Example 3 with ClosingEvent

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()));
        }
    });
}
Also used : SatelliteFocusedEvent(org.rstudio.studio.client.common.satellite.events.SatelliteFocusedEvent) FocusHandler(com.google.gwt.event.dom.client.FocusHandler) ClosingEvent(com.google.gwt.user.client.Window.ClosingEvent) ClosingHandler(com.google.gwt.user.client.Window.ClosingHandler) FocusEvent(com.google.gwt.event.dom.client.FocusEvent)

Aggregations

ClosingEvent (com.google.gwt.user.client.Window.ClosingEvent)3 ClosingHandler (com.google.gwt.user.client.Window.ClosingHandler)3 Element (com.google.gwt.dom.client.Element)1 FocusEvent (com.google.gwt.event.dom.client.FocusEvent)1 FocusHandler (com.google.gwt.event.dom.client.FocusHandler)1 ResizeEvent (com.google.gwt.event.logical.shared.ResizeEvent)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 CodeMirror (net.codemirror.lib.CodeMirror)1 ChangesHandler (net.codemirror.lib.CodeMirror.ChangesHandler)1 SatelliteFocusedEvent (org.rstudio.studio.client.common.satellite.events.SatelliteFocusedEvent)1 ServerError (org.rstudio.studio.client.server.ServerError)1 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)1 ChunkSatelliteWindowOpenedEvent (org.rstudio.studio.client.workbench.views.source.editors.text.events.ChunkSatelliteWindowOpenedEvent)1 ChunkOutputHost (org.rstudio.studio.client.workbench.views.source.editors.text.rmd.ChunkOutputHost)1