List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel
public HorizontalPanel()
From source file:burrito.client.widgets.panels.table.PageController.java
License:Apache License
/** * Creates a new pagecontroller//from ww w .j av a2 s . c o m * * @param showPageLabel * @param maxPagesShown * If not <code>null</code> then this will be the maximum number * of pages shown in the page controller. */ public PageController(boolean showPageLabel) { HorizontalPanel wrapper = new HorizontalPanel(); wrapper.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); if (showPageLabel) { Label label = new Label(messages.page()); label.addStyleName("k5-PageController-label"); wrapper.add(label); } next = new PushButton(new Image(GWT.getModuleBaseURL() + "images/page-next.png?v=2")); previous = new PushButton(new Image(GWT.getModuleBaseURL() + "images/page-previous.png?v=2")); next.getUpDisabledFace().setImage(new Image(GWT.getModuleBaseURL() + "images/page-next-disabled.png?v=2")); previous.getUpDisabledFace() .setImage(new Image(GWT.getModuleBaseURL() + "images/page-previous-disabled.png?v=2")); next.addStyleName("k5-PageController-nextButton"); previous.addStyleName("k5-PageController-previousButton"); currentPageLabel = createCurrentPageAnchor(); currentPageLabel.addStyleName("k5-PageController-link-selected"); next.setEnabled(false); previous.setEnabled(false); next.setTitle(messages.next()); previous.setTitle(messages.previous()); wrapper.add(previous); wrapper.add(currentPageLabel); wrapper.add(next); next.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (PageControllerHandler handler : handlers) { handler.loadPage(currentPageZeroIndexed + 1); } } }); previous.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (PageControllerHandler handler : handlers) { handler.loadPage(currentPageZeroIndexed - 1); } } }); initWidget(wrapper); addStyleName("k5-PageController"); setVisible(false); }
From source file:burrito.client.widgets.panels.table.Table.java
License:Apache License
protected void renderTable() { // remove all previous rows for (int i = 1; i < table.getRowCount(); i++) { table.removeRow(i);/* www . j a v a 2 s . com*/ } int leftMargin = 0; if (rowsSelectable) { leftMargin++; // add margin because of select box } table.resize(currentModel.size() + 1, this.numberOfColumns); int row = 1; for (final T obj : currentModel) { String[] names = table.getRowFormatter().getStyleName(row).split(" "); for (String style : names) { if (style.length() > 0) table.getRowFormatter().removeStyleName(row, style); } if (rowsSelectable) { final int thisRowAsFinal = row; CheckBox select = new CheckBox(); select.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue().booleanValue()) { table.getRowFormatter().addStyleName(thisRowAsFinal, "k5-Table-row-selected"); } else { table.getRowFormatter().removeStyleName(thisRowAsFinal, "k5-Table-row-selected"); } } }); table.setWidget(row, 0, select); } for (int column = 0; column < numberOfModelColumns; column++) { table.setWidget(row, column + leftMargin, cellRenderers.get(column).render(obj)); } table.getRowFormatter().addStyleName(row, "k5-Table-row"); if (row % 2 == 0) { table.getRowFormatter().addStyleName(row, "k5-Table-row-even"); } else { table.getRowFormatter().addStyleName(row, "k5-Table-row-odd"); } String rowStyle = rowStyle(row, obj); if (rowStyle != null) { table.getRowFormatter().addStyleName(row, rowStyle); } if (rowsOrderable && rowOrderHandler != null) { final int fRow = row; Anchor up = new Anchor(messages.up()); up.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { move(fRow - 1, -1); } }); up.addStyleName("k5-Table-order-up"); Anchor down = new Anchor(messages.down()); down.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { move(fRow - 1, 1); } }); down.addStyleName("k5-Table-order-down"); HorizontalPanel hp = new HorizontalPanel(); hp.add(up); hp.add(down); int rightMargin = 1; if (rowsEditable) { rightMargin++; } table.setWidget(row, numberOfColumns - rightMargin, hp); } if (rowsEditable && rowEditHandler != null) { Anchor edit = new Anchor(messages.edit()); String href = rowEditHandler.getHref(obj); if (href != null) { edit.setHref(href); } else { edit.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { rowEditHandler.onRowEditClicked(obj); } }); } table.setWidget(row, numberOfColumns - 1, edit); } row++; } }
From source file:burrito.client.widgets.panels.table.Table.java
License:Apache License
/** * Adds a batch action to this table. A batch action is performed on * selected rows in the table./* w w w. j a v a2s . c o m*/ * * @param batchAction */ public void addBatchAction(final BatchAction<T> batchAction) { batchJobs.add(new VerticalSpacer(10)); HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); final Button b = new Button(batchAction.getButtonText()); ClickHandler ch = new ClickHandler() { @Override public void onClick(ClickEvent event) { final List<T> selected = getSelectedRows(); if (selected == null || selected.isEmpty()) { return; } batchAction.performAction(selected, new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { b.setEnabled(true); b.removeStyleName("loading"); infoPopup.setTextAndShow(batchAction.getSuccessText(selected)); load(pageController.getCurrentPage()); } @Override public void onFailure(Throwable caught) { b.setEnabled(true); b.removeStyleName("loading"); throw new RuntimeException(caught); } }); b.setEnabled(false); b.addStyleName("loading"); } }; b.addClickHandler(ch); hp.add(b); hp.add(new Label(batchAction.getDescription())); batchJobs.add(hp); }
From source file:bwbv.rlt.client.ui.HeaderPane.java
License:Apache License
/** * Build this conditionally based on isLoggedIn * @param isLoggedIn//from w w w . j a v a 2s. c o m * @return */ private HorizontalPanel buildHeaderPanel(boolean isLoggedIn) { HorizontalPanel panel = new HorizontalPanel(); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); if (isLoggedIn) { panel.setSpacing(10); panel.add(new Label("Welcome " + clientState.getUserName())); Button logoutButton = new Button("Logout"); logoutButton.setStyleName("LogoutButton"); logoutButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { logout(); } }); panel.add(logoutButton); } else { Button loginButon = new Button("Login"); loginButon.setStyleName("LoginButton"); loginButon.addClickListener(new ClickListener() { public void onClick(Widget sender) { showNewUserNameRequestPopupPanel(); } }); panel.add(loginButon); } return panel; }
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 w ww . j a v a 2 s . com } 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 www.j av 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(//from w w w.java2 s .c o m 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.PlotWithInteractiveLegend.java
License:Open Source License
protected Widget createUi() { VerticalPanel panel = new VerticalPanel(); Widget plotWidget = plot.getWidget(); legendPanel = new HorizontalPanel(); panel.add(legendPanel);/* ww w . j ava 2 s . co m*/ panel.add(plotWidget); 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);/*from w w w.j av a 2 s. co m*/ panel.add(legendPanel); return 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 . j av a2 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 + " ")); 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>>(); }