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

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

Introduction

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

Prototype

@Override
    public void add(Widget w) 

Source Link

Usage

From source file:com.google.lotrepls.client.CommandPrompt.java

License:Apache License

/**
 * This creates an immutable copy of the prompt and input area suitable for
 * adding to the page.//w  w  w .j a  va  2 s . c  om
 */
public Widget createImmutablePanel() {
    HorizontalPanel panelCopy = new HorizontalPanel();

    Label promptCopy = new Label(prompt.getText());
    promptCopy.setStyleName(prompt.getStyleName());
    promptCopy.getElement().getStyle().setProperty("width",
            prompt.getElement().getStyle().getProperty("width"));
    panelCopy.add(promptCopy);

    final InterpreterType t = type;
    final String scriptText = inputArea.getText();

    TextArea inputAreaCopy = new TextArea() {
        {
            this.addDomHandler(new DoubleClickHandler() {
                public void onDoubleClick(DoubleClickEvent event) {
                    final DialogBox box = new DialogBox();
                    VerticalPanel boxPanel = new VerticalPanel();

                    boxPanel.add(new Label("Use the following URL to share this script with friends:"));

                    String url = buildUrl(t, scriptText);

                    boxPanel.add(new Anchor(trimUrl(url), url));

                    Button close = new Button("Close");
                    close.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent event) {
                            box.hide();
                        }
                    });
                    close.setStyleName("closeButton");

                    boxPanel.add(close);
                    box.add(boxPanel);

                    box.getElement().getStyle().setProperty("border", "1px solid");
                    box.getElement().getStyle().setProperty("borderColor", "green");
                    box.getElement().getStyle().setProperty("backgroundColor", "black");
                    box.center();
                }
            }, DoubleClickEvent.getType());
        }
    };
    inputAreaCopy.setStyleName(inputArea.getStyleName());
    resizeInputArea(true);
    inputAreaCopy.setText(scriptText);
    inputAreaCopy.setVisibleLines(inputArea.getVisibleLines());
    inputAreaCopy.setReadOnly(true);

    SimplePanel inputAreaDivCopy = new SimplePanel();

    inputAreaDivCopy.add(inputAreaCopy);

    inputAreaDivCopy.getElement().setAttribute("style", inputAreaDiv.getElement().getAttribute("style"));

    panelCopy.add(inputAreaDivCopy);
    panelCopy.setCellWidth(inputAreaDivCopy, "100%");

    return panelCopy;
}

From source file:com.google.sampling.experiential.client.ChartPanel.java

License:Open Source License

/**
 * Show photos in a side-sliding gallery.
 *
 * @return The photo gallery widget/*from ww w  . j a  va 2s. c o m*/
 */
private Widget createPhotoSlider() {
    // I want a horizontally scrolling panel that shows photos in date order
    //
    //      / photo1 | photo2 | photo3 \
    //     (                            )
    //      \  date  |  date  |  date  /
    //
    ScrollPanel photosPanel = new ScrollPanel();
    photosPanel.setHeight("480");
    photosPanel.setWidth("800");

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setHeight("450");
    photosPanel.add(horizontalPanel);
    for (EventDAO event : data) {
        String[] blobs = event.getBlobs();
        if (blobs == null || blobs.length == 0) {
            continue;
        }
        for (int i = 0; i < blobs.length; i++) {
            String blobData = blobs[i];
            if (blobData.length() == 0 || blobData.equals("==")) {
                continue;
            }

            String formattedResponseTime = formatTime(event.getResponseTime());
            String formattedScheduledTime = formatTime(event.getScheduledTime());
            HTML picture = new HTML("<div style=\"text-align:center;margin-left:2;margin-right:2;\">"
                    + "<img height=\"375\" src=\"data:image/jpg;base64," + blobData + "\"><br><b>"
                    + event.getWho() + "</b><br><b>" + formattedResponseTime + "</b>" + "<br><b>"
                    + formattedScheduledTime + "</b>" + "</div>");
            horizontalPanel.add(picture);
        }
    }
    return photosPanel;
}

From source file:com.google.sampling.experiential.client.ContentTypeView.java

License:Open Source License

/**
 * /*from  ww w .  java2 s  .  c  o m*/
 */
