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

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

Introduction

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

Prototype

public void setFontWeight(FontWeight value) 

Source Link

Usage

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

License:Apache License

public void loadSecondPart() {
    HorizontalPanel hp = new HorizontalPanel();
    Button threadDump = new Button("Get Thread Dump");
    hp.add(threadDump);/*w w  w  .j a va 2s.co m*/
    addRadioButtons(hp);
    Button close = new Button("Close");
    hp.add(close);
    close.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            hide();
        }
    });

    hp.setWidth("100%");
    hp.setCellHorizontalAlignment(close, HorizontalAlignmentConstant.endOf(Direction.LTR));
    Style style = close.getElement().getStyle();
    style.setColor("orange");
    style.setFontWeight(FontWeight.BOLDER);
    fp.add(hp);
    fp.add(cpu);
    fp.add(memory);
    fp.add(memoryDetails);
    fp.add(sysLoad);
    addExtraElements(fp);
    fp.add(details);

    threadDump.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ThreadDumpPopup tdp = new ThreadDumpPopup();
            tdp.center();

            service.getThreadDump(serverCode, new AsyncCallback<ThreadDump>() {

                @Override
                public void onSuccess(ThreadDump result) {
                    tdp.setDump(result);
                }

                @Override
                public void onFailure(Throwable caught) {
                    tdp.setText("Can't get thread dump:" + caught.getMessage());
                }
            });
        }
    });

    getMemoryStats(chunks);
    getCpuStats(chunks);

    service.getRuntimeInfo(serverCode, new AsyncCallback<RuntimeInfo>() {

        @Override
        public void onSuccess(RuntimeInfo result) {
            updateRuntimeInfo(result);
            int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
            setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), 26);

        }

        @Override
        public void onFailure(Throwable caught) {
            Log.error("error while getting server cpu stats:" + caught.getMessage());

        }
    });

    getExtraData(chunks);

    RepeatingCommand refreshCommand = new RepeatingCommand() {

        @Override
        public boolean execute() {
            if (refresh) {
                getMemoryStats(chunks);
                getCpuStats(chunks);
                getExtraData(chunks);
                Log.debug("Reschedule refresh");
            }
            return refresh;
        }
    };
    Scheduler.get().scheduleFixedDelay(refreshCommand, 20000);
}

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

License:Apache License

private void updateServersTable() {
    sp.clear();//from  w  w  w. ja  va  2 s .co 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.ServersWidget.java

License:Apache License

private void blinkCertButton() {
    Boolean blink = Boolean.valueOf(certs.getElement().getAttribute("blink"));
    if (!blink) {
        certs.getElement().setAttribute("blink", "true");
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

            @Override/*w w w. ja v a2  s  .c om*/
            public boolean execute() {
                Boolean blink = Boolean.valueOf(certs.getElement().getAttribute("blink"));
                Style style = certs.getElement().getStyle();
                if (blink) {
                    style.setColor("red".equals(style.getColor()) ? "green" : "red");
                    style.setFontWeight(FontWeight.BOLDER);
                } else {
                    style.setColor("black");
                    style.setFontWeight(FontWeight.NORMAL);
                }
                return blink;
            }
        }, 1000);
    }
}

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  a  2s. 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.jbpm.form.builder.ng.model.common.panels.FieldSetPanel.java

License:Apache License

