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

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

Introduction

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

Prototype

public HorizontalPanel() 

Source Link

Document

Creates an empty horizontal panel.

Usage

From source file:com.google.gwt.sample.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.
 *
 * @param textBox the text box to handle
 * @param addSelection add handlers to update label
 * @return the Label that will be updated
 *//*from w  w w.j  ava2  s . c  o m*/
@ShowcaseSource
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:com.google.gwt.sample.showcase.client.content.widgets.CwBasicButton.java

License:Apache License

/**
 * Initialize this example.//from  w ww.ja  va  2 s  .  co  m
 */
@ShowcaseSource
@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) {
            Window.alert(constants.cwBasicButtonClickMessage());
        }
    });
    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:com.google.gwt.sample.showcase.client.content.widgets.CwCustomButton.java

License:Apache License

/**
 * Initialize this example.// ww  w.j  av a  2s . c om
 */
@ShowcaseSource
@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(new Image(Showcase.images.gwtLogo()));
    normalPushButton.ensureDebugId("cwCustomButton-push-normal");
    pushPanel.add(normalPushButton);

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

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

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

    // Return the panel
    return vpanel;
}

From source file:com.google.gwt.sample.stockwatcher.client.Cells.java

private void loadLinks() {
    RootPanel links = RootPanel.get("navigationLinks");
    links.clear();/*from  w ww.  j ava  2  s.  com*/

    cellListLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            loadContent(createCellList());
        }
    });

    cellTableLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            loadContent(createCellTable());
        }
    });

    cellTreeLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            loadContent(createCellTree());
        }
    });

    cellBrowserLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            loadContent(createCellBrowser());
        }
    });

    HorizontalPanel linksPanel = new HorizontalPanel();
    linksPanel.setSpacing(5);

    linksPanel.add(cellListLink);
    linksPanel.add(cellTableLink);
    linksPanel.add(cellTreeLink);
    linksPanel.add(cellBrowserLink);

    links.add(linksPanel);
}

From source file:com.google.gwt.sample.stockwatcher.client.ChartUtilities.java

public static HorizontalPanel createGaugeChart(final String name, final int size) {
    final HorizontalPanel lol = new HorizontalPanel();
    final Chart chart = new Chart();
    chart.setType(Series.Type.SOLID_GAUGE).setLegend(new Legend().setEnabled(false))
            .setCredits(new Credits().setEnabled(false)).setAlignTicks(false).setPlotBackgroundImage(null)
            .setBorderWidth(0).setPlotShadow(false).setExporting(new Exporting().setEnabled(false))
            .setChartTitle(new ChartTitle().setText("Latest " + name + " sensor reading"))
            .setPane(new Pane().setStartAngle(-90).setEndAngle(90).setCenter("50%", "85%")
                    .setBackground(new PaneBackground().setInnerRadius("60%").setOuterRadius("100%")
                            .setShape(PaneBackground.Shape.ARC).setBackgroundColor("rgba(0,0,0,0)")))
            .setSolidGaugePlotOptions(new SolidGaugePlotOptions().setAnimation(false));

    final ArrayList<String> attributes = Data.sensorAttributeList.get(name);

    final Number maxTreshold = (Number) Double.parseDouble(attributes.get(8));
    chart.getYAxis().setMin(0);//from   ww  w .  j  av a 2 s .  c  om
    chart.getYAxis().setMax(maxTreshold);
    chart.getYAxis().setLineColor("gray");

    chart.setBackgroundColor(new Color().setLinearGradient(0.0, 0.0, 1.0, 1.0).addColorStop(0, 0, 0, 0, 1)
            .addColorStop(0, 0, 0, 0, 0));

    chart.getYAxis().setTickPosition(Axis.TickPosition.INSIDE).setMinorTickPosition(Axis.TickPosition.INSIDE)
            .setLineColor("white").setTickColor("white").setMinorTickColor("white").setLineWidth(2)
            .setEndOnTick(true).setLabels(new YAxisLabels()
                    // There is no documented "distance" option for gauge chart axes
                    .setOption("distance", -20));

    final Series series = chart.createSeries();
    chart.addSeries(series.setName("Reading").addPoint(0));
    final Timer tempTimer = new Timer() {
        @Override
        public void run() {
            if (MainMenuPage.mainPanel.isVisible())
                Utility.newRequestObj().getLatestReading(name, new AsyncCallback<Double>() {
                    public void onFailure(Throwable caught) {
                        //                    Window.alert("Unable to get "+Data.currentUser+"'s sensor subscription");
                    }

                    public void onSuccess(Double reply) {
                        if (lol.isVisible()) {
                            //                    double temp = Utility.round(new Random().nextDouble()*Double.parseDouble(attributes.get(8)));
                            double temp = Utility.round(reply);
                            series.getPoints()[0].update(temp);
                            chart.setColors(updateColor(temp, maxTreshold));
                            lol.add(chart);
                        } else {
                            cancel();
                        }
                    }
                });
        }
    };

    tempTimer.scheduleRepeating(2000);
    Data.gaugeTimers.add(tempTimer);

    chart.setSize(Window.getClientWidth() * 1 / size, Window.getClientHeight() * 1 / size);
    if (size > 4) {
        chart.setSize(Window.getClientWidth() * 1 / 4, Window.getClientHeight() * 1 / 4);
    }
    lol.add(chart);
    return lol;
}

