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

protected Label(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:com.blackducksoftware.tools.commonframework.core.gwt.ui.StandardLoginScreen.java

License:Open Source License

/**
 * Builds the password label.//from w w  w.j a v  a  2  s  .  co m
 *
 * @return the label
 */
private Label buildPasswordLabel() {
    Label passwordFieldLabel = new Label("Password:");
    passwordFieldLabel.setStyleName("gwt-Login-Label");
    passwordFieldLabel.setSize("73px", "21px");
    return passwordFieldLabel;
}

From source file:com.blackducksoftware.tools.commonframework.core.gwt.ui.StandardLoginScreen.java

License:Open Source License

/**
 * Builds the version label./*from   w  w  w. jav  a  2 s .c  om*/
 *
 * @param appVersionString
 *            the app version string
 * @return the label
 */
private Label buildVersionLabel(String appVersionString) {
    Label versionLabel = new Label("");
    versionLabel.setStyleName("gwt-Version-Label");
    versionLabel.setSize("93px", "36px"); // was "93px", "18px"
    String versionToDisplay = debugMode ? LOGIN_SCREEN_VERSION_STRING : appVersionString;
    versionLabel.setText(versionToDisplay);
    return versionLabel;
}

From source file:com.blackducksoftware.tools.commonframework.core.gwt.ui.StandardLoginScreen.java

License:Open Source License

/**
 * Builds the copyright label./*from  w  ww .ja v  a 2 s  . c  o  m*/
 *
 * @return the label
 */
private Label buildCopyrightLabel() {
    Label lblCopyrightBlack = new Label(COPYRIGHT_STRING);
    lblCopyrightBlack.setSize("592px", "44px");
    return lblCopyrightBlack;
}

From source file:com.blockwithme.client.WebApp.java

License:Apache License

@Override
public void onModuleLoad() {
    GWT.create(WebAppInjector.class);

    try {/* www  .  ja v a2s  .  com*/
        final MetricRegistry registry = new MetricRegistry();
        final Counter clicks = registry.counter(MetricRegistry.name("WebApp", "clicks"));
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(registry)
                .outputTo(LoggerFactory.getLogger("com.example.metrics")).convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS).build();
        reporter.start(5, TimeUnit.SECONDS);

        final Button startButton = new Button("Send msg to worker");
        RootPanel.get("container1").add(startButton);

        final Window window = getWindow();//elemental.client.Browser.getWindow();

        final WebWorker<Worker> worker = WebWorkerFacade.newWorker("sampleworker", new WebWorkerListener() {
            @Override
            public void onMessage(final String channel, final JSONObject message) {
                final Label l = new Label("Worker says: " + channel + " => " + message);
                RootPanel.get("container2").insert(l, 0);
            }
        });

        startButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                try {
                    clicks.inc();
                    worker.postMessage(null, "Hello worker");
                } catch (final Exception e) {
                    window.alert("Error message from worker: " + e);
                }
            }
        });
    } catch (final Exception e) {
        LOG.log(Level.SEVERE, "FAIL!", e);
    }
}

From source file:com.bradrydzewski.gwt.calendar.client.agenda.AgendaView.java

License:Open Source License

