Example usage for com.google.gwt.user.client.ui Widget addStyleName

List of usage examples for com.google.gwt.user.client.ui Widget addStyleName

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget addStyleName.

Prototype

public void addStyleName(String style) 

Source Link

Document

Adds a secondary or dependent style name to this object.

Usage

From source file:de.eckhartarnold.client.Filmstrip.java

License:Apache License

/**
 * The constructor of class <code>Filmstrip</code>
 * @param thumbnailImages  the thumb nail images to be displayed on the
 *                         film strip//from  w w  w  .j  a va  2  s  .  c om
 */
public Filmstrip(Thumbnails thumbnailImages) {
    this.thumbnails = thumbnailImages;
    envelope = new SimplePanel();
    envelope.addStyleName("filmstripEnvelope");
    panel = new AbsolutePanel();
    panel.addStyleName("filmstripPanel");
    envelope.setWidget(panel);
    initWidget(envelope);
    // sinkEvents(Event.ONMOUSEWHEEL);

    ClickHandler imageClickHandler = new ClickHandler() {
        public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            if (pickImageCallback != null) {
                pickImageCallback.onPickImage(thumbnails.indexOf((Image) sender));
            }
        }
    };

    MouseDownHandler imageMouseDownHandler = new MouseDownHandler() {
        public void onMouseDown(MouseDownEvent event) {
            Widget sender = (Widget) event.getSource();
            if (pickImageCallback != null && sender != thumbnails.get(cursor)) {
                sender.addStyleName("filmstripPressed");
            }
        }
    };

    MouseOverHandler imageMouseOverHandler = new MouseOverHandler() {
        public void onMouseOver(MouseOverEvent event) {
            Widget sender = (Widget) event.getSource();
            if (pickImageCallback != null && sender != thumbnails.get(cursor)) {
                sender.addStyleName("filmstripTouched");
            }
        }
    };

    MouseOutHandler imageMouseOutHandler = new MouseOutHandler() {
        public void onMouseOut(MouseOutEvent event) {
            Widget sender = (Widget) event.getSource();
            if (pickImageCallback != null && sender != thumbnails.get(cursor)) {
                sender.removeStyleName("filmstripTouched");
                sender.removeStyleName("filmstripPressed");
            }
        }
    };

    MouseUpHandler imageMouseUpHandler = new MouseUpHandler() {
        public void onMouseUp(MouseUpEvent event) {
            Widget sender = (Widget) event.getSource();
            if (pickImageCallback != null && sender != thumbnails.get(cursor)) {
                sender.removeStyleName("filmstripPressed");
            }
        }
    };

    for (int i = 0; i < thumbnails.size(); i++) {
        Image img = thumbnails.get(i);
        if (i == cursor)
            img.setStyleName("filmstripHighlighted");
        else
            img.setStyleName("filmstrip");
        img.addClickHandler(imageClickHandler);
        img.addMouseDownHandler(imageMouseDownHandler);
        img.addMouseOverHandler(imageMouseOverHandler);
        img.addMouseOutHandler(imageMouseOutHandler);
        img.addMouseUpHandler(imageMouseUpHandler);
    }

    visible = new HashSet<Image>();
}

From source file:de.eckhartarnold.client.GalleryWidget.java

License:Apache License

