Example usage for com.google.gwt.user.client Window addWindowClosingHandler

List of usage examples for com.google.gwt.user.client Window addWindowClosingHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window addWindowClosingHandler.

Prototype

public static HandlerRegistration addWindowClosingHandler(final ClosingHandler handler) 

Source Link

Document

Adds a Window.ClosingEvent handler.

Usage

From source file:org.eclipse.che.ide.bootstrap.DefaultIdeInitializationStrategy.java

License:Open Source License

private Operation<Void> showUI() {
    return aVoid -> {
        standardComponentsInitializerProvider.get().initialize();
        appStateManager.readStateFromPreferences();
        showRootPresenter();//from   w  w  w .  ja  v a2  s .c  om

        // Bind browser's window events
        Window.addWindowClosingHandler(event -> eventBus.fireEvent(createWindowClosingEvent(event)));
        Window.addCloseHandler(event -> eventBus.fireEvent(createWindowClosedEvent()));
    };
}

From source file:org.eclipse.che.ide.client.BootstrapController.java

License:Open Source License

private void displayIDE() {
    // Start UI//from   w w w.  j a va2s .co m
    SimpleLayoutPanel mainPanel = new SimpleLayoutPanel();

    RootLayoutPanel.get().add(mainPanel);

    // Make sure the root panel creates its own stacking context
    RootLayoutPanel.get().getElement().getStyle().setZIndex(0);

    WorkspacePresenter workspacePresenter = workspaceProvider.get();

    // Display IDE
    workspacePresenter.go(mainPanel);

    // Bind browser's window events
    Window.addWindowClosingHandler(new Window.ClosingHandler() {
        @Override
        public void onWindowClosing(Window.ClosingEvent event) {
            eventBus.fireEvent(WindowActionEvent.createWindowClosingEvent(event));
        }
    });

    Window.addCloseHandler(new CloseHandler<Window>() {
        @Override
        public void onClose(CloseEvent<Window> event) {
            eventBus.fireEvent(WindowActionEvent.createWindowClosedEvent());
        }
    });

    elemental.html.Window window = Browser.getWindow();

}

From source file:org.ednovo.gooru.client.mvp.assessments.play.collection.AssessmentsPlayerPresenter.java

License:Open Source License