@Override
public void doLayout() {

    appointmentAdapterList.clear();/*from  w  ww  .  j  a v a2  s  .c  o m*/
    appointmentGrid.clear();
    for (int i = appointmentGrid.getRowCount() - 1; i >= 0; i--) {
        appointmentGrid.removeRow(i);
    }

    //Get the start date, make sure time is 0:00:00 AM
    Date startDate = (Date) calendarWidget.getDate().clone();
    Date today = new Date();
    Date endDate = (Date) calendarWidget.getDate().clone();
    endDate.setDate(endDate.getDate() + 1);
    DateUtils.resetTime(today);
    DateUtils.resetTime(startDate);
    DateUtils.resetTime(endDate);

    int row = 0;

    for (int i = 0; i < calendarWidget.getDays(); i++) {

        // Filter the list by date
        List<Appointment> filteredList = AppointmentUtil.filterListByDate(calendarWidget.getAppointments(),
                startDate, endDate);

        if (filteredList != null && filteredList.size() > 0) {

            appointmentGrid.setText(row, 0, DEFAULT_DATE_FORMAT.format(startDate));

            appointmentGrid.getCellFormatter().setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP);
            appointmentGrid.getFlexCellFormatter().setRowSpan(row, 0, filteredList.size());
            appointmentGrid.getFlexCellFormatter().setStyleName(row, 0, "dateCell");
            int startingCell = 1;

            //Row styles will alternate, so we set the style accordingly
            String rowStyle = (i % 2 == 0) ? "row" : "row-alt";

            //If a Row represents the current date (Today) then we style it differently
            if (startDate.equals(today))
                rowStyle += "-today";

            for (Appointment appt : filteredList) {

                // add the time range
                String timeSpanString = DEFAULT_TIME_FORMAT.format(appt.getStart()) + " - "
                        + DEFAULT_TIME_FORMAT.format(appt.getEnd());
                Label timeSpanLabel = new Label(timeSpanString.toLowerCase());
                appointmentGrid.setWidget(row, startingCell, timeSpanLabel);

                // add the title and description
                FlowPanel titleContainer = new FlowPanel();
                InlineLabel titleLabel = new InlineLabel(appt.getTitle());
                titleContainer.add(titleLabel);
                InlineLabel descLabel = new InlineLabel(" - " + appt.getDescription());
                descLabel.setStyleName("descriptionLabel");
                titleContainer.add(descLabel);
                appointmentGrid.setWidget(row, startingCell + 1, titleContainer);

                SimplePanel detailContainerPanel = new SimplePanel();
                AppointmentDetailPanel detailContainer = new AppointmentDetailPanel(detailContainerPanel, appt);

                appointmentAdapterList.add(new AgendaViewAppointmentAdapter(titleLabel, timeSpanLabel,
                        detailContainerPanel, detailContainer.getMoreDetailsLabel(), appt));

                //add the detail container
                titleContainer.add(detailContainer);

                //add click handlers to title, date and details link
                timeSpanLabel.addClickHandler(appointmentClickHandler);
                titleLabel.addClickHandler(appointmentClickHandler);
                detailContainer.getMoreDetailsLabel().addClickHandler(appointmentClickHandler);

                // Format the Cells
                appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell,
                        HasVerticalAlignment.ALIGN_TOP);
                appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell + 1,
                        HasVerticalAlignment.ALIGN_TOP);
                appointmentGrid.getCellFormatter().setStyleName(row, startingCell, "timeCell");
                appointmentGrid.getCellFormatter().setStyleName(row, startingCell + 1, "titleCell");
                appointmentGrid.getRowFormatter().setStyleName(row, rowStyle);

                // increment the row
                // make sure the starting column is reset to 0
                startingCell = 0;
                row++;
            }
        }

        // increment the date
        startDate.setDate(startDate.getDate() + 1);
        endDate.setDate(endDate.getDate() + 1);
    }
}

From source file:com.bradrydzewski.gwt.calendar.client.monthview.MonthView.java

License:Open Source License

/**
 * Configures a single day in the month grid of this <code>MonthView</code>.
 *
 * @param row//from   www .j av a 2s . c o  m
 *            The row in the grid on which the day will be set
 * @param col
 *            The col in the grid on which the day will be set
 * @param date
 *            The Date in the grid
 * @param isToday
 *            Indicates whether the day corresponds to today in the month
 *            view
 * @param notInCurrentMonth
 *            Indicates whether the day is in the current visualized month
 *            or belongs to any of the two adjacent months of the current
 *            month
 * @param weekNumber
 *            The weekNumber to show in the cell, only appears in the first col.
 */
