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:ar.com.kyol.jet.client.JetTable.java

License:Open Source License

protected void addColumn(Object columnHeading) {
    Widget widget = createCellWidget(columnHeading);
    int cell = this.getHeader().getCellCount(HEADER_ROW_INDEX);

    widget.setWidth("100%");
    widget.addStyleName("JetTable-ColumnLabel");

    this.getHeader().setWidget(HEADER_ROW_INDEX, cell, widget);

    this.getHeader().getCellFormatter().addStyleName(HEADER_ROW_INDEX, cell, "JetTable-ColumnLabelCell");
}

From source file:asquare.gwt.tk.client.ui.AlertDialog.java

License:Apache License

/**
 * Adds a widget to button panel. The widget will be added to the focus
 * cycle if it implements {@link HasFocus} and does not have a tabIndex < 0.
 * The widget must implement {@link SourcesClickEvents}. When the widget is
 * clicked, the specified command will be executed.
 * //w w w. j ava  2 s  . co m
 * @param widget the widget to add
 * @param hotKey the keycode of a key which will execute the widget's
 *            associated command when pressed
 * @param type a constant representing special button behavior
 * @param closeDialog <code>true</code> to close the dialog when the
 *            button is clicked
 * @param command a command to execute if the widget is clicked, or
 *            <code>null</code>
 * @throws ClassCastException if <code>widget</code> does not implement
 *             {@link SourcesClickEvents}
 */
public void addButton(Widget widget, char hotKey, int type, final boolean closeDialog, final Command command) {
    HasClickHandlers clickable = (HasClickHandlers) widget;
    boolean focusable = widget instanceof Focusable;
    final HideAndExecuteCommand command0 = new HideAndExecuteCommand(AlertDialog.this, closeDialog, command);

    clickable.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            command0.execute();
        }
    });
    m_buttonPanel.add(widget);
    if (focusable) {
        getFocusModel().add((Focusable) widget);
    }
    if ((type & BUTTON_DEFAULT) != 0) {
        widget.addStyleName("tk-AlertDialog-defaultButton");
        m_defaultButton = widget;
        if (focusable && getFocusModel().contains((Focusable) widget)) {
            getFocusModel().setFocusWidget((Focusable) widget);
        }
    }
    if ((type & BUTTON_CANCEL) != 0) {
        m_keyMap.put((char) KeyEvent.KEYCODE_ESCAPE, command0);
    }
    if (hotKey > 0) {
        m_keyMap.put(Character.toUpperCase(hotKey), command0);
    }
}

From source file:asquare.gwt.tkdemo.client.demos.DebugPanel.java

License:Apache License

public DebugPanel() {
    ColumnPanel outer = new ColumnPanel();

    initWidget(outer);/*from  w ww .  ja  v a  2 s  .c  om*/

    Widget docPanel = createDocPanel();
    docPanel.addStyleName("division");
    outer.add(docPanel);

    RowPanel right = new RowPanel();
    outer.add(right);

    Widget controlPanel = createControlPanel(m_eventListener);
    controlPanel.addStyleName("division");
    controlPanel.addStyleName("example");
    right.add(controlPanel);

    Widget widgetPanel = createWidgetPanel();
    widgetPanel.addStyleName("division");
    widgetPanel.addStyleName("example");
    right.add(widgetPanel);

    m_eventListener.install();
}

From source file:burrito.client.crud.CrudEntityEdit.java

License:Apache License

private void init() {

    for (CrudField field : desc.getFields()) {
        CrudInputField<?> inputField = CrudFieldResolver.createInputField(field, service);
        if (inputField == null) {
            continue;
        }/*from  w  ww .j a  va2s . c om*/
        String label = getDisplayLabel(field, desc.getEntityName());
        String description = getDescriptionLabel(field, desc.getEntityName());
        Widget w = inputField.getDisplayWidget();
        if (firstField == null && w instanceof InputField) {
            firstField = (InputField<?>) w;
        }
        String underscore = desc.getEntityName().replace('.', '_');
        w.addStyleName(underscore + "_" + field.getName());
        w.addStyleName(underscore);
        add(w, label, description);
        fields.add(inputField);
    }

}

From source file:burrito.client.widgets.form.EditForm.java

License:Apache License

