List of usage examples for com.google.gwt.user.client.ui Widget setHeight
public void setHeight(String height)
From source file:org.opencms.gwt.client.property.CmsVfsModePropertyEditor.java
License:Open Source License
/** * Updates the panel height depending on the content of the current tab.<p> *//*from ww w . j a v a 2 s.c o m*/ protected void updateHeight() { int tabIndex = m_panel.getTabPanel().getSelectedIndex(); boolean changedTab = tabIndex != m_oldTabIndex; m_oldTabIndex = tabIndex; Widget tabWidget = m_panel.getTabPanel().getWidget(tabIndex); Element tabElement = tabWidget.getElement(); Element innerElement = tabElement.getFirstChildElement(); int contentHeight = CmsDomUtil.getCurrentStyleInt(innerElement, Style.height); int spaceLeft = m_dialog.getAvailableHeight(0); int newHeight = Math.min(spaceLeft, contentHeight) + 50; if ((m_panel.getTabPanel().getOffsetHeight() != newHeight) || changedTab) { m_panel.getTabPanel().setHeight(newHeight + "px"); if (CmsCoreProvider.get().isIe7()) { int selectedIndex = m_panel.getTabPanel().getSelectedIndex(); Widget widget = m_panel.getTabPanel().getWidget(selectedIndex); widget.setHeight((newHeight - 45) + "px"); m_dialog.center(); } } }
From source file:org.openremote.web.console.widget.ScreenIndicator.java
License:Open Source License
public ScreenIndicator(List<Integer> screenIds) { super(new HorizontalPanel(), CLASS_NAME); HorizontalPanel container = (HorizontalPanel) getWidget(); DOM.setIntStyleAttribute(getElement(), "zIndex", 1000); DOM.setStyleAttribute(getElement(), "overflow", "hidden"); container.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); this.screenIds = screenIds; screenIndicators = new ArrayList<Widget>(); if (screenIds != null) { width = INDICATOR_SIZE * ((screenIds.size() * 2) - 1); setWidth(width + "px"); setHeight(INDICATOR_SIZE + "px"); height = INDICATOR_SIZE;/*from ww w. j a v a 2s . co m*/ // Add a simple div for each screen for (int i = 0; i < screenIds.size(); i++) { int cellWidth = INDICATOR_SIZE; //cellWidth = i != screenIds.size()-1 ? cellWidth + INDICATOR_SPACING : cellWidth; Widget screenIndicator = new SimplePanel(); screenIndicator.setWidth(INDICATOR_SIZE + "px"); screenIndicator.setHeight(INDICATOR_SIZE + "px"); screenIndicator.setStylePrimaryName(ITEM_CLASS_NAME); screenIndicators.add(screenIndicator); container.add(screenIndicator); container.setCellWidth(screenIndicator, cellWidth + "px"); if (i < screenIds.size() - 1) { // Add a spacer Widget spacer = new SimplePanel(); spacer.setWidth(INDICATOR_SIZE + "px"); spacer.setHeight(INDICATOR_SIZE + "px"); spacer.setStylePrimaryName(SPACER_CLASS_NAME); container.add(spacer); container.setCellWidth(spacer, cellWidth + "px"); } } } }
From source file:org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox.java
License:Open Source License
public void setContent(Widget content) { this.content = content; if (content != null) { dialogContent.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); dialogContent.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); dialogContent.setWidget(0, 0, content); dialogContent.getCellFormatter().setStyleName(0, 0, "dialog-content"); DOM.setStyleAttribute(dialogContent.getCellFormatter().getElement(0, 0), "padding", //$NON-NLS-1$ "5px 10px 10px 10px"); //$NON-NLS-1$ content.setHeight("100%"); //$NON-NLS-1$ content.setWidth("100%"); //$NON-NLS-1$ }//from w w w . jav a2 s. c o m }
From source file:org.pentaho.mantle.client.admin.EmailTestDialog.java
License:Open Source License
public void setContent(Widget content) { this.content = content; if (content != null) { dialogContent.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); dialogContent.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); dialogContent.setWidget(0, 0, content); dialogContent.getCellFormatter().setStyleName(0, 0, "dialog-content"); DOM.setStyleAttribute(dialogContent.getCellFormatter().getElement(0, 0), "padding", //$NON-NLS-1$ "10px 20px 20px 20px"); //$NON-NLS-1$ content.setHeight("100%"); //$NON-NLS-1$ content.setWidth("100%"); //$NON-NLS-1$ }/*from www . j ava2 s .co m*/ }
From source file:org.pentaho.pac.client.AdminConsoleMasterDetailsPanel.java
License:Open Source License
public void addPage(int pageId, String toggleButtonLabel, final Widget page) { ToggleButton toggleButton = new ToggleButton(toggleButtonLabel); toggleButton.setStylePrimaryName("leftToggleButtons"); //$NON-NLS-1$ toggleButton.addClickListener(this); pageMap.put(pageId, new PageInfo(toggleButton, page)); leftPanel.addButton(toggleButton);//from w w w . jav a2 s .c om page.setWidth("100%"); //$NON-NLS-1$ page.setHeight("610px"); //$NON-NLS-1$ rightPanel.addPage(page); }
From source file:org.pentaho.ui.xul.gwt.AbstractGwtXulComponent.java
License:Open Source License
public void layout() { if (this instanceof XulContainer == false) { // Core version of parser doesn't call layout unless the node is a container... return;/* ww w . j a v a 2 s .co m*/ } setVisible(isVisible()); if (this.container != null) { this.container.clear(); } Object w = getManagedObject(); double totalFlex = 0.0; for (XulComponent comp : this.getChildNodes()) { if (comp.getManagedObject() == null) { continue; } if (comp.getFlex() > 0 && comp.isVisible()) { flexLayout = true; totalFlex += comp.getFlex(); } } // if(flexLayout) // gc.fill = GridBagConstraints.BOTH; List<XulComponent> nodes = this.getChildNodes(); XulContainer thisContainer = (XulContainer) this; Align alignment = (StringUtils.isEmpty(thisContainer.getAlign()) == false) ? Align.valueOf(thisContainer.getAlign().toUpperCase()) : null; // TODO: this is a different behavior than we implemented in Swing. if (!flexLayout && StringUtils.isEmpty(thisContainer.getAlign()) == false) { SimplePanel fillerPanel = new SimplePanel(); switch (alignment) { case END: container.add(fillerPanel); if (this.getOrientation() == Orient.VERTICAL) { // VBox and such ((VerticalPanel) container).setCellHeight(fillerPanel, "100%"); } else { ((HorizontalPanel) container).setCellWidth(fillerPanel, "100%"); } break; case CENTER: container.add(fillerPanel); if (this.getOrientation() == Orient.VERTICAL) { // VBox and such ((VerticalPanel) container).setCellHeight(fillerPanel, "50%"); } else { ((HorizontalPanel) container).setCellWidth(fillerPanel, "50%"); } break; } } for (int i = 0; i < children.size(); i++) { XulComponent comp = nodes.get(i); Object wrappedWidget = comp.getManagedObject(); if (wrappedWidget == null || !(wrappedWidget instanceof Widget)) { continue; } Widget component = (Widget) wrappedWidget; component.getElement().setId(comp.getId()); if (component == null) { continue; } SimplePanel componentWrapper = new SimplePanel(); componentWrapper.add(component); container.add(componentWrapper); if (this.getOrientation() == Orient.VERTICAL) { // VBox container.setWidth("100%"); } else { // HBox container.setHeight("100%"); } if (flexLayout) { int componentFlex = comp.getFlex(); if (componentFlex > 0) { String percentage = Math.round((componentFlex / totalFlex) * 100) + "%"; if (this.getOrientation() == Orient.VERTICAL) { // VBox ((VerticalPanel) container).setCellHeight(componentWrapper, percentage); ((VerticalPanel) container).setCellWidth(componentWrapper, "100%"); component.setWidth("100%"); if (comp.getFlex() > 0) { componentWrapper.setHeight("100%"); component.setHeight("100%"); } } else { // HBox ((HorizontalPanel) container).setCellWidth(componentWrapper, percentage); ((HorizontalPanel) container).setCellHeight(componentWrapper, "100%"); component.setHeight("100%"); if (comp.getFlex() > 0) { componentWrapper.setWidth("100%"); component.setHeight("100%"); } } } } Style wrapperStyle = componentWrapper.getElement().getStyle(); Style style = component.getElement().getStyle(); // By default 100%, respect hard-coded width if (this.getOrientation() == Orient.VERTICAL) { // VBox if (comp.getWidth() > 0) { style.setProperty("width", comp.getWidth() + "px"); } else { wrapperStyle.setProperty("width", "100%"); } if (comp.getHeight() > 0) { style.setProperty("height", comp.getHeight() + "px"); } else if (comp.getFlex() > 0) { wrapperStyle.setProperty("height", "100%"); } } else { // HBox if (comp.getHeight() > 0) { style.setProperty("height", comp.getHeight() + "px"); } else { wrapperStyle.setProperty("height", "100%"); } if (comp.getWidth() > 0) { style.setProperty("width", comp.getWidth() + "px"); } else if (comp.getFlex() > 0) { wrapperStyle.setProperty("width", "100%"); } } } // TODO: this is a different behavior than we implemented in Swing. if (!flexLayout && container != null) { SimplePanel fillerPanel = new SimplePanel(); if (alignment == null) { alignment = Align.START; } switch (alignment) { case START: if (this.getOrientation() != Orient.VERTICAL) { ((HorizontalPanel) container).setCellWidth(fillerPanel, "100%"); container.add(fillerPanel); } break; case CENTER: container.add(fillerPanel); if (this.getOrientation() == Orient.VERTICAL) { // VBox and such ((VerticalPanel) container).setCellHeight(fillerPanel, "50%"); } else { ((HorizontalPanel) container).setCellWidth(fillerPanel, "50%"); } break; case END: break; } } initialized = true; }
From source file:org.pentaho.ui.xul.gwt.tags.GwtFileUpload.java
License:Open Source License
@SuppressWarnings("deprecation") public void init(com.google.gwt.xml.client.Element srcEle, XulDomContainer container) { mainPanel = new VerticalPanel(); setManagedObject(mainPanel);/* w ww . ja va 2s . c o m*/ super.init(srcEle, container); if (!StringUtils.isEmpty(srcEle.getAttribute("action"))) { setAction(buildActionUrl(GWT.getModuleBaseURL(), srcEle.getAttribute("action"))); } if (!StringUtils.isEmpty(srcEle.getAttribute("onuploadsuccess"))) { setOnUploadSuccess(srcEle.getAttribute("onuploadsuccess")); } if (!StringUtils.isEmpty(srcEle.getAttribute("onuploadfailure"))) { setOnUploadFailure(srcEle.getAttribute("onuploadfailure")); } uploadForm = new FormPanel(); uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); uploadForm.setHeight(getHeight() + "px"); uploadForm.setWidth(getWidth() + "px"); // Create a panel to hold all of the form widgets. HorizontalPanel panel = new HorizontalPanel(); uploadForm.setWidget(panel); uploadForm.setVisible(true); // Create a FileUpload widget. upload = new FileUpload(); upload.setStylePrimaryName("gwt-StyledFileUpload"); upload.setName("uploadFormElement"); //$NON-NLS-1$ upload.getElement().setId("uploadFormElement"); upload.setVisible(true); upload.setHeight(getHeight() + "px"); upload.setWidth(getWidth() + "px"); upload.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { setSelectedFile(upload.getFilename()); } }); uploadPanel = new VerticalPanel(); // -- upload styling -- // String uploadButtonImage = srcEle.getAttribute("image"); String uploadButtonDisabledImage = srcEle.getAttribute("disabledimage"); hiddenPanel = new HTMLPanel("<div id='hidden_div' class='gwt_file_upload_hidden_div'></div>"); uploadTextBox = new GwtLabel(); uploadTextBox.setId("gwt_FileUpload_uploadTextBox"); GwtButton uploadButton = new GwtButton(); uploadButton.setId("gwt_FileUpload_uploadButton"); uploadButton.setHeight(22); final LabelWidget label = new LabelWidget("uploadFormElement"); label.setStyleName("gwt_file_upload_label"); // If "image" attribute has been defined in the fileupload control do not display the file textfield AND do not // set the button label. if (StringUtils.isEmpty(uploadButtonImage)) { uploadButton.setLabel("..."); final Widget labelWidget = (Widget) uploadTextBox.getManagedObject(); label.add(labelWidget); uploadTextBox.layout(); labelWidget.setHeight(getHeight() + "px"); labelWidget.setWidth((getWidth() - 55) + "px"); DOM.setStyleAttribute(labelWidget.getElement(), "lineHeight", getHeight() + "px"); } else { uploadButton.setImage(uploadButtonImage); uploadButton.setDisabledImage(uploadButtonDisabledImage); } label.add((Widget) uploadButton.getManagedObject()); uploadButton.layout(); hiddenPanel.add(upload, "hidden_div"); hiddenPanel.add(label, "hidden_div"); // -- upload styling -- // uploadPanel.add(hiddenPanel); panel.add(uploadPanel); mainPanel.add(uploadForm); if (getHeight() >= 0) { mainPanel.setHeight(getHeight() + "px"); } if (getWidth() >= 0) { mainPanel.setWidth(getWidth() + "px"); } uploadForm.addFormHandler(new FormHandler() { public void onSubmit(FormSubmitEvent event) { if (upload.getFilename() == null) { try { GwtFileUpload.this.getXulDomContainer().invoke(getOnUploadFailure(), new Object[] { new Throwable("No file has been selected. Please select the file to upload") }); return; } catch (XulException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public void onSubmitComplete(FormSubmitCompleteEvent event) { String results = event.getResults(); try { if (results != null && results.indexOf(ERROR) >= 0) { if (results.indexOf(ERROR) + ERROR.length() < results.length()) { String result = results.replaceAll("\\<.*?>", ""); GwtFileUpload.this.getXulDomContainer().invoke(getOnUploadFailure(), new Object[] { new Throwable(result) }); } } else { if (results != null) { String result = results.replaceAll("\\<.*?>", ""); GwtFileUpload.this.getXulDomContainer().invoke(getOnUploadSuccess(), new Object[] { result }); } else { GwtFileUpload.this.getXulDomContainer().invoke(getOnUploadFailure(), new Object[] { new Throwable("Unable to find upload service or " + "Upload service returned nothing") }); } } } catch (XulException xule) { xule.printStackTrace(); } } }); uploadForm.setWidth("100%"); }
From source file:org.sigmah.client.ui.view.contact.ContactView.java
License:Open Source License
private void fixTabViewHeight(final Widget tabView, final TabItem tabItem) { Timer timer = new Timer() { @Override/*from w ww. jav a2s.c o m*/ public void run() { if (tabView.isVisible() && tabItem == tabPanel.getSelectedItem()) { tabView.setHeight(tabItem.getHeight() + "px"); } } }; timer.schedule(200); }
From source file:org.utgenome.gwt.widget.client.Style.java
License:Apache License
public static void fullHeight(Widget w) { w.setHeight("100%"); }
From source file:rocket.widget.client.splitter.HorizontalSplitterPanel.java
License:Apache License
/** * This is the most important event handler that takes care of adjusting the * widths of the widgets before and after the splitter being moved. * /*from w ww. j ava 2 s. c o m*/ * @param event */ protected void onMouseMove(final MouseMoveEvent event) { Checker.notNull("parameter:event", event); while (true) { final Splitter splitter = (Splitter) event.getWidget(); // need to figure out if mouse has moved to the right or left... final int mouseX = event.getPageX(); final int splitterX = splitter.getElement().getAbsoluteLeft(); // if the mouse has not moved horizontally but vertically so exit... int delta = mouseX - splitterX; if (0 == delta) { break; } // grab the widgets before and after the splitter being dragged... final InternalPanel panel = this.getPanel(); final int panelIndex = panel.indexOf(splitter); final Widget beforeWidget = panel.get(panelIndex - 1); int beforeWidgetWidth = beforeWidget.getOffsetWidth() + delta; final Widget afterWidget = panel.get(panelIndex + 1); int afterWidgetWidth = afterWidget.getOffsetWidth() - delta; final int widthSum = beforeWidgetWidth + afterWidgetWidth; final List<SplitterItem> items = this.getItems(); // if the mouse moved left make sure the beforeWidget width is not // less than its minimumWidth. if (delta < 0) { final SplitterItem beforeWidgetItem = items.get(panelIndex / 2); final int minimumWidth = beforeWidgetItem.getMinimumSize(); if (beforeWidgetWidth < minimumWidth) { delta = minimumWidth - (beforeWidgetWidth - delta); beforeWidgetWidth = minimumWidth; afterWidgetWidth = widthSum - beforeWidgetWidth; } } // since the mouse moved right make sure the afterWidget width is // not less than its minimumWidth if (delta > 0) { final SplitterItem afterWidgetItem = items.get(panelIndex / 2 + 1); final int minimumWidth = afterWidgetItem.getMinimumSize(); if (afterWidgetWidth < minimumWidth) { delta = afterWidgetWidth + delta - minimumWidth; afterWidgetWidth = minimumWidth; beforeWidgetWidth = widthSum - afterWidgetWidth; } } // save! beforeWidget.setWidth(beforeWidgetWidth + "px"); afterWidget.setWidth(afterWidgetWidth + "px"); // update the coordinates of both the splitter and after widget... adjustXCoordinate(splitter, delta); adjustXCoordinate(afterWidget, delta); beforeWidget.setHeight("100%"); splitter.setHeight("100%"); afterWidget.setHeight("100%"); // its necessary to prevent the event to stop text selection in // opera. event.stop(); break; } }