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:net.s17fabu.vip.gwt.showcase.client.content.panels.CwAbsolutePanel.java

License:Apache License

/**
 * Initialize this example.//from www  .  j a  v  a2s. com
 */
@Override
public Widget onInitialize() {
    // Create a new panel
    widgetMap = new HashMap<String, Widget>();
    absolutePanel = new AbsolutePanel();
    absolutePanel.setSize("250px", "250px");
    absolutePanel.ensureDebugId("cwAbsolutePanel");

    // Add an HTML widget to the panel
    String[] widgetNames = constants.cwAbsolutePanelWidgetNames();
    HTML text = new HTML(constants.cwAbsolutePanelHelloWorld());
    absolutePanel.add(text, 10, 20);
    widgetMap.put(widgetNames[0], text);

    // Add a Button to the panel
    Button button = new Button(constants.cwAbsolutePanelClickMe());
    absolutePanel.add(button, 80, 45);
    widgetMap.put(widgetNames[1], button);

    // Add a Button to the panel
    Grid grid = new Grid(2, 3);
    grid.setBorderWidth(1);
    for (int i = 0; i < 3; i++) {
        grid.setHTML(0, i, i + "");
        grid.setWidget(1, i, Showcase.images.gwtLogoThumb().createImage());
    }
    absolutePanel.add(grid, 60, 100);
    widgetMap.put(widgetNames[2], grid);

    // Wrap the absolute panel in a DecoratorPanel
    DecoratorPanel absolutePanelWrapper = new DecoratorPanel();
    absolutePanelWrapper.setWidget(absolutePanel);

    // Create the options bar
    DecoratorPanel optionsWrapper = new DecoratorPanel();
    optionsWrapper.setWidget(createOptionsBar());

    // Add the components to a panel and return it
    HorizontalPanel mainLayout = new HorizontalPanel();
    mainLayout.setSpacing(10);
    mainLayout.add(optionsWrapper);
    mainLayout.add(absolutePanelWrapper);

    return mainLayout;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.panels.CwHorizontalPanel.java

License:Apache License

/**
 * Initialize this example.//from   w w w.  jav  a2  s .c om
 */
@Override
public Widget onInitialize() {
    // Create a Horizontal Panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(5);

    // Add some content to the panel
    for (int i = 1; i < 5; i++) {
        hPanel.add(new Button(constants.cwHorizontalPanelButton() + " " + i));
    }

    // Return the content
    hPanel.ensureDebugId("cwHorizontalPanel");
    return hPanel;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.text.CwBasicText.java

License:Apache License

/**
 * Create a TextBox example that includes the text box and an optional
 * handler that updates a Label with the currently selected text.
 * //from w w  w . ja  va 2s  .  c o m
 * @param textBox the text box to handle
 * @param addSelection add handlers to update label
 * @return the Label that will be updated
 */
private HorizontalPanel createTextExample(final TextBoxBase textBox, boolean addSelection) {
    // Add the text box and label to a panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(4);
    hPanel.add(textBox);

    // Add handlers
    if (addSelection) {
        // Create the new label
        final Label label = new Label(constants.cwBasicTextSelected() + ": 0, 0");

        // Add a KeyUpHandler
        textBox.addKeyUpHandler(new KeyUpHandler() {
            public void onKeyUp(KeyUpEvent event) {
                updateSelectionLabel(textBox, label);
            }
        });

        // Add a ClickHandler
        textBox.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                updateSelectionLabel(textBox, label);
            }
        });

        // Add the label to the box
        hPanel.add(label);
    }

    // Return the panel
    return hPanel;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.widgets.CwBasicButton.java

License:Apache License

/**
 * Initialize this example.//from   w ww  .ja v a2 s .  c om
 */
