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

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

Introduction

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

Prototype

public void setSpacing(int spacing) 

Source Link

Document

Sets the amount of spacing between this panel's cells.

Usage

From source file:bingo.client.Bingo.java

License:Open Source License

/**
 * This is the entry point method./*w  w  w. ja va  2s  .  co 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:bufferings.ktr.wjr.client.ui.WjrPopupPanel.java

License:Apache License

/**
 * Constructs the WjrPopupPanel.//ww  w. j  a  va 2s .  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:bwbv.rlt.client.ui.HeaderPane.java

License:Apache License

/**
 * Build this conditionally based on isLoggedIn
 * @param isLoggedIn//from  w  ww . j a v  a  2  s . c  o 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.nanometrics.gflot.client.example.DecimationExample.java

License:Open Source License

public Widget createExample() {
    PlotWithOverviewModel model = new PlotWithOverviewModel(PlotModelStrategy.downSamplingStrategy(20));
    PlotOptions plotOptions = new PlotOptions();
    plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true));
    plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true));
    plotOptions.setDefaultShadowSize(0);

    final SeriesHandler series = model.addSeries("Random Series", "#003366");

    // create the plot
    final PlotWithOverview plot = new PlotWithOverview(model, plotOptions);

    // pull the "fake" RPC service for new data
    final Timer updater = new Timer() {
        @Override/*from w  ww  .  jav  a2  s  .  c  o m*/
        public void run() {
            update(series, plot);
        }
    };

    // put it on a panel
    FlowPanel panel = new FlowPanel();
    panel.add(plot);
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    buttonsPanel.setSpacing(5);
    buttonsPanel.add(new Button("Start", new ClickListener() {
        public void onClick(Widget sender) {
            updater.scheduleRepeating(1000);
        }
    }));
    buttonsPanel.add(new Button("Stop", new ClickListener() {
        public void onClick(Widget sender) {
            updater.cancel();
        }
    }));
    panel.add(buttonsPanel);
    return panel;
}

From source file:ca.nanometrics.gflot.client.example.SlidingWindowExample.java

License:Open Source License

public Widget createExample() {
    PlotWithOverviewModel model = new PlotWithOverviewModel(PlotModelStrategy.slidingWindowStrategy(20));
    PlotOptions plotOptions = new PlotOptions();
    plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true));
    plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true));
    plotOptions.setDefaultShadowSize(0);
    plotOptions.setXAxisOptions(new TimeSeriesAxisOptions());

    PlotOptions overviewPlotOptions = new PlotOptions().setDefaultShadowSize(0)
            .setLegendOptions(new LegendOptions().setShow(false))
            .setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setFill(true))
            .setSelectionOptions(//w  w w.j  a  v a2 s  .  c o  m
                    new SelectionOptions().setMode(SelectionOptions.X_SELECTION_MODE).setDragging(true))
            .setXAxisOptions(new TimeSeriesAxisOptions());

    final SeriesHandler series = model.addSeries("Random Series", "#FF9900");

    // create the plot
    final PlotWithOverview plot = new PlotWithOverview(model, plotOptions, overviewPlotOptions);

    // pull the "fake" RPC service for new data
    final Timer updater = new Timer() {
        @Override
        public void run() {
            update(series, plot);
        }
    };

    // put it on a panel
    FlowPanel panel = new FlowPanel();
    panel.add(plot);
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    buttonsPanel.setSpacing(5);
    buttonsPanel.add(new Button("Start", new ClickListener() {
        public void onClick(Widget sender) {
            updater.scheduleRepeating(1000);
        }
    }));
    buttonsPanel.add(new Button("Stop", new ClickListener() {
        public void onClick(Widget sender) {
            updater.cancel();
        }
    }));
    panel.add(buttonsPanel);
    return panel;
}

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

License:Apache License

