Example usage for com.vaadin.ui Panel setWidth

List of usage examples for com.vaadin.ui Panel setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui Panel setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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/*w ww  .ja  va2 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.recipients.RecipientByMailList.java

License:Apache License

private void init() {
    final Panel rootPanel = new Panel("Sender");
    rootPanel.setWidth("800px");

    viewTable = new Table();
    viewTable.setWidth("100%");

    viewTable.setData(mail.getId());//from   w  w w .  j a va2 s. c o  m
    viewTable.setImmediate(true);
    beanContainer = new BeanContainer<Long, Recipient>(Recipient.class);

    List<Recipient> recipientList = getRecipientList();
    for (Recipient recipient : recipientList) {
        beanContainer.addItem(recipient.getId(), recipient);
    }

    viewTable.setContainerDataSource(beanContainer);
    viewTable.addGeneratedColumn("openmail", new OpenMailColumnGenerator());

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

    viewTable.setColumnHeaders(new String[] { "ID", "Firstname", "Lastname", "E-Mail", "Opened Mail", //"Bounced"
    });

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

    rootPanel.addComponent(viewTable);
    setCompositionRoot(rootPanel);
}

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

License:Apache License

private void init() {
    final Panel rootPanel = new Panel("Recipients");
    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()
    //      {/*from ww w  .jav  a 2s. c  o  m*/
    //         @Override
    //         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();
            }
        }
    });

    Button exportTable = new Button("Export");
    exportTable.setImmediate(true);
    exportTable.setIcon(new ThemeResource("../runo/icons/16/document-xsl.png"));
    exportTable.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            log.debug("Starting export");
            TableExport te = new ExcelExport(viewTable, "Recipient list", "Recipient list",
                    "Recipient_list.xls", false);
            log.debug("Converting table");
            te.convertTable();
            log.debug("Sending converted table...");
            boolean success = te.sendConverted();
            if (success) {
                log.debug("Sending should be successful");
            } else {
                log.warn("Sending not successfull, maybe IOException occured?");
            }
        }
    });

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

    List<Recipient> recipientList = getRecipientList();
    for (Recipient recipient : recipientList) {
        beanContainer.addItem(recipient.getId(), recipient);
    }

    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", "title", "firstname", "lastname", "email", "active",
            "gender", "birthday", "city", "country", "language", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Title", "Firstname", "Lastname", "E-Mail", "Active",
            "Gender", "Birthday", "City", "Country", "Language", "Actions" });

    viewTable.setColumnCollapsingAllowed(true);

    viewTable.setColumnCollapsed("gender", true);
    viewTable.setColumnCollapsed("title", true);
    viewTable.setColumnCollapsed("birthday", true);
    viewTable.setColumnCollapsed("city", true);
    viewTable.setColumnCollapsed("country", true);
    viewTable.setColumnCollapsed("language", true);

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

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

    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//  ww w.j a va 2 s.co 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.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 www . ja  va2  s .co  m
        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);
}

From source file:de.escidoc.admintool.view.context.ContextAddView.java

License:Open Source License

