List of usage examples for com.google.gwt.dom.client Style setOutlineStyle
public void setOutlineStyle(OutlineStyle value)
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 w w w . j a v a 2s .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.eas.widgets.boxes.DecoratorBox.java
public DecoratorBox(HasValue<T> aDecorated) { super();// www. j av a 2 s . c o m 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:jetbrains.jetpad.projectional.view.toGwt.BaseViewMapper.java
License:Apache License
@Override protected void registerSynchronizers(SynchronizersConfiguration conf) { super.registerSynchronizers(conf); Style targetStyle = getTarget().getStyle(); if (!isDomPosition()) { targetStyle.setPosition(Style.Position.ABSOLUTE); } else {/*from w w w . j av a 2s .c o m*/ targetStyle.setPosition(Style.Position.RELATIVE); } if (!isDomPosition() || !isDomLayout()) { final ReadableProperty<Rectangle> positionInParent; if (getParent() instanceof BaseViewMapper) { final BaseViewMapper<?, ?> parent = (BaseViewMapper<?, ?>) getParent(); positionInParent = new DerivedProperty<Rectangle>(getSource().bounds(), parent.getSource().bounds()) { @Override public Rectangle doGet() { Rectangle sourceBounds = getSource().bounds().get(); Rectangle parentSourceBounds = parent.getSource().bounds().get(); return sourceBounds.sub(parentSourceBounds.origin); } }; } else { positionInParent = getSource().bounds(); } final Value<Boolean> valid = new Value<>(false); conf.add(Synchronizers.forEventSource(EventSources.composite(positionInParent, getSource().border()), new Runnable() { @Override public void run() { valid.set(false); whenValid(new Runnable() { @Override public void run() { if (valid.get()) return; final Rectangle value = positionInParent.get(); Style style = getTarget().getStyle(); if (!isDomPosition()) { style.setLeft(value.origin.x, Style.Unit.PX); style.setTop(value.origin.y, Style.Unit.PX); } if (!isDomLayout()) { int width = value.dimension.x; int height = value.dimension.y; style.setWidth(width, Style.Unit.PX); style.setHeight(height, Style.Unit.PX); } valid.set(true); } }); } })); } if (!isCustomBackgroundSync()) { conf.add(Synchronizers.forPropsOneWay(getSource().background(), new WritableProperty<Color>() { @Override public void set(Color value) { Style style = getTarget().getStyle(); if (value == null) { style.setBackgroundColor(null); } else { style.setBackgroundColor(value.toCssColor()); } } })); } conf.add(Synchronizers.forPropsOneWay(getSource().border(), new WritableProperty<Color>() { @Override public void set(Color value) { Style style = getTarget().getStyle(); if (value != null) { style.setOutlineColor(value.toCssColor()); style.setOutlineWidth(1, Style.Unit.PX); style.setOutlineStyle(Style.OutlineStyle.SOLID); } else { style.clearOutlineStyle(); style.clearOutlineColor(); style.clearBorderWidth(); } } })); conf.add(Synchronizers.forPropsOneWay(getSource().visible(), new WritableProperty<Boolean>() { @Override public void set(final Boolean value) { whenValid(new Runnable() { @Override public void run() { getTarget().getStyle().setDisplay(value ? Style.Display.BLOCK : Style.Display.NONE); } }); } })); conf.add(Synchronizers.forPropsOneWay(getSource().hasShadow(), new WritableProperty<Boolean>() { @Override public void set(Boolean value) { if (value) { getTarget().getStyle().setProperty("boxShadow", "2px 2px 4px black"); } else { getTarget().getStyle().setProperty("boxShadow", null); } } })); }
From source file:jetbrains.jetpad.projectional.view.toGwt.ViewContainerToElementMapper.java
License:Apache License
public ViewContainerToElementMapper(ViewContainer source, Element target, final boolean eventsDisabled) { super(source, target); myCtx = new ViewToDomContext() { @Override/* www . j ava 2 s.c om*/ public ReadableProperty<Rectangle> visibleArea() { return myVisibleArea; } @Override public MapperFactory<View, Element> getFactory() { return ViewMapperFactory.factory(this); } @Override public Boolean areEventsDisabled() { return eventsDisabled; } }; disablePopup(myRootDiv); target.appendChild(myRootDiv); myRootDiv.setTabIndex(0); final Style rootDivStyle = myRootDiv.getStyle(); rootDivStyle.setPosition(Style.Position.RELATIVE); rootDivStyle.setPadding(0, Style.Unit.PX); rootDivStyle.setOverflow(Style.Overflow.VISIBLE); rootDivStyle.setOutlineStyle(Style.OutlineStyle.NONE); }
From source file:stroom.widget.htree.client.LayeredCanvas.java
License:Apache License
private Canvas createLayer(final String name) { Canvas canvas = Canvas.createIfSupported(); if (canvas != null) { layerMap.put(name, canvas);/*from w ww . j av a 2 s . c om*/ final Style style = canvas.getElement().getStyle(); style.setPosition(Position.ABSOLUTE); style.setLeft(0, Unit.PX); style.setTop(0, Unit.PX); style.setWidth(width, Unit.PX); style.setHeight(height, Unit.PX); style.setOutlineStyle(OutlineStyle.NONE); canvas.setCoordinateSpaceWidth(width); canvas.setCoordinateSpaceHeight(height); add(canvas); } return canvas; }