Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment MIDDLE_RIGHT.

Prototype

Alignment MIDDLE_RIGHT

To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.

Click Source Link

Usage

From source file:br.com.anteros.mobileserver.app.form.ParameterForm.java

License:Apache License

private void createButtons() {
    buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*  w  w w .jav  a 2 s .c  o  m*/
    buttons.setWidth("640px");

    btnOk = new Button("Ok", this);
    btnOk.addStyleName("default");
    btnOk.setIcon(new ThemeResource("icons/16/ok.png"));
    buttons.addComponent(btnOk);
    buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);
    buttons.setExpandRatio(btnOk, 1);

    btnCancel = new Button("Cancela", this);
    btnCancel.setIcon(new ThemeResource("icons/16/cancel.png"));
    buttons.addComponent(btnCancel);
    buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);

    parameterForm.getFooter().addComponent(buttons);
}

From source file:br.com.anteros.mobileserver.app.form.ProcedureForm.java

License:Apache License

private void createButtons() {
    buttons = new HorizontalLayout();
    buttons.setSpacing(true);//from   www  .j a v a2s  .co  m
    buttons.setWidth("100%");

    btnAddParameter = new Button("Adicionar", this);
    btnAddParameter.setIcon(new ThemeResource("icons/16/parameterAdd.png"));
    buttons.addComponent(btnAddParameter);
    buttons.setComponentAlignment(btnAddParameter, Alignment.MIDDLE_LEFT);

    btnRemoveParameter = new Button("Remover", this);
    btnRemoveParameter.setIcon(new ThemeResource("icons/16/parameterRemove.png"));
    buttons.addComponent(btnRemoveParameter);
    buttons.setComponentAlignment(btnRemoveParameter, Alignment.MIDDLE_LEFT);

    btnEditParameter = new Button("Editar", this);
    btnEditParameter.setIcon(new ThemeResource("icons/16/parameterEdit.png"));
    buttons.addComponent(btnEditParameter);
    buttons.setComponentAlignment(btnEditParameter, Alignment.MIDDLE_LEFT);

    btnImport = new Button("Importar parmetros", this);
    btnImport.setIcon(new ThemeResource("icons/16/import.png"));
    buttons.addComponent(btnImport);
    buttons.setComponentAlignment(btnImport, Alignment.MIDDLE_LEFT);

    btnMoveUp = new Button("Mover p/cima", this);
    btnMoveUp.setIcon(new ThemeResource("icons/16/moveUp.png"));
    buttons.addComponent(btnMoveUp);
    buttons.setComponentAlignment(btnMoveUp, Alignment.MIDDLE_LEFT);

    btnMoveDown = new Button("Mover p/baixo", this);
    btnMoveDown.setIcon(new ThemeResource("icons/16/moveDown.png"));
    buttons.addComponent(btnMoveDown);
    buttons.setComponentAlignment(btnMoveDown, Alignment.MIDDLE_LEFT);

    btnOk = new Button("Ok", this);
    btnOk.addStyleName("default");
    btnOk.setIcon(new ThemeResource("icons/16/ok.png"));
    buttons.addComponent(btnOk);
    buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);
    buttons.setExpandRatio(btnOk, 1);

    btnCancel = new Button("Cancela", this);
    btnCancel.setIcon(new ThemeResource("icons/16/cancel.png"));
    buttons.addComponent(btnCancel);
    buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);
    buttons.setMargin(true, false, true, false);
}

From source file:br.com.anteros.mobileserver.app.form.TableForm.java

License:Apache License

private void createButtons() {
    buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*from  www .ja  v a 2 s.c  o m*/
    buttons.setWidth("100%");

    buttons.addComponent(buttonsFields);
    buttons.setExpandRatio(buttonsFields, 1);

    btnOk = new Button("Ok", this);
    btnOk.addStyleName("default");
    btnOk.setIcon(new ThemeResource("icons/16/ok.png"));
    btnOk.addListener(this);
    buttons.addComponent(btnOk);
    buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);

    btnCancel = new Button("Cancela", this);
    btnCancel.setIcon(new ThemeResource("icons/16/cancel.png"));
    btnCancel.addListener(this);
    buttons.addComponent(btnCancel);
    buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);
    buttons.setMargin(true, false, true, false);
}

From source file:br.com.anteros.mobileserver.app.form.TableForm.java

License:Apache License

