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

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

Introduction

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

Prototype

public void setBackgroundColor(String value) 

Source Link

Usage

From source file:jake2.gwt.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();/*from w w  w . j  a va2  s  .c  om*/
    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");

    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 {
        final refexport_t renderer = wireframe ? new GwtWireframeGLRenderer(canvas)
                : new GwtWebGLRenderer(canvas, video);
        Globals.re = renderer;

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

        S.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.
        Qcommon.Init(new String[] { "GQuake" });

        // Enable stdout.
        Globals.nostdout = Cvar.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) {
                        SCR.UpdateScreen2();
                    } else {
                        int dt = (int) (curTime - startTime);
                        GwtKBD.Frame(dt);
                        Qcommon.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);
        body.setInnerHTML(NO_WEBGL_MESSAGE);
    }
}

From source file:jetbrains.jetpad.projectional.domUtil.DomTextEditor.java

License:Apache License

private void updateCaretAndSelection() {
    Style caretStyle = myCaretDiv.getStyle();
    updateCaretPosition();//w w w  .j a  v  a 2s .  c  o  m
    caretStyle.setTop(0, Style.Unit.PX);
    caretStyle.setWidth(1, Style.Unit.PX);
    caretStyle.setHeight(getLineHeight(), Style.Unit.PX);
    caretStyle.setBackgroundColor("black");

    Style selectionStyle = mySelectionDiv.getStyle();
    selectionStyle.setTop(0, Style.Unit.PX);
    selectionStyle.setHeight(getLineHeight(), Style.Unit.PX);
    selectionStyle.setBackgroundColor("Highlight");
    selectionStyle.setColor("HighlightText");

    updateSelectionBoundsAndText();
}

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 a  v  a2  s .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:net.sf.mmm.client.ui.gwt.widgets.richtext.FeatureBehaviorBackgroundColor.java

License:Apache License

/**
 * {@inheritDoc}//from  w  w  w .j  av  a  2 s  .c  om
 */
@Override
protected void applyFontSettings(Color value, Style style) {

    style.setBackgroundColor(value.toString());
}

From source file:org.clevermore.monitor.client.servers.ServersWidget.java

License:Apache License

