Example usage for com.google.gwt.user.client.ui HorizontalPanel setHorizontalAlignment

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setHorizontalAlignment

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HorizontalPanel setHorizontalAlignment.

Prototype

public void setHorizontalAlignment(HorizontalAlignmentConstant align) 

Source Link

Document

Sets the default horizontal alignment to be used for widgets added to this panel.

Usage

From source file:bingo.client.Bingo.java

License:Open Source License

/**
 * This is the entry point method./*from   w  ww  .jav a  2s  . c o  m*/
 */
public void onModuleLoad() {
    Label titleLabel = new Label();
    titleLabel.setText(strings.title());
    RootPanel.get("title").add(titleLabel);

    // This is the general notification text box
    RootPanel.get("message").add(message);

    // Cheking if the user has already an user id
    final String cookie = Cookies.getCookie(COOKIE_ID);

    // Validating the cookie
    bingoService.statusUserId(cookie, new AsyncCallback<Integer>() {
        @Override
        public void onFailure(Throwable caught) {
            message.setText(caught.getMessage());
            Cookies.removeCookie(COOKIE_ID);
        }

        @Override
        public void onSuccess(Integer status) {
            // TODO: Control the logged status (I should not get a user if s/he is already logged)
            if (status.intValue() == BingoService.NO_LOGGED || status.intValue() == BingoService.LOGGED) {
                bingoService.getUserId(new AsyncCallback<String>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        message.setText(strings.errorUserCreation());
                    }

                    @Override
                    public void onSuccess(String result) {
                        userId = result;
                    }
                });

                message.setHTML("");

                // Showing image to enter
                ImageResource imageResource = BingoResources.INSTANCE.entry();
                Image entryImage = new Image(imageResource.getSafeUri());
                RootPanel.get("buttons").add(entryImage);

                // Selecting behavior (admin / voter) 
                HorizontalPanel entryPoint = new HorizontalPanel();

                entryPoint.setStyleName("mainSelectorPanel");
                entryPoint.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
                entryPoint.setSpacing(50);

                // 
                // CREATING A BINGO
                //
                VerticalPanel leftPanel = new VerticalPanel();
                leftPanel.setStyleName("selectorPanel");

                Label leftPanelTitle = new Label();
                leftPanelTitle.setStyleName("selectorPanelTitle");
                leftPanelTitle.setText(strings.leftPanelTitle());
                leftPanel.add(leftPanelTitle);
                leftPanel.setCellHorizontalAlignment(leftPanelTitle, HasHorizontalAlignment.ALIGN_CENTER);

                Grid leftSubPanel = new Grid(2, 2);
                leftSubPanel.setWidget(0, 0, new Label(strings.createBingoName()));
                final TextBox bingoNameBox = new TextBox();
                leftSubPanel.setWidget(0, 1, bingoNameBox);

                leftSubPanel.setWidget(1, 0, new Label(strings.createBingoPassword()));
                final PasswordTextBox bingoPasswordBox = new PasswordTextBox();
                leftSubPanel.setWidget(1, 1, bingoPasswordBox);
                leftPanel.add(leftSubPanel);

                final Button createButton = new Button("Create");
                createButton.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        bingoService.createBingo(userId, bingoNameBox.getText(), bingoPasswordBox.getText(),
                                new AsyncCallback<String>() {
                                    @Override
                                    public void onFailure(Throwable caught) {
                                        message.setText(caught.getMessage());
                                    }

                                    @Override
                                    public void onSuccess(final String gameId) {
                                        final BingoGrid bingoGrid = new BingoGrid();
                                        initAdminGrid(userId, bingoGrid, false);
                                        RootPanel.get("bingoTable").clear();
                                        RootPanel.get("bingoTable").add(bingoGrid);
                                        message.setText(strings.welcomeMessageCreation());

                                        // Setting the cookie
                                        Date expirationDate = new Date();
                                        expirationDate.setHours(expirationDate.getHours() + EXPIRATION_VALUE);
                                        Cookies.setCookie(COOKIE_ID, userId, expirationDate);
                                    }
                                });
                    }
                });
                leftPanel.add(createButton);
                leftPanel.setCellHorizontalAlignment(createButton, HasHorizontalAlignment.ALIGN_CENTER);
                entryPoint.add(leftPanel);

                // 
                // JOINING
                //
                VerticalPanel rightPanel = new VerticalPanel();
                rightPanel.setStyleName("selectorPanel");

                Label rightPanelTitle = new Label();
                rightPanelTitle.setStyleName("selectorPanelTitle");
                rightPanelTitle.setText(strings.rightPanelTitle());
                rightPanel.add(rightPanelTitle);
                rightPanel.setCellHorizontalAlignment(rightPanelTitle, HasHorizontalAlignment.ALIGN_CENTER);

                Grid rightSubPanel = new Grid(2, 2);
                rightSubPanel.setWidget(0, 0, new Label(strings.joinToBingoName()));
                final ListBox joinExistingBingoBox = new ListBox();
                bingoService.getBingos(new AsyncCallback<String[][]>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        joinExistingBingoBox.addItem(strings.noBingos());
                    }

                    @Override
                    public void onSuccess(String[][] result) {
                        if (result == null) {
                            joinExistingBingoBox.addItem(strings.noBingos());
                        } else {
                            for (int i = 0; i < result.length; i++) {
                                String gameName = result[i][0];
                                String gameId = result[i][1];
                                joinExistingBingoBox.addItem(gameName, gameId);
                            }
                        }
                    }
                });
                rightSubPanel.setWidget(0, 1, joinExistingBingoBox);

                rightSubPanel.setWidget(1, 0, new Label(strings.joinToBingoPassword()));
                final PasswordTextBox joinBingoPasswordBox = new PasswordTextBox();
                rightSubPanel.setWidget(1, 1, joinBingoPasswordBox);
                rightPanel.add(rightSubPanel);

                final Button joinButton = new Button("Join");
                joinButton.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        int index = joinExistingBingoBox.getSelectedIndex();
                        if (index < 0)
                            message.setText(strings.noSelectedItem());
                        else {
                            final String gameId = joinExistingBingoBox.getValue(index);
                            if (gameId == null)
                                message.setText(strings.noSelectedItem());
                            else {
                                bingoService.joinBingo(userId, gameId, joinBingoPasswordBox.getText(),
                                        new AsyncCallback<Void>() {
                                            @Override
                                            public void onFailure(Throwable caught) {
                                                message.setText(caught.getMessage());
                                            }

                                            @Override
                                            public void onSuccess(Void result) {
                                                final BingoGrid bingoGrid = new BingoGrid();
                                                initUserGrid(bingoGrid);
                                                RootPanel.get("bingoTable").clear();
                                                RootPanel.get("bingoTable").add(bingoGrid);

                                                message.setText(strings.welcomeMessageJoin());

                                                // Setting the cookie
                                                Date expirationDate = new Date();
                                                expirationDate
                                                        .setHours(expirationDate.getHours() + EXPIRATION_VALUE);
                                                Cookies.setCookie(COOKIE_ID, userId, expirationDate);
                                            }
                                        });
                            }
                        }
                    }
                });
                rightPanel.add(joinButton);
                rightPanel.setCellHorizontalAlignment(joinButton, HasHorizontalAlignment.ALIGN_CENTER);
                entryPoint.add(rightPanel);

                RootPanel.get("bingoTable").add(entryPoint);

            } else if (status.intValue() == BingoService.ADMIN) {
                message.setText("Detected cookie: " + cookie + " as admin");
                userId = cookie;

                bingoService.statusBingo(userId, new AsyncCallback<Integer>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        message.setText(caught.getMessage());
                    }

                    @Override
                    public void onSuccess(Integer result) {
                        int status = result.intValue();
                        final BingoGrid bingoGrid = new BingoGrid();
                        if (status == BingoService.RUNNING) {
                            initAdminGrid(userId, bingoGrid, false);
                            message.setText(strings.welcomeMessageCreation());
                        } else if (status == BingoService.FINISHED) {
                            initAdminGrid(userId, bingoGrid, true);
                            message.setText(strings.finishMessage());
                        }
                        RootPanel.get("bingoTable").clear();
                        RootPanel.get("bingoTable").add(bingoGrid);
                    }
                });

            } else if (status.intValue() == BingoService.PARTICIPANT) {
                message.setText("Detected cookie: " + cookie + " as participant");
                userId = cookie;

                final BingoGrid bingoGrid = new BingoGrid();
                initUserGrid(bingoGrid);
                updateUserGrid(bingoGrid, null);
                RootPanel.get("bingoTable").clear();
                RootPanel.get("bingoTable").add(bingoGrid);
            }
        }
    });
}

