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

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

Introduction

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

Prototype

public void setStyleName(String style) 

Source Link

Document

Clears all of the object's style names and sets it to the given style.

Usage

From source file:org.opencms.acacia.client.ui.CmsAttributeChoiceWidget.java

License:Open Source License

/**
 * Adds a choice to the widget.<p>
 *
 * @param choice the choice to add//from w w  w.  jav  a2 s .c om
 */
public void addChoice(Widget choice) {

    choice.setStyleName(I_CmsLayoutBundle.INSTANCE.attributeChoice().choice());
    m_choices.add(choice);
}

From source file:org.openelis.gwt.widget.MenuItem.java

License:Open Source License

public Widget create(String icon, Widget wid, String descriptionText) {
    FlexTable table = new FlexTable();
    table.setStyleName("TopMenuRowContainer");
    iconPanel.setStyleName(icon);//from w w w . java  2 s .  c o  m
    HorizontalPanel hp = new HorizontalPanel();
    hp.add(wid);
    hp.setCellWidth(wid, "100%");
    hp.add(openIcon);
    hp.setWidth("100%");
    VerticalPanel textPanel = new VerticalPanel();
    //Label label = new Label(labelText);
    wid.setStyleName("topMenuItemTitle");
    wid.addStyleName("locked");

    Label description;
    if ("EXCEPTION".equals(descriptionText))
        description = new Label();
    else
        description = new Label(descriptionText);

    description.setStyleName("topMenuItemDesc");
    table.setWidget(0, 0, iconPanel);
    textPanel.add(hp);
    textPanel.setCellWidth(hp, "100%");
    textPanel.add(description);
    textPanel.setWidth("100%");
    table.setWidget(0, 1, textPanel);
    table.getFlexCellFormatter().setStyleName(0, 0, "topMenuIcon");
    table.getFlexCellFormatter().setStyleName(0, 1, "topMenuItemMiddle");
    return table;
}

From source file:org.openelis.gwt.widget.MenuItem.java

License:Open Source License

public static Widget createDefault(String icon, Widget wid, String descriptionText) {
    FlexTable table = new FlexTable();
    table.setStyleName("TopMenuRowContainer");
    AbsolutePanel iconPanel = new AbsolutePanel();
    iconPanel.setStyleName(icon);/*from   w w  w.  j  a v a 2s. c o m*/
    VerticalPanel textPanel = new VerticalPanel();
    //Label label = new Label(labelText);
    wid.setStyleName("topMenuItemTitle");
    wid.addStyleName("locked");

    Label description;
    if ("EXCEPTION".equals(descriptionText))
        description = new Label();
    else
        description = new Label(descriptionText);

    description.setStyleName("topMenuItemDesc");
    table.setWidget(0, 0, iconPanel);
    textPanel.add(wid);
    textPanel.add(description);
    table.setWidget(0, 1, textPanel);
    table.getFlexCellFormatter().setStyleName(0, 0, "topMenuIcon");
    table.getFlexCellFormatter().setStyleName(0, 1, "topMenuItemMiddle");
    return table;
}

From source file:org.openelis.gwt.widget.MenuItem.java

License:Open Source License

public static Widget createTableHeader(String icon, Widget wid) {
    HorizontalPanel hp = new HorizontalPanel();
    //hp.setStyleName("TopHeaderRowContainer");
    hp.add(wid);//from   w w w.  j a v a2  s . c  o  m
    wid.setStyleName("HeaderLabel");
    hp.setCellWidth(wid, "100%");
    AbsolutePanel ap = new AbsolutePanel();
    hp.add(ap);
    hp.setCellWidth(ap, "16px");
    ap.setHeight("18px");
    ap.setWidth("16px");
    hp.setCellHorizontalAlignment(ap, HasAlignment.ALIGN_RIGHT);
    hp.setCellHorizontalAlignment(wid, HasAlignment.ALIGN_CENTER);
    return hp;
}

From source file:org.overlord.sramp.ui.client.widgets.dialogs.GrowlDialog.java

License:Apache License

/**
 * Sets the dialog's message (directly as a {@link Widget}).  This variant allows clients
 * to set rich HTML as the growl content, complete with behavior (event handlers).
 * @param message// w w w  .ja  v  a  2s  .  c  o  m
 */
public void setMessage(Widget message, GrowlType type) {
    if (this.message != null) {
        main.remove(this.message);
    }
    FlowPanel messageWrapper = new FlowPanel();
    messageWrapper.setStyleName("growlMessage");
    if (type == GrowlType.error) {
        HorizontalPanel errorPanel = new HorizontalPanel();
        Widget icon = new InlineLabel(" ");
        icon.setStyleName("errorMessage");

        errorPanel.add(icon);
        errorPanel.add(message);

        errorPanel.setCellWidth(icon, "1%");
        errorPanel.setCellVerticalAlignment(icon, HasVerticalAlignment.ALIGN_MIDDLE);

        messageWrapper.add(errorPanel);
    } else {
        messageWrapper.add(message);
    }
    this.message = messageWrapper;
    main.add(messageWrapper);
    setGrowlType(type);
}