private void init() {
    VerticalPanel outer = new VerticalPanel();
    HorizontalPanel line = new HorizontalPanel();
    line.setStyleName("left");
    Label keyLabel = new Label("Content Type:");
    keyLabel.setStyleName("keyLabel");
    outer.add(keyLabel);
    radio1 = new RadioButton("contentType", "Fixed Question Set");
    radio2 = new RadioButton("contentType", "Questions are asked on specific dates (QotD)");
    radio1.setChecked(!questionsChange);
    radio2.setChecked(questionsChange);

    line.add(radio1);
    line.add(radio2);
    outer.add(line);
    mainPanel.add(outer);
}

From source file:com.google.sampling.experiential.client.DurationView.java

License:Open Source License

/**
 *
 *///from  ww w . j ava 2  s.  com
private void init() {
    mainPanel.setStyleName("bordered");
    VerticalPanel outer = new VerticalPanel();
    HorizontalPanel line = new HorizontalPanel();
    line.setStyleName("left");
    HTML keyLabel = new HTML("<h3>" + myConstants.duration() + ":</h3>");
    //keyLabel.setStyleName("keyLabel");
    outer.add(keyLabel);
    radio1 = new RadioButton("duration", myConstants.ongoingDuration());
    radio2 = new RadioButton("duration", myConstants.fixedDuration());
    radio1.setChecked(!fixedDuration);
    radio2.setChecked(fixedDuration);

    line.add(radio1);
    line.add(radio2);
    outer.add(line);

    final HorizontalPanel datePanel = new HorizontalPanel();
    VerticalPanel startPanel = new VerticalPanel();
    datePanel.add(startPanel);
    startBox = new DateBox();
    startBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getShortDateFormat()));
    startBox.setValue(FORMATTER.parse(startDate));

    Label startLabel = new Label(myConstants.startDate() + ":");
    keyLabel.setStyleName("keyLabel");

    startPanel.add(startLabel);
    startPanel.add(startBox);

    VerticalPanel endPanel = new VerticalPanel();
    datePanel.add(endPanel);
    endBox = new DateBox();
    endBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getShortDateFormat()));
    endBox.setValue(FORMATTER.parse(endDate));

    Label endLabel = new Label(myConstants.endDate() + ":");
    keyLabel.setStyleName("keyLabel");

    endPanel.add(endLabel);
    endPanel.add(endBox);

    datePanel.setVisible(fixedDuration);
    line.add(datePanel);

    ClickListener selectionListener = new ClickListener() {

        @Override
        public void onClick(Widget sender) {
            if (sender.equals(radio1)) {
                datePanel.setVisible(false);
            } else {
                datePanel.setVisible(true);
            }
        }

    };
    radio1.addClickListener(selectionListener);
    radio2.addClickListener(selectionListener);
    mainPanel.add(outer);
}

From source file:com.google.sampling.experiential.client.EsmPanel.java

License:Open Source License