@Override
public Widget onInitialize() {
    // Create a panel to align the widgets
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(10);

    // Add a normal button
    Button normalButton = new Button(constants.cwBasicButtonNormal(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            clickButtonResponseService.clickButtonResponse(new AsyncCallback<String>() {

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Error:" + caught.getMessage());
                }

                @Override
                public void onSuccess(String result) {
                    Window.alert(result);
                }

            });
        }
    });
    normalButton.ensureDebugId("cwBasicButton-normal");
    hPanel.add(normalButton);

    // Add a disabled button
    Button disabledButton = new Button(constants.cwBasicButtonDisabled());
    disabledButton.ensureDebugId("cwBasicButton-disabled");
    disabledButton.setEnabled(false);
    hPanel.add(disabledButton);

    // Return the panel
    return hPanel;
}

From source file:net.s17fabu.vip.gwt.showcase.client.content.widgets.CwCustomButton.java

License:Apache License

/**
 * Initialize this example./*w ww  .  j a va2 s  .  c om*/
 */
@Override
public Widget onInitialize() {
    // Create a panel to layout the widgets
    VerticalPanel vpanel = new VerticalPanel();
    HorizontalPanel pushPanel = new HorizontalPanel();
    pushPanel.setSpacing(10);
    HorizontalPanel togglePanel = new HorizontalPanel();
    togglePanel.setSpacing(10);

    // Combine all the panels
    vpanel.add(new HTML(constants.cwCustomButtonPush()));
    vpanel.add(pushPanel);
    vpanel.add(new HTML("<br><br>" + constants.cwCustomButtonToggle()));
    vpanel.add(togglePanel);

    // Add a normal PushButton
    PushButton normalPushButton = new PushButton(Showcase.images.gwtLogo().createImage());
    normalPushButton.ensureDebugId("cwCustomButton-push-normal");
    pushPanel.add(normalPushButton);

    // Add a disabled PushButton
    PushButton disabledPushButton = new PushButton(Showcase.images.gwtLogo().createImage());
    disabledPushButton.ensureDebugId("cwCustomButton-push-disabled");
    disabledPushButton.setEnabled(false);
    pushPanel.add(disabledPushButton);

    // Add a normal ToggleButton
    ToggleButton normalToggleButton = new ToggleButton(Showcase.images.gwtLogo().createImage());
    normalToggleButton.ensureDebugId("cwCustomButton-toggle-normal");
    togglePanel.add(normalToggleButton);

    // Add a disabled ToggleButton
    ToggleButton disabledToggleButton = new ToggleButton(Showcase.images.gwtLogo().createImage());
    disabledToggleButton.ensureDebugId("cwCustomButton-toggle-disabled");
    disabledToggleButton.setEnabled(false);
    togglePanel.add(disabledToggleButton);

    // Return the panel
    return vpanel;
}

From source file:net.scran24.admin.client.DownloadMissingFoods.java

public DownloadMissingFoods() {
    final FlowPanel contents = new FlowPanel();

    HorizontalPanel hpanel = new HorizontalPanel();

    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hpanel.setSpacing(10);

    dateFrom = new DatePicker();
    dateTo = new DatePicker();

    hpanel.add(new Label("From:"));
    hpanel.add(dateFrom);//from  www.  j av  a 2s .  c om
    hpanel.add(new Label("To:"));
    hpanel.add(dateTo);

    final long day = 24 * 60 * 60 * 1000;

    final Button downloadMissingFoods = WidgetFactory.createButton("Download missing foods report",
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    long timeFrom = dateFrom.getValue().getTime();
                    long timeTo = dateTo.getValue().getTime() + day;

                    String url = GWT.getModuleBaseURL() + "../admin/downloadMissingFoods?timeFrom="
                            + Long.toString(timeFrom) + "&timeTo=" + Long.toString(timeTo);
                    Window.open(url, "_blank", "status=0,toolbar=0,menubar=0,location=0");
                }
            });

    downloadMissingFoods.getElement().addClassName("scran24-admin-button");

    downloadMissingFoods.setEnabled(false);

    dateFrom.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateTo.getValue() != null) {
                downloadMissingFoods.setEnabled(false);
            }

        }
    });

    dateTo.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateFrom.getValue() != null) {
                downloadMissingFoods.setEnabled(true);
            }
        }
    });

    contents.add(hpanel);
    contents.add(WidgetFactory.createButtonsPanel(downloadMissingFoods));

    initWidget(contents);
}

