Example usage for com.vaadin.ui Window setVisible

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

Introduction

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

Prototype

@Override
    public void setVisible(boolean visible) 

Source Link

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void appendImportMenu(CustomMenuBar.MenuItem parent, CustomMenuBar.MenuItem beforeItem) {
    final Window importWindow = new Window() {
        private static final long serialVersionUID = -397373017493034496L;

        @Override/*from  w w w .ja  v  a  2 s.co m*/
        public void close() {
            setVisible(false);
        }
    };
    importWindow.setCaption("Import from sequence");
    importWindow.setResizable(false);

    final CanvasImport canvasImport = new CanvasImport();
    importWindow.getContent().addComponent(canvasImport);
    importWindow.center();
    importWindow.setVisible(false);

    @SuppressWarnings("unused")
    CustomMenuBar.MenuItem importMenu = parent.addItemBefore("Import", null, new CustomMenuBar.Command() {
        private static final long serialVersionUID = -6735134306275926140L;

        @Override
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            if (!importWindow.isVisible()) {
                if (getWindow().getChildWindows().contains(importWindow) == false) {
                    getWindow().addWindow(importWindow);
                }

                importWindow.setVisible(true);
            }
        }
    }, beforeItem);

    importWindow.setSizeUndefined();
    importWindow.getContent().setSizeUndefined();

    final Window importFromStringWindow = new Window() {
        private static final long serialVersionUID = 7035248961169308096L;

        @Override
        public void close() {
            setVisible(false);
        }
    };

    importFromStringWindow.setCaption("Import sequence from string");
    importFromStringWindow.setWidth("400px");

    final ImportStructureFromStringDialog importStructureStringDialog = new ImportStructureFromStringDialog(
            theCanvas);

    importStructureStringDialog.addListener(new UserInputEndedListener() {
        @Override
        public void done(boolean cancelled) {
            if (!cancelled) {
                if (!theCanvas.theDoc.importFromString(importStructureStringDialog.getSequenceString(),
                        theCanvas
                                .getImportFormatShortFormat(importStructureStringDialog.getSequenceFormat()))) {
                    IGGApplication.reportMessage(LogUtils.getLastError());

                    LogUtils.clearLastError();
                }
            }
        }
    });

    WeeLayout layout = new WeeLayout(Direction.VERTICAL);
    layout.setSizeFull();
    importFromStringWindow.setContent(layout);
    layout.addComponent(importStructureStringDialog, Alignment.MIDDLE_CENTER);

    importFromStringWindow.center();
    importFromStringWindow.setVisible(false);

    @SuppressWarnings("unused")
    CustomMenuBar.MenuItem importFromStringMenu = parent.addItemBefore("Import from string", null,
            new CustomMenuBar.Command() {
                private static final long serialVersionUID = 1586089744665899803L;

                @Override
                public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
                    if (!importFromStringWindow.isVisible()) {
                        if (getWindow().getChildWindows().contains(importFromStringWindow) == false) {
                            getWindow().addWindow(importFromStringWindow);
                        }

                        importFromStringWindow.setVisible(true);
                    }
                }
            }, beforeItem);
}

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void appendNotationMenu(CustomMenuBar.MenuItem parent) {
    final HashMap<String, String> notationIndex = new HashMap<String, String>();

    CustomMenuBar.Command notationChangeCommand = new CustomMenuBar.Command() {
        private static final long serialVersionUID = 5081687058270283137L;

        @Override//from   ww  w.  j  av a2  s  . com
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            String notation = notationIndex.get(selectedItem.getText());
            theCanvas.setNotation(notation);
        }
    };

    parent.addItem("CFG notation", notationChangeCommand);
    notationIndex.put("CFG notation", GraphicOptions.NOTATION_CFG);

    parent.addItem("CFG black and white notation", notationChangeCommand);
    notationIndex.put("CFG black and white notation", GraphicOptions.NOTATION_CFGBW);

    parent.addItem("CFG with linkage placement notation", notationChangeCommand);
    notationIndex.put("CFG with linkage placement notation", GraphicOptions.NOTATION_CFGLINK);

    parent.addItem("UOXF notation", notationChangeCommand);
    notationIndex.put("UOXF notation", GraphicOptions.NOTATION_UOXF);

    parent.addItem("UOXFCOL notation", notationChangeCommand);
    notationIndex.put("UOXFCOL notation", GraphicOptions.NOTATION_UOXFCOL);

    parent.addItem("Text only notation", notationChangeCommand);
    notationIndex.put("Text only notation", GraphicOptions.NOTATION_TEXT);

    parent.addItem("Show Masses", new ThemeResource("icons/uncheckedbox.png"), new CustomMenuBar.Command() {
        private static final long serialVersionUID = 6140157670134115820L;

        @Override
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            //selectedItem.setIcon(arg0);

            boolean showMasses = theCanvas.theWorkspace.getGraphicOptions().SHOW_MASSES_CANVAS;

            if (showMasses) {
                theCanvas.theWorkspace.getGraphicOptions().SHOW_MASSES_CANVAS = false;
                selectedItem.setIcon(new ThemeResource("icons/uncheckedbox.png"));
            } else {
                theCanvas.theWorkspace.getGraphicOptions().SHOW_MASSES_CANVAS = true;
                selectedItem.setIcon(new ThemeResource("icons/checkbox.png"));
            }

            theCanvas.documentUpdated();
        }
    });

    parent.addItem("Show reducing end symbol", new ThemeResource("icons/uncheckedbox.png"),
            new CustomMenuBar.Command() {
                private static final long serialVersionUID = -5209359926737326181L;

                @Override
                public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
                    boolean showRedEnd = theCanvas.theWorkspace.getGraphicOptions().SHOW_REDEND_CANVAS;

                    if (showRedEnd) {
                        theCanvas.theWorkspace.getGraphicOptions().SHOW_REDEND_CANVAS = false;
                        selectedItem.setIcon(new ThemeResource("icons/uncheckedbox.png"));
                    } else {
                        theCanvas.theWorkspace.getGraphicOptions().SHOW_REDEND_CANVAS = true;
                        selectedItem.setIcon(new ThemeResource("icons/checkbox.png"));
                    }

                    theCanvas.documentUpdated();
                }
            });

    final Window massOptionsDialog = new Window() {
        private static final long serialVersionUID = -5094399884130705221L;

        @Override
        public void close() {
            setVisible(false);
        }
    };

    massOptionsDialog.setResizable(false);
    //massOptionsDialog.setIcon(new ThemeResource("icons/massoptions.png"));

    massOptionsDialog.setCaption("Mass options");

    MassOptionsDialog dialog = new MassOptionsDialog(theCanvas.theDoc.getStructures(),
            theCanvas.theWorkspace.getDefaultMassOptions());

    dialog.addMassOptionListener(this);

    massOptionsDialog.addComponent(dialog);

    ((VerticalLayout) massOptionsDialog.getContent()).setComponentAlignment(dialog, Alignment.MIDDLE_CENTER);

    massOptionsDialog.setVisible(false);

    massOptionsDialog.center();

    parent.addItem("Mass options", new CustomMenuBar.Command() {
        private static final long serialVersionUID = -589321392382766804L;

        @Override
        public void menuSelected(CustomMenuBar.MenuItem selectedItem) {
            if (massOptionsDialog.getParent() == null) {
                getWindow().addWindow(massOptionsDialog);
            }

            massOptionsDialog.setVisible(true);
        }
    });

    massOptionsDialog.setSizeUndefined();
    massOptionsDialog.getContent().setSizeUndefined();
}

