List of usage examples for com.google.gwt.user.client.ui Widget setWidth
public void setWidth(String width)
From source file:org.openelis.gwt.widget.tree.TreeColumn.java
License:Open Source License
public Widget getDisplayWidget(TreeDataItem row) { TableDataCell cell = new TableDataCell(null); if (columnIndex < row.cells.size()) cell = row.cells.get(columnIndex); Widget wid = null; Object val = null; if (colWidget instanceof CheckBox) { wid = new CheckBoxContainer(); IconContainer icon = new IconContainer(); if (CheckBox.CHECKED.equals(cell.getValue())) icon.setStyleName(CheckBox.CHECKED_STYLE); else if (controller.queryMode && cell.getValue() == null) icon.setStyleName(CheckBox.UNKNOWN_STYLE); else//from w w w .j a v a 2 s. co m icon.setStyleName(CheckBox.UNCHECKED_STYLE); setAlign(HasHorizontalAlignment.ALIGN_CENTER); ((AbsolutePanel) wid).add(icon); DOM.setStyleAttribute(wid.getElement(), "align", "center"); wid.setWidth((currentWidth) + "px"); } else { if (colWidget instanceof AutoComplete) { if (controller.queryMode) { val = cell.getValue(); if (val == null) val = ""; } else { TableDataRow vrow = (TableDataRow) cell.getValue(); if (vrow != null) ((AutoComplete) colWidget).setSelection(vrow); else ((AutoComplete) colWidget).setSelection(null, ""); val = ((AutoComplete) colWidget).getTextBoxDisplay(); } } else if (colWidget instanceof Dropdown) { if (cell.getValue() instanceof ArrayList) ((Dropdown) colWidget).setSelectionKeys((ArrayList<Object>) cell.getValue()); else ((Dropdown) colWidget).setSelection(cell.getValue()); val = ((Dropdown) colWidget).getTextBoxDisplay(); } else { ((HasField) colWidget).setFieldValue(cell.getValue()); } if (val == null) val = ((HasField) colWidget).getFieldValue(); Label label = new Label(""); if (colWidget instanceof org.openelis.gwt.widget.Label) label.setStyleName(colWidget.getStyleName()); else label.setStyleName("ScreenLabel"); if (val != null) { if (colWidget instanceof CalendarLookUp) { label.setText((((CalendarLookUp) colWidget).getField().format())); } else if (colWidget instanceof AutoComplete && controller.queryMode) { label.setText((String) val); } else if (colWidget instanceof DropdownWidget) { label.setText(((DropdownWidget) colWidget).getTextBoxDisplay()); } else if (colWidget instanceof TextBoxBase) { label.setText(((TextBoxBase) colWidget).getText()); } else if (colWidget instanceof Label) label.setText(((Label) colWidget).getText()); } label.setWordWrap(false); wid = label; wid.setWidth((currentWidth) + "px"); } setExceptions(wid, cell.exceptions); wid.addStyleName("TableWidget"); return wid; }
From source file:org.openelis.gwt.widget.tree.TreeColumn.java
License:Open Source License
public Widget getWidgetEditor(TableDataRow row) { TableDataCell cell = new TableDataCell(null); if (columnIndex < row.cells.size()) cell = row.cells.get(columnIndex); Widget editor = colWidget; if (colWidget instanceof CheckBox) { CheckBoxContainer ap = new CheckBoxContainer(); ((CheckBox) editor).setValue((String) cell.getValue()); ap.setWidth((currentWidth) + "px"); ap.add(editor);/*from w w w . j ava 2s . c o m*/ return ap; } editor = colWidget; editor.setWidth((currentWidth) + "px"); if (colWidget instanceof AutoComplete) { if (controller.queryMode) { ((AutoComplete) colWidget).textbox.setText((String) cell.getValue()); } else { TableDataRow vrow = (TableDataRow) cell.getValue(); if (vrow != null) ((AutoComplete) colWidget).setSelection(vrow); else ((AutoComplete) colWidget).setSelection(null, ""); } } else if (colWidget instanceof Dropdown) { if (cell.getValue() instanceof ArrayList) ((Dropdown) colWidget).setSelectionKeys((ArrayList<Object>) cell.getValue()); else ((Dropdown) colWidget).setSelection(cell.getValue()); } else ((HasField) editor).setFieldValue(cell.getValue()); ((HasField) editor).clearExceptions(); setExceptions(editor, cell.exceptions); editor.addStyleName("TableWidget"); return editor; }
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;// w w w. java 2 s . 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 ww w .j ava 2s . co 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$ }/* w w w . ja v a 2 s . c o 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 . j a va2s. c o m*/ 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;/* w w w . jav a2 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);//from www . j a va2 s .c om 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.rstudio.studio.client.application.ui.ApplicationWindow.java
License:Open Source License
@Inject public ApplicationWindow(ApplicationHeader applicationHeader, GlobalDisplay globalDisplay, Provider<CodeSearch> pCodeSearch) { globalDisplay_ = globalDisplay;//from w w w . j av a 2 s .c o m pCodeSearch_ = pCodeSearch; // occupy full client area of the window Window.enableScrolling(false); Window.setMargin("0px"); // app ui contained within a vertical panel applicationPanel_ = new LayoutPanel(); // header bar applicationHeader_ = applicationHeader; Widget applicationHeaderWidget = applicationHeader_.asWidget(); applicationHeaderWidget.setWidth("100%"); applicationPanel_.add(applicationHeader_); updateHeaderTopBottom(); applicationHeaderWidget.setVisible(false); // main view container initWidget(applicationPanel_); }
From source file:org.rstudio.studio.client.projects.model.ProjectTemplateWidget.java
License:Open Source License
public ProjectTemplateWidget(ProjectTemplateDescription description) { widgets_ = new ArrayList<ProjectTemplateWidgetItem>(); // initialize widgets JsArray<ProjectTemplateWidgetDescription> descriptions = description.getWidgetDescription(); int n = descriptions.length(); for (int i = 0; i < n; i++) widgets_.add(createWidget(descriptions.get(i))); // initialize panel VerticalPanel leftPanel = new VerticalPanel(); VerticalPanel rightPanel = new VerticalPanel(); for (int i = 0; i < n; i++) { String position = StringUtil.notNull(descriptions.get(i).getPosition()); Widget widget = widgets_.get(i); if ("right".equals(position.toLowerCase())) rightPanel.add(widget);/* w ww. j a va 2 s. c om*/ else leftPanel.add(widget); } int nLeft = leftPanel.getWidgetCount(); int nRight = rightPanel.getWidgetCount(); Widget primaryWidget; if (nLeft == 0 && nRight == 0) primaryWidget = new FlowPanel(); else if (nRight == 0) primaryWidget = leftPanel; else if (nLeft == 0) primaryWidget = rightPanel; else { // both sides have widgets -- populate appropriately HorizontalPanel panel = new HorizontalPanel(); panel.add(leftPanel); panel.add(rightPanel); primaryWidget = panel; } primaryWidget.setWidth("100%"); initWidget(primaryWidget); }