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:ca.aeso.evq.client.widgets.DatePicker.java

License:Apache License

private Widget drawControls(ListBox names, Label name, int prev, int next, int set) {

    HorizontalPanel hp = new HorizontalPanel();
    hp.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    hp.addStyleName(STYLE_CONTROL_BLOCK);

    if (names == dateTable.monthNames()) {
        monthAction = set;//from   ww  w  .  jav  a 2 s . c o  m
    } else {
        yearAction = set;
    }

    // move left
    //    if (!showYearMonthListing || set == ACTION_SET_MONTH) {
    //      DatePickerCell left = new DatePickerCell("\u00ab"); // \u00ab is <<
    //      left.setType(LocaleCalendarUtils.TYPE_CONTROL);
    //      left.setValue(prev);
    //      left.addStyleName(STYLE_CONTROL);
    //      left.addClickListener(this);
    //      hp.add(left);
    //    }

    // Need list box or not
    if (showYearMonthListing) {

        names.setVisibleItemCount(1);
        names.addStyleName(STYLE_CONTROL_MENU);
        names.addChangeListener(this);

        hp.add(names);

    } else {

        name.addStyleName(STYLE_TITLE);
        hp.add(name);
    }

    // move right
    //    if (!showYearMonthListing || set == ACTION_SET_MONTH) {
    //      DatePickerCell right = new DatePickerCell("\u00bb"); // \u00ab is >>
    //      right.setType(LocaleCalendarUtils.TYPE_CONTROL);
    //      right.setValue(next);
    //      right.addStyleName(STYLE_CONTROL);
    //      right.addClickListener(this);
    //      hp.add(right);
    //    }

    return hp;
}

From source file:ca.nanometrics.gflot.client.example.DecimationExample.java

License:Open Source License

public Widget createExample() {
    PlotWithOverviewModel model = new PlotWithOverviewModel(PlotModelStrategy.downSamplingStrategy(20));
    PlotOptions plotOptions = new PlotOptions();
    plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true));
    plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true));
    plotOptions.setDefaultShadowSize(0);

    final SeriesHandler series = model.addSeries("Random Series", "#003366");

    // create the plot
    final PlotWithOverview plot = new PlotWithOverview(model, plotOptions);

    // pull the "fake" RPC service for new data
    final Timer updater = new Timer() {
        @Override/*from w w w  .  ja  v  a 2s  .  c o m*/
        public void run() {
            update(series, plot);
        }
    };

    // put it on a panel
    FlowPanel panel = new FlowPanel();
    panel.add(plot);
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    buttonsPanel.setSpacing(5);
    buttonsPanel.add(new Button("Start", new ClickListener() {
        public void onClick(Widget sender) {
            updater.scheduleRepeating(1000);
        }
    }));
    buttonsPanel.add(new Button("Stop", new ClickListener() {
        public void onClick(Widget sender) {
            updater.cancel();
        }
    }));
    panel.add(buttonsPanel);
    return panel;
}

From source file:ca.nanometrics.gflot.client.example.SlidingWindowExample.java

License:Open Source License

public Widget createExample() {
    PlotWithOverviewModel model = new PlotWithOverviewModel(PlotModelStrategy.slidingWindowStrategy(20));
    PlotOptions plotOptions = new PlotOptions();
    plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true));
    plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true));
    plotOptions.setDefaultShadowSize(0);
    plotOptions.setXAxisOptions(new TimeSeriesAxisOptions());

    PlotOptions overviewPlotOptions = new PlotOptions().setDefaultShadowSize(0)
            .setLegendOptions(new LegendOptions().setShow(false))
            .setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setFill(true))
            .setSelectionOptions(// www .ja va2s  . c  om
                    new SelectionOptions().setMode(SelectionOptions.X_SELECTION_MODE).setDragging(true))
            .setXAxisOptions(new TimeSeriesAxisOptions());

    final SeriesHandler series = model.addSeries("Random Series", "#FF9900");

    // create the plot
    final PlotWithOverview plot = new PlotWithOverview(model, plotOptions, overviewPlotOptions);

    // pull the "fake" RPC service for new data
    final Timer updater = new Timer() {
        @Override
        public void run() {
            update(series, plot);
        }
    };

    // put it on a panel
    FlowPanel panel = new FlowPanel();
    panel.add(plot);
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    buttonsPanel.setSpacing(5);
    buttonsPanel.add(new Button("Start", new ClickListener() {
        public void onClick(Widget sender) {
            updater.scheduleRepeating(1000);
        }
    }));
    buttonsPanel.add(new Button("Stop", new ClickListener() {
        public void onClick(Widget sender) {
            updater.cancel();
        }
    }));
    panel.add(buttonsPanel);
    return panel;
}

