com.vaadin.ui.Window.addCloseListener()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中com.vaadin.ui.Window.addCloseListener()方法的一些代码示例,展示了Window.addCloseListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.addCloseListener()方法的具体详情如下:
包路径:com.vaadin.ui.Window
类名称:Window
方法名:addCloseListener

Window.addCloseListener介绍

[英]Adds a CloseListener to the window. For a window the CloseListener is fired when the user closes it (clicks on the close button). For a browser level window the CloseListener is fired when the browser level window is closed. Note that closing a browser level window does not mean it will be destroyed. Also note that Opera does not send events like all other browsers and therefore the close listener might not be called if Opera is used.

Since Vaadin 6.5, removing windows using #removeWindow(Window)does fire the CloseListener.
[中]将CloseListener添加到窗口。对于窗口,当用户关闭它(单击关闭按钮)时,CloseListener将被触发。对于浏览器级窗口,关闭浏览器级窗口时会触发CloseListener。请注意,关闭浏览器级别的窗口并不意味着它将被破坏。还要注意,Opera不像其他浏览器那样发送事件,因此如果使用Opera,可能不会调用close listener。
从Vaadin 6.5开始,使用#removeWindow(窗口)移除窗口会触发CloseListener。

代码示例

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.opencms.ui.I_CmsDialogContext#setWindow(com.vaadin.ui.Window)
 */
public void setWindow(Window window) {
  m_window = window;
  m_window.addCloseListener(new CloseListener() {
    private static final long serialVersionUID = 1L;
    public void windowClose(CloseEvent e) {
      handleWindowClose();
    }
  });
}

代码示例来源:origin: mstahv/spring-boot-spatial-example

@Override
public void addWindow(Window window) throws IllegalArgumentException,
    NullPointerException {
  super.addWindow(window);
  window.addCloseListener(this);
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * Initializes action handler.<p>
 *
 * @param window the parent window
 */
public void initActionHandler(final Window window) {
  if (m_actionHandler != null) {
    window.addActionHandler(m_actionHandler);
    window.addCloseListener(new CloseListener() {
      private static final long serialVersionUID = 1L;
      public void windowClose(CloseEvent e) {
        clearActionHandler(window);
      }
    });
  }
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

private <T> CompletableFuture<ChooseResult<T>> openChooser(Chooser<T> chooser) {
  CompletableFuture<ChooseResult<T>> result = new CompletableFuture<>();
  AtomicBoolean dialogCommited = new AtomicBoolean(false);
  Button cancel = new Button("Cancel");
  cancel.addStyleName("v-button-secondary");
  Button choose = new Button("Select");
  choose.addStyleName("v-button-commit");
  choose.addClickListener(event -> {
    dialogCommited.set(true);
    UI.getCurrent().access(() ->
        result.complete(ChooseResult.ofChoice(Optional.ofNullable(chooser.getChoice()))));
  });
  DialogBuilder.dialog()
      .withTitle(StringUtils.defaultIfBlank(chooser.getTitle(), "Choose"))
      .withContent(chooser.asVaadinComponent())
      .withActions(Lists.newArrayList(cancel, choose))
      .buildAndOpen()
      .addCloseListener(e -> {
        chooser.destroy();
        if (!dialogCommited.get()) {
          result.complete(ChooseResult.ofNoChoice());
        }
      });
  return result;
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.opencms.ui.I_CmsDialogContext#start(java.lang.String, com.vaadin.ui.Component, org.opencms.ui.components.CmsBasicDialog.DialogWidth)
 */
public void start(String title, Component dialog, DialogWidth width) {
  if (dialog != null) {
    m_window = CmsBasicDialog.prepareWindow(width);
    m_window.setCaption(title);
    m_window.setContent(dialog);
    UI.getCurrent().addWindow(m_window);
    m_window.addCloseListener(new CloseListener() {
      private static final long serialVersionUID = 1L;
      public void windowClose(CloseEvent e) {
        handleWindowClose();
      }
    });
    if (dialog instanceof CmsBasicDialog) {
      ((CmsBasicDialog)dialog).initActionHandler(m_window);
    }
  }
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.opencms.ui.I_CmsDialogContext#start(java.lang.String, com.vaadin.ui.Component, org.opencms.ui.components.CmsBasicDialog.DialogWidth)
 */
public void start(String title, Component dialog, DialogWidth width) {
  if (dialog != null) {
    m_keepFrameOnClose = false;
    m_window = CmsBasicDialog.prepareWindow(width);
    m_window.setCaption(title);
    m_window.setContent(dialog);
    UI.getCurrent().addWindow(m_window);
    m_window.addCloseListener(new CloseListener() {
      private static final long serialVersionUID = 1L;
      public void windowClose(CloseEvent e) {
        handleWindowClose();
      }
    });
    if (dialog instanceof CmsBasicDialog) {
      ((CmsBasicDialog)dialog).initActionHandler(m_window);
    }
  }
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

protected void openConfirmationWindowForDeletion(final String entityToDelete, final String entityName,
    final FilterHeaderEvent event) {
  final ConfirmationDialog confirmDialog = new ConfirmationDialog(
      i18n.getMessage("caption.entity.delete.action.confirmbox"),
      i18n.getMessage("message.confirm.delete.entity", entityName.toLowerCase(),
          entityToDelete.substring(entityToDelete.indexOf('.') + 1), ""),
      i18n.getMessage(UIMessageIdProvider.BUTTON_OK), i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL),
      ok -> {
        if (ok) {
          deleteEntity(entityToDelete);
        } else {
          removeUpdateAndDeleteColumn();
          getEventBus().publish(this, event);
        }
      });
  confirmDialog.getWindow().addCloseListener(getCloseListenerForEditAndDeleteTag(event));
  UI.getCurrent().addWindow(confirmDialog.getWindow());
  confirmDialog.getWindow().bringToFront();
}

代码示例来源:origin: eclipse/hawkbit

protected void openConfirmationWindowForDeletion(final String entityToDelete, final String entityName,
    final FilterHeaderEvent event) {
  final ConfirmationDialog confirmDialog = new ConfirmationDialog(
      i18n.getMessage("caption.entity.delete.action.confirmbox"),
      i18n.getMessage("message.confirm.delete.entity", entityName.toLowerCase(),
          entityToDelete.substring(entityToDelete.indexOf('.') + 1), ""),
      i18n.getMessage(UIMessageIdProvider.BUTTON_OK), i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL),
      ok -> {
        if (ok) {
          deleteEntity(entityToDelete);
        } else {
          removeUpdateAndDeleteColumn();
          getEventBus().publish(this, event);
        }
      });
  confirmDialog.getWindow().addCloseListener(getCloseListenerForEditAndDeleteTag(event));
  UI.getCurrent().addWindow(confirmDialog.getWindow());
  confirmDialog.getWindow().bringToFront();
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

private void createNotificationWindow() {
  notificationsWindow = new Window();
  notificationsWindow.setWidth(300.0F, Unit.PIXELS);
  notificationsWindow.addStyleName(STYLE_POPUP);
  notificationsWindow.addStyleName(STYLE_NO_CLOSEBOX);
  notificationsWindow.setClosable(true);
  notificationsWindow.setResizable(false);
  notificationsWindow.setDraggable(false);
  notificationsWindow.setId(UIComponentIdProvider.NOTIFICATION_UNREAD_POPUP_ID);
  notificationsWindow.addCloseListener(event -> refreshCaption());
  notificationsWindow.addBlurListener(this::closeWindow);
}

代码示例来源:origin: eclipse/hawkbit

private void createNotificationWindow() {
  notificationsWindow = new Window();
  notificationsWindow.setWidth(300.0F, Unit.PIXELS);
  notificationsWindow.addStyleName(STYLE_POPUP);
  notificationsWindow.addStyleName(STYLE_NO_CLOSEBOX);
  notificationsWindow.setClosable(true);
  notificationsWindow.setResizable(false);
  notificationsWindow.setDraggable(false);
  notificationsWindow.setId(UIComponentIdProvider.NOTIFICATION_UNREAD_POPUP_ID);
  notificationsWindow.addCloseListener(event -> refreshCaption());
  notificationsWindow.addBlurListener(this::closeWindow);
}

代码示例来源:origin: org.ikasan/ikasan-dashboard-jar

public void buttonClick(ClickEvent event) 
  {                
    UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel(authenticationMethod, 
        securityService, authenticationProviderFactory, ldapService);
    
    Window window = new Window("Configure User Directory");
    window.setModal(true);
    window.setHeight("90%");
    window.setWidth("90%");
    
    window.setContent(authMethodPanel);
    
    window.addCloseListener(new Window.CloseListener() 
    {
      // inline close-listener
      public void windowClose(CloseEvent e) 
      {
        populateAll();
      }
    });
    
    UI.getCurrent().addWindow(window);
  }
});

代码示例来源:origin: org.ikasan/ikasan-dashboard-jar

public void buttonClick(ClickEvent event) 
  {
    final UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel(new AuthenticationMethod(), 
        securityService, authenticationProviderFactory, ldapService);
    
    Window window = new Window("Configure User Directory");
    window.setModal(true);
    window.setHeight("90%");
    window.setWidth("90%");
    
    window.setContent(authMethodPanel);
    
    UI.getCurrent().addWindow(window);
    
    window.addCloseListener(new Window.CloseListener() 
    {
      @Override
      public void windowClose(Window.CloseEvent e)
      {
        populateAll();
      }
    });
  }
});