From source file:net.scran24.common.client.widgets.TimePicker.java

public TimePicker(Time initialTime) {
    /*boolean isAm = false;
            //w  w w  .  ja va 2s .c om
    if (initialTime.hours < 12)
       isAm = true;
            
    int ampmHours;
            
    if (isAm) {
       ampmHours = initialTime.hours;
    } else {
       ampmHours = initialTime.hours - 12;
    }
            
    if (ampmHours == 0)
       ampmHours = 12;*/

    hourCounter = new Counter(0, 23, 1, initialTime.hours, "00");
    minuteCounter = new Counter(0, 45, 15, initialTime.minutes, "00");
    // ampm = new AmPmPicker(initialTime.am);

    HorizontalPanel panel = new HorizontalPanel();
    panel.setSpacing(5);
    panel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    panel.add(hourCounter);
    Label label = new Label(":");
    panel.add(label);
    panel.add(minuteCounter);

    //panel.add(ampm);

    initWidget(panel);

    addStyleName("time-picker");
}

From source file:net.scran24.staff.client.DownloadData.java

public DownloadData() {
    final FlowPanel contents = new FlowPanel();
    final FlowPanel surveyDump = new FlowPanel();

    HorizontalPanel hpanel = new HorizontalPanel();

    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hpanel.setSpacing(10);

    dateFrom = new DatePicker();
    dateTo = new DatePicker();

    hpanel.add(new Label("From:"));
    hpanel.add(dateFrom);//from  w  w  w . ja  va 2s  . c  o m
    hpanel.add(new Label("To:"));
    hpanel.add(dateTo);

    // final Button showSurveys = new Button("Show surveys");

    // showSurveys.setWidth("150px");

    final long day = 24 * 60 * 60 * 1000;

    final Button downloadSurveys = WidgetFactory.createButton("Download survey data", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            long timeFrom = dateFrom.getValue().getTime();
            long timeTo = dateTo.getValue().getTime() + day;

            String url = GWT.getModuleBaseURL() + "../staff/downloadData?timeFrom=" + Long.toString(timeFrom)
                    + "&timeTo=" + Long.toString(timeTo) + "&surveyId=" + EmbeddedData.surveyId();
            Window.open(url, "_blank", "status=0,toolbar=0,menubar=0,location=0");
        }
    });

    downloadSurveys.getElement().addClassName("scran24-admin-button");

    final Button downloadActivity = WidgetFactory.createButton("Download activity report", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            long timeFrom = dateFrom.getValue().getTime();
            long timeTo = dateTo.getValue().getTime() + day;

            String url = GWT.getModuleBaseURL() + "../staff/downloadActivity?timeFrom="
                    + Long.toString(timeFrom) + "&timeTo=" + Long.toString(timeTo) + "&surveyId="
                    + EmbeddedData.surveyId();
            Window.open(url, "_blank", "status=0,toolbar=0,menubar=0,location=0");
        }
    });

    downloadActivity.getElement().addClassName("scran24-admin-button");

    // showSurveys.setEnabled(false);
    downloadSurveys.setEnabled(false);
    downloadActivity.setEnabled(false);

    dateFrom.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateTo.getValue() != null) {
                // showSurveys.setEnabled(true);
                downloadSurveys.setEnabled(false);
                downloadActivity.setEnabled(false);
            }

        }
    });

    dateTo.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateFrom.getValue() != null) {
                // showSurveys.setEnabled(true);
                downloadSurveys.setEnabled(true);
                downloadActivity.setEnabled(true);
            }
        }
    });

    // buttons.add(showSurveys);
    // buttons.add(download);

    /*FlowPanel p1 = new FlowPanel();
    p1.add(downloadSurveys);
            
    FlowPanel p2 = new FlowPanel();
    p2.add(downloadActivity);*/

    contents.add(hpanel);
    contents.add(WidgetFactory.createButtonsPanel(downloadSurveys, downloadActivity));
    contents.add(surveyDump);

    initWidget(contents);
}