public FindCourseView(FindCourseViewController controller) {
    controller_ = controller;//w ww . java  2 s .  c om

    // 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.ClientNotificationsImpl.java

License:Apache License

@Override
public void showDialog(String captionHTML, Widget captionWidget, String msg, MessageType messageType,
        List<Button> extraButtons, String containerStyle) {
    ensureImages();/*  w w  w. jav  a 2s.c o  m*/
    HorizontalAlignmentConstant align = messageType == MessageType.ERROR ? HasHorizontalAlignment.ALIGN_LEFT
            : HasHorizontalAlignment.ALIGN_CENTER;
    if (dialogBox != null) {
        dialogBox.hide();
    }
    String title = CommonUtils.friendlyConstant(messageType);
    dialogBox = new GlassDialogBox();
    dialogBox.setAnimationEnabled(dialogAnimationEnabled);
    AbstractImagePrototype aip = null;
    String text = "";
    switch (messageType) {
    case INFO:
        aip = AbstractImagePrototype.create(images.info());
        text = "Information";
        break;
    case WARN:
        aip = AbstractImagePrototype.create(images.warning());
        text = "Warning";
        break;
    case ERROR:
        aip = AbstractImagePrototype.create(images.error());
        text = "Problem notification";
        break;
    }
    dialogBox.setText(text);
    FlexTable ft = new FlexTable();
    containerStyle = containerStyle != null ? containerStyle
            : (messageType == MessageType.ERROR || !CommonUtils.isNullOrEmpty(msg)) ? "medium" : "narrow";
    ft.setCellSpacing(4);
    ft.setStyleName("alcina-Notification");
    ft.addStyleName(containerStyle);
    FlexCellFormatter cf = (FlexCellFormatter) ft.getCellFormatter();
    ft.setWidget(0, 0, aip.createImage());
    cf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    cf.setWidth(0, 0, "40px");
    FlowPanel fp = new FlowPanel();
    fp.setStyleName("text");
    Widget capWidget = captionHTML != null ? new HTML(captionHTML) : captionWidget;
    if (captionHTML != null) {
        capWidget.setStyleName("caption");
    }
    fp.add(capWidget);
    if (!CommonUtils.isNullOrEmpty(msg)) {
        Link nh = new Link("View detail");
        nh.addStyleName("pad-5");
        dialogHtml = new HTML("<span class='logboxpre'>" + msg.replace("\n", "<br>") + "</span>", true);
        final ScrollPanel sp = new ScrollPanel(dialogHtml);
        sp.setStyleName("logbox");
        sp.setVisible(containerStyle.equals("wide"));
        nh.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                sp.setVisible(!sp.isVisible());
            }
        });
        if (LooseContext.getBoolean(ClientNotifications.CONTEXT_AUTOSHOW_DIALOG_DETAIL)) {
            sp.setVisible(true);
        }
        fp.add(nh);
        fp.add(sp);
    }
    ft.setWidget(0, 1, fp);
    cf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(8);
    Button closeButton = new Button("Close");
    hp.add(closeButton);
    if (extraButtons != null) {
        for (Button b : extraButtons) {
            hp.add(b);
        }
    }
    ft.setWidget(1, 0, hp);
    cf.setColSpan(1, 0, 2);
    cf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogBox.setWidget(ft);
    dialogBox.center();
    dialogBox.show();
    Scheduler.get().scheduleDeferred(() -> closeButton.setFocus(true));
}

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

License:Apache License

public CancellableRemoteDialog(String msg, PermissibleActionListener l, boolean autoShow) {
    if (l == null) {
        l = new PermissibleActionListener() {
            public void vetoableAction(PermissibleActionEvent evt) {
                CancellableRemoteDialog.this.hide();
            }/*from  w w  w  .  j  av  a  2s.com*/
        };
    }
    final PermissibleActionListener lCopy = l;
    setText("Please wait...");
    setAnimationEnabled(initialAnimationEnabled());
    Grid grr = new Grid(2, 1);
    status = msg;
    statusLabel = new Label(msg);
    grr.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
    grr.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    grr.setCellPadding(4);
    cancelButton = new Button("Cancel");
    setRetryButton(new Button("Retry"));
    cancelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            PermissibleAction action = new PermissibleAction();
            action.setActionName(CANCEL_ACTION);
            lCopy.vetoableAction(new PermissibleActionEvent(this, action));
        }
    });
    grr.setWidget(0, 0, statusLabel);
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(0);
    hp.add(cancelButton);
    hp.add(getRetryButton());
    getRetryButton().setVisible(false);
    grr.setWidget(1, 0, hp);
    setWidget(grr);
    if (autoShow) {
        centerAndShow();
    }
}

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  . ja  v a 2 s . c  o 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:cl.uai.client.page.EditMarkDialog.java

