List of usage examples for com.google.gwt.user.client.ui Widget setWidth
public void setWidth(String width)
From source file:com.google.gerrit.client.ConfirmationDialog.java
License:Apache License
public ConfirmationDialog(final String dialogTitle, final SafeHtml message, final ConfirmationCallback callback) { super(/* auto hide */false, /* modal */true); setGlassEnabled(true);// w w w . j a v a 2s. c o m setText(dialogTitle); final FlowPanel buttons = new FlowPanel(); final Button okButton = new Button(); okButton.setText(Gerrit.C.confirmationDialogOk()); okButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); callback.onOk(); } }); buttons.add(okButton); cancelButton = new Button(); DOM.setStyleAttribute(cancelButton.getElement(), "marginLeft", "300px"); cancelButton.setText(Gerrit.C.confirmationDialogCancel()); cancelButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); buttons.add(cancelButton); final FlowPanel center = new FlowPanel(); final Widget msgWidget = message.toBlockWidget(); center.add(msgWidget); center.add(buttons); add(center); msgWidget.setWidth("400px"); setWidget(center); }
From source file:com.google.gwt.sample.mobilewebapp.client.desktop.MobileWebAppShellDesktop.java
License:Apache License
/** * Construct a new {@link MobileWebAppShellDesktop}. *///from w ww. j a v a2 s . c o m public MobileWebAppShellDesktop(EventBus bus, TaskChartPresenter pieChart, final PlaceController placeController, TaskListView taskListView, TaskEditView taskEditView, TaskReadView taskReadView) { // Initialize the main menu. Resources resources = GWT.create(Resources.class); mainMenu = new CellList<MainMenuItem>(new MainMenuItem.Cell(), resources); mainMenu.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); // We don't expect to have more than 30 menu items. mainMenu.setVisibleRange(0, 30); // Add items to the main menu. final List<MainMenuItem> menuItems = new ArrayList<MainMenuItem>(); menuItems.add(new MainMenuItem("Task List", new TaskListPlace(false)) { @Override public boolean mapsToPlace(Place p) { // Map to all TaskListPlace instances. return p instanceof TaskListPlace; } }); menuItems.add(new MainMenuItem("Add Task", TaskPlace.getTaskCreatePlace())); mainMenu.setRowData(menuItems); // Choose a place when a menu item is selected. final SingleSelectionModel<MainMenuItem> selectionModel = new SingleSelectionModel<MainMenuItem>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { MainMenuItem selected = selectionModel.getSelectedObject(); if (selected != null && !selected.mapsToPlace(placeController.getWhere())) { placeController.goTo(selected.getPlace()); } } }); mainMenu.setSelectionModel(selectionModel); // Update selection based on the current place. bus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() { public void onPlaceChange(PlaceChangeEvent event) { Place place = event.getNewPlace(); for (MainMenuItem menuItem : menuItems) { if (menuItem.mapsToPlace(place)) { // We found a match in the main menu. selectionModel.setSelected(menuItem, true); return; } } // We didn't find a match in the main menu. selectionModel.setSelected(null, true); } }); // Initialize this widget. initWidget(uiBinder.createAndBindUi(this)); // Initialize the pie chart. String chartUrlValue = Window.Location.getParameter(CHART_URL_ATTRIBUTE); if (chartUrlValue != null && chartUrlValue.startsWith("f")) { // Chart manually disabled. leftNav.remove(1); // Pie Chart. leftNav.remove(0); // Pie chart legend. } else if (pieChart == null) { // Chart not supported. pieChartContainer.setWidget(new Label("Try upgrading to a modern browser to enable charts.")); } else { // Chart supported. Widget pieWidget = pieChart.asWidget(); pieWidget.setWidth("90%"); pieWidget.setHeight("90%"); pieWidget.getElement().getStyle().setMarginLeft(5.0, Unit.PCT); pieWidget.getElement().getStyle().setMarginTop(5.0, Unit.PCT); pieChartContainer.setWidget(pieChart); } /* * Add all views to the DeckLayoutPanel so we can animate between them. * Using a DeckLayoutPanel here works because we only have a few views, and * we always know that the task views should animate in from the right side * of the screen. A more complex app will require more complex logic to * figure out which direction to animate. */ contentContainer.add(taskListView); contentContainer.add(taskReadView); contentContainer.add(taskEditView); contentContainer.setAnimationDuration(800); // Show a tutorial when the help link is clicked. helpLink.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showTutorial(); } }); }
From source file:com.googlecode.kanbanik.client.components.WindowBox.java
License:Apache License
/** * Convenience method to set the height, width and position of the given widget * * @param panel/*from www .j a va2 s.co m*/ * @param dx * @param dy */ protected void dragResizeWidget(PopupPanel panel, int dx, int dy) { int x = this.getPopupLeft(); int y = this.getPopupTop(); Widget widget = panel.getWidget(); // left + right if ((this.dragMode % 3) != 1) { int w = widget.getOffsetWidth(); // left edge -> move left if ((this.dragMode % 3) == 0) { x += dx; w -= dx; } else { w += dx; } w = w < this.minWidth ? this.minWidth : w; widget.setWidth(w + "px"); } // up + down if ((this.dragMode / 3) != 1) { int h = widget.getOffsetHeight(); // up = dy is negative if ((this.dragMode / 3) == 0) { y += dy; h -= dy; } else { h += dy; } h = h < this.minHeight ? this.minHeight : h; widget.setHeight(h + "px"); } if (this.dragMode / 3 == 0 || this.dragMode % 3 == 0) panel.setPopupPosition(x, y); }
From source file:com.gwtm.ui.client.widgets.FlowGridPanel2.java
License:Apache License
private static void updateUi(FlowGridPanel2 panel) { int width = panel.getElement().getClientWidth(); if (width == 0) width = RootPanel.get().getOffsetWidth() - panel.getElement().getAbsoluteLeft() - panel.getElement().getAbsoluteRight(); int numCols = Utils.DeviceInfo.isLandscape() ? panel.getLandscapeColumns().getColNumber() : panel.getPortraitColumns().getColNumber(); panel.calculatedWidth = width / numCols; panel.calculatedWidth = panel.calculatedWidth; // reduce 30px and give all to the padding on the parent if (width < 0) return;//from w ww . j av a 2 s. c o m for (int i = 0; i < panel.getWidgetCount(); i++) { Widget w = panel.getWidget(i); w.setWidth(panel.calculatedWidth + "px"); w.setHeight(panel.calculatedWidth + "px"); } }
From source file:com.gwtm.ui.client.widgets.SlidingPanel.java
License:Apache License
@Override public void add(Widget w) { // assert (w instanceof Slide) : // "Can only add Slide widgets to SlidePanel."; // we can't assert because gwtdesign adds a Label by default if (Beans.isDesignTime()) { if (!(w instanceof Slide)) { addDesignTimeError("Can only add Slides to SlidePanel. Remove the " + Utils.getSimpleName(w.getClass()) + " widget."); return; }/* w w w. j av a 2 s . c o m*/ } // set the calculated width for each added slide panel w.setWidth(slideWidth + "px"); // add indicator if (getIndicatorVisibility() != IndicatorVisibility.none) indicator.addIndicator(); // add slide to inner panel innerPanel.add(w); }
From source file:com.lorepo.icplayer.client.module.choice.MyPopupPanel.java
License:Apache License
/** * We control size by setting our child widget's size. However, if we don't * currently have a child, we record the size the user wanted so that when we * do get a child, we can set it correctly. Until size is explicitly cleared, * any child put into the popup will be given that size. *//*w ww. j a va 2s . com*/ void maybeUpdateSize() { // For subclasses of PopupPanel, we want the default behavior of setWidth // and setHeight to change the dimensions of PopupPanel's child widget. // We do this because PopupPanel's child widget is the first widget in // the hierarchy which provides structure to the panel. DialogBox is // an example of this. We want to set the dimensions on DialogBox's // FlexTable, which is PopupPanel's child widget. However, it is not // DialogBox's child widget. To make sure that we are actually getting // PopupPanel's child widget, we have to use super.getWidget(). Widget w = super.getWidget(); if (w != null) { if (desiredHeight != null) { w.setHeight(desiredHeight); } if (desiredWidth != null) { w.setWidth(desiredWidth); } } }
From source file:com.pronoiahealth.olhie.client.widgets.FlexTableExt.java
License:Open Source License
/** * Add a column/*ww w . ja v a 2 s .co m*/ * * @param columnHeading */ public void addColumn(Object columnHeading, String styleName, String cellStyleName) { Widget widget = createCellWidget(columnHeading); int cell = getCellCount(HeaderRowIndex); widget.setWidth("100%"); widget.addStyleName(styleName); setWidget(HeaderRowIndex, cell, widget); getCellFormatter().addStyleName(HeaderRowIndex, cell, cellStyleName); }
From source file:com.qualogy.qafe.gwt.client.factory.WindowFactory.java
License:Apache License
public static void setWidgetToMainPanel(Widget w, WindowGVO windowGVO) { if (w != null) { clearWidgetFromMainPanel();//www.j ava2 s . com SimplePanel mainPanel = ClientApplicationContext.getInstance().getMainPanel(); if (mainPanel == null) { mainPanel = new SimplePanel(); mainPanel.setWidth(Window.getClientWidth() + "px"); mainPanel.setHeight(Window.getClientHeight() + "px"); ClientApplicationContext.getInstance().setMainPanel(mainPanel); MenuBar menuBar = ClientApplicationContext.getInstance().getApplicationsMenu(); if (menuBar != null) { menuBar.addStyleName("SDIMenu"); RootPanel.get().add((Widget) mainPanel, 0, 24); } else { RootPanel.get().add((Widget) mainPanel, 0, 0); } } w.setWidth(Window.getClientWidth() + "px"); w.setHeight(Window.getClientHeight() + "px"); mainPanel.addStyleName("SDIWrapper"); mainPanel.setWidget(w); w.addStyleName("SDIPanel"); if (windowGVO != null) { RendererHelper.addStyle(windowGVO.getRootPanel(), w); } } }
From source file:com.sciencegadgets.client.ui.CommunistPanel.java
License:Open Source License
protected void redistribute() { int count = this.getWidgetCount(); if (count <= 0) { return;//from ww w . j av a2 s . co m } int portion = 100 / count; for (int i = 0; i < count; i++) { Widget member = getWidget(i); if (isHorizontal) { member.setWidth(portion + "%"); member.setHeight("100%"); } else { member.setHeight(portion + "%"); member.setWidth("100%"); } } }
From source file:com.square.client.gwt.client.composant.bloc.BlocArrondiBleu.java
License:Open Source License
@Override public void add(Widget contenu) { conteneurWidget.add(contenu); contenu.setWidth(AppControllerConstants.POURCENT_100); }