From source file:net.scran24.staff.client.StaffPage.java

private void initStage1(final FlowPanel div) {
    div.add(new HTMLPanel("h2", "1. Set the start and end dates"));

    HorizontalPanel hpanel = new HorizontalPanel();

    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hpanel.setSpacing(10);

    final DatePicker dateFrom = new DatePicker();
    final DatePicker dateTo = new DatePicker();

    hpanel.add(new Label("Start date:"));
    hpanel.add(dateFrom);/*  www .  j  a v a2  s .  c o  m*/
    hpanel.add(new Label("End date:"));
    hpanel.add(dateTo);

    final Button cont = WidgetFactory.createButton("Continue", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final long twelveHours = 12 * 60 * 60 * 1000;
            long timeFrom = dateFrom.getValue().getTime() - twelveHours;
            long timeTo = dateTo.getValue().getTime() + twelveHours;

            initStage2(timeFrom, timeTo, div);
        }
    });

    cont.setEnabled(false);
    cont.getElement().addClassName("scran24-admin-button");

    dateFrom.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateTo.getValue() != null) {
                cont.setEnabled(true);
            }
        }
    });

    dateTo.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateFrom.getValue() != null) {
                cont.setEnabled(true);
            }
        }
    });

    div.add(hpanel);
    div.add(cont);
}

From source file:net.scran24.staff.client.StaffPage.java

private void updateSchedule() {
    content.clear();//www  .j a  v a  2s .  co  m
    content.add(new HTMLPanel("<h1>Update schedule</h1>"));
    HorizontalPanel hpanel = new HorizontalPanel();

    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hpanel.setSpacing(10);

    final DatePicker dateFrom = new DatePicker();
    final DatePicker dateTo = new DatePicker();

    final Button update = WidgetFactory.createButton("Update", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final long twelveHours = 12 * 60 * 60 * 1000;
            final long timeFrom = dateFrom.getValue().getTime() - twelveHours;
            final long timeTo = dateTo.getValue().getTime() + twelveHours;

            surveyControl.getParameters(new AsyncCallback<SurveyParameters>() {
                @Override
                public void onFailure(Throwable caught) {
                    content.clear();
                    content.add(new HTMLPanel("<p>Server error: </p>" + caught.getMessage()));
                }

                @Override
                public void onSuccess(SurveyParameters result) {
                    surveyControl.setParameters(result.withDates(timeFrom, timeTo), new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            content.clear();
                            content.add(new HTMLPanel("<p>Server error: </p>" + caught.getMessage()));
                        }

                        @Override
                        public void onSuccess(Void result) {
                            Location.reload();
                        }
                    });
                }
            });
        }
    });

    update.getElement().addClassName("scran24-admin-button");

    dateFrom.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateTo.getValue() != null) {
                update.setEnabled(true);
            }
        }
    });

    dateTo.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateFrom.getValue() != null) {
                update.setEnabled(true);
            }
        }
    });

    update.setEnabled(false);

    switch (parameters.state) {
    case SUSPENDED:
    case ACTIVE:
        dateFrom.setValue(new Date(parameters.startDate), true);
        dateTo.setValue(new Date(parameters.endDate), true);
        break;
    case NOT_INITIALISED:
        break;
    }

    hpanel.add(new Label("Start date:"));
    hpanel.add(dateFrom);
    hpanel.add(new Label("End date:"));
    hpanel.add(dateTo);

    content.add(hpanel);
    content.add(update);
}