private void updateServersTable() {
    sp.clear();/*  w w w.ja  v  a2s  .c o m*/
    FlexTable ft = new FlexTable();
    sp.add(ft);
    ft.getElement().setId("infoTable");
    ft.setCellPadding(0);
    ft.setCellSpacing(0);

    Collections.sort(servesList, new Comparator<ConnectedServer>() {

        @Override
        public int compare(ConnectedServer o1, ConnectedServer o2) {
            double o1p = 0, o2p = 0;
            if (o1.getStatus() && o2.getStatus()) {
                if (o1.getCpuUsage() > 80 || o2.getCpuUsage() > 80) {
                    // sort by CPU
                    o1p = o1.getCpuUsage();
                    o2p = o2.getCpuUsage();
                } else {
                    // sort by memory
                    o1p = o1.getMemoryUsage().getPercentage();
                    o2p = o2.getMemoryUsage().getPercentage();
                }
            } else if (o1.getStatus()) {
                o1p = o1.getMemoryUsage().getPercentage();
                o2p = 100;
            } else if (o2.getStatus()) {
                o1p = 100;
                o2p = o2.getMemoryUsage().getPercentage();
            }
            return (int) (o2p * 100d - o1p * 100d);
        }
    });

    int i = 0, j = 0;
    HTML t;
    ft.setText(i, j++, "Code, Name");
    ft.setText(i, j++, "Up Time");

    t = new HTML("Memory");
    t.setTitle("Latest memory status.");
    ft.setWidget(i, j++, t);

    t = new HTML("Max GC");
    t.setTitle("Max GC time in the last 24 hours.");
    ft.setWidget(i, j++, t);

    t = new HTML("Cpu");
    t.setTitle("Latest CPU load.");
    ft.setWidget(i, j++, t);

    t = new HTML("SYSL");
    t.setTitle("Linux system load.");
    ft.setWidget(i, j++, t);

    ft.getRowFormatter().getElement(i++).setId("th");

    int offline = 0;

    serversMap.clear();

    for (ConnectedServer cs : servesList) {
        serversMap.put(cs.getServerCode(), cs);

        j = 0;
        offline += cs.getStatus() ? 0 : 1;
        if (!toShow(cs.getName())) {
            continue;
        }
        if (cs.getStatus()) {
            final HTML name = new HTML("<a href=#>" + cs.getServerCode() + "," + cs.getName() + "</a>");
            name.getElement().setAttribute("code", "" + cs.getServerCode());
            name.setTitle(cs.getToolTip());
            name.addMouseOverHandler(handCursor);

            name.addClickHandler(getThreadDump);

            ft.setWidget(i, j++, name);
            ft.setText(i, j++, ClientStringFormatter.formatMilisecondsToHours(cs.getUpTime()));

            HTML usage = new HTML(ClientStringFormatter.formatMBytes(cs.getMemoryUsage().getUsed()) + " / "
                    + ClientStringFormatter.formatMBytes(cs.getMemoryUsage().getMax()) + " MB,  "
                    + ClientStringFormatter.formatMillisShort(cs.getMemoryUsage().getPercentage()) + "%");
            ft.setWidget(i, j++, usage);

            StringBuilder gcs = new StringBuilder();
            double gcMax = Double.MIN_VALUE;

            // Iterating over all available pools
            for (Double gch : cs.getGcHistories()) {
                gcs.append(ClientStringFormatter.formatMillisShort(gch)).append(", ");
                if (gch > gcMax) {
                    gcMax = gch;
                }
            }
            if (gcs.length() > 0) {
                gcs.setLength(gcs.length() - 2);
            }
            final HTML memory = new HTML(gcs.toString());
            memory.setTitle("Click to see GC history");
            memory.addMouseOverHandler(handCursor);
            memory.addClickHandler(getGCHistory);
            memory.getElement().setAttribute("code", "" + cs.getServerCode());

            ft.setWidget(i, j++, memory);
            if (gcMax > 3) {
                Style style = ft.getFlexCellFormatter().getElement(i, j - 1).getStyle();
                style.setBackgroundColor("#C00000");
                style.setFontWeight(FontWeight.BOLDER);
                style.setColor("white");
            }

            if (cs.getMemoryUsage().getPercentage() > 90) {
                ft.getRowFormatter().getElement(i).setId("memoryVeryHigh");
            }
            // else if (cs.getMemoryUsage().getPercentage() > 80) {
            // ft.getRowFormatter().getElement(i).setId("memoryHigh");
            // }

            HTML cpu = new HTML(cs.getCpuUsage() + "%");
            ft.setWidget(i, j++, cpu);
            if (cs.getCpuUsage() > 90d) {
                Style style = ft.getFlexCellFormatter().getElement(i, j - 1).getStyle();
                style.setBackgroundColor("#C00000");
                style.setFontWeight(FontWeight.BOLDER);
                style.setColor("white");
            }

            double sla = cs.getSystemLoadAverage();
            HTML sysl = new HTML(sla == -1 ? "N/A" : ClientStringFormatter.formatMillisShort(sla));
            sysl.setTitle("System Load Average");
            ft.setWidget(i, j++, sysl);
            i++;

        } else {
            if (showOffline) {
                final HTML name = new HTML("<a href=#>" + cs.getServerCode() + ", " + cs.getName() + "</a>");
                name.setTitle("JMX >> " + cs.getIp() + ":" + cs.getJmxPort());
                ft.setWidget(i, j++, name);
                ft.setText(i, j++, "Offline");
                ft.setText(i, j++, "Offline");
                ft.setText(i, j++, "Offline");
                ft.setText(i, j++, "0.0%");
                ft.setText(i, j++, "0");
                ft.getRowFormatter().getElement(i++).setId("offline");
            }
        }
    }

    ft.getColumnFormatter().setWidth(0, "100px");

    if (databases != null && databases.size() > 0) {
        for (ConnectedDB cd : databases) {
            j = 0;
            HTML value = new HTML("<b>Database</b>:" + cd.getName() + " (" + cd.getService() + ")");
            value.setTitle(cd.toString());
            ft.setWidget(i, j, value);
            ft.getFlexCellFormatter().setColSpan(i, j, 2);
            ft.setText(i, 1, cd.getIp() + ":" + cd.getPort());
            ft.setText(i, 2, (cd.getStatus() ? "ONLINE" : "OFFLINE"));
            ft.setText(i, 3, "LastPing:" + cd.getLastPingTime() + "ms");
            ft.getFlexCellFormatter().setColSpan(i, 3, 2);
            if ((!cd.getStatus())) {
                ft.getRowFormatter().getElement(i).setId("offline");
            }
            i++;
        }
    }
    serversLabel.setText("Servers:" + servesList.size() + " (" + offline + ")");
}