public void selectedTabChange(SelectedTabChangeEvent event) {
    TabSheet tabsheet = event.getTabSheet();
    Tab tab = tabsheet.getTab(tabsheet.getSelectedTab());
    if (tab != null) {
        buttons.removeComponent(buttonsFields);
        buttons.removeComponent(buttonsParameters);
        buttons.removeComponent(btnOk);//from  w  w w. ja  v a2s  .co  m
        buttons.removeComponent(btnCancel);
        if (tab.getCaption().equals("Campos")) {
            buttons.addComponent(buttonsFields);
            buttons.setExpandRatio(buttonsFields, 1);
        } else {
            buttons.addComponent(buttonsParameters);
            buttons.setExpandRatio(buttonsParameters, 1);
        }
        buttons.addComponent(btnOk);
        buttons.addComponent(btnCancel);
        buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);
        buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);
    }
}

From source file:br.com.anteros.mobileserver.util.UserMessages.java

License:Apache License

public Window confirm(String title, String message, String okTitle, String cancelTitle,
        Button.ClickListener listener) {

    if (title == null) {
        title = CONFIRM_OK_TITLE;/*from  w ww  . j  a va  2s .  c  om*/
    }
    if (cancelTitle == null) {
        cancelTitle = CONFIRM_CANCEL_TITLE;
    }
    if (okTitle == null) {
        okTitle = CONFIRM_OK_TITLE;
    }

    final Window confirm = new Window(title);
    this.confirm = confirm;
    win.addWindow(confirm);

    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            Object data = ce.getWindow().getData();
            if (data != null) {
                try {
                } catch (Exception exception) {
                    error("Unhandled Exception", exception);
                }
            }
        }
    });

    int chrW = 5;
    int chrH = 15;
    int txtWidth = Math.max(250, Math.min(350, message.length() * chrW));
    int btnHeight = 25;
    int vmargin = 100;
    int hmargin = 40;

    int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth;

    confirm.setWidth((txtWidth + hmargin) + "px");
    confirm.setHeight((vmargin + txtHeight + btnHeight) + "px");
    confirm.getContent().setSizeFull();

    confirm.center();
    confirm.setModal(true);

    Label text = new Label(message);
    text.setWidth("100%");
    text.setHeight("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setHeight(btnHeight + 5 + "px");
    buttons.setWidth("100%");
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button cancel = new Button(cancelTitle, listener);
    cancel.setIcon(new ThemeResource("icons/16/no.png"));
    cancel.setData(USER_CONFIRM_CANCEL);
    cancel.setClickShortcut(KeyCode.ESCAPE);
    Button ok = new Button(okTitle, listener);
    ok.setIcon(new ThemeResource("icons/16/yes.png"));
    ok.setData(USER_CONFIRM_OK);
    ok.setClickShortcut(KeyCode.ENTER);
    buttons.addComponent(ok);
    buttons.setExpandRatio(ok, 1);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);

    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);

    confirm.addComponent(text);
    confirm.addComponent(buttons);
    ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f);
    confirm.setResizable(false);
    return confirm;
}

From source file:ch.bfh.ti.soed.hs16.srs.purple.view.ReservationView.java

License:Open Source License

/**
 * Function initalizes the reservation view
 *//*from w ww. j  av a  2 s .c o  m*/