From source file:ca.nanometrics.gflot.client.PlotWithRightInteractiveLegend.java

License:Open Source License

@Override
protected Widget createUi() {
    HorizontalPanel panel = new HorizontalPanel();
    Widget plotWidget = plot.getWidget();

    legendPanel = new VerticalPanel();

    panel.add(plotWidget);
    panel.add(legendPanel);//  w w w  .  j av  a2  s . co  m

    return panel;
}

From source file:ca.upei.ic.timetable.client.ApplicationView.java

License:Apache License

public ApplicationView(ApplicationController app) {
    app_ = app;/*w  w  w .  jav a 2s .c  om*/

    // hide the root panel first
    hide();

    // create the application view elements
    // we are using a horizontal split panel to host the left side (course view)
    // and the right side (calendar view)
    DockPanel panel = GWT.create(DockPanel.class);
    panel.setSize("980px", "580px");

    final View findCourseView = app_.getFindCourseController().getView();

    // find course button
    final Button findCourseButton = GWT.create(Button.class);
    findCourseButton.setText("Find Course...");
    findCourseButton.setPixelSize(250, 28);
    findCourseButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            findCourseView.show();
        }

    });
    // message view
    final View messageView = app_.getMessageController().getView();

    // course view
    final View courseView = app_.getCourseController().getView();
    courseView.getWidget().setWidth("340px");

    // calendar view
    final View calendarView = app_.getCourseCalendarController().getView();

    // top panel
    HorizontalPanel topPanel = GWT.create(HorizontalPanel.class);
    topPanel.add(findCourseButton);
    headerPanel_ = GWT.create(HorizontalPanel.class);
    SimplePanel topleft = PanelUtils.simplePanel(new HTML(""), 61, 28);
    headerPanel_.add(topleft);

    // add headers
    for (int i = 1; i < 6; i++) {
        SimplePanel header = GWT.create(SimplePanel.class);
        header.addStyleName("gridHeaderCell");
        header.setPixelSize(128, 28);
        header.add(new HTML(headerStrings[i]));
        headerPanel_.add(header);
    }

    topPanel.add(headerPanel_);

    // add elements to the dock panel
    // to north (top bar)
    panel.add(PanelUtils.horizontalPanel(findCourseButton, headerPanel_), DockPanel.NORTH);
    // to west (left side bar)
    panel.add(PanelUtils.verticalPanel(
            PanelUtils.decoratorPanel(PanelUtils.scrollPanel(courseView.getWidget(), 240, 555)),
            PanelUtils.horizontalPanel(ButtonUtils.button("Clear", 125, 25, new ClickListener() {
                public void onClick(Widget sender) {
                    app_.getCourseController().clear();
                }
            }, null), ButtonUtils.button("Print...", 125, 25, new ClickListener() {
                public void onClick(Widget sender) {
                    Element wrapper = DOM.createDiv();
                    Element header = (Element) headerPanel_.getElement().cloneNode(true);
                    wrapper.appendChild(header);
                    CalendarPanel calendar = (CalendarPanel) app_.getCourseCalendarController().getView()
                            .getWidget();
                    int height = calendar.getRealHeight();
                    Element calendarElement = (Element) calendar.getElement().cloneNode(true);
                    DOM.setStyleAttribute(calendarElement, "page-break-inside", "avoid");
                    DOM.setStyleAttribute(calendarElement, "height", (height + 50) + "px");
                    wrapper.appendChild(calendarElement);
                    app_.print("Main.css", wrapper.getInnerHTML());
                }
            }, null))), DockPanel.WEST);
    // to center (content)
    panel.add(calendarView.getWidget(), DockPanel.CENTER);

    // to footer (copyright)
    panel.add(new HTML(
            "&copy; 2008 University of Prince Edward Island. This is an <a href=\"http://github.com/upei/\">open-source project</a> licensed under Apache License 2.0."),
            DockPanel.SOUTH);

    // add the horizontal panel
    RootPanel.get().add(panel);
}