From source file:org.pentaho.mantle.client.ui.xul.MantleXul.java

License:Open Source License

/**
 * Callback method for the MantleXulLoader. This is called when the Xul file has been processed.
 * //from  w w  w. ja  v  a 2  s.  com
 * @param runner
 *          GwtXulRunner instance ready for event handlers and initializing.
 */
public void xulLoaded(GwtXulRunner runner) {
    // handlers need to be wrapped generically in GWT, create one and pass it our reference.

    // instantiate our Model and Controller
    controller = new MantleController(new MantleModel(this));

    // Add handler to container
    container = (GwtXulDomContainer) runner.getXulDomContainers().get(0);
    container.addEventHandler(controller);

    try {
        runner.initialize();
    } catch (XulException e) {
        Window.alert("Error initializing XUL runner: " + e.getMessage()); //$NON-NLS-1$
        e.printStackTrace();
        return;
    }

    // Get the toolbar from the XUL doc
    Widget bar = (Widget) container.getDocumentRoot().getElementById("mainToolbarWrapper").getManagedObject(); //$NON-NLS-1$
    Widget xultoolbar = (Widget) container.getDocumentRoot().getElementById("mainToolbar").getManagedObject(); //$NON-NLS-1$
    xultoolbar.getElement().removeClassName("toolbar");
    toolbar.setStylePrimaryName("mainToolbar-Wrapper");
    toolbar.setWidget(bar);

    // Get the menubar from the XUL doc
    Widget menu = (Widget) container.getDocumentRoot().getElementById("mainMenubar").getManagedObject(); //$NON-NLS-1$
    menubar.setWidget(menu);

    // check based on user permissions
    final String moduleBaseURL = GWT.getModuleBaseURL();
    final String moduleName = GWT.getModuleName();
    final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    final String url = contextURL + "api/repo/files/canCreate"; //$NON-NLS-1$
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("accept", "text/plain");
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");

    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    Boolean visible = new Boolean(response.getText());
                    controller.setMenuBarEnabled("newmenu", visible);
                    controller.setToolBarButtonEnabled("newButton", visible);
                }
            }
        });
    } catch (RequestException e) {
        // showError(e);
    }

    // get the admin perspective from the XUL doc
    Widget admin = (Widget) container.getDocumentRoot().getElementById("adminPerspective").getManagedObject(); //$NON-NLS-1$
    admin.setStyleName("admin-perspective");
    admin.getElement().getStyle().clearHeight();
    admin.getElement().getStyle().clearWidth();
    adminPerspective.setWidget(admin);

    Panel adminContentPanel = (Panel) container.getDocumentRoot().getElementById("adminContentPanel")
            .getManagedObject();
    adminContentPanel.add(adminContentDeck);
    adminContentDeck.setHeight("100%");
    adminContentDeck.getElement().getStyle().setProperty("height", "100%");
    fetchPluginOverlays();
}

From source file:org.rebioma.client.TableWidget.java

License:Apache License

/**
 * Sets this table name.//from   w  w  w. j  a  v a 2  s  .  co m
 * 
 * @param name of this table.
 * @param isHTML true if the given name is HTML text.
 */
public void setName(String name, boolean isHTML) {
    this.name = name;
    Widget tableNameWidget;
    if (isHTML) {
        tableNameWidget = new HTML(name);
    } else {
        tableNameWidget = new Label(name);
    }
    outer.insert(tableNameWidget, 1);
    tableNameWidget.setStyleName("table-name");
}

From source file:org.rebioma.client.TableWidget.java

License:Apache License

public void showRecord(int pageSize, int startRow, Widget data[][]) {
    int totalRow = data.length;
    int destColCount = header.getWidgetCount();
    resize(totalRow, pageSize, startRow);
    for (int row = startRow, rowData = 0; row < startRow
            + (table.getWidgetCount() - (startRow % pageSize)); row++, rowData++) {
        Widget[] srcRowData = data[rowData];
        HorizontalPanel rowPanel = getRow(rowData);
        rowPanel.clear();/*  w  w w.j av  a  2  s  .c  om*/
        assert (srcRowData.length == destColCount) : " " + constants.ColMismatch();
        rowPanel.setStyleName("table-row");
        for (int srcColIndex = 0; srcColIndex < destColCount; ++srcColIndex) {
            Widget cellWidget = srcRowData[srcColIndex];
            cellWidget.setStyleName("col-" + header.getWidget(srcColIndex).getStyleName());
            rowPanel.add(cellWidget);
            // grid.setWidget(destRowIndex, srcColIndex, cellWidget);
            // grid.getCellFormatter().setStyleName(destRowIndex, srcColIndex,
            // " row");
        }
    }
}

From source file:org.unitime.timetable.gwt.client.sectioning.TimeGrid.java

License:Apache License