@SuppressWarnings("serial")
@Override
public void initView() {

    siteTitle.addStyleName("h2");
    GregorianCalendar start = new GregorianCalendar();
    GregorianCalendar end = new GregorianCalendar();
    end.add(GregorianCalendar.DAY_OF_YEAR, 40);

    cal.setSizeFull();

    cal.setStartDate(start.getTime());
    cal.setEndDate(end.getTime());
    cal.setVisible(true);

    // Handler opens a new reservation pop-up
    cal.setHandler(new RangeSelectHandler() {

        @Override
        public void rangeSelect(RangeSelectEvent event) {
            Timestamp start = new Timestamp(event.getStart().getTime());
            Timestamp ende = new Timestamp(event.getEnd().getTime());
            if (start.compareTo(ende) == 0)
                ende.setTime(ende.getTime() + 3600 * 1000); //if start and end are the same, add 1 hour to the end
            showPopup(new Reservation(-1, start, ende, null, "", ""));
        }
    });

    /**
     * DateClickHandler
     * switches between daily and monthly view
     */
    cal.setHandler(new DateClickHandler() {

        @Override
        public void dateClick(DateClickEvent event) {
            if (cal.getEndDate().getTime() - cal.getStartDate().getTime() == 0) {
                cal.setStartDate(start.getTime());
                cal.setEndDate(end.getTime());
            } else {
                cal.setStartDate(event.getDate());
                cal.setEndDate(event.getDate());
            }
        }
    });

    clButton = new ClickListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void buttonClick(ClickEvent event) {
            if (event.getButton() == saveButton) //God save the queen
            {
                if (title.isReadOnly()) {
                    setEditable(true);
                    return;
                }
                //Validating checks
                if (title.getValue().length() < 3)
                    title.setStyleName("errorTextField");
                if (rooms.getValue() == null)
                    return;
                Timestamp startTime = new Timestamp(startDate.getValue().getTime());
                Timestamp endTime = new Timestamp(endDate.getValue().getTime());
                List<User> hosts = new ArrayList<User>();
                //Hosts auslesen
                Set<Integer> temp = (Set<Integer>) ReservationView.this.hosts.getValue();
                for (int id : temp)
                    for (int y = 0; y < hostList.size(); y++)
                        if (hostList.get(y).getUserID() == id)
                            hosts.add(hostList.get(y));
                if (hosts.size() == 0) //Wenn kein User als Host ist, wird der aktuelle User als Host genommen
                    hosts.add(actualUser);
                List<User> participants = new ArrayList<User>();
                //Teilnehmer auslesen
                Set<Integer> temp2 = (Set<Integer>) ReservationView.this.participantList.getValue();
                for (int id : temp2)
                    for (int y = 0; y < hostList.size(); y++)
                        if (hostList.get(y).getUserID() == id && !isHost(hostList.get(y), hosts)) //Teilnehmer nur speichern, wenn er nicht bereits Host ist
                            participants.add(hostList.get(y));

                System.out.println(hosts.get(0).getUsername());
                if (res.getReservationID() > 0) //Edit
                {
                    Reservation newRes = new Reservation(res.getReservationID(), startTime, endTime,
                            resCont.getRoom((int) rooms.getValue()), title.getValue(), description.getValue(),
                            hosts, participants);
                    resCont.updateReservation(newRes);
                    popUpWindow.close();
                    calendarUpdate();
                } else //Neu
                {
                    if (resCont.addReservation(
                            new Reservation(-1, startTime, endTime, resCont.getRoom((int) rooms.getValue()),
                                    title.getValue(), description.getValue(), hosts, participants))) {
                        popUpWindow.close();
                        calendarUpdate();
                    }
                }
            }
            if (event.getButton() == deleteButton) //Move the reservation into the trash
            {
                //Confirm
                ConfirmDialog.show(UI.getCurrent(), "Lschen besttigen",
                        "Die Reservation wirklich lschen?", "Ja", "Abbrechen", new ConfirmDialog.Listener() {

                            @Override
                            public void onClose(ConfirmDialog arg0) {
                                if (arg0.isConfirmed()) {
                                    resCont.deleteReservation(res.getReservationID());
                                    cal.removeEvent(res);
                                    res = null;
                                    popUpWindow.close();
                                }
                            }
                        });
            }
            if (event.getButton() == acceptButton) //Accept reservation as participant
            {
                if (resCont.acceptReservation(actualUser, res))
                    popUpWindow.close();
            }
            if (event.getButton() == rejectButton) //reject reservation as participant
            {
                if (resCont.cancelReservation(actualUser, res))
                    popUpWindow.close();
            }
        }
    };

    cal.setHandler(new EventClickHandler() {
        @Override
        public void eventClick(EventClick event) {
            //show the reservation details if clicked on it
            Reservation e = (Reservation) event.getCalendarEvent();

            showPopup(e);
        }
    });

    ValueChangeListener vcl = new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (viewSelect.getValue() == null)
                return;
            int val = (int) viewSelect.getValue();
            if (val != 0)
                actualView = val;
            calendarUpdate();
        }
    };

    viewSelect = new NativeSelect();
    viewSelect.addItem(-1);
    viewSelect.setItemCaption(-1, "bersicht");
    viewSelect.addItem(-2);
    viewSelect.setItemCaption(-2, "Eigene Reservationen");
    viewSelect.select(-1);
    viewSelect.addValueChangeListener(vcl);
    viewSelect.addItem(0);
    viewSelect.setItemCaption(0, "--- Rume ---");
    for (int i = 0; i < roomList.size(); i++) {
        viewSelect.addItem(roomList.get(i).getRoomID());
        viewSelect.setItemCaption(roomList.get(i).getRoomID(),
                roomList.get(i).getName() + "(" + roomList.get(i).getNumberOfSeats() + " Pltze)");
    }

    layout.addComponent(siteTitle, 0, 0);
    layout.addComponent(cal, 0, 1, 1, 1);
    layout.addComponent(viewSelect, 1, 0);
    layout.setComponentAlignment(viewSelect, Alignment.MIDDLE_RIGHT);
    layout.setRowExpandRatio(0, 0.1f);
    layout.setRowExpandRatio(1, 20);
    //layout.setMargin(true);
    //layout.setSpacing(true);
    layout.setSizeFull();
}

From source file:ch.bfh.ti.soed.hs16.srs.purple.view.ViewStructure.java

License:Open Source License

