Example usage for com.google.gwt.user.client.ui Label Label

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

Introduction

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

Prototype

public Label() 

Source Link

Document

Creates an empty label.

Usage

From source file:accelerator.client.ui.StatusPopupPanel.java

License:Open Source License

/**
 * 
 */
public StatusPopupPanel() {
    super(true, false);
    statusLabel = new Label();
    setWidget(statusLabel);
}

From source file:asquare.gwt.tkdemo.client.demos.GlassPanelDemo.java

License:Apache License

public GlassPanelDemo() {
    BasicPanel outer = new BasicPanel();
    outer.addStyleName("division");
    add(outer);/*w ww.  ja va2  s .  c om*/

    String content = "<H2>GlassPanel</H2>" + "<p>A GlassPanel covers the entire surface of the document. "
            + "It prevents user interaction with the document. </p>";
    HTML header = new HTML(content);
    header.addStyleName("description");
    outer.add(header);

    BasicPanel example = new BasicPanel("div", BasicPanel.DISPLAY_BLOCK);
    example.addStyleName("example");
    outer.add(example);

    class CreateExample implements ClickHandler {
        private final String m_cssId;
        private final String m_bodyStyleName;

        public CreateExample(String cssId) {
            this(cssId, GlassPanel.DEFAULT_BODY_STYLENAME);
        }

        public CreateExample(String cssId, String bodyStyleName) {
            m_cssId = cssId;
            m_bodyStyleName = bodyStyleName;
        }

        public void onClick(ClickEvent event) {
            final GlassPanel gp = new GlassPanel(m_bodyStyleName);
            gp.addStyleName(m_cssId);
            gp.addController(new HideGlassPanelController());
            gp.show();
        }
    }

    class ShowExample extends SimpleHyperLink {
        public ShowExample(String label, ClickHandler handler) {
            super(label);
            addClickHandler(handler);
        }
    }

    example.add(new ShowExample("Dark", new CreateExample("glasspanel-ex-dark")));
    example.add(new ShowExample("Light", new CreateExample("glasspanel-ex-light")));
    example.add(new ShowExample("Opaque", new CreateExample("glasspanel-ex-opaque")));
    example.add(new ShowExample("Transparent PNG background image", new ClickHandler() {
        public void onClick(ClickEvent event) {
            final GlassPanel gp = new GlassPanel();
            gp.addStyleName("glasspanel-ex-transparentPNG");
            Label content = new Label();
            content.setStyleName("Content");
            content.setSize("100%", "100%");
            gp.setWidget(content);
            gp.addController(new HideGlassPanelController());
            gp.show();
        }
    }));
    example.add(new ShowExample("Tiled background image", new CreateExample("glasspanel-ex-tiledBG")));
    example.add(new ShowExample("Centered background image", new CreateExample("glasspanel-ex-centeredBG")));
    example.add(new ShowExample("Foreground text", new ClickHandler() {
        public void onClick(ClickEvent event) {
            final GlassPanel gp = new GlassPanel();
            gp.addStyleName("glasspanel-ex-text");
            HTML contents = new HTML(
                    "<table cellspacing='0' cellpadding='0' style='width: 100%; height: 100%;'>"
                            + "<td align='center' valign='middle'><h1>Wham!</h1></td>" + "</tr></table>");
            contents.setSize("100%", "100%");
            gp.setWidget(contents);
            gp.addController(new HideGlassPanelController());
            gp.show();
        }
    }));
    example.add(new ShowExample("Blur (IE only)",
            new CreateExample("glasspanel-ex-ieBodyBlur", "glasspanel-ex-ieBodyBlur-BODY")));
}

From source file:at.ait.dme.yuma.client.image.annotation.StandardImageAnnotationForm.java

License:EUPL

private HorizontalPanel createRadioPanel(boolean update, ImageAnnotationTreeNode annotationTreeNode) {

    Label scopeLabel = new Label();
    scopeLabel.setStyleName("imageAnnotation-form-label");

    HorizontalPanel radioPanel = new HorizontalPanel();
    radioPanel.add(scopeLabel);//w  w  w  . j  a  va 2 s .  c o  m
    radioPanel.add(
            rdPublic = new RadioButton(SCOPE_RADIO_GROUP_NAME, " " + Application.getConstants().publicScope()));
    radioPanel.add(rdPrivate = new RadioButton(SCOPE_RADIO_GROUP_NAME,
            " " + Application.getConstants().privateScope()));
    rdPublic.setStyleName("imageAnnotation-form-radiobutton");
    rdPrivate.setStyleName("imageAnnotation-form-radiobutton");

    if (update && annotationTreeNode.getAnnotation().getScope() == ImageAnnotation.Scope.PRIVATE)
        rdPrivate.setValue(true, true);
    else
        rdPublic.setValue(true, true);

    return radioPanel;
}