public void add(Widget widget, String label, String description) {
    if (widget instanceof HasValidators) {
        validateables.add((HasValidators) widget);
    }// w ww.j av  a2s  .  com
    if (widget instanceof HasKeyDownHandlers) {
        ((HasKeyDownHandlers) widget).addKeyDownHandler(saveEnablerKeyDownAction);
    }
    if (widget instanceof HasChangeHandlers) {
        ((HasChangeHandlers) widget).addChangeHandler(saveEnablerChangeHandler);
    }
    if (widget instanceof CheckBox) {
        ((CheckBox) widget).addClickHandler(saveEnablerClickHandler);
    }

    List<Widget> companionWidgets = new ArrayList<Widget>();
    if (label == null) {
        label = "";
    }
    Label l = new Label(label);
    l.addStyleName("k5-EditForm-label");
    if (!widget.isVisible())
        l.setVisible(false);
    main.getFlexCellFormatter().setRowSpan(this.currentRow, 0, 2);
    main.setWidget(this.currentRow, 0, l);
    companionWidgets.add(l);

    main.setWidget(this.currentRow, 1, widget);
    widget.addStyleName("cell-widget-inner");
    main.getCellFormatter().addStyleName(this.currentRow, 1, "cell-widget");
    main.getCellFormatter().addStyleName(this.currentRow, 0, "cell-label");

    if (description == null) {
        description = "";
    }

    this.currentRow++;
    Label desc = new Label(description);
    desc.addStyleName("k5-EditForm-description");
    if (!widget.isVisible())
        desc.setVisible(false);
    main.setWidget(this.currentRow, 0, desc);
    main.getCellFormatter().addStyleName(this.currentRow, 0, "cell-description");
    companionWidgets.add(desc);

    this.currentRow++;
    VerticalSpacer spacer = new VerticalSpacer(10);
    main.setWidget(this.currentRow, 0, spacer);
    companionWidgets.add(spacer);
    this.currentRow++;
    companionWidgetsMap.put(widget, companionWidgets);
}

From source file:cc.alcina.framework.gwt.client.gwittir.widget.BoundTableExt.java

License:Open Source License