private void addAdminDescriptorField() {
    adminDescriptorAccordion = new Accordion();
    adminDescriptorAccordion.setWidth(ViewConstants.FIELD_WIDTH);
    adminDescriptorAccordion.setSizeFull();

    final Panel accordionPanel = new Panel();
    accordionPanel.setContent(adminDescriptorAccordion);
    accordionPanel.setSizeFull();/*from   w ww .  ja v  a  2 s . co m*/
    accordionPanel.setWidth(ViewConstants.FIELD_WIDTH);

    final Button addButton = new Button(ViewConstants.ADD_LABEL);
    final Button editButton = new Button(ViewConstants.EDIT_LABEL);
    final Button delButton = new Button(ViewConstants.REMOVE_LABEL);

    addButton.setStyleName("small");
    editButton.setStyleName("small");
    delButton.setStyleName("small");

    addButton.addListener(new NewAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    editButton.addListener(new EditAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    delButton.addListener(new RemoveAdminDescriptorListener(adminDescriptorAccordion));

    panel.addComponent(LayoutHelper.create("Admin Descriptors", accordionPanel, LABEL_WIDTH + 2, 300, false,
            new Button[] { addButton, editButton, delButton }));
}

From source file:de.escidoc.admintool.view.context.ContextEditForm.java

License:Open Source License

private void addAdminDescriptor() {
    adminDescriptorAccordion = new Accordion();
    adminDescriptorAccordion.setWidth(ViewConstants.FIELD_WIDTH);
    adminDescriptorAccordion.setSizeFull();

    final Panel accordionPanel = new Panel();
    accordionPanel.setContent(adminDescriptorAccordion);
    accordionPanel.setSizeFull();/*from w ww .j a  v  a  2 s  .c om*/
    accordionPanel.setWidth(ViewConstants.FIELD_WIDTH);

    addAdminDescButton.setStyleName(AppConstants.SMALL_BUTTON);
    editAdminDescButton.setStyleName(AppConstants.SMALL_BUTTON);
    delAdminDescButton.setStyleName(AppConstants.SMALL_BUTTON);

    addAdminDescButton.addListener(new NewAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    editAdminDescButton.addListener(new EditAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    delAdminDescButton.addListener(new RemoveAdminDescriptorListener(adminDescriptorAccordion));

    form.addComponent(LayoutHelper.create("Admin Descriptors", accordionPanel, LABEL_WIDTH, 300, false,
            new Button[] { addAdminDescButton, editAdminDescButton, delAdminDescButton }));
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * Helper method. Puts a blank in front of a component.
 * /* w w w.j a va 2 s .  c o  m*/
 * @param label
 *            The label in front of the control.
 * @param accordion
 *            The accordion to display.
 * @param width
 *            the fixed size of the label. The parameter has to be in CSS style, i.e. 400px for instance.
 * @param height
 * @param required
 *            should it be marked with an asterisk.
 * @return The component in an horizontal layout. A blank in front and afterwards is inserted.
 */
public static synchronized HorizontalLayout create(final String label, final Accordion accordion,
        final int width, final int height, final boolean required) {
    final HorizontalLayout hor = new HorizontalLayout();
    hor.setHeight(height + Constants.PX);
    hor.addComponent(new Label(" "));
    final String text = Constants.P_ALIGN_RIGHT + label + Constants.P;
    Label l;
    hor.addComponent(l = new Label(text, Label.CONTENT_XHTML));
    l.setSizeUndefined();
    l.setWidth(width + Constants.PX);
    hor.setComponentAlignment(l, Alignment.MIDDLE_RIGHT);
    if (required) {
        hor.addComponent(new Label(
                "&nbsp;<span style=\"color:red; position:relative; top:" + (height / 2 - 13) + "px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hor.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }

    final Panel pan = new Panel();
    pan.setSizeFull();
    // Have it take all space available in the layout.
    accordion.setSizeFull();
    // Some components to put in the Accordion.

    final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n\t<X>\n\t\t<today>\n\t\t</today>\n\t\t<today/>\n\t\t<today/>\n\t</X>\n</root>";

    for (int i = 0; i < 30; i++) {
        accordion.addTab(new Label(xml, Label.CONTENT_PREFORMATTED), "Tab" + i, null);
    }

    pan.addComponent(accordion);
    // pan.setSizeUndefined();
    pan.setWidth(accordion.getWidth() + Constants.PX);
    // pan.setHeight("500px");
    pan.setStyleName(Reindeer.PANEL_LIGHT);
    hor.addComponent(pan);
    hor.setComponentAlignment(pan, Alignment.MIDDLE_RIGHT);
    hor.addComponent(new Label(" "));
    hor.setSpacing(false);
    return hor;
}

From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java

private Component getProfiles(Group g) {
    VerticalLayout layoutRootProfiles = new VerticalLayout();
    layoutRootProfiles.setMargin(false);
    layoutRootProfiles.setWidth("100%");
    Panel panelProfiles = new Panel(Language.get(Word.PROFILES));
    Language.setCustom(Word.PROFILES, s -> panelProfiles.setCaption(s));
    panelProfiles.setWidth("100%");
    panelProfiles.setHeight("200px");

    VerticalLayout layoutProfiles = new VerticalLayout();
    mapLayoutProfiles.put(g, layoutProfiles);
    layoutProfiles.setWidth("100%");

    refreshProfiles(g, layoutProfiles);// w w w  .  j a  v  a  2 s . co  m

    panelProfiles.setContent(layoutProfiles);
    layoutRootProfiles.addComponent(panelProfiles);

    if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) {
        CssLayout addProfileGroup = new CssLayout();
        addProfileGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
        addProfileGroup.setWidth("100%");

        TextField textFieldAddProfile = new TextField();
        Language.setCustom(Word.PROFILE_NAME, s -> textFieldAddProfile.setPlaceholder(s));
        textFieldAddProfile.setMaxLength(255);
        textFieldAddProfile.setWidth("35%");
        addProfileGroup.addComponent(textFieldAddProfile);

        Button buttonAddProfile = new Button();
        buttonAddProfile.setIcon(VaadinIcons.PLUS);
        buttonAddProfile.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonAddProfile.setWidth("15%");
        buttonAddProfile.addClickListener(e -> {
            try {
                String name = textFieldAddProfile.getValue();
                textFieldAddProfile.clear();
                Runnable onClose = () -> refreshAll(g);
                UI.getCurrent().addWindow(GroupProfileWindow.create(g, name, true, onClose));
            } catch (UserNotFoundException ex) {
                VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND));
            }
        });
        addProfileGroup.addComponent(buttonAddProfile);

        layoutRootProfiles.addComponent(addProfileGroup);
    }
    return layoutRootProfiles;
}

From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java

private Component getMembers(Group g) {
    VerticalLayout layoutRootMembers = new VerticalLayout();
    layoutRootMembers.setMargin(false);/*  ww  w  . j  a v  a2 s  .  c om*/
    layoutRootMembers.setWidth("100%");
    Panel panelMembers = new Panel(Language.get(Word.MEMBERS));
    Language.setCustom(Word.MEMBERS, s -> panelMembers.setCaption(s));
    panelMembers.setWidth("100%");
    panelMembers.setHeight("200px");

    VerticalLayout layoutMembers = new VerticalLayout();
    mapLayoutMembers.put(g, layoutMembers);
    layoutMembers.setWidth("100%");

    refreshMembers(g, layoutMembers);

    panelMembers.setContent(layoutMembers);
    layoutRootMembers.addComponent(panelMembers);

    if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) {
        CssLayout addUserGroup = new CssLayout();
        addUserGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
        addUserGroup.setWidth("100%");

        TextField textFieldaddUser = new TextField();
        Language.setCustom(Word.USERNAME, s -> textFieldaddUser.setPlaceholder(s));
        textFieldaddUser.setMaxLength(255);
        textFieldaddUser.setWidth("70%");
        addUserGroup.addComponent(textFieldaddUser);

        Button buttonAddUser = new Button();
        buttonAddUser.setIcon(VaadinIcons.PLUS);
        buttonAddUser.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonAddUser.setWidth("30%");
        buttonAddUser.addClickListener(e -> {
            try {
                User u = UserUtils.getUser(textFieldaddUser.getValue());
                textFieldaddUser.clear();
                GroupUtils.addUser(g, u);
                refreshAll(g);
            } catch (UserNotFoundException ex) {
                VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND));
            }
        });
        addUserGroup.addComponent(buttonAddUser);

        layoutRootMembers.addComponent(addUserGroup);
    }

    return layoutRootMembers;
}