From source file:ca.upei.ic.timetable.client.CalendarPanel.java

License:Apache License

/**
 * This method must be called after all settings done.
 *//*from  w  w  w  . ja v  a  2  s.  c o  m*/
void init() {

    calendarInnerHeight_ = Calendar.RESOLUTION * 14 * 4;
    calendarInnerWidth_ = width_ - 17;

    // create the horizontalPanel
    panel_ = GWT.create(HorizontalPanel.class);

    // add panels
    for (int i = 0; i < 7; i++) {
        panel_.add((Widget) GWT.create(AbsolutePanel.class));
    }

    // create the scroll panel
    outerPanel_ = GWT.create(ScrollPanel.class);

    // create the absolute wrapper
    AbsolutePanel wrapper = GWT.create(AbsolutePanel.class);
    wrapper.setPixelSize(calendarInnerWidth_, calendarInnerHeight_);

    // set the calendar width and height
    panel_.setPixelSize(calendarInnerWidth_ - calendarLeftDescriptionWidth_, calendarInnerHeight_);

    // add the sub panel and set size
    outerPanel_.add(wrapper);
    outerPanel_.setPixelSize(width_, height_);

    // deal with type
    switch (calendar_.getType()) {
    case Calendar.FIVE:
        panel_.getWidget(0).setSize("0px", "0px");

        courseWidth_ = (calendarInnerWidth_ - calendarLeftDescriptionWidth_) / 5; // minus
        // the
        // scroll
        // bar
        // width
        for (int i = 1; i < 6; i++) {
            panel_.getWidget(i).setPixelSize(courseWidth_, calendarInnerHeight_);
        }
        panel_.getWidget(6).setSize("0px", "0px");

        break;
    case Calendar.SEVEN:
        courseWidth_ = (calendarInnerWidth_ - calendarLeftDescriptionWidth_) / 7;
        for (int i = 0; i < 7; i++) {
            panel_.getWidget(i).setPixelSize(courseWidth_, calendarInnerHeight_);
        }
        break;
    default:
        throw new IllegalArgumentException("Calendar type is invalid.");
    }

    // add to observer list
    calendar_.addObserver("itemDidAdd", this);
    calendar_.addObserver("itemDidRemove", this);

    // create the grid
    HorizontalPanel grid = new HorizontalPanel();
    grid.setPixelSize(calendarInnerWidth_ - calendarLeftDescriptionWidth_, calendarInnerHeight_);
    grid.addStyleName("grid");

    // FIXME tricky part, needs to change
    for (int i = 0; i < 5; i++) {
        VerticalPanel gridColumn = GWT.create(VerticalPanel.class);
        gridColumn.addStyleName("gridColumn");
        gridColumn.setHeight(Integer.toString(calendarInnerHeight_) + "px");
        gridColumn.setWidth(Integer.toString(courseWidth_ - 1) + "px");

        for (int j = 0; j < 14 * 60 / Calendar.RESOLUTION / 2; j++) {
            SimplePanel cell = GWT.create(SimplePanel.class);
            cell.addStyleName("gridCell");
            cell.setHeight(Integer.toString(Calendar.RESOLUTION * 2 - 1) + "px");
            cell.setWidth(Integer.toString(courseWidth_ - 1) + "px");

            final int day = i;
            final int hour = j;

            gridColumn.add(PanelUtils.focusPanel(cell, new ClickListener() {

                public void onClick(Widget sender) {
                    if (cellClickListener_ != null) {
                        Map<String, Integer> params = new HashMap<String, Integer>();
                        params.put("day", day);
                        params.put("hour", hour);
                        cellClickListener_.setContext(params);
                        cellClickListener_.onClick(sender);
                    }
                }

            }, null, null, null));
        }
        grid.add(gridColumn);
    }

    // create the with description panel
    HorizontalPanel panelWithDescription = GWT.create(HorizontalPanel.class);
    VerticalPanel leftDescription = GWT.create(VerticalPanel.class);
    leftDescription.setPixelSize(calendarLeftDescriptionWidth_, calendarInnerHeight_);
    leftDescription.addStyleName("timeColumn");
    // first row
    SimplePanel firstTimeCell = GWT.create(SimplePanel.class);
    firstTimeCell.addStyleName("timeCell");
    firstTimeCell.setPixelSize(calendarLeftDescriptionWidth_ - 1, Calendar.RESOLUTION);
    leftDescription.add(firstTimeCell);

    for (int i = 0; i < 14 * 60 / Calendar.RESOLUTION / 2; i++) {
        SimplePanel cell = GWT.create(SimplePanel.class);
        cell.addStyleName("timeCell");
        cell.setPixelSize(calendarLeftDescriptionWidth_ - 1, Calendar.RESOLUTION * 2);

        String half;

        if (i % 2 == 0) {
            half = "30";
        } else {
            half = "00";
        }

        // half time adjustment
        int tp = i / 2 + 8;
        tp = tp + i % 2;

        String ampm = "am";

        if (tp >= 12) {
            ampm = "pm";
        }
        if (tp > 12) {
            tp -= 12;
        }

        cell.add(new HTML(Integer.toString(tp) + ":" + half + ampm + "&nbsp;"));

        leftDescription.add(cell);
    }

    panelWithDescription.add(leftDescription);
    panelWithDescription.add(panel_);

    // add the elements
    wrapper.add(grid, calendarLeftDescriptionWidth_, 0);
    wrapper.add(panelWithDescription, 0, 0);

    initWidget(outerPanel_);

    // set the style primary name
    outerPanel_.setStylePrimaryName("wi-CalendarPanel");
    // create the map
    itemWidgets_ = new HashMap<CalendarItem, Set<Widget>>();
}