From source file:bingo.client.Bingo.java

License:Open Source License

private void initAdminGrid(final String userId, final BingoGrid bingoGrid, final boolean hasFinished) {
    final Timer timer = new Timer() {
        int totalParticipants = 0;

        @Override//from w w w.  j a  v  a  2s.com
        public void run() {
            bingoService.getTotalParticipants(userId, new AsyncCallback<Integer>() {
                @Override
                public void onFailure(Throwable caught) {
                }

                @Override
                public void onSuccess(Integer result) {
                    totalParticipants = result.intValue();
                }
            });

            bingoService.getVotes(userId, new AsyncCallback<int[][]>() {
                @Override
                public void onFailure(Throwable caught) {
                    message.setText(caught.getMessage());
                }

                @Override
                public void onSuccess(int[][] result) {
                    if (result == null) {
                        result = new int[BingoGrid.ROW][BingoGrid.COL];
                        for (int i = 0; i < BingoGrid.ROW; i++)
                            for (int j = 0; j < BingoGrid.COL; j++)
                                result[i][j] = 0;
                    }

                    for (int row = 0; row < BingoGrid.ROW; ++row)
                        for (int col = 0; col < BingoGrid.COL; ++col) {
                            bingoGrid.setVoteString(row, col, String.valueOf(result[row][col]),
                                    String.valueOf(totalParticipants));
                        }
                }
            });
        }
    };

    // If the game is not finished, repeat; if so, run once
    if (!hasFinished)
        timer.scheduleRepeating(ADMIN_TIMER);
    else
        timer.run();

    HorizontalPanel panel = new HorizontalPanel();
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    final Button finishButton = new Button();

    // If the game is not finished, allow finishing it; if so, allow download data
    if (!hasFinished)
        finishButton.setText(strings.finishBingo());
    else
        finishButton.setText(strings.download());

    finishButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (!hasFinished)
                bingoService.finishBingo(userId, new AsyncCallback<Void>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        message.setText(caught.getMessage());
                    }

                    @Override
                    public void onSuccess(Void result) {
                        message.setText(strings.finishedBingo());
                        finishButton.setText(strings.download());
                        timer.cancel();
                    }
                });

            bingoService.getVotes(userId, new AsyncCallback<int[][]>() {
                @Override
                public void onFailure(Throwable caught) {
                    message.setText(caught.getMessage());
                }

                @Override
                public void onSuccess(int[][] result) {
                    // Create a popup dialog box
                    final DialogBox box = new DialogBox();
                    box.setText(strings.info());
                    box.setAnimationEnabled(true);

                    final Button boxAcceptButton = new Button(strings.accept());
                    boxAcceptButton.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            box.hide();
                        }
                    });

                    Label boxLabel = new Label();
                    boxLabel.setText(strings.finishMessage());
                    HTML voteData = new HTML();
                    if (result == null) {
                        result = new int[BingoGrid.ROW][BingoGrid.COL];
                        for (int i = 0; i < BingoGrid.ROW; i++)
                            for (int j = 0; j < BingoGrid.COL; j++)
                                result[i][j] = 0;
                    }

                    String cellKey = "";
                    String cellString = "";
                    String voteDataString = "";
                    for (int row = 0; row < BingoGrid.ROW; ++row)
                        for (int col = 0; col < BingoGrid.COL; ++col) {
                            cellKey = "cell" + row + col;
                            cellString = strings.map().get(cellKey);
                            voteDataString += "&nbsp;&nbsp;&nbsp;" + cellString + " = " + result[row][col]
                                    + "<br>";
                        }
                    voteData.setHTML(voteDataString);
                    voteData.addStyleName("boxData");

                    VerticalPanel boxPanel = new VerticalPanel();
                    boxPanel.addStyleName("boxPanel");
                    boxPanel.add(boxLabel);
                    boxPanel.add(voteData);

                    HorizontalPanel buttonsPanel = new HorizontalPanel();
                    buttonsPanel.add(boxAcceptButton);
                    boxPanel.add(buttonsPanel);
                    boxPanel.setCellHorizontalAlignment(buttonsPanel, HasHorizontalAlignment.ALIGN_CENTER);

                    box.setWidget(boxPanel);
                    box.center();
                }
            });
        }
    });
    panel.add(finishButton);

    final Button terminateButton = new Button(strings.terminateButton());
    terminateButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // Create a popup dialog box
            final DialogBox box = new DialogBox();
            box.setText(strings.warning());
            box.setAnimationEnabled(true);

            final Button boxCancelButton = new Button(strings.cancel());
            boxCancelButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    box.hide();
                }
            });
            final Button boxAcceptButton = new Button(strings.accept());
            boxAcceptButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    bingoService.terminateBingo(userId, new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            message.setText(caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            message.setText(strings.terminatedBingo());
                            timer.cancel();
                        }

                    });
                    box.hide();
                }
            });

            final Label boxLabel = new Label();
            boxLabel.setText(strings.terminateMessage());

            VerticalPanel boxPanel = new VerticalPanel();

            boxPanel.addStyleName("boxPanel");
            boxPanel.add(boxLabel);

            HorizontalPanel buttonsPanel = new HorizontalPanel();
            buttonsPanel.add(boxCancelButton);
            buttonsPanel.add(boxAcceptButton);
            boxPanel.add(buttonsPanel);

            box.setWidget(boxPanel);
            box.center();
        }
    });
    panel.add(terminateButton);

    RootPanel.get("buttons").clear();
    RootPanel.get("buttons").add(panel);
}