private void configureDayInGrid(int row, int col, Date date, boolean isToday, boolean notInCurrentMonth,
        int weekNumber) {
    HorizontalPanel panel = new HorizontalPanel();
    String text = String.valueOf(date.getDate());
    Label label = new Label(text);

    StringBuilder headerStyle = new StringBuilder(CELL_HEADER_STYLE);
    StringBuilder cellStyle = new StringBuilder(CELL_STYLE);
    boolean found = false;

    for (Date day : getSettings().getHolidays()) {
        if (DateUtils.areOnTheSameDay(day, date)) {
            headerStyle.append("-holiday");
            cellStyle.append("-holiday");
            found = true;
            break;
        }
    }

    if (isToday) {
        headerStyle.append("-today");
        cellStyle.append("-today");
    } else if (!found && DateUtils.isWeekend(date)) {
        headerStyle.append("-weekend");
        cellStyle.append("-weekend");
    }

    if (notInCurrentMonth) {
        headerStyle.append("-disabled");
    }

    label.setStyleName(headerStyle.toString());
    addDayClickHandler(label, (Date) date.clone());

    if (col == 0 && getSettings().isShowingWeekNumbers()) {
        Label weekLabel = new Label(String.valueOf(weekNumber));
        weekLabel.setStyleName(WEEKNUMBER_LABEL_STYLE);

        panel.add(weekLabel);
        panel.setCellWidth(weekLabel, "25px");
        DOM.setStyleAttribute(label.getElement(), "paddingLeft", "5px");
        addWeekClickHandler(weekLabel, (Date) date.clone());
    }
    panel.add(label);

    appointmentCanvas.add(panel);
    dayLabels.add(label);
    dayPanels.add(panel);

    //monthCalendarGrid.setWidget(row, col, panel);
    monthCalendarGrid.getCellFormatter().setVerticalAlignment(row, col, HasVerticalAlignment.ALIGN_TOP);
    monthCalendarGrid.getCellFormatter().setStyleName(row, col, cellStyle.toString());
}

From source file:com.brainz.wokhei.client.about.AboutModulePart.java

@Override
public void loadModulePart() {

    History.addValueChangeHandler(this);

    HarnessStringsFromHTML();/*from w ww .  ja  v  a 2  s  . c  o m*/

    //MAIN LAYOUT
    VerticalPanel leftColumnPanel = new VerticalPanel();
    leftColumnPanel.setWidth("280px");
    leftColumnPanel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);

    VerticalPanel rightColumnPanel = new VerticalPanel();
    rightColumnPanel.setWidth("400px");
    rightColumnPanel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);

    DOM.setStyleAttribute(_text.getElement(), "whiteSpace", "pre");
    _text.setWidth("370px");
    _text.setWordWrap(true);
    HorizontalPanel main = new HorizontalPanel();
    main.add(leftColumnPanel);
    main.add(new Image("../images/stuff2.png"));
    main.add(getWhiteSpace(30));
    main.add(rightColumnPanel);

    //RIGHT COLUMN 
    _title.setStyleName("sectionTitle");
    _title.addStyleName("fontAR");
    _title.setText(_aboutUsTitle);
    _text.setStyleName("sectionText");
    _text.setHTML(_aboutUsText);

    _contactUsPanel = getContactUsPanel();
    _contactUsPanel.setVisible(false);

    _licensesPanel = getLicensesPanel();
    _licensesPanel.setVisible(false);

    _panels.add(_contactUsPanel);
    _panels.add(_licensesPanel);

    rightColumnPanel.add(_title);
    rightColumnPanel.add(getWhiteSpace(20));
    rightColumnPanel.add(_text);
    rightColumnPanel.add(_contactUsPanel);
    rightColumnPanel.add(_licensesPanel);

    //LEFT COLUMN
    Label aboutWokhei = new Label(_aboutTitle);
    aboutWokhei.setStyleName("pageTitle");
    aboutWokhei.addStyleName("fontAR");

    VerticalPanel menu = new VerticalPanel();
    menu.setSpacing(10);

    addMenuItem(menu, _aboutUsTitle, _aboutUsText, "aboutUs");
    addMenuItem(menu, _whatWokheiTitle, _whatWokheiText, "whatWokhei");
    addMenuItem(menu, _differentWokheiTitle, _differentWokheiText, "whatDifferent");
    addMenuItem(menu, _licensesTitle, _licensesPanel, "licenses");
    addMenuItem(menu, _restaurantTitle, _restaurantText, "whyRestaurant");
    addMenuItem(menu, _networkTitle, _networkText, "network");
    addMenuItem(menu, _contactUsTitle, _contactUsPanel, "contactUs");

    leftColumnPanel.add(aboutWokhei);
    leftColumnPanel.add(getWhiteSpace(10));
    leftColumnPanel.add(menu);

    RootPanel.get("aboutBodyPart").add(main);
    applyCufon();

    History.fireCurrentHistoryState();
}

