List of usage examples for com.google.gwt.dom.client Style setDisplay
public void setDisplay(Display value)
From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java
License:Apache License
public static String trimToWidth(String s, String style, int pxWidth, String ellipsis) { if (pxWidth <= 20) { return s; }/* www . ja v a 2 s. c o m*/ ellipsis = ellipsis == null ? "\u2026" : ellipsis; int r0 = 0; int r1 = s.length(); Label l = new Label(); setElementStyle(l.getElement(), style); Style cStyle = l.getElement().getStyle(); cStyle.setPosition(Position.ABSOLUTE); cStyle.setLeft(0, Unit.PX); cStyle.setTop(0, Unit.PX); cStyle.setDisplay(Display.INLINE_BLOCK); cStyle.setProperty("whitespace", "nowrap"); cStyle.setProperty("visibility", "hidden"); RootPanel.get().add(l); boolean tried = false; while (true) { int mid = (r1 - r0) / 2 + r0; String t = tried ? s.substring(0, mid) + ellipsis : s; l.setText(t); if (l.getOffsetWidth() <= pxWidth) { if (!tried || (r1 - r0) <= 1) { RootPanel.get().remove(l); return t; } r0 = mid; } else { if (!tried) { tried = true; } else { r1 = mid; } } } }
From source file:com.bearsoft.gwt.ui.widgets.DecoratorBox.java
public void setWidget(HasValue<T> w) { if (decorated != w) { if (changeValueHandler != null) { changeValueHandler.removeHandler(); }/*from ww w . ja va 2 s . c o m*/ if (keyDownHandler != null) keyDownHandler.removeHandler(); if (keyUpHandler != null) keyUpHandler.removeHandler(); if (keyPressHandler != null) keyPressHandler.removeHandler(); if (focusHandler != null) focusHandler.removeHandler(); if (blurHandler != null) blurHandler.removeHandler(); if (decorated instanceof Widget) { ((Widget) decorated).removeFromParent(); } decorated = w; if (decorated != null) { changeValueHandler = decorated.addValueChangeHandler(new ValueChangeHandler<T>() { @Override public void onValueChange(ValueChangeEvent<T> event) { fireValueChangeEvent(); } }); if (decorated instanceof Widget) { CommonResources.INSTANCE.commons().ensureInjected(); ((Widget) decorated).getElement() .addClassName(CommonResources.INSTANCE.commons().borderSized()); Style style = ((Widget) decorated).getElement().getStyle(); style.setBorderWidth(0, Style.Unit.PX); style.setPadding(0, Style.Unit.PX); style.setMargin(0, Style.Unit.PX); style.setPosition(Style.Position.ABSOLUTE); style.setDisplay(Style.Display.INLINE_BLOCK); style.setLeft(0, Style.Unit.PX); style.setTop(0, Style.Unit.PX); style.setHeight(100, Style.Unit.PCT); style.setWidth(100, Style.Unit.PCT); style.setOutlineStyle(Style.OutlineStyle.NONE); style.setBackgroundColor("inherit"); style.setColor("inherit"); contentWrapper.setWidget((Widget) decorated); } if (decorated instanceof HasKeyDownHandlers) { keyDownHandler = ((HasKeyDownHandlers) decorated).addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { KeyDownEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasKeyUpHandlers) { keyUpHandler = ((HasKeyUpHandlers) decorated).addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { KeyUpEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasKeyPressHandlers) { keyPressHandler = ((HasKeyPressHandlers) decorated).addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { KeyPressEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasFocusHandlers) { focusHandler = ((HasFocusHandlers) decorated).addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { DecoratorBox.this.getElement().addClassName(DECORATOR_FOCUSED_CLASS_NAME); FocusEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasBlurHandlers) { blurHandler = ((HasBlurHandlers) decorated).addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { DecoratorBox.this.getElement().removeClassName(DECORATOR_FOCUSED_CLASS_NAME); BlurEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } } } }
From source file:com.dianaui.universal.core.client.ui.DateTimePicker.java
License:Apache License
@Override public void setVisible(final boolean visible) { Style style = container.getElement().getStyle(); if (visible) { style.setDisplay(Style.Display.BLOCK); style.setZIndex(9999);//from www . j a v a2 s .com style.setPosition(Style.Position.ABSOLUTE); style.setProperty("right", "auto"); } else { super.setVisible(false); style.clearDisplay(); style.clearZIndex(); style.clearPosition(); style.clearTop(); style.clearLeft(); } }
From source file:com.dianaui.universal.core.client.ui.InlineHelpBlock.java
License:Apache License
public InlineHelpBlock() { super();//from w w w . jav a 2 s. c o m Style style = getElement().getStyle(); style.setDisplay(Display.INLINE_BLOCK); style.setMarginTop(0, Unit.PX); style.setMarginBottom(5, Unit.PX); style.setPaddingLeft(10, Unit.PX); }
From source file:com.eas.widgets.boxes.DecoratorBox.java
public DecoratorBox(HasValue<T> aDecorated) { super();/*from w w w .j a v a2s. com*/ decorated = aDecorated; if (decorated instanceof HasValue<?>) { decorated.addValueChangeHandler(new ValueChangeHandler<T>() { @Override public void onValueChange(ValueChangeEvent<T> event) { setClearButtonVisible(nullable && event.getValue() != null); } }); } if (decorated instanceof HasDecorations) { HasWidgets container = ((HasDecorations) decorated).getContainer(); ((Widget) container).addStyleName("decorator"); container.add(selectButton); container.add(clearButton); initWidget((Widget) decorated); } else { CommonResources.INSTANCE.commons().ensureInjected(); ((Widget) decorated).getElement().addClassName(CommonResources.INSTANCE.commons().borderSized()); Style style = ((Widget) decorated).getElement().getStyle(); style.setMargin(0, Style.Unit.PX); style.setPosition(Style.Position.ABSOLUTE); style.setDisplay(Style.Display.INLINE_BLOCK); style.setLeft(0, Style.Unit.PX); style.setTop(0, Style.Unit.PX); style.setHeight(100, Style.Unit.PCT); style.setWidth(100, Style.Unit.PCT); style.setOutlineStyle(Style.OutlineStyle.NONE); FlowPanel panel = new FlowPanel(); panel.addStyleName("decorator"); initWidget(panel); panel.add((Widget) decorated); panel.add(selectButton); panel.add(clearButton); } ((Widget) decorated).addStyleName("decorator-content"); selectButton.getElement().addClassName("decorator-select"); selectButton.getElement().getStyle().setDisplay(Style.Display.NONE); selectButton.getElement().getStyle().setHeight(100, Style.Unit.PCT); selectButton.getElement().getStyle().setPosition(Style.Position.RELATIVE); clearButton.getElement().addClassName("decorator-clear"); clearButton.getElement().getStyle().setDisplay(Style.Display.NONE); clearButton.getElement().getStyle().setHeight(100, Style.Unit.PCT); clearButton.getElement().getStyle().setPosition(Style.Position.RELATIVE); selectButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { selectValue(); } }, ClickEvent.getType()); clearButton.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { clearValue(); setFocus(true); } }, ClickEvent.getType()); organizeButtonsContent(); getElement().<XElement>cast().addResizingTransitionEnd(this); if (decorated instanceof HasValue<?>) { changeValueHandler = decorated.addValueChangeHandler(new ValueChangeHandler<T>() { @Override public void onValueChange(ValueChangeEvent<T> event) { fireValueChangeEvent(); } }); } if (decorated instanceof HasKeyDownHandlers) { keyDownHandler = ((HasKeyDownHandlers) decorated).addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { KeyDownEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasKeyUpHandlers) { keyUpHandler = ((HasKeyUpHandlers) decorated).addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { KeyUpEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasKeyPressHandlers) { keyPressHandler = ((HasKeyPressHandlers) decorated).addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { KeyPressEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasFocusHandlers) { focusHandler = ((HasFocusHandlers) decorated).addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { FocusEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } if (decorated instanceof HasBlurHandlers) { blurHandler = ((HasBlurHandlers) decorated).addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { BlurEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this); } }); } }
From source file:com.googlesource.gerrit.plugins.labelui.client.LabelPanel.java
License:Apache License
private static void center(Image image) { Style s = image.getElement().getStyle(); s.setProperty("margin-left", "auto"); s.setProperty("margin-right", "auto"); s.setDisplay(Display.BLOCK); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.groupbox.CubaGroupBoxWidget.java
License:Apache License
public void setCollapsable(boolean collapsable) { Style expanderStyle = expander.getStyle(); if (collapsable) { expanderStyle.clearProperty("display"); removeStyleDependentName("nocollapsable"); } else {//w w w .j a v a 2 s .com addStyleDependentName("nocollapsable"); expanderStyle.setDisplay(Style.Display.NONE); } Tools.textSelectionEnable(captionNode, !collapsable); this.collapsable = collapsable; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.sourcecodeeditor.CubaSuggestPopup.java
License:Apache License
public CubaSuggestPopup() { Style style = loadingImage.getElement().getStyle(); style.clearWidth(); style.clearHeight(); style.setDisplay(Style.Display.BLOCK); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.table.CubaScrollTableWidget.java
License:Apache License
public void setPresentationsMenu(Widget presentationsMenu) { if (_delegate.presentationsMenu != presentationsMenu) { Style presentationsIconStyle = ((CubaScrollTableHead) tHead).presentationsEditIcon.getElement() .getStyle();/*ww w .ja va2s .c om*/ if (presentationsMenu == null) { presentationsIconStyle.setDisplay(Style.Display.NONE); } else { presentationsIconStyle.setDisplay(Style.Display.BLOCK); } } _delegate.presentationsMenu = presentationsMenu; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.treetable.CubaTreeTableWidget.java
License:Apache License
public void setPresentationsMenu(Widget presentationsMenu) { if (_delegate.presentationsMenu != presentationsMenu) { Style presentationsIconStyle = ((CubaTreeTableTableHead) tHead).presentationsEditIcon.getElement() .getStyle();/*from w w w .j a va 2s . com*/ if (presentationsMenu == null) { presentationsIconStyle.setDisplay(Style.Display.NONE); } else { presentationsIconStyle.setDisplay(Style.Display.BLOCK); } } _delegate.presentationsMenu = presentationsMenu; }