From source file:bufferings.ktr.wjr.client.ui.WjrPopupPanel.java

License:Apache License

/**
 * Constructs the WjrPopupPanel./*from  ww w .j  ava 2 s  .c  o  m*/
 */
public WjrPopupPanel() {
    HorizontalPanel mainPanel = new HorizontalPanel();
    mainPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    mainPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    mainPanel.setSpacing(5);
    mainPanel.setStyleName(UI_STATE_HIGHLIGHT);
    mainPanel.setSize("200px", "30px");
    mainPanel.setVisible(false);
    mainPanel.getElement().getStyle().setPosition(Position.ABSOLUTE);
    mainPanel.getElement().getStyle().setPropertyPx("left", -9999);
    mainPanel.getElement().setId(DOM.createUniqueId());

    label = new Label();
    label.setStyleName(UI_WIDGET);
    mainPanel.add(label);

    initWidget(mainPanel);
    RootPanel.get().add(this);
}

From source file:burrito.client.widgets.panels.table.PageController.java

License:Apache License

/**
 * Creates a new pagecontroller/*from ww  w  . ja v a  2 s.  c o m*/
 * 
 * @param showPageLabel
 * @param maxPagesShown
 *            If not <code>null</code> then this will be the maximum number
 *            of pages shown in the page controller.
 */