From source file:au.org.scoutmaster.views.ContactView.java

private void showMailForm(final TextField emailField) {
    final Window mailWindow = new Window("Send Email");
    mailWindow.setWidth("80%");
    mailWindow.setHeight("80%");
    final User sender = (User) getSession().getAttribute("user");
    mailWindow.setContent(new EmailForm(mailWindow, sender, getCurrent(), emailField.getValue()));
    mailWindow.setVisible(true);
    mailWindow.center();/* w  ww .j  a  va 2s.c  o  m*/
    UI.getCurrent().addWindow(mailWindow);

}

From source file:com.naoset.framework.frontend.component.profile.CustomerEditWindowView.java

private void openWindow() {
    Window myWindow = new Window("Cliente");
    myWindow.addStyleName("profile-window");
    myWindow.setId(ID);//from www . j a v  a  2 s.  c om
    Responsive.makeResponsive(this);

    myWindow.setModal(true);
    myWindow.setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    myWindow.setResizable(false);
    myWindow.setClosable(false);
    myWindow.setHeight(90.0f, Unit.PERCENTAGE);
    VerticalLayout layout = new VerticalLayout();
    CustomerPanelView customerPanelView = new CustomerPanelView();

    layout.addComponent(customerPanelView.buildCustomerPanel(null));
    layout.addComponent(builtButton());

    myWindow.setContent(layout);
    myWindow.setVisible(true);
    UI.getCurrent().addWindow(myWindow);
    myWindow.focus();
}