public EsmPanel(final SignalScheduleDAO schedule) {
    MyConstants myConstants = GWT.create(MyConstants.class);
    this.schedule = schedule;
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setSpacing(2);/*ww  w  . jav  a 2s . co m*/
    initWidget(verticalPanel);

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(2);
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellVerticalAlignment(horizontalPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalPanel.setWidth("");

    Label lblFrequency = new Label(myConstants.frequency() + ":");
    lblFrequency.setStyleName("gwt-Label-Header");
    horizontalPanel.add(lblFrequency);
    ValueSpinnerFixed frequencySpinner = new ValueSpinnerFixed(schedule.getEsmFrequency(), 0, 100);
    frequencySpinner.getTextBox().setWidth("18px");
    frequencySpinner.setWidth("35px");
    horizontalPanel.add(frequencySpinner);
    frequencySpinner.getSpinner().addSpinnerListener(new SpinnerListener() {
        public void onSpinning(long value) {
            schedule.setEsmFrequency((int) value);
        }
    });

    Label lblPeriod = new Label(myConstants.period() + ": ");
    lblPeriod.setStyleName("gwt-Label-Header");
    horizontalPanel.add(lblPeriod);

    final ListBox listBox = new ListBox();
    for (int i = 0; i < SignalScheduleDAO.ESM_PERIODS.length; i++) {
        listBox.addItem(SignalScheduleDAO.ESM_PERIODS_NAMES[i]);
    }
    horizontalPanel.add(listBox);
    listBox.setVisibleItemCount(1);
    Integer period = schedule.getEsmPeriodInDays();
    if (period == null) {
        period = SignalScheduleDAO.DEFAULT_ESM_PERIOD;
        schedule.setEsmPeriodInDays(SignalScheduleDAO.DEFAULT_ESM_PERIOD);
    }
    listBox.setSelectedIndex(period);
    listBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            schedule.setEsmPeriodInDays(listBox.getSelectedIndex());
        }
    });
    verticalPanel.add(horizontalPanel);

    HorizontalPanel weekendsPanel = new HorizontalPanel();
    weekendsPanel.setSpacing(2);
    weekendsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(weekendsPanel);
    weekendsPanel.setWidth("");
    Label lblWeekends = new Label(myConstants.includeWeekends() + ": ");
    lblWeekends.setStyleName("gwt-Label-Header");
    weekendsPanel.add(lblWeekends);

    final CheckBox weekendsBox = new CheckBox("");
    weekendsPanel.add(weekendsBox);
    weekendsBox.setValue(schedule.getEsmWeekends());
    weekendsBox.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            schedule.setEsmWeekends(weekendsBox.getValue());
        }

    });

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    horizontalPanel_1.setSpacing(2);
    horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(horizontalPanel_1);
    horizontalPanel_1.setWidth("");

    Label lblStartHour = new Label(myConstants.startTime() + ":");
    lblStartHour.setStyleName("gwt-Label-Header");
    horizontalPanel_1.add(lblStartHour);
    lblStartHour.setWidth("83px");

    Date setTime = null;
    if (schedule.getEsmStartHour() != null) {
        setTime = new Date();
        long offset = schedule.getEsmStartHour();
        int hours = (int) (offset / (60 * 60 * 1000));
        int minutes = (int) (offset - (hours * 60 * 60 * 1000)) / (60 * 1000);
        setTime.setHours(hours);
        setTime.setMinutes(minutes);
        setTime.setSeconds(0);
    } else {
        Date now = new Date();
        now.setMinutes(0);
        now.setSeconds(0);
        setTime = now;
    }

    final TimePickerFixed startTimeBox = new TimePickerFixed(setTime, DateTimeFormat.getFormat("aa"),
            DateTimeFormat.getFormat("hh"), DateTimeFormat.getFormat("mm"), null);

    horizontalPanel_1.add(startTimeBox);

    HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    horizontalPanel_2.setSpacing(2);
    horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(horizontalPanel_2);
    horizontalPanel_2.setWidth("");
    startTimeBox.addValueChangeHandler(new ValueChangeHandler() {
        public void onValueChange(ValueChangeEvent event) {
            Date dateTime = startTimeBox.getDateTime();
            long offset = (dateTime.getHours() * 60 * 60 * 1000) + (dateTime.getMinutes() * 60 * 1000);
            schedule.setEsmStartHour(offset);
        }
    });

    Label lblEndTime = new Label(myConstants.endTime() + ":  ");
    lblEndTime.setStyleName("gwt-Label-Header");
    horizontalPanel_2.add(lblEndTime);
    lblEndTime.setWidth("83px");

    setTime = null;
    if (schedule.getEsmEndHour() != null) {
        setTime = new Date();
        long offset = schedule.getEsmEndHour();
        int hours = (int) (offset / (60 * 60 * 1000));
        int minutes = (int) (offset - (hours * 60 * 60 * 1000)) / (60 * 1000);
        setTime.setHours(hours);
        setTime.setMinutes(minutes);
    } else {
        Date now = new Date();
        now.setMinutes(0);
        now.setSeconds(0);
        setTime = now;
    }

    final TimePickerFixed endTimePicker = new TimePickerFixed(setTime, DateTimeFormat.getFormat("aa"),
            DateTimeFormat.getFormat("hh"), DateTimeFormat.getFormat("mm"), null);

    horizontalPanel_2.add(endTimePicker);
    endTimePicker.addValueChangeHandler(new ValueChangeHandler() {
        public void onValueChange(ValueChangeEvent event) {
            Date dateTime = endTimePicker.getDateTime();
            long offset = (dateTime.getHours() * 60 * 60 * 1000) + (dateTime.getMinutes() * 60 * 1000);
            schedule.setEsmEndHour(offset);
        }
    });

    TimeoutPanel timeoutPanel = new TimeoutPanel(schedule);
    verticalPanel.add(timeoutPanel);
    timeoutPanel.setWidth("286px");

    MinimumBufferPanel minimumBufferPanel = new MinimumBufferPanel(schedule);
    verticalPanel.add(minimumBufferPanel);
    minimumBufferPanel.setWidth("286px");

    SnoozePanel snoozePanel = new SnoozePanel(schedule);
    verticalPanel.add(snoozePanel);
    snoozePanel.setWidth("286px");

}