License:Open Source License

/**
 * Creates a comment dialog at a specific position
 * //from  ww w  .  j  a  va  2  s. c om
 * @param posx Top position for the dialog
 * @param posy Left position for the dialog
 * @param level An optional rubric level in case we are editing one
 */
public EditMarkDialog(int posx, int posy, int level, int regradeid) {
    super(true, false);

    this.regradeId = regradeid;

    this.levelId = level;
    Level lvl = MarkingInterface.submissionData.getLevelById(levelId);

    if (EMarkingConfiguration.getKeywords() != null && EMarkingConfiguration.getKeywords().length() > 0) {
        logger.fine("Keywords: " + EMarkingConfiguration.getKeywords());
    }
    if (!EMarkingConfiguration.getKeywords().equals("") && (level > 0 || regradeid > 0)) {
        feedbackArray = new ArrayList<FeedbackObject>();
        feedbackPanel = new FeedbackInterface();
        feedbackPanel.setParent(this);
    } else {
        simplePanel = true;
    }

    superPanel = new HorizontalPanel();
    superPanel.addStyleName(Resources.INSTANCE.css().feedbackdialog());

    feedbackForStudent = new VerticalPanel();
    feedbackForStudent.addStyleName(Resources.INSTANCE.css().feedbackforstudent());

    feedbackSummary = new ScrollPanel(feedbackForStudent);
    feedbackSummary.addStyleName(Resources.INSTANCE.css().feedbacksummary());

    mainPanel = new VerticalPanel();
    mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialog());

    // Adds the CSS style and other settings
    this.addStyleName(Resources.INSTANCE.css().commentdialog());
    this.setAnimationEnabled(true);
    this.setGlassEnabled(true);

    bonusTxt = new TextBox();
    bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslist());

    this.levelsList = new ListBox();
    this.levelsList.addStyleName(Resources.INSTANCE.css().levelslist());
    this.levelsList.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            int levelid = Integer.parseInt(levelsList.getValue(levelsList.getSelectedIndex()));
            levelId = levelid;
            Level lvl = MarkingInterface.submissionData.getLevelById(levelId);
            setBonus(lvl.getBonus());
        }
    });

    // If there's a rubric level we should edit a Mark
    // otherwise we are just editing its comment
    if (this.levelId == 0) {
        this.setHTML(MarkingInterface.messages.AddEditComment());
    } else {
        this.setHTML(MarkingInterface.messages.AddEditMark() + "<br/>" + lvl.getCriterion().getDescription());
    }

    // Position the dialog
    if (simplePanel) {
        this.setPopupPosition(posx, posy);
    } else {
        // The Dialog is more big, so we need to fix the position
        this.setPopupPosition((int) (Window.getClientWidth() * 0.08), (int) (Window.getClientHeight() * 0.15));
    }

    if (this.levelId > 0) {

        loadLevelsList();

        HorizontalPanel hpanelLevels = new HorizontalPanel();
        hpanelLevels.setWidth("100%");
        Label messages = new Label(MarkingInterface.messages.Level());
        hpanelLevels.add(messages);
        hpanelLevels.add(levelsList);
        hpanelLevels.setCellHorizontalAlignment(levelsList, HasHorizontalAlignment.ALIGN_RIGHT);
        mainPanel.add(hpanelLevels);
        mainPanel.setCellHorizontalAlignment(hpanelLevels, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Save button
    Button btnSave = new Button(MarkingInterface.messages.Save());
    btnSave.addStyleName(Resources.INSTANCE.css().btnsave());
    btnSave.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (levelId > 0 && !bonusIsValid()) {
                Window.alert(MarkingInterface.messages.InvalidBonusValue());
                return;
            }
            cancelled = false;
            hide();
        }
    });

    // Cancel button
    Button btnCancel = new Button(MarkingInterface.messages.Cancel());
    btnSave.addStyleName(Resources.INSTANCE.css().btncancel());
    btnCancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    // The comment text box
    TextArea txt = new TextArea();
    txt.setVisibleLines(5);
    txt.getElement().getStyle().setMarginBottom(5, Unit.PT);
    txtComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt);
    txtComment.setAutoSelectEnabled(false);
    txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestbox());

    HorizontalPanel hpanelComment = new HorizontalPanel();
    hpanelComment.setWidth("100%");
    hpanelComment.add(new Label(MarkingInterface.messages.Comment()));
    hpanelComment.add(txtComment);
    hpanelComment.setCellHorizontalAlignment(txtComment, HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(hpanelComment);
    mainPanel.setCellHorizontalAlignment(hpanelComment, HasHorizontalAlignment.ALIGN_RIGHT);

    // If the rubric level is not null then create the bonus list and add it to the dialog 
    if (this.levelId > 0) {
        setBonus(lvl.getBonus());

        HorizontalPanel hpanelBonus = new HorizontalPanel();
        hpanelBonus.setWidth("100%");
        hpanelBonus.add(new Label(MarkingInterface.messages.SetBonus()));
        hpanelBonus.add(bonusTxt);
        hpanelBonus.setCellHorizontalAlignment(bonusTxt, HasHorizontalAlignment.ALIGN_RIGHT);
        if (EMarkingConfiguration.isFormativeFeedbackOnly()) {
            hpanelBonus.setVisible(false);
        }
        mainPanel.add(hpanelBonus);
        mainPanel.setCellHorizontalAlignment(hpanelBonus, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // The regrade comment text box
    txt = new TextArea();
    txt.setVisibleLines(5);
    txt.getElement().getStyle().setMarginBottom(5, Unit.PT);
    txtRegradeComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt);

    if (this.regradeId > 0) {

        mainPanel.add(new HTML("<hr>"));
        mainPanel.add(new Label(MarkingInterface.messages.Regrade()));

        // Add the textbox
        HorizontalPanel hpanelRegradeComment = new HorizontalPanel();
        hpanelRegradeComment.setWidth("100%");
        hpanelRegradeComment.add(new Label(MarkingInterface.messages.RegradeComment()));
        hpanelRegradeComment.add(txtRegradeComment);
        hpanelRegradeComment.setCellHorizontalAlignment(txtRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT);
        mainPanel.add(hpanelRegradeComment);
        mainPanel.setCellHorizontalAlignment(hpanelRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Add buttons
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(2);
    hpanel.setWidth("100%");
    hpanel.add(btnSave);
    hpanel.add(btnCancel);
    hpanel.setCellWidth(btnSave, "100%");
    hpanel.setCellWidth(btnCancel, "0px");
    hpanel.setCellHorizontalAlignment(btnCancel, HasHorizontalAlignment.ALIGN_RIGHT);
    hpanel.setCellHorizontalAlignment(btnSave, HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(hpanel);
    mainPanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    if (simplePanel) {
        // No feedback
        this.setWidget(mainPanel);
    } else {
        // Remove CSS Style
        mainPanel.removeStyleName(Resources.INSTANCE.css().editmarkdialog());
        mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialogWithFeedback());

        bonusTxt.removeStyleName(Resources.INSTANCE.css().bonuslist());
        bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslistWithFeedback());

        this.levelsList.removeStyleName(Resources.INSTANCE.css().levelslist());
        this.levelsList.addStyleName(Resources.INSTANCE.css().levelslistWithFeedback());

        txtComment.removeStyleName(Resources.INSTANCE.css().editmarksuggestbox());
        txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestboxWithFeedback());

        // Add feedback panel
        mainPanel.add(new HTML("<h4>Feedback</h4>"));
        mainPanel.add(feedbackSummary);

        superPanel.add(mainPanel);
        superPanel.add(feedbackPanel);
        this.setWidget(superPanel);
    }
}