private void initRawGallery() {
    assert panel == null;

    panel = new VerticalPanel();
    panel.addStyleName("gallery");
    panel.getElement().setAttribute("align", "center");
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    // add a filler so that the vertical panel is not empty (and its 
    // horizontal size not zero) when the thumbnail pictures are added.
    // filler = new HTML("&nbsp;");
    // panel.add(filler);

    ClickHandler imageClickHandler = new ClickHandler() {
        public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            //        String id = DOM.getElementAttribute(sender.getElement(), "id");
            String id = sender.getElement().getAttribute("id");
            firePickImage(Integer.parseInt(id));
            sender.removeStyleName("galleryTouched");
            sender.removeStyleName("galleryPressed");
        }/*  w w  w  . ja  v a  2  s.c  o m*/
    };

    MouseDownHandler imageMouseDownHandler = new MouseDownHandler() {
        public void onMouseDown(MouseDownEvent event) {
            Widget sender = (Widget) event.getSource();
            sender.addStyleName("galleryPressed");
        }
    };

    MouseOverHandler imageMouseOverHandler = new MouseOverHandler() {
        public void onMouseOver(MouseOverEvent event) {
            Widget sender = (Widget) event.getSource();
            sender.addStyleName("galleryTouched");
        }
    };

    MouseOutHandler imageMouseOutHandler = new MouseOutHandler() {
        public void onMouseOut(MouseOutEvent event) {
            Widget sender = (Widget) event.getSource();
            sender.removeStyleName("galleryTouched");
            sender.removeStyleName("galleryPressed");
        }
    };

    for (int i = 0; i < thumbnails.size(); i++) {
        Image img = thumbnails.get(i);
        img.setStyleName("galleryImage");
        Element imgElement = img.getElement();
        //      DOM.setElementAttribute(imgElement, "id", String.valueOf(i));
        imgElement.setAttribute("id", String.valueOf(i));
        img.addClickHandler(imageClickHandler);
        img.addMouseDownHandler(imageMouseDownHandler);
        img.addMouseOverHandler(imageMouseOverHandler);
        img.addMouseOutHandler(imageMouseOutHandler);
    }

    initWidget(panel);
}

From source file:de.swm.commons.mobile.client.utils.IsSWMMobileWidgetHelper.java

License:Apache License

/**
 * Adds a secondary style to a widget./*w  w w  .  j  ava 2  s  .  com*/
 * 
 * @param widget
 *            the widget to add the style to
 * @param style
 *            style name.
 */
public void setSecondaryStyle(Widget widget, String style) {
    widget.addStyleName(style);
}

From source file:de.swm.commons.mobile.client.widgets.CheckBoxGroup.java

License:Apache License

@Override
public void onDragStart(DragEvent e) {
    pressed = Utils.getTargetItemIndex(getElement(), e.getNativeEvent().getEventTarget());
    if (pressed >= 0) {
        Widget item = getWidget(pressed);
        item.addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getCheckRadioBoxCss().pressed());
    }/*from  w  w w  .j  ava  2  s  .  c o  m*/
}

From source file:edu.caltech.ipac.firefly.core.layout.LayoutSelector.java

private Widget makeImage(final TablePanel.View v) {
    Image img = new Image(v.getIcon());
    img.setSize("24px", "24px");
    if (v.getName().equals(selView)) {
        img.addStyleName("selected-view");
        return img;
    } else {//from  w  ww  . jav  a  2  s . c  o  m
        Widget w = GwtUtil.makeImageButton(img, v.getShortDesc(), new ClickHandler() {
            public void onClick(ClickEvent event) {
                selView = v.getName();
                TablePanel table = hub.getActiveTable();
                table.switchView(selView);
                layout();
            }
        });
        w.addStyleName("selectable-view");
        return w;
    }
}

From source file:edu.caltech.ipac.firefly.ui.background.BackgroundGroupsDialog.java

private void setBackground(Widget w, boolean on) {
    if (on) {/*from  www  .j  a va  2  s .  com*/
        w.removeStyleName(_ffCss.tableRowBackAlt2());
        w.addStyleName(_ffCss.tableRowBackAlt1());
    } else {
        w.removeStyleName(_ffCss.tableRowBackAlt1());
        w.addStyleName(_ffCss.tableRowBackAlt2());
    }
}

From source file:edu.caltech.ipac.firefly.ui.background.DownloadGroupPanel.java