public FieldSetPanel() {
    super();/*from  w ww. j a  v a 2 s  . c o  m*/
    Style divStyle = getElement().getStyle();
    Style lgndStyle = legend.getStyle();

    divStyle.setBorderWidth(2, Unit.PX);
    divStyle.setBorderStyle(BorderStyle.SOLID);
    divStyle.setMarginTop(0.5, Unit.EM);
    divStyle.setMarginBottom(0.5, Unit.EM);
    divStyle.setMarginRight(0, Unit.PX);
    divStyle.setMarginLeft(0, Unit.PX);
    divStyle.setPaddingTop(0, Unit.PX);
    divStyle.setPaddingBottom(0, Unit.PX);
    divStyle.setPaddingRight(0.5, Unit.EM);
    divStyle.setPaddingLeft(0.5, Unit.EM);

    lgndStyle.setFontSize(100.0, Unit.PCT);
    lgndStyle.setFontWeight(FontWeight.NORMAL);
    lgndStyle.setMarginTop(-0.5, Unit.EM);
    lgndStyle.setMarginRight(0, Unit.PX);
    lgndStyle.setMarginLeft(0, Unit.PX);
    lgndStyle.setMarginBottom(0, Unit.PX);
    lgndStyle.setBackgroundColor("white");
    lgndStyle.setColor("black");
    lgndStyle.setFloat(Style.Float.LEFT);
    lgndStyle.setPaddingTop(0, Unit.PX);
    lgndStyle.setPaddingBottom(0, Unit.PX);
    lgndStyle.setPaddingRight(2, Unit.PX);
    lgndStyle.setPaddingLeft(2, Unit.PX);

    getElement().appendChild(legend);
}

From source file:org.komodo.web.client.panels.vdb.property.panel.NoPropertiesPanel.java

License:Open Source License

/**
 * Create new instance/*from   w  w w.  j  av a 2s . co  m*/
 *
 * @param parentWidth parent width
 * @param parentHeight parent height
 */
protected NoPropertiesPanel(double parentWidth, double parentHeight) {
    Style style = getElement().getStyle();
    style.setFontWeight(FontWeight.BOLD);
    style.setTextAlign(TextAlign.CENTER);
    style.setLineHeight(parentHeight, Unit.EM);

    add(noPropsLabel);
}

From source file:org.komodo.web.client.panels.vdb.VdbEditPanel.java

License:Apache License

private Widget createObjectPropertiesPanel() {
    Style objPropPanelStyle = objectPropertiesPanel.getElement().getStyle();

    /*//from   w  ww  .j ava 2 s. co m
     * Want to position the properties panel so its always to the right
     * of the diagram panel, even when zoomed in. Float: left fails to
     * work at this point since zoom in enough and the properties
     * panel jumps down below.
     */

    /*
     * Set the position of the properties panel to absolute so that we
     * are now in charge of its location
     */
    objPropPanelStyle.setPosition(Position.ABSOLUTE);

    /*
     * Set its position as being on same level as diagram panel
     */
    objPropPanelStyle.setTop(0, Unit.EM);

    /*
     * Move it to the right of the diagram panel which is the
     * diagram panel width + border width + an extra 2 units
     * to account for the vertical scrollbar width
     */
    objPropPanelStyle.setLeft(DIAGRAM_PANEL_WIDTH + BORDER_WIDTH + 2, Unit.EM);

    /*
     * Set its width and height to appropriate values
     */
    objPropPanelStyle.setWidth((DIAGRAM_PANEL_WIDTH * 3) / 5, Unit.EM);
    objPropPanelStyle.setHeight(EDIT_PANEL_HEIGHT, Unit.EM);

    /*
     * Set its background colour to a subtle shade that just frames the panel
     */
    objPropPanelStyle.setBackgroundColor("#fAfAfA"); //$NON-NLS-1$

    /*
     * Set overflow to use scrollbars if required
     */
    objPropPanelStyle.setOverflow(Overflow.AUTO);

    /*
     * Add the title
     */
    Label propertyTitle = new Label("Property Editor"); //$NON-NLS-1$
    Style titleStyle = propertyTitle.getElement().getStyle();

    /*
     * Centre the title
     * Set its font size and make it bold
     * Set its height as this ensures a value we can know when
     * passing on the remaining content area to the sub panels, ie.
     * SUB_PANEL_HEIGHT = DIAGRAM_PANEL_HEIGHT
     *                                          - PROPERTY_TITLE_HEIGHT + (BORDER_WIDTH * 2)
     */
    titleStyle.setTextAlign(TextAlign.CENTER);
    titleStyle.setFontSize(1, Unit.EM);
    titleStyle.setFontWeight(FontWeight.BOLD);
    titleStyle.setLineHeight(PROPERTY_TITLE_HEIGHT, Unit.EM);
    titleStyle.setHeight(PROPERTY_TITLE_HEIGHT, Unit.EM);
    objectPropertiesPanel.add(propertyTitle);

    return objectPropertiesPanel;
}

