Example usage for com.vaadin.ui HorizontalLayout setComponentAlignment

List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setComponentAlignment.

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:com.skysql.manager.ui.UsersSettings.java

License:Open Source License

/**
 * Removes the user./*from w w w  .  jav  a 2  s . co  m*/
 *
 * @param event the event
 */
public void removeUser(Button.ClickEvent event) {
    secondaryDialog = new ModalWindow("Delete User", null);
    UI.getCurrent().addWindow(secondaryDialog);
    secondaryDialog.addCloseListener(this);

    final VerticalLayout formContainer = new VerticalLayout();
    formContainer.setMargin(new MarginInfo(true, true, false, true));
    formContainer.setSpacing(false);

    final Form form = new Form();
    formContainer.addComponent(form);
    form.setFooter(null);
    form.setDescription("Delete user " + userInfo.completeNamesByID(selectedUserID) + " from the system");

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            form.discard();
            secondaryDialog.close();
        }
    });

    Button okButton = new Button("Delete User");
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                form.setComponentError(null);
                form.commit();
                boolean success = userInfo.deleteUser(selectedUserID);
                if (success) {
                    select.removeItem(selectedUserID);
                } else {
                    return;
                }
            } catch (EmptyValueException e) {
                return;
            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
                return;
            }
            secondaryDialog.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(formContainer);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.skysql.manager.ui.WarningWindow.java

License:Open Source License

/**
 * Instantiates a new warning window.//from ww  w  .  ja  va 2 s .com
 *
 * @param caption the caption
 * @param message the message
 * @param label the label
 * @param okListener the ok listener
 */
public WarningWindow(String caption, String message, String label, Button.ClickListener okListener) {
    super(caption, "60%");

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setWidth("100%");
    wrapper.setMargin(true);
    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.setWidth("100px");
    wrapper.addComponent(iconLayout);
    Embedded image = new Embedded(null, new ThemeResource("img/warning.png"));
    iconLayout.addComponent(image);
    VerticalLayout textLayout = new VerticalLayout();
    textLayout.setSizeFull();
    wrapper.addComponent(textLayout);
    wrapper.setExpandRatio(textLayout, 1.0f);

    Label msgLabel = new Label(message);
    msgLabel.addStyleName("warning");
    textLayout.addComponent(msgLabel);
    textLayout.setComponentAlignment(msgLabel, Alignment.MIDDLE_CENTER);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(Button.ClickEvent event) {
            warningWindow.close();
        }
    });

    Button okButton = new Button(label);
    okButton.addClickListener(okListener);
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) this.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.squadd.chat.ChatController.java

public HorizontalLayout createChatLineFrom(ChatMessage message) {
    HorizontalLayout chatLine = new HorizontalLayout();
    Panel messagePanel = createMessagePanel(message);
    Panel photoPanel = createPhotoPanel(userFromImageEmbedded);
    //FormLayout photoPanel = createPhotoLayout(userFromImageEmbedded);
    HorizontalLayout dateLayout = createDateLayout(message);
    chatLine.addComponents(photoPanel, messagePanel, dateLayout);
    chatLine.setExpandRatio(messagePanel, 1);
    chatLine.setComponentAlignment(dateLayout, Alignment.BOTTOM_CENTER);
    //chatLine.setWidth("900px");
    //chatLine.setMargin(true);
    return chatLine;
}

From source file:com.squadd.chat.ChatController.java

public HorizontalLayout createChatLineTo(ChatMessage message) {
    HorizontalLayout chatLine = new HorizontalLayout();
    Panel messagePanel = createMessagePanel(message);
    Panel photoPanel = createPhotoPanel(userToImageEmbedded);
    //FormLayout photoPanel = createPhotoLayout(userToImageEmbedded);
    HorizontalLayout dateLayout = createDateLayout(message);
    chatLine.addComponents(dateLayout, messagePanel, photoPanel);
    chatLine.setExpandRatio(messagePanel, 1);
    //chatLine.setWidth("900px");
    chatLine.setComponentAlignment(dateLayout, Alignment.BOTTOM_CENTER);
    //chatLine.setMargin(false);
    return chatLine;
}

From source file:com.squadd.UI.ChatAndParticipantsLayout.java

public ChatAndParticipantsLayout(Group group) {
    Label label = new Label("Participants");
    label.setSizeUndefined();/*from  ww  w . j  a  va2s.  c o m*/
    HorizontalLayout hor = new HorizontalLayout();
    hor.setWidth(0.67 * Display.width + "px");
    hor.addComponent(label);
    hor.setComponentAlignment(label, Alignment.TOP_CENTER);
    parts.setWidth(0.68 * Display.width + "px");
    parts.setContent(hor);
    parts.setStyleName("backColorGrey");

    Label label1 = new Label("Group Chat");
    label1.setSizeUndefined();
    HorizontalLayout hor1 = new HorizontalLayout();
    hor1.setWidth(0.67 * Display.width + "px");
    hor1.addComponent(label);
    hor1.setComponentAlignment(label, Alignment.TOP_CENTER);
    grChat.setWidth(0.68 * Display.width + "px");
    grChat.setContent(hor);
    grChat.setStyleName("backColorGrey");

}

From source file:com.squadd.UI.ConfirmRegistrationLayout.java

private void centerAligningComponent(HorizontalLayout where, Component what) {
    where.setSizeFull();
    where.setComponentAlignment(what, Alignment.TOP_CENTER);
}