private Widget makeDetailStateWidget(int idx) {

    Widget retval;
    String desc;// w w  w .  j av  a2 s  .  c o m

    int partCount = getPartCount(_monItem);
    if (partCount == 0)
        partCount = 1;
    switch (_monItem.getState()) {

    case STARTING:
        desc = (partCount == 1) ? STATUS_STARTING_TXT : STATUS_STARTING_PART_TXT + (idx + 1);
        retval = createWorkingWidget(desc);
        break;
    case WAITING:
        desc = (partCount == 1) ? _waitingMsg : STATUS_WAITING_PART_TXT + (idx + 1);
        retval = createWorkingWidget(desc);
        break;
    case WORKING:
        if (_monItem.getStatus().getPartProgress(idx).isDone()) {
            retval = makeSuccessWidget(idx);
            retval.addStyleName("downloadElement-download");
        } else {
            _detailUI[idx].setProgressDetail(_monItem.getStatus(), idx);
            retval = _detailUI[idx].getProgressDetailWidget();
        }
        break;
    case SUCCESS:
        retval = makeSuccessWidget(idx);
        retval.addStyleName("downloadElement-download");
        break;
    case USER_ABORTED:
    case FAIL:
    case CANCELED:
        retval = new Label(STATUS_CANCELED_TXT);
        retval.addStyleName("downloadElement-warning");
        break;
    default:
        retval = new Label("Unknown: " + _monItem.getState().toString());
        retval.addStyleName("downloadElement-unknown");
        break;
    }

    return retval;

}

From source file:edu.caltech.ipac.firefly.ui.BadgeButton.java

public static Widget makeBadge(int cnt) {
    Widget badge = new HTML(cnt + "");
    badge.setStyleName("firefly-v2-badge");
    if (cnt > 9) {
        badge.addStyleName("firefly-v2-badge-2-digit");
    } else {/*from  w w  w .  j ava2s .c o  m*/
        badge.addStyleName("firefly-v2-badge-1-digit");

    }
    return badge;
}

From source file:edu.caltech.ipac.firefly.ui.LinkButtonFactory.java

public void makeIntoLinkButton(final String linkButtonStyle, final String mouseOverStyle,
        final String mouseOffStyle, final Widget... link) {

    MouseOverHandler mOver = new MouseOverHandler() {
        public void onMouseOver(MouseOverEvent event) {
            for (Widget w : link) {
                if (mouseOffStyle != null)
                    w.removeStyleName(mouseOffStyle);
                if (mouseOverStyle != null)
                    w.addStyleName(mouseOverStyle);
            }//from  www. java  2 s.  co  m
        }
    };

    MouseOutHandler mOut = new MouseOutHandler() {
        public void onMouseOut(MouseOutEvent event) {
            for (Widget w : link) {
                if (mouseOverStyle != null)
                    w.removeStyleName(mouseOverStyle);
                if (mouseOffStyle != null)
                    w.addStyleName(mouseOffStyle);
            }
        }
    };

    for (Widget w : link) {
        if (linkButtonStyle != null)
            w.addStyleName(linkButtonStyle);
        if (mouseOffStyle != null)
            w.addStyleName(mouseOffStyle);

        if (w instanceof HasAllMouseHandlers) {
            HasAllMouseHandlers ol = (HasAllMouseHandlers) w;
            ol.addMouseOverHandler(mOver);
            ol.addMouseOutHandler(mOut);
        }
    }
}

From source file:edu.caltech.ipac.firefly.ui.searchui.FuseSearchPanel.java

private Widget createSidebar() {
    FlowPanel sideBarPanel = new FlowPanel();
    int i = 0;//  w  ww  .  ja va2s . c om
    boolean first = true;
    for (SearchUI sUI : searchUIList) {
        final int panelIdx = i;
        Label link = GwtUtil.makeLinkButton(sUI.getPanelTitle(), sUI.getDesc(), new ClickHandler() {
            public void onClick(ClickEvent event) {
                setActiveSearchUIPanel(panelIdx);
            }
        });
        sideLinkList.add(link);
        sideBarPanel.add(link);

        GwtUtil.setStyles(link, "paddingTop", first ? "40px" : "15px", "textAlign", "left");
        first = false;
        i++;
    }
    GwtUtil.setStyles(sideBarPanel, "borderRight", "1px solid rgba(0,0,0,.40)");
    Widget wrapper = GwtUtil.wrap(sideBarPanel, 45, 1, 50, 8);
    wrapper.addStyleName("SideBarWrapper");
    return wrapper;
}