/**
 * Function inits the components of the graphical userinterface (GUI).
 *
 * @param vaadinRequest//from w w  w.  j  a  v  a 2s .  c o  m
 *            - The vaadin request
 */
@Override
protected void init(VaadinRequest vaadinRequest) {

    this.contentPanel.setStyleName(Reindeer.PANEL_LIGHT);
    this.contentPanel.setSizeFull();
    this.contentPanel.addStyleName("contenPanel");
    this.contentPanel.setImmediate(true);
    this.logo.addStyleName("logo");

    this.reservationView.initView();
    this.registrationView.initView();
    this.userProfileView.initView();

    initMenu();

    if (this.loginController.isUserLoggedInOnSession()) {
        this.menu.setVisible(true);
        setContent(this.reservationView);
    } else {
        this.menu.setVisible(false);
        setContent(this.registrationView);
    }

    this.fullSite.setImmediate(true);
    this.loginView.initView();
    this.loginView.display(this.loginLogoutPart);

    this.fullSite.addComponent(this.logo, 0, 0);
    this.fullSite.setComponentAlignment(this.logo, Alignment.MIDDLE_LEFT);
    this.fullSite.addComponent(this.loginLogoutPart, 1, 0);
    this.fullSite.setComponentAlignment(this.loginLogoutPart, Alignment.MIDDLE_RIGHT);
    this.fullSite.setRowExpandRatio(0, 0);

    this.fullSite.addComponent(this.menu, 0, 1, 1, 1);
    this.fullSite.setComponentAlignment(this.menu, Alignment.TOP_LEFT);

    this.fullSite.addComponent(this.contentPanel, 0, 2, 1, 2);
    this.fullSite.setComponentAlignment(this.contentPanel, Alignment.TOP_LEFT);
    this.fullSite.setRowExpandRatio(2, 10);

    this.fullSite.setSizeFull();
    this.setContent(this.fullSite);

}

From source file:ch.bfh.ti.soed.hs16.srs.purple.view.ViewStructure.java

License:Open Source License

/**
 * Function updates the login/logout part of the view. The menu will also be
 * removed on logout and added on login.
 *
 * @param layout/*from  w  w  w.ja  v a  2  s  .c o m*/
 *            - The layout
 * @param loggedIn
 *            - logged in or not
 */
public void refreshLoginLogoutContent(HorizontalLayout layout, boolean loggedIn) {
    if (loggedIn) {
        this.menu.setVisible(true);
        setContent(this.reservationView);
    } else {
        this.menu.setVisible(false);
        setContent(this.registrationView);
    }

    this.fullSite.replaceComponent(this.loginLogoutPart, layout);
    this.fullSite.setComponentAlignment(layout, Alignment.MIDDLE_RIGHT);

    this.loginLogoutPart = layout;
}

From source file:ch.wscr.management.ui.view.MemberView.java

/**
 * Header der View erstellen/*from   w  ww .  j a  va  2 s .  c  om*/
 *
 * @return der Header
 */
private Component buidViewHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100f, Unit.PERCENTAGE);
    header.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    header.setSpacing(true);

    Label title = new Label("Mitgliederverwaltung");
    title.setSizeUndefined();
    title.addStyleName(ValoTheme.LABEL_H1);

    header.addComponent(title);

    Label gap = new Label();
    gap.setWidth(10, Unit.PIXELS);

    header.addComponent(gap);
    header.setExpandRatio(title, 1);
    return header;
}

From source file:com.cms.view.SearchCustomerFromTaxCode.java

private void buildSearchGrid() {
    leftPanel.setCaption("Tm kim khch hng");
    Label lbTaxCode = CommonUtils.buildLabel("M s thu", false);
    taxCode = CommonUtils.buildTextField(null, 20, "ALT + 1");
    taxCode.focus();/*from   w w w .  j av a 2  s .c om*/
    taxCode.addShortcutListener(new AbstractField.FocusShortcut(taxCode, ShortcutAction.KeyCode.NUM1,
            ShortcutAction.ModifierKey.ALT));
    btnSearch = new Button("Tm kim", FontAwesome.SEARCH);
    searchGrid = new GridLayout(3, 1);
    CommonUtils.setBasicAttributeLayout(searchGrid, "Tm kim thng tin theo m s thu", true);
    searchGrid.addComponent(lbTaxCode, 0, 0);
    searchGrid.addComponent(taxCode, 1, 0);
    searchGrid.addComponent(btnSearch, 2, 0);
    searchGrid.setComponentAlignment(lbTaxCode, Alignment.MIDDLE_RIGHT);
    searchGrid.setComponentAlignment(taxCode, Alignment.MIDDLE_LEFT);
    searchGrid.setComponentAlignment(btnSearch, Alignment.MIDDLE_LEFT);
    leftLayout.addComponent(searchGrid);
}