public PageController(boolean showPageLabel) {
    HorizontalPanel wrapper = new HorizontalPanel();
    wrapper.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    if (showPageLabel) {
        Label label = new Label(messages.page());
        label.addStyleName("k5-PageController-label");
        wrapper.add(label);
    }
    next = new PushButton(new Image(GWT.getModuleBaseURL() + "images/page-next.png?v=2"));
    previous = new PushButton(new Image(GWT.getModuleBaseURL() + "images/page-previous.png?v=2"));
    next.getUpDisabledFace().setImage(new Image(GWT.getModuleBaseURL() + "images/page-next-disabled.png?v=2"));
    previous.getUpDisabledFace()
            .setImage(new Image(GWT.getModuleBaseURL() + "images/page-previous-disabled.png?v=2"));
    next.addStyleName("k5-PageController-nextButton");
    previous.addStyleName("k5-PageController-previousButton");
    currentPageLabel = createCurrentPageAnchor();
    currentPageLabel.addStyleName("k5-PageController-link-selected");
    next.setEnabled(false);
    previous.setEnabled(false);
    next.setTitle(messages.next());
    previous.setTitle(messages.previous());
    wrapper.add(previous);
    wrapper.add(currentPageLabel);
    wrapper.add(next);
    next.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            for (PageControllerHandler handler : handlers) {
                handler.loadPage(currentPageZeroIndexed + 1);
            }
        }
    });
    previous.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            for (PageControllerHandler handler : handlers) {
                handler.loadPage(currentPageZeroIndexed - 1);
            }
        }
    });
    initWidget(wrapper);
    addStyleName("k5-PageController");
    setVisible(false);
}

From source file:bwbv.rlt.client.ui.HeaderPane.java

License:Apache License

/**
 * Build this conditionally based on isLoggedIn
 * @param isLoggedIn//from  w ww  .j a  v a2s. co m
 * @return
 */