From source file:ca.upei.ic.timetable.client.FindCourseView.java

License:Apache License

public FindCourseView(FindCourseViewController controller) {
    controller_ = controller;//from  w  w  w. j  a  va2 s  . com

    // set up the dialog box
    dialogBox_ = new DialogBox(false, true); // autohide = false, modal = true
    dialogBox_.setAnimationEnabled(true);
    dialogBox_.setText("Find Courses...");

    // i have a horizontal panel
    HorizontalPanel filterPanel = new HorizontalPanel();
    // i have a level flex table
    levelTable_ = controller_.getLevelModel().getWidget();
    departmentTable_ = controller_.getDepartmentModel().getWidget();
    semesterTable_ = controller_.getSemesterModel().getWidget();
    startTimeWidget_ = controller_.getStartTimeModel().getWidget();

    // button panel
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);

    // i have an OK button
    final Button okButton = new Button("Search");
    okButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            // search and close the dialog
            controller_.search();
            hide();
        }

    });

    okButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ENTER) {
                okButton.click();
            }
        }

    });

    final Button cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
        }
    });

    cancelButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ESCAPE)
                cancelButton.click();
        }

    });

    SimplePanel empty = new SimplePanel();
    empty.setWidth("230px");
    buttonPanel.add(empty);
    buttonPanel.add(cancelButton);
    buttonPanel.add(okButton);
    buttonPanel.setSpacing(5);
    buttonPanel.setWidth("485px");

    // add the panel to the dialog box
    dialogBox_.add(PanelUtils.verticalPanel(PanelUtils.horizontalPanel(
            PanelUtils.verticalPanel(PanelUtils.scrollPanel(levelTable_, 250, 180),
                    PanelUtils.scrollPanel(semesterTable_, 250, 120),
                    PanelUtils.scrollPanel(startTimeWidget_, 250, 30)),
            PanelUtils.scrollPanel(departmentTable_, 250, 320)), buttonPanel));
    dialogBox_.setPopupPosition(240, 0);
}