From source file:com.google.gwt.sample.stockwatcher.client.ContentPanel.java

public ContentPanel() {
    wholePanel = new HorizontalPanel();
    leftPanel = new HorizontalPanel();
    middlePanel = new VerticalPanel();
    rightPanel = new HorizontalPanel();

    wholePanel.add(leftPanel);/*w  ww.  j  a v a2s  .c om*/
    wholePanel.add(middlePanel);
    wholePanel.add(rightPanel);
    wholePanel.setSize("100%", BasePage.contentPanelHeight + "px");
    wholePanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    wholePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    wholePanel.setCellHorizontalAlignment(leftPanel, HasHorizontalAlignment.ALIGN_LEFT);
    wholePanel.setCellHorizontalAlignment(middlePanel, HasHorizontalAlignment.ALIGN_CENTER);
    wholePanel.setCellHorizontalAlignment(rightPanel, HasHorizontalAlignment.ALIGN_RIGHT);
    wholePanel.setCellVerticalAlignment(middlePanel, HasVerticalAlignment.ALIGN_TOP);

    leftPanel.setHeight("100%");
    middlePanel.setSize("100%", "100%");
    rightPanel.setHeight("100%");

    initWidget(wholePanel);
}

From source file:com.google.gwt.sample.stockwatcher.client.FilterMenu.java

public void addNewRow(Widget widget) {
    HorizontalPanel panel = new HorizontalPanel();
    panel.getElement().getStyle().setPaddingTop(8, Unit.PX);
    panel.getElement().getStyle().setPaddingLeft(2.5, Unit.PX);
    panel.getElement().getStyle().setPaddingRight(2.5, Unit.PX);
    panel.add(widget);//from  w  w  w  .  j a  va  2  s . c o m
    mainPanel.add(panel);
    count++;
}

From source file:com.google.gwt.sample.stockwatcher.client.FilterMenu.java

public void addItem(Widget widget) {
    if (groupExist(count)) {
        getPanel(count).add(widget);//  w  w w.  ja  v a 2  s  .  c  om
    } else {
        HorizontalPanel panel = new HorizontalPanel();
        panel.getElement().getStyle().setPaddingLeft(2.5, Unit.PX);
        panel.getElement().getStyle().setPaddingRight(2.5, Unit.PX);
        panel.add(widget);
        mainPanel.add(panel);
    }
}

From source file:com.google.gwt.sample.stockwatcher.client.FilterMenu.java

public void addItem(String title, Widget widget) {
    if (groupExist(title)) {
        getPanel(title).add(widget);/*  www .j  a v a2  s.  co m*/
    } else {
        HorizontalPanel panel = new HorizontalPanel();
        panel.getElement().getStyle().setPaddingLeft(2.5, Unit.PX);
        panel.getElement().getStyle().setPaddingRight(2.5, Unit.PX);
        panel.setTitle(title);
        panel.add(widget);
        mainPanel.add(panel);
    }

}