From source file:com.trivago.mail.pigeon.web.components.groups.GroupList.java

License:Apache License

public GroupList() {
    final GroupList gl = this;
    final Panel rootPanel = new Panel("Groups");
    rootPanel.setWidth("800px");
    Button groupListNewButton = new Button("Add group");
    groupListNewButton.setImmediate(true);
    groupListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    groupListNewButton.addListener(new Button.ClickListener() {
        @Override//from   ww w.ja  v  a 2 s.c o m
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddNewGroup(gl);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    viewTable = new Table();
    viewTable.setWidth("100%");
    final Button editButton = new Button("Edit");
    editButton.setImmediate(true);
    editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    editButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (viewTable.isEditable()) {
                viewTable.setEditable(false);
                editButton.setCaption("Edit");
                viewTable.requestRepaintAll();
                editButton.getWindow().showNotification("Save successful",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            } else {
                viewTable.setEditable(true);
                editButton.setCaption("Save");
                viewTable.requestRepaintAll();
            }
        }
    });

    viewTable.setImmediate(true);
    beanContainer = new BeanContainer<>(RecipientGroup.class);

    List<RecipientGroup> groupList = getGroupList();
    for (RecipientGroup group : groupList) {
        beanContainer.addItem(group.getId(), group);
    }

    viewTable.setContainerDataSource(beanContainer);
    viewTable.addGeneratedColumn("memberNumber", new GroupColumnGenerator());
    viewTable.addGeneratedColumn("Actions", new ActionButtonColumnGenerator());

    // First set the vis. cols, then the headlines (the other way round leads to an exception)
    viewTable.setVisibleColumns(new String[] { "id", "name", "memberNumber", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Name", "Member #", "Actions" });

    viewTable.setColumnExpandRatio(3, 2);
    viewTable.setColumnExpandRatio(4, 2);

    HorizontalLayout topButtonLayout = new HorizontalLayout();
    topButtonLayout.setSpacing(true);
    topButtonLayout.setMargin(false, false, true, false);
    topButtonLayout.addComponent(groupListNewButton);
    topButtonLayout.addComponent(editButton);

    rootPanel.addComponent(topButtonLayout);
    rootPanel.addComponent(viewTable);

    setCompositionRoot(rootPanel);
}

From source file:com.trivago.mail.pigeon.web.components.mail.ActionButtonColumnGenerator.java

License:Apache License

@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
    HorizontalLayout hl = new HorizontalLayout();
    Button showNlConentButton = new Button();
    showNlConentButton.setDescription("View");
    showNlConentButton.setImmediate(true);
    showNlConentButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));

    showNlConentButton.addListener(new Button.ClickListener() {
        @Override// ww  w.ja  va 2  s  . c  o m
        public void buttonClick(Button.ClickEvent event) {
            Mail m = new Mail((Long) itemId);
            Window nlConentView = new Window("Newsletter Contents of ID " + itemId);
            // Create an empty tab sheet.
            TabSheet tabsheet = new TabSheet();

            Panel pText = new Panel("Text Content");
            Panel pHtml = new Panel("Text Content");
            RichTextArea textArea = new RichTextArea();
            textArea.setValue(m.getText());
            textArea.setReadOnly(true);

            RichTextArea richTextArea = new RichTextArea();
            richTextArea.setValue(m.getHtml());
            richTextArea.setReadOnly(true);

            pText.addComponent(textArea);
            pHtml.addComponent(richTextArea);

            richTextArea.setHeight("50%");
            richTextArea.setWidth("100%");
            textArea.setHeight("50%");
            textArea.setWidth("100%");

            nlConentView.setResizable(true);
            nlConentView.setWidth("800px");
            nlConentView.setHeight("600px");

            tabsheet.addTab(pText);
            tabsheet.getTab(pText).setCaption("Text Version");
            tabsheet.addTab(pHtml);
            tabsheet.getTab(pHtml).setCaption("Html Version");

            nlConentView.addComponent(tabsheet);
            source.getWindow().addWindow(nlConentView);
            nlConentView.setVisible(true);
        }
    });

    final Button showOpenendMails = new Button();
    showOpenendMails.setDescription("Show recipients of this mailling");
    showOpenendMails.setIcon(new ThemeResource("../runo/icons/16/users.png"));
    showOpenendMails.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Mail m = new Mail((Long) itemId);
            ModalRecipientListByMail modalRecipientListByMail = new ModalRecipientListByMail(m);
            source.getWindow().addWindow(modalRecipientListByMail);
            modalRecipientListByMail.setVisible(true);

        }
    });

    hl.addComponent(showNlConentButton);
    hl.addComponent(showOpenendMails);
    return hl;
}