protected void addRow(final SourcesPropertyChangeEvents o) {
    int row = table.getRowCount();
    if (((((masks & BoundTableExt.HEADER_MASK) > 0) && (row >= 2))
            || (((masks & BoundTableExt.HEADER_MASK) == 0) && (row >= 1)))
            && ((masks & BoundTableExt.SPACER_ROW_MASK) > 0)) {
        table.setWidget(row, 0, new Label(""));
        table.getFlexCellFormatter().setColSpan(row, 0, this.columns.length);
        table.getRowFormatter().setStyleName(row, "spacer");
        row++;/*ww  w. j  ava 2s .  c o  m*/
    }
    Binding bindingRow = new Binding();
    topBinding.getChildren().add(bindingRow);
    int count = topBinding.getChildren().size();
    final Widget handle;
    int startColumn = 0;
    if ((this.masks & BoundTableExt.ROW_HANDLE_MASK) > 0) {
        if ((this.masks & BoundTableExt.HANDLES_AS_CHECKBOXES) > 0) {
            handle = new Checkbox();
        } else {
            handle = new Button(
                    (this.getActive() && (rowHandles.size() < 9)) ? Integer.toString(this.rowHandles.size() + 1)
                            : " ");
        }
        handle.setStyleName("rowHandle");
        ((HasFocus) handle).addFocusListener(new FocusListener() {
            public void onFocus(Widget sender) {
                if (shiftDown) {
                    return;
                }
                setActive(true);
                List newSelected = null;
                if ((masks & BoundTableExt.MULTIROWSELECT_MASK) > 0) {
                    newSelected = new ArrayList(getSelected());
                    if (newSelected.contains(o)) {
                        newSelected.remove(o);
                    } else {
                        newSelected.add(o);
                    }
                } else {
                    newSelected = new ArrayList();
                    newSelected.add(o);
                }
                setSelected(newSelected);
            }

            public void onLostFocus(Widget sender) {
            }
        });
        ((SourcesClickEvents) handle).addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                setActive(true);
                List newSelected = null;
                if ((masks & BoundTableExt.MULTIROWSELECT_MASK) > 0) {
                    newSelected = new ArrayList(getSelected());
                    if (newSelected.contains(o)) {
                        newSelected.remove(o);
                    } else {
                        newSelected.add(o);
                    }
                } else {
                    newSelected = new ArrayList();
                    newSelected.add(o);
                }
                if (handle != null) {
                    ((HasFocus) handle).setFocus(true);
                }
                if (handle != null) {
                    ((HasFocus) handle).setFocus(true);
                }
                setSelected(newSelected);
            }
        });
        startColumn++;
        this.rowHandles.add(handle);
        this.table.setWidget(row, 0, handle);
    } else {
        handle = null;
    }
    if (count < 10) {
        SuggestedKeyBinding kb = new SuggestedKeyBinding(Integer.toString(count).charAt(0), false, true, false);
        Task task = new Task() {
            public void run() {
                List newSelected = new ArrayList(getSelected());
                if (newSelected.contains(o)) {
                    newSelected.remove(o);
                } else {
                    newSelected.add(o);
                }
                setSelected(newSelected);
                if (handle != null) {
                    ((HasFocus) handle).setFocus(true);
                }
            }
        };
        this.keyBindings.put(kb, task);
        if (this.getActive()) {
            try {
                KeyboardController.INSTANCE.register(kb, task);
            } catch (KeyBindingException kbe) {
                BoundTableExt.LOG.log(Level.DEBUG, "Unable to register" + kb, kbe);
            }
        }
    }
    for (int col = 0; col < this.columns.length; col++) {
        Widget widget = (Widget) createCellWidget(bindingRow, col, o);
        try {
            table.setWidget(row, col + startColumn, widget);
            if (widget instanceof HasFocus) {
                addSelectedFocusListener((HasFocus) widget, topBinding.getChildren().size() - 1,
                        col + startColumn);
            }
            if (widget instanceof SourcesClickEvents) {
                addSelectedClickListener((SourcesClickEvents) widget, topBinding.getChildren().size() - 1,
                        col + startColumn);
            }
            if (this.columns[col].getWidgetStyleName() != null) {
                widget.addStyleName(this.columns[col].getWidgetStyleName());
            }
            if (this.columns[col].getStyleName() != null) {
                table.getCellFormatter().setStyleName(row, col + startColumn, this.columns[col].getStyleName());
            }
        } catch (RuntimeException e) {
            BoundTableExt.LOG.log(Level.ERROR, widget + "", e);
        }
    }
    if ((this.masks & BoundTableExt.END_ROW_BUTTON) > 0) {
        EndRowButton endRowButton = new EndRowButton();
        table.setWidget(row, this.columns.length + startColumn, endRowButton);
        int f_row = row;
        endRowButton.addClickHandler(e -> {
            EndRowButtonClickedEvent.fire(BoundTableExt.this, f_row, o);
        });
    }
    if (collectionPropertyChangeListener != null) {
        o.addPropertyChangeListener(collectionPropertyChangeListener);
        listenedToByCollectionChangeListener.add(o);
    }
    boolean odd = (this.calculateRowToObjectOffset(new Integer(row)).intValue() % 2) != 0;
    this.table.getRowFormatter().setStyleName(row, odd ? "odd" : "even");
    bindingRow.setLeft();
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void addOrRemoveStyleName(Widget w, String styleName, boolean add) {
    if (!add) {/* ww  w. j  a  va2s  .c  o  m*/
        w.removeStyleName(styleName);
    } else {
        w.addStyleName(styleName);
    }
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void setOrRemoveStyleName(Widget widget, String styleName, boolean set) {
    if (set) {//from  ww  w.  j  a va 2 s.c o m
        widget.addStyleName(styleName);
    } else {
        widget.removeStyleName(styleName);
    }
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void toggleStyleName(Widget w, String styleName) {
    String current = w.getStyleName();
    if (current.contains(styleName)) {
        w.removeStyleName(styleName);// w w w  . j a v  a  2 s  . com
    } else {
        w.addStyleName(styleName);
    }
}

From source file:cc.alcina.framework.gwt.client.widget.complex.FastROBoundTable.java

License:Apache License

@Override
protected void addRow(final SourcesPropertyChangeEvents o) {
    int row = table.getRowCount();
    final CheckBox handle;
    int startColumn = 0;
    final List<CheckBox> handles = this.rowHandles;
    if ((this.masks & BoundTableExt.ROW_HANDLE_MASK) > 0) {
        handle = new CheckBox();
        handle.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                setActive(true);/*  w w w  . j a  va 2s.  c  o m*/
                List newSelected = null;
                if ((masks & BoundTableExt.MULTIROWSELECT_MASK) > 0) {
                    newSelected = new ArrayList(getSelectedObjects());
                } else {
                    for (CheckBox cb : handles) {
                        if (cb != handle) {
                            cb.setValue(false);
                        }
                    }
                    newSelected = new ArrayList();
                }
                if (!handle.getValue()) {
                    newSelected.remove(o);
                } else {
                    newSelected.add(o);
                }
                setSelected(newSelected);
                setSelectedObjects(newSelected);
            }
        });
        startColumn++;
        this.rowHandles.add(handle);
        this.table.setWidget(row, 0, handle);
    } else {
        handle = null;
    }
    for (int col = 0; col < this.columns.length; col++) {
        Widget widget = (Widget) createCellWidget(col, o);
        if (this.columns[col].getWidgetStyleName() != null) {
            widget.addStyleName(this.columns[col].getWidgetStyleName());
        }
        table.setWidget(row, col + startColumn, widget);
        if (this.columns[col].getStyleName() != null) {
            table.getCellFormatter().setStyleName(row, col + startColumn, this.columns[col].getStyleName());
        }
    }
    if ((this.masks & BoundTableExt.END_ROW_BUTTON) > 0) {
        EndRowButton endRowButton = new EndRowButton();
        table.setWidget(row, this.columns.length + startColumn, endRowButton);
        int f_row = row;
        endRowButton.addClickHandler(e -> {
            EndRowButtonClickedEvent.fire(FastROBoundTable.this, f_row, o);
        });
    }
    boolean odd = (this.calculateRowToObjectOffset(new Integer(row)).intValue() % 2) != 0;
    this.table.getRowFormatter().setStyleName(row, odd ? "odd" : "even");
}