From source file:com.brainz.wokhei.client.home.OrderBrowserModulePart.java

private void setupDownloadStuff(final Status status) {
    downloadPanel = new VerticalPanel();
    downloadPanel.setSpacing(5);// www  . ja  v a2 s. c om
    Label downloadPng = new Label(Messages.DOWNLOAD_RASTERIZED.getString());
    downloadPng.setStyleName("labelButton");
    downloadPng.addStyleName("downloadLabelLink");
    downloadPng.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (status.equals(Status.BOUGHT)) {
                Window.open(GWT.getHostPageBaseURL() + "wokhei/getfile?orderid=" + _currentOrder.getId()
                        + "&fileType=" + FileType.PNG_LOGO, "_new", "");
            }
        }
    });

    downloadPanel.add(downloadPng);

    if (status.equals(Status.BOUGHT)) {
        Label downloadPdf = new Label(Messages.DOWNLOAD_VECTORIAL.getString());
        downloadPdf.setStyleName("labelButton");
        downloadPdf.addStyleName("downloadLabelLink");
        downloadPdf.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                Window.open(GWT.getHostPageBaseURL() + "wokhei/getfile?orderid=" + _currentOrder.getId()
                        + "&fileType=" + FileType.PDF_VECTORIAL_LOGO, "_new", "");
            }
        });

        downloadPanel.add(downloadPdf);
    }
    downloadPanelContainer.add(downloadPanel);
}

From source file:com.bramosystems.oss.player.core.client.PlayerUtil.java

License:Apache License

/**
 * Returns a widget that may be used to notify the user when a required plugin
 * is not available.  The widget provides a link to the plugin download page.
 *
 * <h4>CSS Style Rules</h4>//from   ww w .  j a  va  2 s.  com
 * <ul>
 * <li>.player-MissingPlugin { the missing plugin widget }</li>
 * <li>.player-MissingPlugin-title { the title section }</li>
 * <li>.player-MissingPlugin-message { the message section }</li>
 * </ul>
 *
 * @param plugin the missing plugin
 * @param title the title of the message
 * @param message descriptive message to notify user about the missing plugin
 * @param asHTML {@code true} if {@code message} should be interpreted as HTML,
 *          {@code false} otherwise.
 *
 * @return missing plugin widget.
 * @since 0.6
 */
public static Widget getMissingPluginNotice(final Plugin plugin, String title, String message, boolean asHTML) {
    DockPanel dp = new DockPanel() {

        @Override
        public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            switch (event.getTypeInt()) {
            case Event.ONCLICK:
                if (plugin.getDownloadURL().length() > 0) {
                    Window.open(plugin.getDownloadURL(), "dwnload", "");
                }
            }
        }
    };
    dp.setHorizontalAlignment(DockPanel.ALIGN_LEFT);
    dp.sinkEvents(Event.ONCLICK);
    dp.setWidth("200px");

    Label titleLb = null, msgLb = null;
    if (asHTML) {
        titleLb = new HTML(title);
        msgLb = new HTML(message);
    } else {
        titleLb = new Label(title);
        msgLb = new Label(message);
    }

    dp.add(titleLb, DockPanel.NORTH);
    dp.add(msgLb, DockPanel.CENTER);

    titleLb.setStylePrimaryName("player-MissingPlugin-title");
    msgLb.setStylePrimaryName("player-MissingPlugin-message");
    dp.setStylePrimaryName("player-MissingPlugin");

    DOM.setStyleAttribute(dp.getElement(), "cursor", "pointer");
    return dp;
}

From source file:com.bramosystems.oss.player.core.client.skin.CustomPlayerControl.java

License:Apache License