From source file:com.squadd.UI.EditVersionLayout.java

private void buildLayout() {
    HorizontalLayout knopki = new HorizontalLayout(save, cancel);
    knopki.setSizeUndefined();//ww w.  j av a 2  s  .  co m
    knopki.setSpacing(true);
    HorizontalLayout hor = new HorizontalLayout(knopki);
    hor.setWidth(0.4 * Display.width + "px");
    hor.setComponentAlignment(knopki, Alignment.TOP_RIGHT);
    FormLayout data = new FormLayout(groupName, placeName, date, description);
    HorizontalLayout first = new HorizontalLayout();
    groupPhoto.setWidth(0.2 * Display.width + "px");
    groupPhoto.setHeight(0.2 * Display.width + "px");
    first.addComponent(groupPhoto);
    VerticalLayout lst = new VerticalLayout();
    lst.setSpacing(true);
    lst.addComponents(hor, data);

    HorizontalLayout uploadAndUsers = new HorizontalLayout(uploadPhoto);
    uploadAndUsers.setWidth(0.2 * Display.width + "px");
    uploadPhoto.setSizeUndefined();
    uploadAndUsers.setComponentAlignment(uploadPhoto, Alignment.MIDDLE_CENTER);
    VerticalLayout vert = new VerticalLayout(groupPhoto, uploadAndUsers);
    HorizontalLayout second = new HorizontalLayout(vert);

    HorizontalLayout photoAndInfo = new HorizontalLayout(second, lst);

    addComponent(photoAndInfo);
}

From source file:com.squadd.UI.GroupChatLayout.java

public GroupChatLayout(Group group) {
    name = new Panel();
    Label label = new Label("Group Chat");
    label.setSizeUndefined();/*from w w w .  j  av  a  2 s . co m*/
    HorizontalLayout hor = new HorizontalLayout();
    hor.setWidth(0.67 * Display.width + "px");
    hor.addComponent(label);
    hor.setComponentAlignment(label, Alignment.TOP_CENTER);
    name.setWidth(0.68 * Display.width + "px");
    name.setContent(hor);
    name.setStyleName("backColorGrey");
    message = new TextArea();
    msg = new ArrayList();
    send = new Button("send");
    content = new VerticalLayout();

    dateComparator = new Comparator<GroupChat>() {
        @Override
        public int compare(GroupChat o1, GroupChat o2) {
            return -o1.getDate().compareTo(o2.getDate());
        }
    };
    configureLayout(group);
    configureActions(group);
}

From source file:com.squadd.UI.GroupChatLayout.java

private void configureLayout(Group group) {
    HorizontalLayout sendL = new HorizontalLayout(message, send);
    sendL.setWidth(Display.width * 0.68 + "px");
    send.setSizeUndefined();/*from w  ww .  j  a  v a2 s  .  c  o  m*/
    message.setWidth(0.61 * Display.width - send.getWidth() + "px");
    sendL.setComponentAlignment(send, Alignment.MIDDLE_RIGHT);

    DBManager db = new DBManager();
    List<GroupChat> jb = (ArrayList) db.getAllGroupMessages(group.getGroupId());
    Collections.sort(jb, dateComparator);
    msg = new ArrayList<MessageLayout>();
    for (int i = 0; i < jb.size(); ++i) {
        Label when = new Label(jb.get(i).getDate().toString());
        Image photo = new ImageGetter().get(group);
        Label text = new Label(jb.get(i).getMessage());
        msg.add(new MessageLayout(when, photo, text));
    }

    for (int i = 0; i < msg.size(); ++i) {
        content.addComponent(msg.get(i));
    }

    cont = new VerticalLayout(sendL, content);
    cont.setVisible(false);
    VerticalLayout all = new VerticalLayout(name, cont);
    addComponent(all);

}

From source file:com.squadd.UI.GroupMainInfoLayout.java

private void buildLayout() {
    HorizontalLayout knopki = new HorizontalLayout(edit);
    knopki.setSizeUndefined();/*from w ww  .jav a 2s.  c  om*/
    knopki.setSpacing(true);
    HorizontalLayout hor = new HorizontalLayout(knopki);
    hor.setWidth(0.4 * Display.width + "px");
    hor.setComponentAlignment(knopki, Alignment.TOP_RIGHT);
    description.setWidth(0.2 * Display.width + "px");
    FormLayout data = new FormLayout(groupName, placeName, date, description);
    HorizontalLayout first = new HorizontalLayout();
    groupPhoto.setWidth(0.2 * Display.width + "px");
    groupPhoto.setHeight(0.2 * Display.width + "px");
    first.addComponent(groupPhoto);
    HorizontalLayout seventh = new HorizontalLayout();
    seventh.setWidth(0.2 * Display.width + "px");
    seventh.addComponents(uploadPhoto);
    uploadPhoto.setSizeUndefined();
    seventh.setComponentAlignment(uploadPhoto, Alignment.TOP_CENTER);
    VerticalLayout lst = new VerticalLayout();
    lst.setSpacing(true);
    lst.addComponents(hor, data);

    VerticalLayout photoAndUpload = new VerticalLayout(first, seventh);
    HorizontalLayout photoAndInfo = new HorizontalLayout(photoAndUpload, lst);

    VerticalLayout content = new VerticalLayout(photoAndInfo);

    addComponent(content);
}