private HorizontalPanel buildHeaderPanel(boolean isLoggedIn) {
    HorizontalPanel panel = new HorizontalPanel();
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    if (isLoggedIn) {
        panel.setSpacing(10);
        panel.add(new Label("Welcome " + clientState.getUserName()));

        Button logoutButton = new Button("Logout");
        logoutButton.setStyleName("LogoutButton");
        logoutButton.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                logout();
            }
        });
        panel.add(logoutButton);
    } else {
        Button loginButon = new Button("Login");
        loginButon.setStyleName("LoginButton");
        loginButon.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                showNewUserNameRequestPopupPanel();
            }
        });
        panel.add(loginButon);
    }
    return panel;
}

From source file:ca.aeso.evq.client.widgets.DatePicker.java

License:Apache License

private Widget drawControls(ListBox names, Label name, int prev, int next, int set) {

    HorizontalPanel hp = new HorizontalPanel();
    hp.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    hp.addStyleName(STYLE_CONTROL_BLOCK);

    if (names == dateTable.monthNames()) {
        monthAction = set;//  w w w  .  j a v  a 2 s.c o  m
    } else {
        yearAction = set;
    }

    // move left
    //    if (!showYearMonthListing || set == ACTION_SET_MONTH) {
    //      DatePickerCell left = new DatePickerCell("\u00ab"); // \u00ab is <<
    //      left.setType(LocaleCalendarUtils.TYPE_CONTROL);
    //      left.setValue(prev);
    //      left.addStyleName(STYLE_CONTROL);
    //      left.addClickListener(this);
    //      hp.add(left);
    //    }

    // Need list box or not
    if (showYearMonthListing) {

        names.setVisibleItemCount(1);
        names.addStyleName(STYLE_CONTROL_MENU);
        names.addChangeListener(this);

        hp.add(names);

    } else {

        name.addStyleName(STYLE_TITLE);
        hp.add(name);
    }

    // move right
    //    if (!showYearMonthListing || set == ACTION_SET_MONTH) {
    //      DatePickerCell right = new DatePickerCell("\u00bb"); // \u00ab is >>
    //      right.setType(LocaleCalendarUtils.TYPE_CONTROL);
    //      right.setValue(next);
    //      right.addStyleName(STYLE_CONTROL);
    //      right.addClickListener(this);
    //      hp.add(right);
    //    }

    return hp;
}

From source file:ca.upei.ic.timetable.client.FindCourseView.java

License:Apache License

public FindCourseView(FindCourseViewController controller) {
    controller_ = controller;/*from  w  w  w . j a  v a2s.c o m*/

    // set up the dialog box
    dialogBox_ = new DialogBox(false, true); // autohide = false, modal = true
    dialogBox_.setAnimationEnabled(true);
    dialogBox_.setText("Find Courses...");

    // i have a horizontal panel
    HorizontalPanel filterPanel = new HorizontalPanel();
    // i have a level flex table
    levelTable_ = controller_.getLevelModel().getWidget();
    departmentTable_ = controller_.getDepartmentModel().getWidget();
    semesterTable_ = controller_.getSemesterModel().getWidget();
    startTimeWidget_ = controller_.getStartTimeModel().getWidget();

    // button panel
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);

    // i have an OK button
    final Button okButton = new Button("Search");
    okButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            // search and close the dialog
            controller_.search();
            hide();
        }

    });

    okButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ENTER) {
                okButton.click();
            }
        }

    });

    final Button cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
        }
    });

    cancelButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ESCAPE)
                cancelButton.click();
        }

    });

    SimplePanel empty = new SimplePanel();
    empty.setWidth("230px");
    buttonPanel.add(empty);
    buttonPanel.add(cancelButton);
    buttonPanel.add(okButton);
    buttonPanel.setSpacing(5);
    buttonPanel.setWidth("485px");

    // add the panel to the dialog box
    dialogBox_.add(PanelUtils.verticalPanel(PanelUtils.horizontalPanel(
            PanelUtils.verticalPanel(PanelUtils.scrollPanel(levelTable_, 250, 180),
                    PanelUtils.scrollPanel(semesterTable_, 250, 120),
                    PanelUtils.scrollPanel(startTimeWidget_, 250, 30)),
            PanelUtils.scrollPanel(departmentTable_, 250, 320)), buttonPanel));
    dialogBox_.setPopupPosition(240, 0);
}

From source file:cc.alcina.framework.gwt.client.stdlayout.MainTabPanel.java

License:Apache License