代码示例来源:origin: eclipse/hawkbit

window.addCloseListener(e -> {
  if (!isImplicitClose) {
    cancelButton.click();

代码示例来源:origin: OpenNMS/opennms

window.setClosable(false);
window.setResizable(false);
window.addCloseListener(new Window.CloseListener() {
  @Override
  public void windowClose(Window.CloseEvent e) {

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

window.addCloseListener(e -> {
  if (!isImplicitClose) {
    cancelButton.click();

代码示例来源:origin: org.opencms/opencms-core

/**
 * Shows the password reset dialog.<p>
 */
public void showPasswordResetDialog() {
  String caption = CmsVaadinUtils.getMessageText(Messages.GUI_PWCHANGE_FORGOT_PASSWORD_0);
  A_CmsUI r = A_CmsUI.get();
  r.setContent(new Label());
  Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
  CmsBasicDialog dialog = new CmsBasicDialog();
  VerticalLayout result = new VerticalLayout();
  dialog.setContent(result);
  window.setContent(dialog);
  window.setCaption(caption);
  window.setClosable(true);
  final CmsForgotPasswordDialog forgotPassword = new CmsForgotPasswordDialog();
  window.addCloseListener(new CloseListener() {
    /** Serial version id. */
    private static final long serialVersionUID = 1L;
    public void windowClose(CloseEvent e) {
      forgotPassword.cancel();
    }
  });
  for (Button button : forgotPassword.getButtons()) {
    dialog.addButton(button);
  }
  r.addWindow(window);
  window.center();
  VerticalLayout vl = result;
  vl.addComponent(forgotPassword);
}

代码示例来源:origin: org.opencms/opencms-core

m_window.addCloseListener(new CloseListener() {

相关文章