private Widget getPlayerWidget(final UIStyleResource imgPack) {
    imgPack.ensureInjected();//from  w w  w.  j  a  va  2s.c  om

    seekbar = new CSSSeekBar(5);
    seekbar.setStylePrimaryName(STYLE_NAME);
    seekbar.addStyleDependentName("seekbar");
    seekbar.setWidth("95%");
    seekbar.addSeekChangeHandler(new SeekChangeHandler() {

        @Override
        public void onSeekChanged(SeekChangeEvent event) {
            player.setPlayPosition(event.getSeekPosition() * player.getMediaDuration());
        }
    });

    playTimer = new Timer() {

        @Override
        public void run() {
            updateSeekState();
        }
    };

    play = new CPCButton(imgPack.playDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            switch (playState) {
            case Stop:
            case Pause:
                try { // play media...
                    play.setEnabled(false); // avoid multiple clicks
                    player.playMedia();
                } catch (PlayException ex) {
                    DebugEvent.fire(player, DebugEvent.MessageType.Error, ex.getMessage());
                }
                break;
            case Playing:
                player.pauseMedia();
            }
        }
    });
    play.setStyleName(imgPack.play());
    play.setEnabled(false);

    stop = new CPCButton(imgPack.stopDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            player.stopMedia();
        }
    });
    stop.setStyleName(imgPack.stop());
    stop.setEnabled(false);

    prev = new CPCButton(imgPack.prevDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (player instanceof PlaylistSupport) {
                try {
                    ((PlaylistSupport) player).playPrevious();
                } catch (PlayException ex) {
                    next.setEnabled(false);
                    DebugEvent.fire(player, DebugEvent.MessageType.Info, ex.getMessage());
                }
            }
        }
    });
    prev.setStyleName(imgPack.prev());
    prev.setEnabled(false);

    next = new CPCButton(imgPack.nextDisabled(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (player instanceof PlaylistSupport) {
                try {
                    ((PlaylistSupport) player).playNext();
                } catch (PlayException ex) {
                    next.setEnabled(false);
                    DebugEvent.fire(player, DebugEvent.MessageType.Info, ex.getMessage());
                }
            }
        }
    });
    next.setStyleName(imgPack.next());
    next.setEnabled(false);

    vc = new VolumeControl(5);
    vc.setStyleName(imgPack.volume());
    vc.setPopupStyleName(STYLE_NAME + "-volumeControl");
    vc.addVolumeChangeHandler(new VolumeChangeHandler() {

        @Override
        public void onVolumeChanged(VolumeChangeEvent event) {
            player.setVolume(event.getNewVolume());
        }
    });

    player.addLoadingProgressHandler(new LoadingProgressHandler() {

        @Override
        public void onLoadingProgress(LoadingProgressEvent event) {
            seekbar.setLoadingProgress(event.getProgress());
            vc.setVolume(player.getVolume());
            updateSeekState();
        }
    });
    player.addPlayStateHandler(new PlayStateHandler() {

        @Override
        public void onPlayStateChanged(PlayStateEvent event) {
            int index = event.getItemIndex();
            switch (event.getPlayState()) {
            case Paused:
                toPlayState(PlayState.Pause, imgPack);
                next.setEnabled(index < (((PlaylistSupport) player).getPlaylistSize() - 1));
                prev.setEnabled(index > 0);
                break;
            case Started:
                toPlayState(PlayState.Playing, imgPack);
                next.setEnabled(index < (((PlaylistSupport) player).getPlaylistSize() - 1));
                prev.setEnabled(index > 0);
                break;
            case Stopped:
            case Finished:
                toPlayState(PlayState.Stop, imgPack);
                next.setEnabled(false);
                prev.setEnabled(false);
                break;
            }
        }
    });
    player.addPlayerStateHandler(new PlayerStateHandler() {

        @Override
        public void onPlayerStateChanged(PlayerStateEvent event) {
            switch (event.getPlayerState()) {
            case Ready:
                play.setEnabled(true);
                vc.setVolume(player.getVolume());
            }
        }
    });

    // Time label..
    timeLabel = new Label("--:-- / --:--");
    timeLabel.setWordWrap(false);
    timeLabel.setHorizontalAlignment(Label.ALIGN_CENTER);

    // build the UI...
    DockPanel face = new DockPanel();
    face.setStyleName("");
    face.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
    face.setSpacing(3);
    face.add(vc, DockPanel.WEST);
    face.add(play, DockPanel.WEST);
    face.add(stop, DockPanel.WEST);
    face.add(prev, DockPanel.WEST);
    face.add(next, DockPanel.WEST);
    face.add(timeLabel, DockPanel.EAST);
    face.add(seekbar, DockPanel.CENTER);

    face.setCellWidth(seekbar, "100%");
    face.setCellHorizontalAlignment(seekbar, DockPanel.ALIGN_CENTER);
    return face;
}