public ArrayList<Meeting> addClass(ClassAssignmentInterface.ClassAssignment row, int index) {
    if (!row.isAssigned())
        return null;
    iClasses.add(row);//from  ww w .j a va  2  s.c o m
    String name = (row.isFreeTime() ? MESSAGES.freeTimeCourse() + " " + MESSAGES.freeTimeSubject()
            : row.getSubject() + " " + row.getCourseNbr() + " " + row.getSubpart());
    String longName = name + (row.isFreeTime() ? "" : " " + row.getSection());
    String time = row.getDaysString(CONSTANTS.shortDays()) + " " + row.getStartString(CONSTANTS.useAmPm())
            + " - " + row.getEndString(CONSTANTS.useAmPm());
    ArrayList<String> notes = new ArrayList<String>();
    ArrayList<String> notesNoHtml = new ArrayList<String>();
    if (row.hasTitle() && CONSTANTS.showCourseTitle()) {
        notes.add(row.getTitle());
        notesNoHtml.add(row.getTitle());
    }
    if (row.hasRoom()) {
        notes.add(row.getRooms(", "));
        notesNoHtml.add(row.getRooms(", "));
    }
    String color = iColor.getColor(row);
    if (row.hasInstructors()) {
        if (!iPrint) {
            String instructors = "";
            for (int i = 0; i < row.getInstructors().size(); i++) {
                String email = (row.hasInstructorEmails() && i < row.getInstructorEmails().size()
                        ? row.getInstructorEmails().get(i)
                        : null);
                if (email != null && !email.isEmpty()) {
                    ImageLink il = new ImageLink(new Image(RESOURCES.email()), "mailto:" + email);
                    il.setTitle(MESSAGES.sendEmail(row.getInstructors().get(i)));
                    il.setStyleName("A.unitime-SimpleLink");
                    il.getElement().getStyle().setMarginRight(1, Unit.PX);
                    instructors += il.getElement().getString() + row.getInstructors().get(i)
                            + (i + 1 < row.getInstructors().size() ? ", " : "");
                } else {
                    instructors += row.getInstructors().get(i)
                            + (i + 1 < row.getInstructors().size() ? ", " : "");
                }
            }
            notes.add(instructors);
            notesNoHtml.add(row.getInstructors(", "));
        } else {
            notes.add(row.getInstructors(", "));
            notesNoHtml.add(row.getInstructors(", "));
        }
    }
    if (row.hasDatePattern()) {
        notes.add(row.getDatePattern());
        notesNoHtml.add(row.getDatePattern());
    }
    String note = "";
    for (String n : notesNoHtml) {
        if (n == null || n.isEmpty())
            continue;
        if (!note.isEmpty())
            note += ", ";
        note += n;
    }
    String title = longName + " (" + time + ", " + note + ")";
    if (note.isEmpty()) {
        title = longName + " (" + time + ")";
        note = time;
    }
    final ArrayList<Meeting> meetings = new ArrayList<Meeting>();
    for (int day : row.getDays()) {
        meetings.add(addMeeting(index, day, row.getStart(), row.getLength(), name, notes, row.getNote(), title,
                color, row.isPinned(), meetings));
    }
    if (row.isPinned())
        for (Meeting m : meetings)
            m.setPinned(true);
    if (row.hasDistanceConflict()) {
        for (Meeting m : meetings) {
            Widget dist = new Image(RESOURCES.distantConflict());
            if (iPrint) {
                dist = new Label(MESSAGES.distanceConflict(row.getBackToBackDistance()));
                dist.setStyleName("label");
                // FIXME: Workaround about inability of image bundle images to be printed
                // dist = new Image(GWT.getHostPageBaseURL() + "roadrunner16.png");
            }
            dist.setTitle(MESSAGES.backToBackDistance(row.getBackToBackRooms(), row.getBackToBackDistance()));
            m.addIcon(dist);
        }
    }
    if (row.isOfHighDemand() && !iPrint) {
        for (Meeting m : meetings) {
            Image highDemand = new Image(RESOURCES.highDemand());
            highDemand.setTitle(MESSAGES.highDemand(row.getExpected(), row.getAvailableLimit()));
            m.addIcon(highDemand);
        }
    }
    if (row.isSaved() && !iPrint) {
        for (Meeting m : meetings)
            m.setSaved(row.isSaved());
    }
    if (row.isCancelled() && !iPrint) {
        for (Meeting m : meetings) {
            Image cancelled = new Image(RESOURCES.cancelled());
            cancelled.setTitle(MESSAGES.classCancelled(name));
            m.addIcon(cancelled);
        }
    }
    iMeetings.add(meetings);
    return meetings;
}

From source file:org.waveprotocol.wave.client.widget.menu.PopupMenu.java

License:Apache License

@Override
public void addDivider() {
    Widget divider = new Label();
    divider.setStyleName(RESOURCES.css().divider());
    popup.add(divider);//from  w  w w .  j  av  a  2s  .  c o m
}