Example usage for com.vaadin.ui Window addCloseListener

List of usage examples for com.vaadin.ui Window addCloseListener

Introduction

In this page you can find the example usage for com.vaadin.ui Window addCloseListener.

Prototype

public Registration addCloseListener(CloseListener listener) 

Source Link

Document

Adds a CloseListener to the window.

Usage

From source file:org.geant.sat.ui.EntityListViewer.java

License:BSD License

/**
 * Import entity click handler - creates a sub window for user to enter the
 * data.//  w w w  . java  2  s . c  o  m
 * 
 * @param event
 *            button click event.
 */
private void importEntity(ClickEvent event) {

    // We create a simple window for user to enter entity information
    Window importerWindow = new EntityImporterWindow(getMainUI());
    importerWindow.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            List<EntityDetails> refreshedEntities = getFilteredEntityDetails();
            LOG.debug("Updating the entities, new number of entities is {}", refreshedEntities.size());
            entities.setItems(refreshedEntities);
            entities.setHeightByRows(refreshedEntities.size() > 0 ? refreshedEntities.size() : 1);

        }
    });
    getMainUI().addWindow(importerWindow);

}

From source file:org.ikasan.dashboard.ui.administration.panel.UserDirectoriesPanel.java

License:BSD License

protected void init() {
    Label userDirectories = new Label("User Directories");
    userDirectories.setStyleName(ValoTheme.LABEL_HUGE);

    Label parapraphOne = new Label();
    parapraphOne.setCaptionAsHtml(true);
    parapraphOne.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The table below shows the user directories currently configured for Ikasan.");
    parapraphOne.addStyleName(ValoTheme.LABEL_TINY);
    parapraphOne.addStyleName(ValoTheme.LABEL_LIGHT);

    Label parapraphTwo = new Label();
    parapraphTwo.setCaptionAsHtml(true);
    parapraphTwo.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The order of the directory is the order in which it will be searched for users and groups."
            + " It is recommended that each user exists in a single directory.");
    parapraphTwo.addStyleName(ValoTheme.LABEL_TINY);
    parapraphTwo.addStyleName(ValoTheme.LABEL_LIGHT);

    this.mainLayout.setWidth("100%");
    this.mainLayout.setSpacing(true);

    this.mainLayout.addComponent(userDirectories);
    this.mainLayout.addComponent(parapraphOne);
    this.mainLayout.addComponent(parapraphTwo);

    Button newDirectoryButton = new Button("Add Directory");
    newDirectoryButton.addClickListener(new Button.ClickListener() {
        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);/*w ww.j  av a  2 s  . c  o m*/
            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();
                }
            });
        }
    });

    this.mainLayout.addComponent(newDirectoryButton);

    this.setWidth("100%");
    this.setHeight("100%");

    this.directoryTable = new Table();
    this.directoryTable.setWidth("100%");
    this.directoryTable.setHeight("600px");
    this.directoryTable.setCellStyleGenerator(new IkasanCellStyleGenerator());
    this.directoryTable.addContainerProperty("Directory Name", String.class, null);
    this.directoryTable.addContainerProperty("Type", String.class, null);
    this.directoryTable.addContainerProperty("Order", Layout.class, null);
    this.directoryTable.addContainerProperty("Operations", Layout.class, null);

    this.directoryTable.setColumnExpandRatio("Directory Name", 25);
    this.directoryTable.setColumnExpandRatio("Type", 25);

    this.directoryTable.setColumnAlignment("Order", Align.CENTER);
    this.directoryTable.setColumnExpandRatio("Order", 10);
    this.directoryTable.setColumnAlignment("Operations", Align.CENTER);
    this.directoryTable.setColumnWidth("Operations", 300);

    this.mainLayout.addComponent(this.directoryTable);

    this.mainLayout.setMargin(true);

    Panel wrapperPanel = new Panel();
    wrapperPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    wrapperPanel.setSizeFull();
    wrapperPanel.setContent(this.mainLayout);

    HorizontalLayout wrapperLayout = new HorizontalLayout();
    wrapperLayout.setSizeFull();
    wrapperLayout.setMargin(true);
    wrapperLayout.addComponent(wrapperPanel);

    this.setContent(wrapperLayout);
}