From source file:at.ait.dme.yuma.suite.apps.image.core.client.treeview.ImageAnnotationEditForm.java

License:EUPL

protected HorizontalPanel createScopePanel() {
    HorizontalPanel radioPanel = new HorizontalPanel();

    Label scopeLabel = new Label();
    scopeLabel.setStyleName("imageAnnotation-form-label");

    rdPublic = new RadioButton(SCOPE_RADIO_GROUP_NAME, " " + i18n.publicScope());
    rdPublic.setStyleName("imageAnnotation-form-radiobutton");

    rdPrivate = new RadioButton(SCOPE_RADIO_GROUP_NAME, " " + i18n.privateScope());
    rdPrivate.setStyleName("imageAnnotation-form-radiobutton");

    if (annotation != null && annotation.getAnnotation().getScope() == Scope.PRIVATE) {
        rdPrivate.setValue(true, true);//from  w  w w .  j ava  2 s .c  om
    } else {
        rdPublic.setValue(true, true);
    }

    radioPanel.add(scopeLabel);
    radioPanel.add(rdPublic);
    radioPanel.add(rdPrivate);

    return radioPanel;
}

From source file:bingo.client.Bingo.java

License:Open Source License

/**
 * This is the entry point method./*  w w  w. j  av a2 s . 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: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 ava  2 s.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:bingo.client.BingoCell.java

License:Open Source License

public BingoCell(SafeUri uri, String label, String votes) {
    super(3, 1);/*from   w  w  w .  ja  v a 2  s  .  c  o m*/
    this.setCellPadding(3);

    FlowPanel imagePanel = new FlowPanel();
    imagePanel.setSize(IMAGE_WIDTH, IMAGE_HEIGHT);
    Image cellImage = new Image(uri);
    cellImage.setStyleName("cell-image");
    imagePanel.add(cellImage);

    Label labelText = new Label();
    labelText.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    labelText.setText(label);
    labelText.setStyleName("cell-label");

    Label votesText = new Label(votes);
    this.votes = votesText;
    this.votes.setStyleName("cell-votes");

    this.voted = false;

    this.setWidget(0, 0, imagePanel);
    this.getCellFormatter().setHeight(0, 0, IMAGE_HEIGHT);
    this.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
    this.setWidget(1, 0, labelText);
    this.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    this.setWidget(2, 0, this.votes);
    this.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);
}

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

License:Apache License

/**
 * Constructs the WjrPopupPanel./*w ww. j  av a 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.inputfield.InputField.java

License:Apache License

/**
 * Constructs an InputField./* ww  w  .  j a  v a  2  s  . co m*/
 * 
 * @param required
 *            Use <code>true</true> if this field should be required
 */
public InputField(boolean required) {
    this.required = required;
    field = createField();
    validationError = new Label();
    validationError.addStyleName("validationError");
    setValidationError(null);
    wrapper.setWidget(0, 0, field);
    requiredStar = new Label("*");
    if (required) {
        wrapper.setWidget(0, 1, requiredStar);
        addInputFieldValidator(new RequiredValidator());
    }
    initWidget(wrapper);
    setStyleName("k5-InputField");
}

From source file:burrito.client.widgets.selection.SelectionList.java

License:Apache License

/**
 * Creates an empty selection list with no values to select from. Using this
 * constructor is useful if you need to load the model asynchronously. If
 * you use this constructor you must make sure you call setModel(),
 * setLabelCreator() and render()./* www.  j  av a2s.c o m*/
 * 
 * @param nullSelectLabel
 */
public SelectionList(boolean required) {
    this.required = required;

    listBox = new ListBox();
    wrapper.setWidget(0, 0, listBox);

    validationError = new Label();
    validationError.addStyleName("validationError");
    setValidationError(null);

    requiredStar = new Label("*");
    if (required) {
        wrapper.setWidget(0, 1, requiredStar);
    }

    wrapper.setWidget(0, 2, pleaseWaitLabel);

    initWidget(wrapper);

    addStyleName("k5-SelectionBox");
}