private HorizontalPanel createButtonsPanel() {
    HorizontalPanel hp = new HorizontalPanel();
    hp.setStyleName("alcina-MainMenuRight");
    hp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    for (IsWidget button : buttons) {
        if (button instanceof LoginStateVisibleWithWidget) {
            button.asWidget().ensureDebugId(((LoginStateVisibleWithWidget) button).getDebugId());
        }//  w ww.  ja  v  a2 s  .  com
        hp.add(button);
        hp.add(new BarSep());
    }
    return hp;
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.LoginDisplayer.java

License:Apache License

public LoginDisplayer() {
    dialogBox = new GlassDialogBox();
    dialogBox.setText("Login");
    dialogBox.setAnimationEnabled(true);
    mainPanel = new FlowPanel();
    mainPanel.setStyleName("alcina-Login");
    mainPanel.ensureDebugId(AlcinaDebugIds.LOGIN_FORM);
    this.introWidget = new FlowPanel();
    introWidget.setVisible(false);// w  w  w  . j a  va  2 s .co  m
    mainPanel.add(introWidget);
    introWidget.setStyleName("intro");
    cancelButton = new Button("Cancel");
    okButton = new Button("Login");
    okButton.ensureDebugId(AlcinaDebugIds.LOGIN_SUBMIT);
    table = new FlexTable();
    table.setWidth("100%");
    table.setCellSpacing(2);
    this.usernameLabel = new Label("Username: ");
    table.setWidget(0, 0, usernameLabel);
    nameBox = new TextBox();
    WidgetUtils.disableTextBoxHelpers(nameBox);
    nameBox.ensureDebugId(AlcinaDebugIds.LOGIN_USERNAME);
    table.setWidget(0, 1, nameBox);
    table.setWidget(1, 0, new Label("Password: "));
    pwdBox = new PasswordTextBox();
    WidgetUtils.disableTextBoxHelpers(pwdBox);
    pwdBox.ensureDebugId(AlcinaDebugIds.LOGIN_PASSWORD);
    table.setWidget(1, 1, pwdBox);
    pwdBox.addKeyPressHandler(new EnterAsClickKeyboardListener(pwdBox, okButton));
    nameBox.addKeyPressHandler(new EnterAsClickKeyboardListener(nameBox, okButton));
    rememberMeBox = new CheckBox();
    rememberMeBox.setValue(true);
    table.setWidget(2, 0, rememberMeBox);
    table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    table.setWidget(2, 1, new Label("Remember me on this computer"));
    statusLabel = new Label("Logging in");
    statusLabel.setVisible(false);
    table.setWidget(4, 1, statusLabel);
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    hPanel.setSpacing(5);
    hPanel.add(okButton);
    okButton.addStyleName("marginRight10");
    hPanel.add(cancelButton);
    table.setWidget(3, 1, hPanel);
    mainPanel.add(table);
    dialogBox.setWidget(mainPanel);
}

From source file:client.LogoPanel.java

License:Open Source License

/**
 * default constructor.//from  w w w  .  j  av a2 s.  c  om
 * 
 * @param images
 */
private LogoPanel(final Images images) {
    final VerticalPanel outer = new VerticalPanel();

    outer.setWidth("100%");
    outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    final Image logo = images.phosphoruslogo2().createImage();

    RpcRequest.common().isLoggedIn(new AsyncCallback() {
        public void onFailure(final Throwable caught) {
            LogoPanel.this.setSigendOut();
        }

        public void onSuccess(final Object result) {
            LogoPanel.this.setSigendIn((String) result);
        }
    });

    RpcRequest.common().isSecure(new AsyncCallback() {
        public void onFailure(final Throwable caught) {
            LogoPanel.this.aai.setStyleName("gui-TopPanel-Label");
            LogoPanel.this.aai.setText("Unable to determine Security-Status");
        }

        public void onSuccess(final Object result) {
            boolean res = ((Boolean) result).booleanValue();

            if (res) {
                LogoPanel.this.aai.setStyleName("gui-TopPanel-Sec");
                LogoPanel.this.aai.setText("Security Toolkit available!");
            } else {
                LogoPanel.this.aai.setStyleName("gui-TopPanel-UnSec");
                LogoPanel.this.aai.setText("Unsecured");
            }
        }
    });

    outer.add(logo);

    this.label.setStyleName("gui-TopPanel-Label");
    this.link.setStyleName("gui-TopPanel-Link");

    final HorizontalPanel panel = new HorizontalPanel();
    panel.setWidth("100%");
    panel.setStyleName("gui-TopPanel-Status");
    panel.add(this.label);
    panel.add(this.aai);
    panel.add(this.link);

    outer.add(panel);
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    this.initWidget(outer);
    this.setStyleName("gui-TopPanel");
}