From source file:org.investovator.ui.main.AdminGameConfigLayout.java

License:Open Source License

private void startDailySummaryAddGameWizard() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Create New Game");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);/*from   ww  w . j  av a2 s.co m*/
    subWindow.setContent(subContent);

    // Put some components in it
    subContent.addComponent(new NewDataPlaybackGameWizard(subWindow));

    // set window characteristics
    subWindow.center();
    subWindow.setClosable(false);
    subWindow.setDraggable(false);
    subWindow.setResizable(false);
    subWindow.setModal(true);

    subWindow.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent closeEvent) {
            //getUI().getNavigator().navigateTo(UIConstants.MAINVIEW);
            getUI().getPage().reload();
        }
    });

    // Add it to the root component
    UI.getCurrent().addWindow(subWindow);
}

From source file:org.investovator.ui.main.components.AdminGameCreateView.java

License:Open Source License

private void startDailySummaryAddGameWizard() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Create New Game");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);//from  w  w  w. j a  va  2 s  .co  m
    subWindow.setContent(subContent);

    // Put some components in it
    subContent.addComponent(new NewDataPlaybackGameWizard(subWindow));

    // set window characteristics
    subWindow.center();
    subWindow.setClosable(false);
    subWindow.setDraggable(false);
    subWindow.setResizable(false);
    subWindow.setModal(true);

    subWindow.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent closeEvent) {
            getUI().getNavigator().navigateTo(UIConstants.MAINVIEW);
            //                getUI().getPage().reload();
        }
    });

    // Add it to the root component
    UI.getCurrent().addWindow(subWindow);
}

From source file:org.opencms.ui.components.CmsBasicDialog.java

License:Open Source License

/**
 * Initializes action handler.<p>//from w  w  w. j a v a 2  s  .  c  o  m
 *
 * @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);
            }
        });
    }
}

From source file:org.opencms.ui.login.CmsLoginUI.java

License:Open Source License

/**
 * Shows the password reset dialog.<p>
 *///from ww  w.  ja  v a2  s. c  om
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);
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.WallboardConfigView.java

License:Open Source License

/**
 * This method is used to add a new {@link TabSheet.Tab} component. It creates a new window querying the user for the name of the new {@link Wallboard}.
 *//*from  w ww.  jav  a2 s. c o m*/
protected void addNewTabComponent() {
    final Window window = new Window("New Ops Board");

    window.setModal(true);
    window.setClosable(false);
    window.setResizable(false);
    window.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent e) {
            m_dashboardOverview.refreshTable();
        }
    });
    getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        TextField name = new TextField("Ops Board Name");

        {
            addComponent(new FormLayout() {
                {
                    setSizeUndefined();
                    setMargin(true);

                    String newName = "Untitled";
                    int i = 1;
                    if (WallboardProvider.getInstance().containsWallboard(newName)) {
                        do {
                            i++;
                            newName = "Untitled #" + i;
                        } while (WallboardProvider.getInstance().containsWallboard(newName));
                    }
                    name.setValue(newName);
                    addComponent(name);
                    name.focus();
                    name.selectAll();

                    name.addValidator(new AbstractStringValidator("Title must be unique") {
                        @Override
                        protected boolean isValidValue(String s) {
                            return (!WallboardProvider.getInstance().containsWallboard(s) && !"".equals(s));
                        }
                    });
                }
            });

            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button cancel = new Button("Cancel");
                    cancel.setDescription("Cancel editing");
                    cancel.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            // NMS-7560: Toggle the tab in order to allow us to click it again
                            m_tabSheet.togglePlusTab();
                            window.close();
                        }
                    });

                    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
                    addComponent(cancel);
                    setExpandRatio(cancel, 1);
                    setComponentAlignment(cancel, Alignment.TOP_RIGHT);

                    Button ok = new Button("Save");
                    ok.setDescription("Save configuration");
                    ok.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            if (name.isValid()) {
                                Wallboard wallboard = new Wallboard();
                                wallboard.setTitle(name.getValue());

                                WallboardProvider.getInstance().addWallboard(wallboard);
                                WallboardProvider.getInstance().save();

                                WallboardEditor wallboardEditor = new WallboardEditor(m_dashletSelector,
                                        wallboard);
                                TabSheet.Tab tab = m_tabSheet.addTab(wallboardEditor, wallboard.getTitle());

                                wallboardEditor.setTab(tab);

                                m_wallboardEditorMap.put(wallboard, tab);

                                tab.setClosable(true);

                                m_tabSheet.setSelectedTab(tab);

                                window.close();
                            }
                        }
                    });

                    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

                    addComponent(ok);
                }
            });
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.ValidationComponent.java

