List of usage examples for com.google.gwt.dom.client Style setMarginRight
public void setMarginRight(double value, Unit unit)
From source file:com.haulmont.cuba.web.toolkit.ui.client.aggregation.TableAggregationRow.java
License:Apache License
public void setCellWidth(int cellIx, int width) { // CAUTION: copied from VScrollTableRow with small changes final Element cell = DOM.getChild(tr, cellIx); Style wrapperStyle = cell.getFirstChildElement().getStyle(); int wrapperWidth = width; if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isOpera10()) { /*//from w w w . j a v a 2 s. com * Some versions of Webkit and Opera ignore the width * definition of zero width table cells. Instead, use 1px * and compensate with a negative margin. */ if (width == 0) { wrapperWidth = 1; wrapperStyle.setMarginRight(-1, Style.Unit.PX); } else { wrapperStyle.clearMarginRight(); } } wrapperStyle.setPropertyPx("width", wrapperWidth); cell.getStyle().setPropertyPx("width", width); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.fieldgrouplayout.CubaFieldGroupLayoutComponentSlot.java
License:Apache License
@Override public void positionHorizontally(double currentLocation, double allocatedSpace, double marginRight) { if (!isCaptionInline()) { super.positionHorizontally(currentLocation, allocatedSpace, marginRight); return;/*from w w w .ja v a 2 s . co m*/ } // CAUTION copied from VLayoutSlot.positionHorizontally(~) Style style = wrapper.getStyle(); double availableWidth = allocatedSpace; VCaption caption = getCaption(); Style captionStyle = caption != null ? caption.getElement().getStyle() : null; int captionWidth = getCaptionWidth(); boolean clearCaptionRight = false; boolean captionAboveCompnent; if (caption == null) { captionAboveCompnent = false; style.clearPaddingLeft(); clearCaptionRight = true; } else { captionAboveCompnent = !caption.shouldBePlacedAfterComponent(); if (!captionAboveCompnent) { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } captionStyle.clearLeft(); captionStyle.setRight(0, Style.Unit.PX); style.setPaddingRight(captionWidth, Style.Unit.PX); } else { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } style.setPaddingLeft(captionWidth, Style.Unit.PX); captionStyle.setLeft(0, Style.Unit.PX); captionStyle.clearRight(); clearCaptionRight = true; } } // Take into account right indicators double indicatorsWidth = 0; if (rightCaption != null) { indicatorsWidth = WidgetUtil.getRequiredWidth(rightCaption); availableWidth -= indicatorsWidth; if (availableWidth < 0) { availableWidth = 0; } style.setPaddingRight(indicatorsWidth, Style.Unit.PX); } else if (clearCaptionRight) { style.clearPaddingRight(); } if (marginRight > 0) { style.setMarginRight(marginRight, Style.Unit.PX); } else { style.clearMarginRight(); } if (isRelativeWidth()) { style.setPropertyPx("width", (int) availableWidth); } else { style.clearProperty("width"); } double allocatedContentWidth = 0; if (isRelativeWidth()) { String percentWidth = getWidget().getElement().getStyle().getWidth(); double percentage = parsePercent(percentWidth); allocatedContentWidth = availableWidth * (percentage / 100); reportActualRelativeWidth(Math.round((float) allocatedContentWidth)); } AlignmentInfo alignment = getAlignment(); if (!alignment.isLeft()) { double usedWidth; if (isRelativeWidth()) { if (isCaptionInline()) { usedWidth = allocatedContentWidth + indicatorsWidth + captionWidth; } else { usedWidth = allocatedContentWidth + indicatorsWidth; } } else { usedWidth = getWidgetWidth() + indicatorsWidth; } if (alignment.isHorizontalCenter()) { currentLocation += (allocatedSpace - usedWidth) / 2d; if (captionAboveCompnent) { captionStyle.setLeft(Math.round(usedWidth - captionWidth) / 2, Style.Unit.PX); } } else { currentLocation += (allocatedSpace - usedWidth); if (captionAboveCompnent) { captionStyle.setLeft(Math.round(usedWidth - captionWidth), Style.Unit.PX); } } } else { if (captionAboveCompnent) { captionStyle.setLeft(0, Style.Unit.PX); } } style.setLeft(Math.round(currentLocation), Style.Unit.PX); }
From source file:com.vaadin.client.SimpleTree.java
License:Apache License
public SimpleTree() { setElement(Document.get().createDivElement()); Style style = getElement().getStyle(); style.setProperty("whiteSpace", "nowrap"); style.setPadding(3, Unit.PX);// ww w .j a v a2s .com style.setPaddingLeft(12, Unit.PX); // handle styling style = handle.getStyle(); style.setDisplay(Display.NONE); style.setTextAlign(TextAlign.CENTER); style.setWidth(0.5, Unit.EM); style.setHeight(0.5, Unit.EM); style.setCursor(Cursor.POINTER); style.setBackgroundColor("gray"); style.setColor("white"); style.setPadding(4, Unit.PX); style.setMarginRight(3, Unit.PX); style.setLineHeight(0.5, Unit.EM); handle.setInnerHTML("+"); getElement().appendChild(handle); getElement().appendChild(text); // children styling style = children.getStyle(); style.setPaddingLeft(1.5, Unit.EM); style.setDisplay(Display.NONE); getElement().appendChild(children); addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (event.getNativeEvent().getEventTarget().cast() == handle) { if (children.getStyle().getDisplay().intern() == Display.NONE.getCssName()) { open(event.getNativeEvent().getAltKey()); } else { close(); } } else if (event.getNativeEvent().getEventTarget().cast() == text) { select(event); } } }, ClickEvent.getType()); }
From source file:com.vaadin.client.ui.layout.VLayoutSlot.java
License:Apache License
public void positionHorizontally(double currentLocation, double allocatedSpace, double marginRight) { Style style = wrapper.getStyle(); double availableWidth = allocatedSpace; VCaption caption = getCaption();/*from ww w. j av a2 s . c om*/ Style captionStyle = caption != null ? caption.getElement().getStyle() : null; int captionWidth = getCaptionWidth(); boolean captionAboveCompnent; if (caption == null) { captionAboveCompnent = false; style.clearPaddingRight(); } else { captionAboveCompnent = !caption.shouldBePlacedAfterComponent(); if (!captionAboveCompnent) { availableWidth -= captionWidth; if (availableWidth < 0) { availableWidth = 0; } captionStyle.clearLeft(); captionStyle.setRight(0, Unit.PX); style.setPaddingRight(captionWidth, Unit.PX); } else { captionStyle.setLeft(0, Unit.PX); captionStyle.clearRight(); style.clearPaddingRight(); } } if (marginRight > 0) { style.setMarginRight(marginRight, Unit.PX); } else { style.clearMarginRight(); } style.setPropertyPx("width", (int) availableWidth); double allocatedContentWidth = 0; if (isRelativeWidth()) { String percentWidth = getWidget().getElement().getStyle().getWidth(); double percentage = parsePercent(percentWidth); allocatedContentWidth = availableWidth * (percentage / 100); reportActualRelativeWidth(Math.round((float) allocatedContentWidth)); } style.setLeft(Math.round(currentLocation), Unit.PX); AlignmentInfo alignment = getAlignment(); if (!alignment.isLeft()) { double usedWidth; if (isRelativeWidth()) { usedWidth = allocatedContentWidth; } else { usedWidth = getWidgetWidth(); } double padding = (allocatedSpace - usedWidth); if (alignment.isHorizontalCenter()) { padding = padding / 2; } long roundedPadding = Math.round(padding); if (captionAboveCompnent) { captionStyle.setLeft(roundedPadding, Unit.PX); } widget.getElement().getStyle().setLeft(roundedPadding, Unit.PX); } else { if (captionAboveCompnent) { captionStyle.setLeft(0, Unit.PX); } // Reset left when changing back to align left widget.getElement().getStyle().clearLeft(); } }
From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java
License:Apache License
/** * Update the offset off the caption relative to the slot * <p>/*from w w w . j a va 2s . co m*/ * For internal use only. May be removed or replaced in the future. * * @param caption * The caption element * @deprecated As of 7.2, call or override * {@link #updateCaptionOffset(Element)} instead */ @Deprecated public void updateCaptionOffset(com.google.gwt.user.client.Element caption) { Element captionWrap = caption.getParentElement(); Style captionWrapStyle = captionWrap.getStyle(); captionWrapStyle.clearPaddingTop(); captionWrapStyle.clearPaddingRight(); captionWrapStyle.clearPaddingBottom(); captionWrapStyle.clearPaddingLeft(); Style captionStyle = caption.getStyle(); captionStyle.clearMarginTop(); captionStyle.clearMarginRight(); captionStyle.clearMarginBottom(); captionStyle.clearMarginLeft(); // Get caption position from the classname CaptionPosition captionPosition = getCaptionPositionFromElement(captionWrap); if (captionPosition == CaptionPosition.LEFT || captionPosition == CaptionPosition.RIGHT) { int captionWidth; if (layoutManager != null) { captionWidth = layoutManager.getOuterWidth(caption) - layoutManager.getMarginWidth(caption); } else { captionWidth = caption.getOffsetWidth(); } if (captionWidth > 0) { if (captionPosition == CaptionPosition.LEFT) { captionWrapStyle.setPaddingLeft(captionWidth, Unit.PX); captionStyle.setMarginLeft(-captionWidth, Unit.PX); } else { captionWrapStyle.setPaddingRight(captionWidth, Unit.PX); captionStyle.setMarginRight(-captionWidth, Unit.PX); } } } if (captionPosition == CaptionPosition.TOP || captionPosition == CaptionPosition.BOTTOM) { int captionHeight; if (layoutManager != null) { captionHeight = layoutManager.getOuterHeight(caption) - layoutManager.getMarginHeight(caption); } else { captionHeight = caption.getOffsetHeight(); } if (captionHeight > 0) { if (captionPosition == CaptionPosition.TOP) { captionWrapStyle.setPaddingTop(captionHeight, Unit.PX); captionStyle.setMarginTop(-captionHeight, Unit.PX); } else { captionWrapStyle.setPaddingBottom(captionHeight, Unit.PX); captionStyle.setMarginBottom(-captionHeight, Unit.PX); } } } }
From source file:com.vaadin.terminal.gwt.client.SimpleTree.java
License:Open Source License
public SimpleTree() { setElement(Document.get().createDivElement()); Style style = getElement().getStyle(); style.setProperty("whiteSpace", "nowrap"); style.setPadding(3, Unit.PX);//from www . jav a 2 s . c om style = handle.getStyle(); style.setDisplay(Display.NONE); style.setProperty("textAlign", "center"); style.setWidth(10, Unit.PX); style.setCursor(Cursor.POINTER); style.setBorderStyle(BorderStyle.SOLID); style.setBorderColor("#666"); style.setBorderWidth(1, Unit.PX); style.setMarginRight(3, Unit.PX); style.setProperty("borderRadius", "4px"); handle.setInnerHTML("+"); getElement().appendChild(handle); getElement().appendChild(text); style = children.getStyle(); style.setPaddingLeft(20, Unit.PX); style.setDisplay(Display.NONE); getElement().appendChild(children); addDomHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (event.getNativeEvent().getEventTarget().cast() == handle) { if (children.getStyle().getDisplay().intern() == Display.NONE.getCssName()) { open(event.getNativeEvent().getShiftKey()); } else { close(); } } else if (event.getNativeEvent().getEventTarget().cast() == text) { select(event); } } }, ClickEvent.getType()); }
From source file:ilarkesto.gwt.client.desktop.fields.AEditableDropdownField.java
License:Open Source License
private RadioButton createRadioButton(boolean horizontal, String key, String label) { RadioButton radioButton = new RadioButton(getId(), label); radioButton.getElement().setId(getId() + "_radiobutton_"); radioButton.setValue(isSelectedOptionKey(key)); if (getEditVetoMessage() != null) { radioButton.setEnabled(false);//from ww w . j a va 2s . c o m radioButton.setTitle(getEditVetoMessage()); } Style style = radioButton.getElement().getStyle(); style.setProperty("minWidth", "100px"); style.setProperty("minHeight", "32px"); style.setDisplay(Display.BLOCK); style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT); style.setWidth(horizontal ? getTextBoxWidth() / 2 : getTextBoxWidth(), Unit.PX); style.setMarginRight(Widgets.defaultSpacing, Unit.PX); if (NULL_KEY.equals(key)) { style.setColor(Colors.greyedText); } if (!isParentMultiField()) { radioButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (fieldEditorDialogBox == null) return; fieldEditorDialogBox.submit(); } }); } radioButtons.put(key, radioButton); return radioButton; }
From source file:ilarkesto.gwt.client.desktop.fields.AEditableMultiSelectionField.java
License:Open Source License
private IsWidget createCheckboxesEditorWidget(Collection<String> optionKeys) { checkboxes = new LinkedHashMap<String, CheckBox>(); boolean horizontal = isHorizontal(); Panel panel = horizontal ? new FlowPanel() : new VerticalPanel(); Collection<String> selectedKeys = getSelectedOptionKeys(); int inRow = 0; for (String key : optionKeys) { String label = getTextForOption(getValueForKey(key)); CheckBox checkBox = new CheckBox(label); checkBox.getElement().setId(getId() + "_checkbox_" + key); checkBox.setValue(selectedKeys.contains(key)); if (getEditVetoMessage() == null) { } else {/*ww w . j a va 2 s . co m*/ checkBox.setEnabled(false); checkBox.setTitle(getEditVetoMessage()); } updateStyle(checkBox); checkBox.addValueChangeHandler(new CheckboxChangeHandler(checkBox)); if (horizontal) { Style style = checkBox.getElement().getStyle(); style.setProperty("minWidth", "100px"); style.setDisplay(Display.BLOCK); style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT); style.setWidth(220, Unit.PX); style.setMarginRight(Widgets.defaultSpacing, Unit.PX); } checkboxes.put(key, checkBox); panel.add(checkBox); inRow++; if (horizontal && inRow >= 3) { panel.add(new HTML("<br>")); inRow = 0; } } if (horizontal) { panel.add(Widgets.clear()); } if (optionKeys.size() >= 10) { panel.add(new ActionButton(new SelectAllCheckboxesAction())); panel.add(new ActionButton(new DeselectAllCheckboxesAction())); } return panel; }
From source file:ilarkesto.gwt.client.desktop.Widgets.java
License:Open Source License
public static Widget horizontalLine(int margin) { SimplePanel spacer = new SimplePanel(); Style style = spacer.getElement().getStyle(); style.setFloat(Float.LEFT);/*from w ww .j ava 2 s . c o m*/ style.setWidth(1, Unit.PX); style.setHeight(100, Unit.PCT); style.setBackgroundColor("#999999"); style.setMarginLeft(margin, Unit.PX); style.setMarginRight(margin, Unit.PX); return spacer; }
From source file:org.guvnor.ala.ui.client.widget.artifact.ArtifactSelectorView.java
License:Apache License
@Override public void init(final ArtifactSelectorPresenter presenter) { this.presenter = presenter; final ArtifactListView artifactListView = presenter.getArtifactListView(); artifactListView.addColumn(buildSelectColumn(), getSelectColumnLabel()); artifactListView.setContentHeight("200px"); final Style style = artifactListView.asWidget().getElement().getStyle(); style.setMarginLeft(0, Style.Unit.PX); style.setMarginRight(0, Style.Unit.PX); artifactListContainer.add(artifactListView); }