@Inject
public AssessmentsPlayerPresenter(AssessmentsPlayerMetadataPresenter metadataPresenter,
        AssessmentsResourcePlayerMetadataPresenter resoruceMetadataPresenter,
        AssessmentsPlayerTocPresenter collectionPlayerTocPresenter,
        AssessmentsSharePresenter collectionSharePresenter,
        AssessmentsResourceInfoPresenter resourceInfoPresenter,
        AssessmentsResourceNarrationPresenter resourceNarrationPresenter, EventBus eventBus,
        IsAssessmentsPlayerView view, IsAssessmentsPlayerProxy proxy,
        AddResourceAssessmentsPresenter addResourcePresenter, AddAssessmentsPresenter addCollectionPresenter,
        AssessmentsFlagPresenter collectionFlagPresenter,
        AssessmentsResourceFlagPresenter resourceFlagPresenter, SignUpPresenter signUpViewPresenter,
        AssessmentsEndPresenter collectionEndPresenter, ShelfMainPresenter shelfMainPresenter,
        SearchAddResourceToCollectionPresenter searchAddResourceToCollectionPresenter) {
    super(view, proxy);
    getView().setUiHandlers(this);
    this.metadataPresenter = metadataPresenter;
    this.resoruceMetadataPresenter = resoruceMetadataPresenter;
    this.collectionPlayerTocPresenter = collectionPlayerTocPresenter;
    this.resourceNarrationPresenter = resourceNarrationPresenter;
    this.collectionSharePresenter = collectionSharePresenter;
    this.resourceInfoPresenter = resourceInfoPresenter;
    this.addCollectionPresenter = addCollectionPresenter;
    this.addResourcePresenter = addResourcePresenter;
    this.collectionFlagPresenter = collectionFlagPresenter;
    this.resourceFlagPresenter = resourceFlagPresenter;
    this.signUpViewPresenter = signUpViewPresenter;
    this.collectionEndPresenter = collectionEndPresenter;
    this.shelfMainPresenter = shelfMainPresenter;
    this.searchAddResourceToCollectionPresenter = searchAddResourceToCollectionPresenter;
    resoruceMetadataPresenter.setCollectionPlayerPresnter(this, true);

    getView().setFullScreenButton(resoruceMetadataPresenter.getFullScreenButton());

    getView().setNarrationButton(resoruceMetadataPresenter.getNarrationButton());
    resourceFlagPresenter.setCollectionPlayerPresenter(this);
    collectionFlagPresenter.setCollectionPlayerPresenter(this);
    metadataPresenter.setCollectionPlayerPresenter(this);
    collectionPlayerTocPresenter.setCollectionPlayerPresnter(this);
    collectionEndPresenter.setCollectionPlayerPresenter(this);
    collectionSharePresenter.setCollectionPlayerPresenter(this);
    resourceInfoPresenter.setCollectionPlayerPresenter(this);
    addResourcePresenter.getAddCollectionViewButton().setVisible(false);
    addCollectionPresenter.getAddResourceViewButton().setVisible(false);

    getView().removeStudentViewButton();
    getView().hideFlagButton(false);//www  .  j ava2s  .  c  o  m
    addRegisteredHandler(UpdateFlagIconColorEvent.TYPE, this);
    addRegisteredHandler(PostUserReviewEvent.TYPE, this);

    courseGooruId = AppClientFactory.getPlaceManager().getRequestParameter("courseId", null);
    unitGooruId = AppClientFactory.getPlaceManager().getRequestParameter("unitId", null);
    lessonGooruId = AppClientFactory.getPlaceManager().getRequestParameter("lessonId", null);

    classGooruId = AppClientFactory.getPlaceManager().getRequestParameter("cid", null);
    ;
    assessmentGooruId = AppClientFactory.getPlaceManager().getRequestParameter("id", null);
    gooruUid = AppClientFactory.getLoggedInUser().getGooruUId();

    Window.addWindowClosingHandler(new ClosingHandler() {

        @Override
        public void onWindowClosing(ClosingEvent event) {
        }
    });

}

From source file:org.geomajas.gwt.client.command.GwtCommandDispatcher.java

License:Open Source License

private GwtCommandDispatcher() {
    locale = LocaleInfo.getCurrentLocale().getLocaleName();
    if ("default".equals(locale)) {
        locale = null;/*  www.  ja  va  2 s.  c o m*/
    }
    deferreds = new ArrayList<Deferred>();
    service = (GeomajasServiceAsync) GWT.create(GeomajasService.class);
    setServiceEndPointUrl(GWT.getModuleBaseURL() + "geomajasService");
    setUseLazyLoading(true);
    setShowError(true);

    Window.addWindowClosingHandler(new ClosingHandler() {

        public void onWindowClosing(ClosingEvent event) {
            GwtCommandDispatcher.getInstance().setShowError(false);

            // Cancel all outstanding requests:
            for (Deferred deferred : deferreds) {
                deferred.cancel();
            }
        }
    });
}

From source file:org.geosdi.geoplatform.gui.client.mvc.BaseAppView.java

License:Open Source License

private void addWindowClosingListener() {
    this.handlerRegistration = Window.addWindowClosingHandler(new Window.ClosingHandler() {
        @Override//from   w w w .j  av  a  2  s. c o m
        public void onWindowClosing(Window.ClosingEvent closingEvent) {
            String message = new String();
            IMementoSave mementoSave = MementoModuleInjector.MainInjector.getInstance().getMementoSave();
            if (!mementoSave.isEmpty()) {
                message = "Warning: There are unsaved operations on the tree. ";
            }
            message += "Do you really want to leave the application?";
            closingEvent.setMessage(message);
        }
    });
}