From source file:com.trivago.mail.pigeon.web.components.mail.NewsletterList.java

License:Apache License

public NewsletterList() {

    final NewsletterList nl = this;
    final Panel rootPanel = new Panel("Newsletter");
    rootPanel.setWidth("800px");

    viewTable = new Table();
    viewTable.setWidth("100%");
    beanContainer = new BeanContainer<>(Mail.class);

    Button senderListNewButton = new Button("New Newsletter");
    senderListNewButton.setImmediate(true);
    senderListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    senderListNewButton.addListener(new Button.ClickListener() {
        @Override//from w  ww .  ja v a 2 s.co m
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddNewsletter(nl);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });
    Button statusPopup = new Button("Show delivery status");
    statusPopup.setImmediate(true);
    statusPopup.setIcon(new ThemeResource("../runo/icons/16/globe.png"));
    statusPopup.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new PopupActiveNewsletters();
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    List<Mail> mailList = getMailList();
    for (Mail mail : mailList) {
        beanContainer.addItem(mail.getId(), mail);
    }

    viewTable.setContainerDataSource(beanContainer);
    viewTable.addGeneratedColumn("Sender", new SenderColumnGenerator());
    viewTable.addGeneratedColumn("Actions", new ActionButtonColumnGenerator());

    // First set the vis. cols, then the headlines (the other way round leads to an exception)
    viewTable.setVisibleColumns(new String[] { "id", "subject", "sendDate", "Sender", "done", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Subject", "Send Date", "Sender", "Finished", "Actions" });

    viewTable.setColumnExpandRatio(6, 2);

    HorizontalLayout topButtonLayout = new HorizontalLayout();
    topButtonLayout.addComponent(senderListNewButton);
    // topButtonLayout.addComponent(statusPopup);
    topButtonLayout.setMargin(false, false, true, false);

    rootPanel.addComponent(topButtonLayout);
    rootPanel.addComponent(viewTable);

    setCompositionRoot(rootPanel);
}

From source file:com.trivago.mail.pigeon.web.components.sender.SenderList.java

License:Apache License

public SenderList() {
    final SenderList sl = this;
    final Panel rootPanel = new Panel("Sender");
    rootPanel.setWidth("800px");

    Button senderListNewButton = new Button("Add Sender");
    senderListNewButton.setImmediate(true);
    senderListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    senderListNewButton.addListener(new Button.ClickListener() {
        @Override/*www.  ja va  2s  . c  o  m*/
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddNewSender(sl);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    viewTable = new Table();
    viewTable.setWidth("100%");
    final Button editButton = new Button("Edit");
    editButton.setImmediate(true);
    editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    editButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (viewTable.isEditable()) {
                viewTable.setEditable(false);
                editButton.setCaption("Edit");
                viewTable.requestRepaintAll();
                editButton.getWindow().showNotification("Save successful",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            } else {
                viewTable.setEditable(true);
                editButton.setCaption("Save");
                viewTable.requestRepaintAll();
            }
        }
    });

    viewTable.setImmediate(true);
    beanContainer = new BeanContainer<Long, Sender>(Sender.class);

    List<Sender> senderList = getSenderList();
    for (Sender sender : senderList) {
        beanContainer.addItem(sender.getId(), sender);
    }

    viewTable.setContainerDataSource(beanContainer);
    viewTable.addGeneratedColumn("Actions", new ActionButtonColumnGenerator());

    // First set the vis. cols, then the headlines (the other way round leads to an exception)
    viewTable.setVisibleColumns(
            new String[] { "id", "name", "fromMail", "replytoMail", "sentMailsCount", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Name", "E-Mail", "Reply To", "E-Mails sent", "Actions" });

    viewTable.setColumnExpandRatio(3, 2);
    viewTable.setColumnExpandRatio(4, 2);

    HorizontalLayout topButtonLayout = new HorizontalLayout();
    topButtonLayout.setSpacing(true);
    topButtonLayout.setMargin(false, false, true, false);
    topButtonLayout.addComponent(senderListNewButton);
    topButtonLayout.addComponent(editButton);

    rootPanel.addComponent(topButtonLayout);
    rootPanel.addComponent(viewTable);

    setCompositionRoot(rootPanel);

}

From source file:com.trivago.mail.pigeon.web.components.templates.ActionButtonColumnGenerator.java

License:Apache License

@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
    HorizontalLayout hl = new HorizontalLayout();

    Button deleteButton = new Button();
    deleteButton.setImmediate(true);//from  ww w.  j a v a2s .  c o m
    deleteButton.setIcon(new ThemeResource("../runo/icons/16/trash.png"));
    deleteButton.setDescription("Delete template");
    deleteButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Transaction tx = ConnectionFactory.getDatabase().beginTx();
            try {
                MailTemplate mt = new MailTemplate((Long) itemId);
                ConnectionFactory.getNewsletterIndex().remove(mt.getDataNode());

                for (Relationship r : mt.getDataNode().getRelationships()) {
                    r.delete();
                }
                mt.getDataNode().delete();

                source.removeItem(itemId);
                source.getWindow().showNotification("Successfully deleted.");
                tx.success();
            } catch (Exception e) {
                source.getWindow().showNotification("Error while deleting entry: " + e.getMessage(),
                        Window.Notification.TYPE_ERROR_MESSAGE);
                log.error(e);
                tx.failure();
            } finally {
                tx.finish();
            }
        }
    });

    Button editButton = new Button();
    editButton.setImmediate(true);
    editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    editButton.setDescription("Edit template");
    editButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddTemplate(
                    (TemplateList) source.getParent().getParent().getParent(), (Long) itemId);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    hl.addComponent(editButton);
    hl.addComponent(deleteButton);
    return hl;
}