From source file:ca.upei.ic.timetable.client.PanelUtils.java

License:Apache License

/**
 * Create a HorizontalPanel that contains a list of widgets
 * @param widgets//from  ww w .  jav  a2  s.  c  om
 * @return
 */
public static HorizontalPanel horizontalPanel(Widget... widgets) {
    HorizontalPanel panel = GWT.create(HorizontalPanel.class);
    for (Widget widget : widgets)
        panel.add(widget);
    return panel;
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void buildSummaryPanel() {
    HorizontalPanel selectionPanel = new HorizontalPanel();

    summaryPanel.clear();//from   ww w . j  a  va2 s  .  c o m
    summaryEndDatePanel.add(new Label("Data:"));
    summaryEndDatePanel.add(summaryEndDate);

    selectionPanel.add(summaryAccountGrid);
    selectionPanel.add(summaryAssetGrid);

    summaryPanel.add(summaryEndDatePanel);
    summaryPanel.add(summaryUpdateButton);
    summaryPanel.add(selectionPanel);
    summaryPanel.add(summaryGrid);
    summaryPanel.add(summaryFlowGrid);
    summaryPanel.add(summaryLogConsole);
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void buildTaxPanel() {
    HorizontalPanel headPanel = new HorizontalPanel();
    VerticalPanel prefPanel = new VerticalPanel();
    VerticalPanel startLossPanel = new VerticalPanel();
    HorizontalPanel lossPanel = new HorizontalPanel();
    HorizontalPanel dayTradeLossPanel = new HorizontalPanel();

    taxPanel.clear();//from  w  w  w  .ja v  a2  s  . c  om
    taxEndDatePanel.add(new Label("Data:"));
    taxEndDatePanel.add(taxEndDate);
    taxPanel.add(taxEndDatePanel);

    StockTaxPrefResetButtonHandler stockTaxPrefButtonHandler = new StockTaxPrefResetButtonHandler();
    Button stockTaxPrefButton = new Button("Restaurar Recomendacoes", stockTaxPrefButtonHandler);

    prefPanel.add(stockTaxPrefButton);
    prefPanel.add(Preference.stockDayTradeAffectExemptionLimit);
    prefPanel.add(Preference.stockExemptGainsReduceCarriedLoss);
    prefPanel.add(Preference.stockTaxRatioOverPretaxEarnings);
    prefPanel.addStyleName("boxedTable");

    lossPanel.add(new Label("Perda acumulada inicial:"));
    lossPanel.add(Preference.startTaxCarryLoss);
    dayTradeLossPanel.add(new Label("Perda acumulada inicial em Day-trade:"));
    dayTradeLossPanel.add(Preference.startTaxDayTradeCarryLoss);

    startLossPanel.add(lossPanel);
    startLossPanel.add(dayTradeLossPanel);

    headPanel.add(prefPanel);
    headPanel.add(startLossPanel);
    taxPanel.add(headPanel);

    taxPanel.add(new Label("Apuracao Mensal:"));
    taxPanel.add(taxGrid);
    taxPanel.add(new Label("Legenda:"));
    taxPanel.add(new Label("IR.Devido: Codigo Receita DARF: Pessoa Fisica = 6015, Pessoa Juridica = 3317"));
    taxPanel.add(new Label("DT.IR.Devido: Codigo Receita DARF: Pessoa Fisica = 6015, Pessoa Juridica = 3317"));
    taxPanel.add(new Label("Resumo Anual:"));
    taxPanel.add(taxYearlySummaryGrid);
    taxPanel.add(new Label("Legenda:"));
    taxPanel.add(new Label("Repasse BTC: Rendimentos Tributaveis"));
    taxPanel.add(new Label("Lucro Liquido na Venda de Titulos: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Cupons de Titulos: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Aluguel de Acoes: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Juros Sobre Capital Proprio: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Dividendos: Rendimentos Isentos e nao Tributaveis"));
    taxPanel.add(new Label("Ganho Liquido Isento: Rendimentos Isentos e nao Tributaveis"));
    taxPanel.add(debugPanel);
}