From source file:org.geowe.client.local.initializer.EventListenerInitializer.java

License:Open Source License

public void initialize() {

    addChangelayerListener();/* ww  w  .j  a va2 s  . c om*/

    addRemoveLayerListener();

    addAddLayerListener();

    addChangeSelectedWMSLayerListener();

    Window.addWindowClosingHandler(new Window.ClosingHandler() {
        @Override
        public void onWindowClosing(final ClosingEvent event) {
            event.setMessage(UIMessages.INSTANCE.leaveWebText());
        }
    });
}

From source file:org.mindinformatics.gwt.domeo.client.Domeo.java

License:Apache License

/**
 * This is the entry point method. The bulk of the application is
 * initialized through an asynchronous pipeline. When the pipeline is
 * completed, the method completeInitialization() is called
 *//* www .j  a va 2  s  .  c  o  m*/
public void onModuleLoad() {
    _domeo = this;
    this.logger.info(this, "Creating Domeo (" + Domeo.APP_VERSION + ") " + getStartingMode());
    _this = this;

    Window.addWindowClosingHandler(new Window.ClosingHandler() {

        @Override
        public void onWindowClosing(ClosingEvent event) {

            if (_this.getAnnotationPersistenceManager().isWorskspaceUnsaved()) {
                Window.alert("The workspace contains unsaved annotation.\n\n"
                        + "By selecting 'Leaving the Page', the unsaved annotations will be lost.\n\n"
                        + "By selecting 'Stay on Page', you will have the chance to save the annotation.\n\n");
                event.setMessage("The workspace contains unsaved annotation.");
            }
        }
    });

    // Window.addCloseHandler(new CloseHandler<Window>() {
    //
    // @Override
    // public void onClose(CloseEvent<Window> event) {
    // Window.alert("2 Closing");
    //
    // }
    // });

    initApplication();

    resources.generalCss().ensureInjected();
}

From source file:org.opencms.ade.containerpage.client.CmsContainerpageController.java

License:Open Source License

/**
 * Initializes the controller.<p>//from w w  w.  j  a v a 2s . c  om
 * 
 * @param handler the container-page handler
 * @param dndHandler the drag and drop handler
 * @param contentEditorHandler the XML content editor handler
 * @param containerpageUtil the container-page utility
 */
public void init(CmsContainerpageHandler handler, CmsDNDHandler dndHandler,
        CmsContentEditorHandler contentEditorHandler, CmsContainerpageUtil containerpageUtil) {

    m_containerpageUtil = containerpageUtil;
    m_handler = handler;
    m_contentEditorHandler = contentEditorHandler;
    m_dndHandler = dndHandler;
    m_cntDndController = m_dndHandler.getController();

    m_elements = new HashMap<String, CmsContainerElementData>();
    m_newElements = new HashMap<String, CmsContainerElementData>();
    m_containerTypes = new HashSet<String>();
    m_containers = new HashMap<String, CmsContainerJso>();

    JsArray<CmsContainerJso> containers = CmsContainerJso.getContainers();
    for (int i = 0; i < containers.length(); i++) {
        CmsContainerJso container = containers.get(i);
        m_containerTypes.add(container.getType());
        m_containers.put(container.getName(), container);
    }
    m_containerBeans = createEmptyContainerBeans();
    // ensure any embedded flash players are set opaque so UI elements may be placed above them
    CmsDomUtil.fixFlashZindex(RootPanel.getBodyElement());
    m_targetContainers = m_containerpageUtil.consumeContainers(m_containers);
    for (CmsContainerPageContainer cont : m_targetContainers.values()) {
        Element elem = DOM.getElementById(cont.getContainerId());
        CmsContainerpageEditor.getZIndexManager().addContainer(cont.getContainerId(), elem);
    }
    resetEditableListButtons();
    Event.addNativePreviewHandler(new NativePreviewHandler() {

        public void onPreviewNativeEvent(NativePreviewEvent event) {

            previewNativeEvent(event);
        }
    });
    // adding on close handler
    Window.addWindowClosingHandler(new ClosingHandler() {

        /**
         * @see com.google.gwt.user.client.Window.ClosingHandler#onWindowClosing(com.google.gwt.user.client.Window.ClosingEvent)
         */
        public void onWindowClosing(ClosingEvent event) {

            deactivateOnClosing();
            if (hasPageChanged() && !isEditingDisabled()) {
                boolean savePage = Window
                        .confirm(Messages.get().key(Messages.GUI_DIALOG_SAVE_BEFORE_LEAVING_0));
                if (savePage) {
                    syncSaveContainerpage();
                } else {
                    unlockContainerpage();
                }
            }
        }
    });
}

