Example usage for com.google.gwt.dom.client Style setColor

List of usage examples for com.google.gwt.dom.client Style setColor

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style setColor.

Prototype

public void setColor(String value) 

Source Link

Usage

From source file:co.fxl.gui.gwt.GWTStyleColor.java

License:Open Source License

void setColor(String color, com.google.gwt.dom.client.Style stylable) {
    stylable.setColor(color);
}

From source file:com.bearsoft.gwt.ui.widgets.DecoratorBox.java

public void setWidget(HasValue<T> w) {
    if (decorated != w) {
        if (changeValueHandler != null) {
            changeValueHandler.removeHandler();
        }/* w  ww.  j a  v  a  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.goodow.wave.client.wavepanel.blip.SetColor.java

License:Apache License

@Override
public void onBrowserEvent(final Event event) {
    if (DOM.eventGetType(event) == Event.ONCLICK) {
        if (changeElm == null) {
            Window.alert("changeElm is null!");
            return;
        }//  w  w  w .j a v  a2 s .  c  om

        NodeList<Element> aTags = changeElm.getElementsByTagName("span");
        Element aTag = aTags.getItem(1);
        Element elm = Element.as(event.getEventTarget());
        Style elmStyle = elm.getStyle();
        Style aTagStyle = aTag.getStyle();

        if (elm.getTitle().equals("White") || elm.getTitle().equals("20% Black")) {
            aTagStyle.setBackgroundColor(elmStyle.getBackgroundColor());
            aTagStyle.setColor("black");
            aTagStyle.setBorderStyle(BorderStyle.SOLID);
            aTagStyle.setBorderWidth(1, Unit.PX);
            aTagStyle.setBorderColor("black");
            aTagStyle.setTextDecoration(TextDecoration.NONE);
        } else {
            if (!aTagStyle.getBorderWidth().equals("")) {
                aTagStyle.clearBorderColor();
                aTagStyle.clearBorderStyle();
                aTagStyle.clearBorderWidth();
            }
            aTagStyle.setTextDecoration(TextDecoration.NONE);
            aTagStyle.setBackgroundColor(elmStyle.getBackgroundColor());
            aTagStyle.setColor("white");
        }
        // Window.alert("title:" + elm.getTitle() + ";color:" + elm.getStyle().getBackgroundColor());
    }
}

From source file:com.googlecode.gwtquake.client.GwtQuake.java

License:Open Source License

public void onModuleLoad() {
    // Initialize drivers.
    Document doc = Document.get();
    doc.setTitle("GWT Quake II");
    BodyElement body = doc.getBody();/*  www  .  j a  v  a 2  s  .  co m*/
    Style style = body.getStyle();
    style.setPadding(0, Unit.PX);
    style.setMargin(0, Unit.PX);
    style.setBorderWidth(0, Unit.PX);
    style.setProperty("height", "100%");
    style.setBackgroundColor("#000");
    style.setColor("#888");

    //   Window.alert("UA: " + userAgent+ " type: " + browserType);

    boolean wireframe = ("" + Window.Location.getHash()).indexOf("wireframe") != -1;

    canvas = (CanvasElement) doc.createElement("canvas");
    video = doc.createElement("video");

    w = Window.getClientWidth();
    h = Window.getClientHeight();
    canvas.setWidth(w);
    canvas.setHeight(h);
    style = canvas.getStyle();
    style.setProperty("height", "100%");
    style.setProperty("width", "100%");

    style = video.getStyle();
    style.setProperty("height", "100%");
    style.setProperty("width", "100%");
    style.setProperty("display", "none");

    body.appendChild(canvas);
    body.appendChild(video);

    try {
        Globals.autojoin.value = Window.Location.getHash().indexOf("autojoin") != -1 ? 1.0f : 0.0f;
        final Renderer renderer = wireframe ? new GwtWireframeGLRenderer(canvas)
                : new GwtWebGLRenderer(canvas, video);
        Globals.re = renderer;

        ResourceLoader.impl = new GwtResourceLoaderImpl();
        Compatibility.impl = new CompatibilityImpl();

        Sound.impl = new GwtSound();
        NET.socketFactory = new WebSocketFactoryImpl();
        //      Sys.impl = new Sys.SysImpl() {
        //        public void exit(int status) {
        //          Window.alert("Something's rotten in Denmark");
        //          Window.Location.assign("gameover.html");
        //        }
        //      };

        // Flags.
        QuakeCommon.Init(new String[] { "GQuake" });

        // Enable stdout.
        Globals.nostdout = ConsoleVariables.Get("nostdout", "0", 0);

        Window.addResizeHandler(new ResizeHandler() {

            public void onResize(ResizeEvent event) {
                if (Window.getClientWidth() == w && Window.getClientHeight() == h) {
                    return;
                }

                w = Window.getClientWidth();
                h = Window.getClientHeight();

                renderer.GLimp_SetMode(new Dimension(w, h), 0, false);
            }
        });

        //      QuakeServer.main(new String[0], new DummySNetImpl(), false);

        timer = new Timer() {
            double startTime = Duration.currentTimeMillis();

            @Override
            public void run() {
                try {
                    double curTime = Duration.currentTimeMillis();
                    boolean pumping = ResourceLoader.Pump();
                    if (pumping) {
                        Screen.UpdateScreen2();
                    } else {
                        int dt = (int) (curTime - startTime);
                        GwtKBD.Frame(dt);
                        QuakeCommon.Frame(dt);
                    }
                    startTime = curTime;
                    timer.schedule(ResourceLoader.Pump() ? LOADING_DELAY : INTER_FRAME_DELAY);
                } catch (Exception e) {
                    Compatibility.printStackTrace(e);
                }
            }
        };
        timer.schedule(INTER_FRAME_DELAY);
    } catch (Exception e) {
        Compatibility.printStackTrace(e);
        DivElement div = doc.createDivElement();
        div.setInnerHTML(NO_WEBGL_MESSAGE);
        body.appendChild(div);
    }
}

From source file:com.googlesource.gerrit.plugins.labelui.client.LabelPanel.java

License:Apache License

private static Label createLabelLabel(LabelInfo label) {
    Label l = new Label(label.name());
    Style s = l.getElement().getStyle();
    s.setCursor(Cursor.DEFAULT);/* ww w. j  ava  2s  .com*/
    if (label.rejected() != null) {
        s.setColor(COLOR_RED);
        l.setTitle("Rejected by " + label.rejected().name());
    } else if (label.approved() != null) {
        s.setColor(COLOR_GREEN);
        l.setTitle("Approved by " + label.approved().name());
    }
    return l;
}

From source file:com.googlesource.gerrit.plugins.labelui.client.LabelPanel.java

License:Apache License

public static Label createValueLabel(String formattedValue, String valueText, short value) {
    Label l = new Label(formattedValue);
    if (valueText != null) {
        l.setTitle(valueText);//  ww w. j  av  a 2 s.c  o m
    }
    Style s = l.getElement().getStyle();
    s.setTextAlign(TextAlign.CENTER);
    s.setCursor(Cursor.DEFAULT);
    if (value > 0) {
        s.setColor(COLOR_GREEN);
    } else if (value < 0) {
        s.setColor(COLOR_RED);
    } else {
        // make label invisible, we cannot omit it since we need the label to show
        // a tooltip
        s.setColor("transparent");
    }
    return l;
}

From source file:com.sciencegadgets.client.ui.LinkPrompt.java

License:Open Source License

public void setColor(String hexColor) {
    Style labelStyle = colorLabel.getElement().getStyle();
    if (hexColor == null || hexColor.length() != 6) {
        if ("".equals(hexColor)) {
            labelStyle.clearColor();/*from  w ww .j av  a2s  . c o m*/
            labelStyle.clearFontWeight();
        } else {
            labelStyle.setColor("red");
            labelStyle.setFontWeight(FontWeight.BOLD);
        }
        HashMap<Parameter, String> pMap = setMapParameters();
        pMap.remove(Parameter.color);
        updateLinks(pMap);
        return;
    }
    try {
        Integer.valueOf(hexColor.substring(0, 2), 16);
        Integer.valueOf(hexColor.substring(2, 4), 16);
        Integer.valueOf(hexColor.substring(4, 6), 16);
    } catch (NumberFormatException e) {
        labelStyle.setColor("red");
        labelStyle.setFontWeight(FontWeight.BOLD);
        return;
    }

    labelStyle.clearColor();
    labelStyle.setFontWeight(FontWeight.BOLD);

    //      HashMap<Parameter, String> algActivityMap = URLParameters
    //            .getParameterMap();
    //      algActivityMap.put(Parameter.themecolor, hexColor);
    //      URLParameters.setParameters(algActivityMap, false);
    URLParameters.addParameter(Parameter.color, hexColor, true);
    initialColor = hexColor;

    HashMap<Parameter, String> pMap = setMapParameters();
    pMap.put(Parameter.color, hexColor);
    updateLinks(pMap);
}

From source file:com.sciencegadgets.client.ui.LinkPrompt.java

License:Open Source License

boolean isValidSpec(Label label, TextBox textBox, ValueListBox<String> listBox) {
    Style labelStyle = label.getElement().getStyle();

    if ("".equals(textBox.getValue()) && listBox.getValue() == null) {
        labelStyle.clearColor();/*from  w  w w  . j ava 2  s.  c om*/
        labelStyle.clearFontWeight();
        return false;
    }

    boolean isValid;
    try {
        Double value = Double.parseDouble(textBox.getValue());
        if (value > 0 && listBox.getValue() != null) {
            isValid = true;
        } else {
            isValid = false;
        }
    } catch (NumberFormatException e) {
        isValid = false;
    }

    if (isValid) {
        labelStyle.clearColor();
        labelStyle.setFontWeight(FontWeight.BOLD);
    } else {
        labelStyle.setColor("red");
        labelStyle.setFontWeight(FontWeight.BOLD);
    }
    return isValid;
}

From source file:com.sciencegadgets.client.ui.SelectionButton.java

License:Open Source License

public void setEnabled(boolean enable) {
    this.isEnabled = enable;
    Style style = getElement().getStyle();
    if (enable) {
        style.clearColor();/*from  www  .jav  a 2 s  .co  m*/
    } else {
        style.setColor("gray");
    }
}

From source file:com.sciencegadgets.client.ui.ToggleSlide.java

License:Open Source License

public void enable(boolean enable) {
    Style style = getElement().getStyle();
    if (enable) {
        style.clearColor();// w w w.  j  av  a 2s .c o  m
    } else {
        style.setColor("gray");
    }
}