List of usage examples for com.google.gwt.user.client.ui Widget setHeight
public void setHeight(String height)
From source file:com.google.gwt.sample.mobilewebapp.client.desktop.MobileWebAppShellDesktop.java
License:Apache License
/** * Construct a new {@link MobileWebAppShellDesktop}. *//*from ww w . jav a 2 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 w ww. j av a2s. c o 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 w w. ja v 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.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 va2 s . c o m 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.qualogy.qafe.gwt.client.factory.WindowFactory.java
License:Apache License
public static void setWidgetToMainPanel(Widget w, WindowGVO windowGVO) { if (w != null) { clearWidgetFromMainPanel();//from ww w . j a va 2 s . c o m 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;// w ww . j a v a 2 s . c o 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.sun.labs.aura.dbbrowser.client.viz.Util.java
License:Open Source License
public static HorizontalPanel getHisto(String name, int value, int maxValue, int maxWidth, String text) { int leftWidth = Math.round(((float) value / (float) maxValue) * (float) maxWidth); if (leftWidth < 1) { leftWidth = 1;/*from w ww .ja va2s . c om*/ } else if (leftWidth > maxWidth) { leftWidth = maxWidth; } int rightWidth = maxWidth - leftWidth; boolean alert = false; if (value / (float) maxValue > 0.75) { alert = true; } HorizontalPanel all = new HorizontalPanel(); all.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); all.add(new StyleLabel(name + ":", "viz-histoName")); HorizontalPanel table = new HorizontalPanel(); table.setWidth(maxWidth + "px"); table.setBorderWidth(0); table.setSpacing(0); Widget left = new Label(""); if (alert) { left.setStyleName("viz-histoLeftAlert"); } else { left.setStyleName("viz-histoLeft"); } left.setWidth(leftWidth + ""); left.setHeight("10px"); left.getElement().getStyle().setPropertyPx("fontSize", 6); Widget right = new Label(""); if (alert) { right.setStyleName("viz-histoRightAlert"); } else { right.setStyleName("viz-histoRight"); } right.setWidth(rightWidth + ""); right.setHeight("10px"); right.getElement().getStyle().setPropertyPx("fontSize", 6); table.add(left); table.add(right); all.add(table); all.add(new StyleLabel(text, "viz-histoText")); return all; }
From source file:com.sun.labs.aura.music.wsitm.client.WebLib.java
License:Open Source License
/** * Returns a populatiry histrogram. To get it wrapped with a title, use other * utility functions getSmallPopularityWidget() or getPopularityWidget() * @param normPopularity popularity as a number between 0 and 1 * @param log plot on log scale// ww w . j a va 2 s. c om * @param height maximum size of 15 * @param maxWidth * @return */ public static HorizontalPanel getPopularityHisto(double normPopularity, boolean log, int height, int maxWidth) { if (log) { normPopularity = Math.log(normPopularity + 1) / Math.log(2); // get the base 2 log } int leftWidth = (int) (normPopularity * maxWidth); if (leftWidth < 1) { leftWidth = 1; } else if (leftWidth > maxWidth) { leftWidth = maxWidth; } int rightWidth = maxWidth - leftWidth; HorizontalPanel table = new HorizontalPanel(); table.setWidth(maxWidth + "px"); table.setBorderWidth(0); table.setSpacing(0); Widget left = new Label(""); left.setStyleName("popLeft"); left.setWidth(leftWidth + ""); left.setHeight(height + "px"); left.getElement().getStyle().setPropertyPx("fontSize", height - 2); Widget right = new Label(""); right.setStyleName("popRight"); right.setWidth(rightWidth + ""); right.setHeight(height + "px"); right.getElement().getStyle().setPropertyPx("fontSize", height - 2); table.add(left); table.add(right); return table; }
From source file:com.vaadin.terminal.gwt.client.ApplicationConnection.java
License:Open Source License
private void updateComponentSize(ComponentDetail cd, UIDL uidl) { String w = uidl.hasAttribute("width") ? uidl.getStringAttribute("width") : ""; String h = uidl.hasAttribute("height") ? uidl.getStringAttribute("height") : ""; float relativeWidth = Util.parseRelativeSize(w); float relativeHeight = Util.parseRelativeSize(h); // First update maps so they are correct in the setHeight/setWidth calls if (relativeHeight >= 0.0 || relativeWidth >= 0.0) { // One or both is relative FloatSize relativeSize = new FloatSize(relativeWidth, relativeHeight); if (cd.getRelativeSize() == null && cd.getOffsetSize() != null) { // The component has changed from absolute size to relative size relativeSizeChanges.add(cd.getComponent()); }/*from ww w . j a v a 2s. co m*/ cd.setRelativeSize(relativeSize); } else if (relativeHeight < 0.0 && relativeWidth < 0.0) { if (cd.getRelativeSize() != null) { // The component has changed from relative size to absolute size relativeSizeChanges.add(cd.getComponent()); } cd.setRelativeSize(null); } Widget component = (Widget) cd.getComponent(); // Set absolute sizes if (relativeHeight < 0.0) { component.setHeight(h); } if (relativeWidth < 0.0) { component.setWidth(w); } // Set relative sizes if (relativeHeight >= 0.0 || relativeWidth >= 0.0) { // One or both is relative handleComponentRelativeSize(cd); } }
From source file:com.vaadin.terminal.gwt.client.ApplicationConnection.java
License:Open Source License
/** * Converts relative sizes into pixel sizes. * //from w w w . j a va 2s .c o m * @param child * @return true if the child has a relative size */ private boolean handleComponentRelativeSize(ComponentDetail cd) { if (cd == null) { return false; } boolean debugSizes = false; FloatSize relativeSize = cd.getRelativeSize(); if (relativeSize == null) { return false; } Widget widget = (Widget) cd.getComponent(); boolean horizontalScrollBar = false; boolean verticalScrollBar = false; Container parent = Util.getLayout(widget); RenderSpace renderSpace; // Parent-less components (like sub-windows) are relative to browser // window. if (parent == null) { renderSpace = new RenderSpace(Window.getClientWidth(), Window.getClientHeight()); } else { renderSpace = parent.getAllocatedSpace(widget); } if (relativeSize.getHeight() >= 0) { if (renderSpace != null) { if (renderSpace.getScrollbarSize() > 0) { if (relativeSize.getWidth() > 100) { horizontalScrollBar = true; } else if (relativeSize.getWidth() < 0 && renderSpace.getWidth() > 0) { int offsetWidth = widget.getOffsetWidth(); int width = renderSpace.getWidth(); if (offsetWidth > width) { horizontalScrollBar = true; } } } int height = renderSpace.getHeight(); if (horizontalScrollBar) { height -= renderSpace.getScrollbarSize(); } if (validatingLayouts && height <= 0) { zeroHeightComponents.add(cd.getComponent()); } height = (int) (height * relativeSize.getHeight() / 100.0); if (height < 0) { height = 0; } if (debugSizes) { VConsole.log("Widget " + Util.getSimpleName(widget) + "/" + getPid(widget.getElement()) + " relative height " + relativeSize.getHeight() + "% of " + renderSpace.getHeight() + "px (reported by " + Util.getSimpleName(parent) + "/" + (parent == null ? "?" : parent.hashCode()) + ") : " + height + "px"); } widget.setHeight(height + "px"); } else { widget.setHeight(relativeSize.getHeight() + "%"); VConsole.error(Util.getLayout(widget).getClass().getName() + " did not produce allocatedSpace for " + widget.getClass().getName()); } } if (relativeSize.getWidth() >= 0) { if (renderSpace != null) { int width = renderSpace.getWidth(); if (renderSpace.getScrollbarSize() > 0) { if (relativeSize.getHeight() > 100) { verticalScrollBar = true; } else if (relativeSize.getHeight() < 0 && renderSpace.getHeight() > 0 && widget.getOffsetHeight() > renderSpace.getHeight()) { verticalScrollBar = true; } } if (verticalScrollBar) { width -= renderSpace.getScrollbarSize(); } if (validatingLayouts && width <= 0) { zeroWidthComponents.add(cd.getComponent()); } width = (int) (width * relativeSize.getWidth() / 100.0); if (width < 0) { width = 0; } if (debugSizes) { VConsole.log("Widget " + Util.getSimpleName(widget) + "/" + getPid(widget.getElement()) + " relative width " + relativeSize.getWidth() + "% of " + renderSpace.getWidth() + "px (reported by " + Util.getSimpleName(parent) + "/" + (parent == null ? "?" : getPid(parent)) + ") : " + width + "px"); } widget.setWidth(width + "px"); } else { widget.setWidth(relativeSize.getWidth() + "%"); VConsole.error(Util.getLayout(widget).getClass().getName() + " did not produce allocatedSpace for " + widget.getClass().getName()); } } return true; }