From source file:com.trivago.mail.pigeon.web.components.templates.TemplateList.java

License:Apache License

public TemplateList() {

    final TemplateList nl = this;
    final Panel rootPanel = new Panel("Newsletter");
    rootPanel.setWidth("800px");

    viewTable = new Table();
    viewTable.setWidth("100%");
    beanContainer = new BeanContainer<Long, MailTemplate>(MailTemplate.class);

    Button senderListNewButton = new Button("New Template");
    senderListNewButton.setImmediate(true);
    senderListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    senderListNewButton.addListener(new Button.ClickListener() {
        @Override//from   w w  w.ja  va  2s .  c  om
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddTemplate(nl);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    List<MailTemplate> mailList = getTemplateList();
    for (MailTemplate mail : mailList) {
        beanContainer.addItem(mail.getId(), mail);
    }

    viewTable.setContainerDataSource(beanContainer);
    viewTable.addGeneratedColumn("Actions", new ActionButtonColumnGenerator());

    // First set the vis. cols, then the headlines (the other way round leads to an exception)
    viewTable.setVisibleColumns(new String[] { "id", "subject", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Subject", "Actions" });

    viewTable.setColumnExpandRatio(6, 2);

    HorizontalLayout topButtonLayout = new HorizontalLayout();
    topButtonLayout.addComponent(senderListNewButton);
    // topButtonLayout.addComponent(statusPopup);
    topButtonLayout.setMargin(false, false, true, false);

    rootPanel.addComponent(topButtonLayout);
    rootPanel.addComponent(viewTable);

    setCompositionRoot(rootPanel);
}