From source file:org.opencms.ade.contenteditor.client.CmsContentEditor.java

License:Open Source License

/**
 * Initializes the window closing handler to ensure the resource will be unlocked when leaving the editor.<p>
 *///from www  .  ja va 2s. com
private void initClosingHandler() {

    m_closingHandlerRegistration = Window.addWindowClosingHandler(new ClosingHandler() {

        /**
         * @see com.google.gwt.user.client.Window.ClosingHandler#onWindowClosing(com.google.gwt.user.client.Window.ClosingEvent)
         */
        public void onWindowClosing(ClosingEvent event) {

            unlockResource();
        }
    });
}

From source file:org.opencms.gwt.client.ui.contenteditor.CmsContentEditorDialog.java

License:Open Source License

/**
 * Opens the dialog for the given sitepath.<p>
 *//* w w w .ja v  a  2 s. c om*/
protected void openDialog() {

    m_dialog = new CmsPopup(Messages.get().key(Messages.GUI_DIALOG_CONTENTEDITOR_TITLE_0) + " - "
            + (m_isNew ? m_editableData.getNewTitle() : m_editableData.getSitePath()));
    m_dialog.addStyleName(I_CmsLayoutBundle.INSTANCE.contentEditorCss().contentEditor());

    // calculate width
    int width = Window.getClientWidth();
    width = (width < 1350) ? width - 50 : 1300;
    m_dialog.setWidth(width);

    // calculate height
    int height = Window.getClientHeight() - 50;
    height = (height < 645) ? 645 : height;
    m_dialog.setHeight(height);

    m_dialog.setGlassEnabled(true);
    m_dialog.setUseAnimation(false);
    CmsIFrame editorFrame = new CmsIFrame(EDITOR_IFRAME_NAME, "");
    m_dialog.addDialogClose(new Command() {

        /**
         * @see com.google.gwt.user.client.Command#execute()
         */
        public void execute() {

            CmsConfirmDialog confirmDlg = new CmsConfirmDialog(
                    Messages.get().key(Messages.GUI_EDITOR_CLOSE_CAPTION_0),
                    Messages.get().key(Messages.GUI_EDITOR_CLOSE_TEXT_0));
            confirmDlg.setHandler(new I_CmsConfirmDialogHandler() {

                public void onClose() {

                    // do nothing
                }

                public void onOk() {

                    CmsContentEditorDialog.this.close();
                }
            });
            confirmDlg.center();
            // Let the confirm dialog handle the closing
            throw new CmsCancelCloseException();
        }
    });

    m_dialog.add(editorFrame);
    m_dialog.center();
    m_form = generateForm();
    RootPanel.getBodyElement().appendChild(m_form);
    m_form.submit();

    // adding on close handler
    m_closingHandlerRegistration = Window.addWindowClosingHandler(new ClosingHandler() {

        public void onWindowClosing(ClosingEvent event) {

            onWindowClose();
        }
    });
}