From source file:org.clevermore.monitor.client.servers.ThreadDumpPopup.java

License:Apache License

public void setDump(ThreadDump threadDump) {
    textArea.setText(threadDump.getDump());
    int i = 1;//from  w  w w .ja  v  a2s .  c  o  m
    for (ThreadInfo ti : threadDump.getThreads()) {
        ft.setText(i, 0, ti.getName());
        ft.setText(i, 1, "" + ti.getId());
        ft.setText(i, 2, ti.getState());

        if ("BLOCKED".equalsIgnoreCase(ti.getState())) {
            Style style = ft.getFlexCellFormatter().getElement(i, 2).getStyle();
            style.setBackgroundColor("#C00000");
            style.setFontWeight(FontWeight.BOLDER);
            style.setColor("white");
        }
        i++;
    }
}

From source file:org.dashbuilder.renderer.client.metric.MetricViewImpl.java

License:Apache License

public void applySettings(DisplayerSettings displayerSettings) {
    this.displayerSettings = displayerSettings;
    int w = displayerSettings.getChartWidth();
    int h = displayerSettings.getChartHeight();
    int mtop = displayerSettings.getChartMarginTop();
    int mbottom = displayerSettings.getChartMarginBottom();
    int mleft = displayerSettings.getChartMarginLeft();
    int mright = displayerSettings.getChartMarginRight();

    // Hero panel (size)
    Style style = heroPanel.getElement().getStyle();
    style.setPadding(0, Style.Unit.PX);
    style.setWidth(w, Style.Unit.PX);
    style.setHeight(h, Style.Unit.PX);
    style.setTextAlign(Style.TextAlign.CENTER);
    style.setVerticalAlign(Style.VerticalAlign.MIDDLE);
    if (!StringUtils.isBlank(displayerSettings.getChartBackgroundColor())) {
        style.setBackgroundColor("#" + displayerSettings.getChartBackgroundColor());
    }//from   ww  w.  ja va  2  s.c  o  m

    // Center panel (paddings)
    style = centerPanel.getElement().getStyle();
    style.setPaddingTop(mtop, Style.Unit.PX);
    style.setPaddingBottom(mbottom, Style.Unit.PX);
    style.setPaddingLeft(mleft, Style.Unit.PX);
    style.setPaddingRight(mright, Style.Unit.PX);

    // Title panel
    titlePanel.setVisible(displayerSettings.isTitleVisible());
    titlePanel.setText(displayerSettings.getTitle());
}

From source file:org.eclipse.che.ide.ui.smartTree.SpeedSearch.java

License:Open Source License

private void initSearchPopUp() {
    this.searchPopUp = new SearchPopUp();
    Style style = this.searchPopUp.getElement().getStyle();

    style.setBackgroundColor("grey");
    style.setBorderStyle(Style.BorderStyle.SOLID);
    style.setBorderColor("#dbdbdb");
    style.setBorderWidth(1, Style.Unit.PX);
    style.setPadding(2, Style.Unit.PX);
    style.setPosition(Style.Position.FIXED);
    style.setTop(100, Style.Unit.PX);
    style.setLeft(20, Style.Unit.PX);
}

From source file:org.eclipse.gef.gwt.GwtRulerComposite.java

License:Open Source License

private LayoutPanel createPickle() {
    LayoutPanel pickle = new LayoutPanel();
    pickle.getElement().setId("PICKLE");
    pickle.setPixelSize(19, 19);/*from   ww  w  .j  av  a 2s.co  m*/
    Style style = pickle.getElement().getStyle();
    style.setBackgroundColor("rgb(230,230,230)");
    return pickle;
}

From source file:org.jbpm.dashboard.renderer.client.panel.ProcessDashboardView.java

License:Apache License

protected DisplayerContainer createMetricContainer(Map<String, Displayer> m, boolean showHeader) {
    DisplayerContainer container = new DisplayerContainer(m, showHeader);
    Style s = container.getView().getHeaderStyle();
    s.setBackgroundColor("white");
    return container;
}