From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java

License:Open Source License

private void createIdLabel(ExperimentDAO experiment) {
    Long experimentVersionStr = 0l;
    if (experiment.getId() != null) {
        experimentVersionStr = experiment.getId();
    }/*from   www  . j a  va2s. co m*/
    HorizontalPanel versionPanel = new HorizontalPanel();
    formPanel.add(versionPanel);
    Label lblExperimentVersion = new Label(myConstants.experimentId() + ":");
    lblExperimentVersion.setStyleName("paco-HTML-Large");
    versionPanel.add(lblExperimentVersion);

    Label experimentVersion = new Label(Long.toString(experimentVersionStr));
    experimentVersion.setStyleName("paco-HTML-Large");
    versionPanel.add(experimentVersion);
}

From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java

License:Open Source License

private void createVersionLabel(ExperimentDAO experiment) {
    String experimentVersionStr = "1";
    if (experiment.getVersion() != null) {
        experimentVersionStr = experiment.getVersion().toString();
    }//from w ww.j  a  v a2  s  .co  m
    HorizontalPanel versionPanel = new HorizontalPanel();
    formPanel.add(versionPanel);

    Label lblExperimentVersion = new Label(myConstants.experimentVersion() + ":");
    lblExperimentVersion.setStyleName("paco-HTML-Large");
    versionPanel.add(lblExperimentVersion);

    Label experimentVersion = new Label(experimentVersionStr);
    experimentVersion.setStyleName("paco-HTML-Large");
    versionPanel.add(experimentVersion);
}

From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java

License:Open Source License

private Widget createCustomRenderingEntryPanel(ExperimentDAO experiment2) {
    VerticalPanel containerPanel = new VerticalPanel();
    containerPanel.setStyleName("bordered");

    HorizontalPanel renderingPanel = new HorizontalPanel();
    customRenderingCheckBox = new CheckBox();
    customRenderingCheckBox//from  w w w.ja v  a2  s. c  o m
            .setValue(experiment.isCustomRendering() != null ? experiment.isCustomRendering() : false);
    renderingPanel.add(customRenderingCheckBox);

    Label renderingLabel = new Label(myConstants.customRendering());
    renderingPanel.add(renderingLabel);

    HTML html = new HTML("&nbsp;&nbsp;&nbsp;<font color=\"red\" size=\"smaller\"><i>("
            + myConstants.iOSIncompatible() + ")</i></font>");
    renderingPanel.add(html);

    containerPanel.add(renderingPanel);

    createCustomRenderingDisclosurePanel(experiment);
    customRenderingPanel.getHeader().setVisible(customRenderingCheckBox.getValue());
    containerPanel.add(customRenderingPanel);

    customRenderingCheckBox.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            customRenderingPanel.getHeader().setVisible(customRenderingCheckBox.getValue());
            customRenderingPanel.setOpen(customRenderingCheckBox.getValue());
        }
    });
    return containerPanel;
}

From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java

License:Open Source License

private void createButtonPanel(ExperimentDAO experiment) {
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.add(createSubmitButton(experiment));
    buttonPanel.add(createCancelButton());
    formPanel.add(buttonPanel);/*from   www .  j a v a 2s. c o m*/
}

From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java

License:Open Source License

private VerticalPanel createPublishingPanel(ExperimentDAO experiment) {
    VerticalPanel containerPanel = new VerticalPanel();
    containerPanel.setStyleName("bordered");

    HorizontalPanel publishingPanel = new HorizontalPanel();
    publishCheckBox = new CheckBox();
    publishCheckBox.setValue(experiment.getPublished());
    publishingPanel.add(publishCheckBox);
    HTML publishLabel = new HTML("<h3> " + myConstants.published() + "</h3>");
    publishingPanel.add(publishLabel);/* w w  w .java  2  s .  c  om*/
    containerPanel.add(publishingPanel);

    createPublishedUsersDisclosurePanel(experiment);
    containerPanel.add(publishedUsersPanel);
    return containerPanel;
}