private void createListeners() {
    btnSettings.addClickListener(new Button.ClickListener() {
        @Override/*w w w .  j a va  2  s  .  c o m*/
        public void buttonClick(Button.ClickEvent event) {
            final ValidationSettingsWindow.ValidationSettingsState state = new ValidationSettingsWindow.ValidationSettingsState();
            state.endpoint = endpoint;
            state.graph = graph;
            state.owUrl = owUrl;
            Window w = new ValidationSettingsWindow(state);
            w.addCloseListener(new Window.CloseListener() {
                @Override
                public void windowClose(Window.CloseEvent e) {
                    try {
                        if (!endpoint.equals(state.endpoint) || !graph.equals(state.graph))
                            repository.shutDown();
                    } catch (RepositoryException ex) {
                        Logger.getLogger(ValidationComponent.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    if (state.repository != null && state.repository.isInitialized()) {
                        repository = state.repository;
                        endpoint = state.endpoint;
                        graph = state.graph;
                        owUrl = state.owUrl;
                        refresh();
                    }
                }
            });
            getUI().addWindow(w);
        }
    });
    btnRDFUnit.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window w = new RDFUnitWindow(repository, endpoint, graph);
            getUI().addWindow(w);
        }
    });
    btnRefresh.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Object selection = criteriaTree.getValue();
            if (selection == null)
                return;
            ((ICQuery) selection).eval();
        }
    });
    btnEvalAll.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            for (ICQuery ic : icHash.keySet())
                ic.eval();
        }
    });
}

From source file:ui.button.AddCertificateButton.java

License:Apache License

public AddCertificateButton(final Integer userId, final String language, final Achievement a) {
    super(Translator.getTranslation("Add Certificate", language), FontAwesome.CERTIFICATE);
    setDescription(Translator.getTranslation("Add Certificate", language));
    addClickListener(new Button.ClickListener() {
        @Override/*w w  w . j  a  v a2 s  .co  m*/
        public void buttonClick(Button.ClickEvent event) {
            UploadReceiver receiver = new CertificateUploadReceiver(userId, language, a);
            Upload upload = new Upload(Translator.getTranslation("Add Certificate", language), receiver);
            upload.addSucceededListener((Upload.SucceededListener) receiver);

            String wcaption = Translator.getTranslation("Upload", language);
            final Window window = new Window(wcaption, upload);
            window.center();
            //window.setModal(true);
            window.setStyleName("window");
            receiver.setWindow(window);
            window.addCloseListener(new Window.CloseListener() {

                @Override
                public void windowClose(Window.CloseEvent e) {
                    window.close();
                }
            });
            getUI().addWindow(window);
        }
    });
}

From source file:ui.button.AddPhotoButton.java

License:Apache License

public AddPhotoButton(final Integer userId, final String language) {
    super(Translator.getTranslation("Add professional photo", language), FontAwesome.CAMERA_RETRO);
    setDescription(Translator.getTranslation("Add professional photo", language));
    addClickListener(new Button.ClickListener() {

        @Override/* w  ww. j  a v a 2s  .  c o m*/
        public void buttonClick(Button.ClickEvent event) {
            UploadReceiver receiver = new PhotoUploadReceiver(userId, language);
            Upload upload = new Upload(Translator.getTranslation("Choose your best photo", language), receiver);
            upload.addSucceededListener((Upload.SucceededListener) receiver);

            String wcaption = Translator.getTranslation("Upload a photo", language);
            final Window window = new Window(wcaption, upload);
            window.center();
            //window.setModal(true);
            window.setStyleName("window");
            receiver.setWindow(window);
            window.addCloseListener(new Window.CloseListener() {

                @Override
                public void windowClose(Window.CloseEvent e) {
                    window.close();
                }
            });
            getUI().addWindow(window);
        }
    });
}