From source file:org.opencms.gwt.client.seo.CmsAliasList.java

License:Open Source License

/**
 * Creates a label for this widget.<p>
 *
 * @param text the text to display in the label
 *
 * @return the created label/*from  w  ww .  j a v a2 s . com*/
 */
protected Label createLabel(String text) {

    Label label = new Label(text);
    Style style = label.getElement().getStyle();
    style.setMarginTop(10, Unit.PX);
    style.setMarginBottom(4, Unit.PX);
    style.setFontWeight(FontWeight.BOLD);
    return label;
}

From source file:org.waveprotocol.wave.client.editor.content.paragraph.DefaultParagraphHtmlRenderer.java

License:Apache License

@Override
public void updateRendering(HasImplNodelets element, String type, String listStyle, int indent,
        Alignment alignment, Direction direction) {

    Element implNodelet = element.getImplNodelet();
    ParagraphBehaviour behaviour = ParagraphBehaviour.of(type);
    boolean toListItem = behaviour == ParagraphBehaviour.LIST;
    boolean isListItem = implNodelet.getTagName().equalsIgnoreCase(LIST_IMPL_TAGNAME);

    if (isListItem != toListItem) {
        Element newNodelet = createNodeletInner(toListItem);
        DomHelper.replaceElement(implNodelet, newNodelet);
        element.setBothNodelets(newNodelet);
        // Ideally onRepair shouldn't require a ContentElement
        ParagraphHelper.INSTANCE.onRepair((ContentElement) element);

        implNodelet = newNodelet;/*from   ww w  .ja  va2s.co  m*/
    }

    //// Type logic ////

    double fontSize = -1;
    FontWeight fontWeight = null;
    implNodelet.removeClassName(NUMBERED_CLASSNAME);

    switch (behaviour) {
    case LIST:
        if (Paragraph.LIST_STYLE_DECIMAL.equals(listStyle)) {
            implNodelet.addClassName(NUMBERED_CLASSNAME);
        }
        break;
    case HEADING:
        fontWeight = FontWeight.BOLD;
        double headingNum = Integer.parseInt(type.substring(1));
        // Do this with CSS instead.
        // h1 -> 1.75, h4 -> 1, others linearly in between.
        double factor = 1 - (headingNum - 1) / (Paragraph.NUM_HEADING_SIZES - 1);
        fontSize = MIN_HEADING_SIZE_EM + factor * (MAX_HEADING_SIZE_EM - MIN_HEADING_SIZE_EM);
        break;
    }

    //// Indent logic ////

    for (String bulletType : BULLET_CLASSNAMES) {
        implNodelet.removeClassName(bulletType);
    }

    if (behaviour == ParagraphBehaviour.LIST) {
        if (listStyle == null) {
            implNodelet.addClassName(bulletClassName(indent));
        }
        indent++;
    }

    int margin = indent * INDENT_UNIT_SIZE_PX;

    //// Update actual values ////

    // NOTE(danilatos): For these, it might be more efficient to check that the
    // value has changed before changing it. This is not currently  known.

    Style style = implNodelet.getStyle();

    if (fontSize != -1) {
        style.setFontSize(fontSize, Unit.EM);
    } else {
        style.clearFontSize();
    }

    if (fontWeight != null) {
        style.setFontWeight(fontWeight);
    } else {
        style.clearFontWeight();
    }

    if (alignment != null) {
        style.setProperty("textAlign", alignment.cssValue());
    } else {
        style.clearProperty("textAlign");
    }

    if (direction != null) {
        style.setProperty("direction", direction.cssValue());
    } else {
        style.clearProperty("direction");
    }

    if (margin == 0) {
        style.clearMarginLeft();
        style.clearMarginRight();
    } else {
        if (direction == Direction.RTL) {
            style.setMarginRight(margin, Unit.PX);
            style.clearMarginLeft();
        } else {
            style.setMarginLeft(margin, Unit.PX);
            style.clearMarginRight();
        }
    }
}