List of usage examples for com.google.gwt.user.client Window addCloseHandler
public static HandlerRegistration addCloseHandler(final CloseHandler<Window> handler)
From source file:org.jboss.errai.bus.client.framework.ClientMessageBusImpl.java
License:Apache License
public ClientMessageBusImpl() { setBusToInitializableState();// w ww . j a v a 2 s . c o m managementConsole = new ManagementConsole(this); clientId = String.valueOf(com.google.gwt.user.client.Random.nextInt(99999)) + "-" + (System.currentTimeMillis() % (com.google.gwt.user.client.Random.nextInt(99999) + 1)); IN_SERVICE_ENTRY_POINT = "in." + getClientId() + ".erraiBus"; OUT_SERVICE_ENTRY_POINT = "out." + getClientId() + ".erraiBus"; // when the window is closing, we want to stop the bus without causing any // errors (unless the server is unavailable of course) (see ERRAI-225) Window.addCloseHandler(new CloseHandler<Window>() { @Override public void onClose(final CloseEvent<Window> event) { if (state != BusState.LOCAL_ONLY) { stop(true); } } }); }
From source file:org.openelis.modules.animalSampleLogin1.client.AnimalSampleLoginScreenUI.java
License:Open Source License
/** * If the checkbox of the menu item "Add With TRF" is checked, opens the * data entry attachment screen and executes the query to fetch unattached * attachments for this domain; if the checkbox is unchecked, closes the * attachment screen if it's open./*from ww w. j a v a 2s .c o m*/ */ protected void addWithTRF() { org.openelis.ui.widget.Window window; ScheduledCommand cmd; AttachmentEntry entry; if (!addWithTRF.isChecked()) { /* * the user unchecked the checkbox for showing Attachment screen, so * try to close that screen if it's open, but recheck the checkbox * to make sure that if the screen can't be closed due to some * record locked on it, the checkbox doesn't stay unchecked */ addWithTRF.setCheck(true); if (trfAttachmentScreen != null) trfAttachmentScreen.getWindow().close(); return; } try { /* * get the system variable that specifies the pattern for finding * this domain's TRFs */ if (attachmentPatternVariable == null) attachmentPatternVariable = SystemVariableService1Impl.INSTANCE .fetchByExactName("attachment_pattern_animal"); /* * the user checked the checkbox for showing attachment screen, so * open that screen if it's closed */ if (trfAttachmentScreen == null) { trfAttachmentScreen = new TRFAttachmentScreenUI() { @Override public String getPattern() { return attachmentPatternVariable.getValue(); } }; } entry = new AttachmentEntry(); window = entry.addTRFScreen(trfAttachmentScreen, "aniTRFAttachment"); isAttachmentScreenOpen = true; /* * a ScheduledCommand is used here because otherwise any "Busy" * message shown by the trf attachment screen get overwritten by the * default "Done" message shown on creating the window */ cmd = new ScheduledCommand() { @Override public void execute() { trfAttachmentScreen.fetchUnattached(); } }; Scheduler.get().scheduleDeferred(cmd); window.addCloseHandler(new CloseHandler<WindowInt>() { @Override public void onClose(CloseEvent<WindowInt> event) { isAttachmentScreenOpen = false; if (closeLoginScreen) /* * the login screen needs to be closed because it is * waiting for Attachment screen to be closed */ screen.window.close(); else addWithTRF.setCheck(false); } }); } catch (Throwable e) { Window.alert(e.getMessage()); logger.log(Level.SEVERE, e.getMessage(), e); } }
From source file:org.openelis.modules.clinicalSampleLogin1.client.ClinicalSampleLoginScreenUI.java
License:Open Source License
/** * If the checkbox of the menu item "Add With TRF" is checked, opens the * data entry attachment screen and executes the query to fetch unattached * attachments for this domain; if the checkbox is unchecked, closes the * attachment screen if it's open.//w ww.j a va 2 s .c om */ protected void addWithTRF() { org.openelis.ui.widget.Window window; ScheduledCommand cmd; AttachmentEntry entry; if (!addWithTRF.isChecked()) { /* * the user unchecked the checkbox for showing Attachment screen, so * try to close that screen if it's open, but recheck the checkbox * to make sure that if the screen can't be closed due to some * record locked on it, the checkbox doesn't stay unchecked */ addWithTRF.setCheck(true); if (trfAttachmentScreen != null) trfAttachmentScreen.getWindow().close(); return; } try { /* * get the system variable that specifies the pattern for finding * this domain's TRFs */ if (attachmentPatternVariable == null) attachmentPatternVariable = SystemVariableService1Impl.INSTANCE .fetchByExactName("attachment_pattern_clinical"); /* * the user checked the checkbox for showing attachment screen, so * open that screen if it's closed */ if (trfAttachmentScreen == null) { trfAttachmentScreen = new TRFAttachmentScreenUI() { @Override public String getPattern() { return attachmentPatternVariable.getValue(); } }; } entry = new AttachmentEntry(); window = entry.addTRFScreen(trfAttachmentScreen, "clinTRFAttachment"); isAttachmentScreenOpen = true; /* * a ScheduledCommand is used here because otherwise any "Busy" * message shown by the trf attachment screen get overwritten by the * default "Done" message shown on creating the window */ cmd = new ScheduledCommand() { @Override public void execute() { trfAttachmentScreen.fetchUnattached(); } }; Scheduler.get().scheduleDeferred(cmd); window.addCloseHandler(new CloseHandler<WindowInt>() { @Override public void onClose(CloseEvent<WindowInt> event) { isAttachmentScreenOpen = false; if (closeLoginScreen) /* * the login screen needs to be closed because it is * waiting for Attachment screen to be closed */ screen.window.close(); else addWithTRF.setCheck(false); } }); } catch (Throwable e) { Window.alert(e.getMessage()); logger.log(Level.SEVERE, e.getMessage(), e); } }
From source file:org.openelis.modules.environmentalSampleLogin1.client.EnvironmentalSampleLoginScreenUI.java
License:Open Source License
/** * If the checkbox of the menu item "Add With TRF" is checked, opens the * data entry attachment screen and executes the query to fetch unattached * attachments for this domain; if the checkbox is unchecked, closes the * attachment screen if it's open./*ww w . ja v a 2 s . c om*/ */ protected void addWithTRF() { org.openelis.ui.widget.Window window; ScheduledCommand cmd; AttachmentEntry entry; if (!addWithTRF.isChecked()) { /* * the user unchecked the checkbox for showing Attachment screen, so * try to close that screen if it's open, but recheck the checkbox * to make sure that if the screen can't be closed due to some * record locked on it, the checkbox doesn't stay unchecked */ addWithTRF.setCheck(true); if (trfAttachmentScreen != null) trfAttachmentScreen.getWindow().close(); return; } try { /* * get the system variable that specifies the pattern for finding * this domain's TRFs */ if (attachmentPatternVariable == null) attachmentPatternVariable = SystemVariableService1Impl.INSTANCE .fetchByExactName("attachment_pattern_env"); /* * the user checked the checkbox for showing attachment screen, so * open that screen if it's closed */ if (trfAttachmentScreen == null) { trfAttachmentScreen = new TRFAttachmentScreenUI() { @Override public String getPattern() { return attachmentPatternVariable.getValue(); } }; } entry = new AttachmentEntry(); window = entry.addTRFScreen(trfAttachmentScreen, "envTRFAttachment"); isAttachmentScreenOpen = true; /* * a ScheduledCommand is used here because otherwise any "Busy" * message shown by the trf attachment screen get overwritten by the * default "Done" message shown on creating the window */ cmd = new ScheduledCommand() { @Override public void execute() { trfAttachmentScreen.fetchUnattached(); } }; Scheduler.get().scheduleDeferred(cmd); window.addCloseHandler(new CloseHandler<WindowInt>() { @Override public void onClose(CloseEvent<WindowInt> event) { isAttachmentScreenOpen = false; if (closeLoginScreen) /* * the login screen needs to be closed because it is * waiting for attachment screen to be closed */ screen.window.close(); else addWithTRF.setCheck(false); /* * make sure that all detached tabs are closed when the * attachment screen is closed */ trfAttachmentScreen.closeTabPanel(); } }); } catch (Throwable e) { Window.alert(e.getMessage()); logger.log(Level.SEVERE, e.getMessage(), e); } }
From source file:org.openelis.modules.neonatalScreeningSampleLogin.client.NeonatalScreeningSampleLoginScreenUI.java
License:Open Source License
/** * If the checkbox of the menu item "Add With TRF" is checked, opens the * data entry attachment screen and executes the query to fetch unattached * attachments for this domain; if the checkbox is unchecked, closes the * attachment screen if it's open.//from w w w. j a v a 2 s . c om */ protected void addWithTRF() { org.openelis.ui.widget.Window window; ScheduledCommand cmd; AttachmentEntry entry; if (!addWithTRF.isChecked()) { /* * the user unchecked the checkbox for showing Attachment screen, so * try to close that screen if it's open, but recheck the checkbox * to make sure that if the screen can't be closed due to some * record locked on it, the checkbox doesn't stay unchecked */ addWithTRF.setCheck(true); if (trfAttachmentScreen != null) trfAttachmentScreen.getWindow().close(); return; } try { /* * get the system variable that specifies the pattern for finding * this domain's TRFs */ if (attachmentPatternVariable == null) attachmentPatternVariable = SystemVariableService1Impl.INSTANCE .fetchByExactName("attachment_pattern_neonatal"); /* * the user checked the checkbox for showing attachment screen, so * open that screen if it's closed */ if (trfAttachmentScreen == null) { trfAttachmentScreen = new TRFAttachmentScreenUI() { @Override public String getPattern() { return attachmentPatternVariable.getValue(); } }; } entry = new AttachmentEntry(); window = entry.addTRFScreen(trfAttachmentScreen, "neoTRFAttachment"); isAttachmentScreenOpen = true; /* * a ScheduledCommand is used here because otherwise any "Busy" * message shown by the trf attachment screen get overwritten by the * default "Done" message shown on creating the window */ cmd = new ScheduledCommand() { @Override public void execute() { trfAttachmentScreen.fetchUnattached(); } }; Scheduler.get().scheduleDeferred(cmd); window.addCloseHandler(new CloseHandler<WindowInt>() { @Override public void onClose(CloseEvent<WindowInt> event) { isAttachmentScreenOpen = false; if (closeLoginScreen) /* * the login screen needs to be closed because it is * waiting for Attachment screen to be closed */ screen.window.close(); else addWithTRF.setCheck(false); } }); } catch (Throwable e) { Window.alert(e.getMessage()); logger.log(Level.SEVERE, e.getMessage(), e); } }
From source file:org.openelis.modules.PTSampleLogin1.client.PTSampleLoginScreenUI.java
License:Open Source License
/** * If the checkbox of the menu item "Add With TRF" is checked, opens the * data entry attachment screen and executes the query to fetch unattached * attachments for this domain; if the checkbox is unchecked, closes the * attachment screen if it's open./* w ww .j a va 2 s. c o m*/ */ protected void addWithTRF() { org.openelis.ui.widget.Window window; ScheduledCommand cmd; AttachmentEntry entry; if (!addWithTRF.isChecked()) { /* * the user unchecked the checkbox for showing Attachment screen, so * try to close that screen if it's open, but recheck the checkbox * to make sure that if the screen can't be closed due to some * record locked on it, the checkbox doesn't stay unchecked */ addWithTRF.setCheck(true); if (trfAttachmentScreen != null) trfAttachmentScreen.getWindow().close(); return; } try { /* * get the system variable that specifies the pattern for finding * this domain's TRFs */ if (attachmentPatternVariable == null) attachmentPatternVariable = SystemVariableService1Impl.INSTANCE .fetchByExactName("attachment_pattern_pt"); /* * the user checked the checkbox for showing attachment screen, so * open that screen if it's closed */ if (trfAttachmentScreen == null) { trfAttachmentScreen = new TRFAttachmentScreenUI() { @Override public String getPattern() { return attachmentPatternVariable.getValue(); } }; } entry = new AttachmentEntry(); window = entry.addTRFScreen(trfAttachmentScreen, "ptTRFAttachment"); isAttachmentScreenOpen = true; /* * a ScheduledCommand is used here because otherwise any "Busy" * message shown by the trf attachment screen get overwritten by the * default "Done" message shown on creating the window */ cmd = new ScheduledCommand() { @Override public void execute() { trfAttachmentScreen.fetchUnattached(); } }; Scheduler.get().scheduleDeferred(cmd); window.addCloseHandler(new CloseHandler<WindowInt>() { @Override public void onClose(CloseEvent<WindowInt> event) { isAttachmentScreenOpen = false; if (closeLoginScreen) /* * the login screen needs to be closed because it is * waiting for Attachment screen to be closed */ screen.window.close(); else addWithTRF.setCheck(false); } }); } catch (Throwable e) { Window.alert(e.getMessage()); logger.log(Level.SEVERE, e.getMessage(), e); } }
From source file:org.openelis.modules.SDWISSampleLogin1.client.SDWISSampleLoginScreenUI.java
License:Open Source License
/** * If the checkbox of the menu item "Add With TRF" is checked, opens the * data entry attachment screen and executes the query to fetch unattached * attachments for this domain; if the checkbox is unchecked, closes the * attachment screen if it's open./*from w w w . j a v a 2s. c o m*/ */ protected void addWithTRF() { org.openelis.ui.widget.Window window; ScheduledCommand cmd; AttachmentEntry entry; if (!addWithTRF.isChecked()) { /* * the user unchecked the checkbox for showing Attachment screen, so * try to close that screen if it's open, but recheck the checkbox * to make sure that if the screen can't be closed due to some * record locked on it, the checkbox doesn't stay unchecked */ addWithTRF.setCheck(true); if (trfAttachmentScreen != null) trfAttachmentScreen.getWindow().close(); return; } try { /* * get the system variable that specifies the pattern for finding * this domain's TRFs */ if (attachmentPatternVariable == null) attachmentPatternVariable = SystemVariableService1Impl.INSTANCE .fetchByExactName("attachment_pattern_sdwis"); /* * the user checked the checkbox for showing attachment screen, so * open that screen if it's closed */ if (trfAttachmentScreen == null) { trfAttachmentScreen = new TRFAttachmentScreenUI() { @Override public String getPattern() { return attachmentPatternVariable.getValue(); } }; } entry = new AttachmentEntry(); window = entry.addTRFScreen(trfAttachmentScreen, "sdwisTRFAttachment"); isAttachmentScreenOpen = true; /* * a ScheduledCommand is used here because otherwise any "Busy" * message shown by the trf attachment screen get overwritten by the * default "Done" message shown on intializing the screen's window */ cmd = new ScheduledCommand() { @Override public void execute() { trfAttachmentScreen.fetchUnattached(); } }; Scheduler.get().scheduleDeferred(cmd); window.addCloseHandler(new CloseHandler<WindowInt>() { @Override public void onClose(CloseEvent<WindowInt> event) { isAttachmentScreenOpen = false; if (closeLoginScreen) /* * the login screen needs to be closed because it is * waiting for Attachment screen to be closed */ screen.window.close(); else addWithTRF.setCheck(false); } }); } catch (Throwable e) { Window.alert(e.getMessage()); logger.log(Level.SEVERE, e.getMessage(), e); } }
From source file:org.rstudio.studio.client.common.satellite.SatelliteManager.java
License:Open Source License
public void initialize() { // export the registration hook used by satellites exportSatelliteRegistrationCallback(); // handle onClosed to automatically close all satellites Window.addCloseHandler(this); }
From source file:org.rstudio.studio.client.pdfviewer.PDFViewer.java
License:Open Source License
@Inject public PDFViewer(EventBus eventBus, final ApplicationServerOperations server, final GlobalDisplay display, final SatelliteManager satelliteManager, final Synctex synctex, final UIPrefs prefs) { display_ = display;//from w w w. j a va2 s. c om server_ = server; synctex_ = synctex; prefs_ = prefs; eventBus.addHandler(CompilePdfCompletedEvent.TYPE, this); eventBus.addHandler(SynctexViewPdfEvent.TYPE, this); eventBus.addHandler(PDFLoadEvent.TYPE, this); eventBus.addHandler(WindowOpenedEvent.TYPE, this); PdfJsWindow.addPDFLoadHandler(this); PdfJsWindow.addPageClickHandler(this); PdfJsWindow.addWindowClosedHandler(this); PdfJsWindow.addPdfJsLoadHandler(this); // when this window is closed, automatically close the PDF.js window, // if it's open Window.addCloseHandler(new CloseHandler<Window>() { @Override public void onClose(CloseEvent<Window> event) { if (pdfJsWindow_ != null) pdfJsWindow_.close(); pdfJsWindow_ = null; } }); }
From source file:org.xwiki.gwt.wysiwyg.client.WysiwygEditorApi.java
License:Open Source License
/** * Creates a new {@link WysiwygEditor} based on the given configuration object. * //from w ww . jav a 2 s .co m * @param jsConfig the {@link JavaScriptObject} used to configure the newly created editor */ public WysiwygEditorApi(JavaScriptObject jsConfig) { if (!isRichTextEditingSupported()) { return; } Config config = new DefaultConfig(jsConfig); // Get the element that will be replaced by the WYSIWYG editor. Element hook = DOM.getElementById(config.getParameter("hookId")); if (hook == null) { return; } // Prepare the DOM by creating a container for the editor. final Element container = DOM.createDiv(); String containerId = hook.getId() + "_container" + Math.round(Math.random() * 1000); container.setId(containerId); hook.getParentElement().insertBefore(container, hook); editor = WysiwygEditorFactory.getInstance().newEditor(config); // Attach the editor to the browser's document. if (editor.getConfig().isDebugMode()) { RootPanel.get(containerId).add(new WysiwygEditorDebugger(editor)); } else { RootPanel.get(containerId).add(editor.getUI()); } // Cleanup when the window is closed. This way the HTML form elements generated on the server preserve their // index and thus can be cached by the browser. Window.addCloseHandler(new CloseHandler<Window>() { public void onClose(CloseEvent<Window> event) { if (editor != null) { editor.destroy(); } if (container.getParentNode() != null) { container.getParentNode().removeChild(container); } } }); }