/** * Replace one class name with another. * * @param oldClassName the class name to be replaced * @param newClassName the class name to replace it */ public final void replaceClassName(String oldClassName, String newClassName) { removeClassName(oldClassName); addClassName(newClassName); }
/** * Add the class name if it doesn't exist or removes it if does. * * @param className the class name to be toggled */ public final void toggleClassName(String className) { boolean added = addClassName(className); if (!added) { removeClassName(className); } }
/** * This convenience method adds or removes a style name for a given element. * This method is typically used to add and remove secondary style names, but * it can be used to remove primary stylenames as well, but that is not * recommended. See {@link #setStyleName(String)} for a description of how * primary and secondary style names are used. * * @param elem the element whose style is to be modified * @param style the secondary style name to be added or removed * @param add <code>true</code> to add the given style, <code>false</code> to * remove it */ protected static void setStyleName(Element elem, String style, boolean add) { if (elem == null) { throw new RuntimeException(NULL_HANDLE_MSG); } style = style.trim(); if (style.length() == 0) { throw new IllegalArgumentException(EMPTY_STYLENAME_MSG); } if (add) { elem.addClassName(style); } else { elem.removeClassName(style); } }
@Override public void onPush(Element parent) { parent.getFirstChildElement().addClassName(style.buttonCellBasePushing()); }
public void setDisabled(boolean isDisabled) { if (this.disabled == isDisabled) { return; } this.disabled = isDisabled; if (disabled) { setResource(resDisabled); getElement().getParentElement().addClassName(styleDisabled); } else { setResource(resEnabled); getElement().getParentElement().removeClassName(styleDisabled); } Roles.getButtonRole().setAriaDisabledState(getElement(), disabled); } }
/** * Enable or disable the fast forward button. * * @param disabled true to disable, false to enable */ private void setFastForwardDisabled(boolean disabled) { if (fastForward == null) { return; } if (disabled) { fastForward.setResource(resources.simplePagerFastForwardDisabled()); fastForward.getElement().getParentElement().addClassName( style.disabledButton()); } else { fastForward.setResource(resources.simplePagerFastForward()); fastForward.getElement().getParentElement().removeClassName( style.disabledButton()); } }
/** * Construct a new {@link NativeHorizontalScrollbar}. * * @param resources the resources used by this widget */ public NativeHorizontalScrollbar(Resources resources) { setElement(uiBinder.createAndBindUi(this)); getElement().addClassName(CommonResources.getInlineBlockStyle()); setHeight(getNativeHeight() + "px"); // Apply the styles. Style style = resources.nativeHorizontalScrollbarStyle(); style.ensureInjected(); getScrollableElement().addClassName(style.nativeHorizontalScrollbar()); // Initialize the implementation. ScrollImpl.get().initialize(scrollable, contentDiv); }
/** * Construct a new {@link NativeVerticalScrollbar}. * * @param resources the resources used by this widget */ public NativeVerticalScrollbar(Resources resources) { setElement(uiBinder.createAndBindUi(this)); getElement().addClassName(CommonResources.getInlineBlockStyle()); setWidth(getNativeWidth() + "px"); // Apply the styles. Style style = resources.nativeVerticalScrollbarStyle(); style.ensureInjected(); getScrollableElement().addClassName(style.nativeVerticalScrollbar()); // inject style used in uibinder UiBinderBundle.INSTANCE.nativeVerticalScrollbarUi().ensureInjected(); // Initialize the implementation. ScrollImpl.get().initialize(scrollable, contentDiv); }
firstPage.getElement().getParentElement().addClassName(style.button()); prevPage.getElement().getParentElement().addClassName(style.button()); label.getElement().getParentElement().addClassName(style.pageDetails()); nextPage.getElement().getParentElement().addClassName(style.button()); if (showFastForwardButton) { fastForward.getElement().getParentElement().addClassName(style.button()); lastPage.getElement().getParentElement().addClassName(style.button());
cornerElem.addClassName(style.customScrollPanelCorner()); cornerLayer = layout.attachChild(cornerElem);
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be a <textarea> element. * * @param element the element to be used */ protected TextArea(final Element element) { super(element.<Element>cast()); TextAreaElement.as(element); element.addClassName(Styles.FORM_CONTROL); }
@Override public void run() { node.addClassName(CellList.this.appearance.css().selected()); } };
public static <E extends Style.HasCssName> void addEnumStyleName(final Element element, final E style) { if (style != null && style.getCssName() != null && !style.getCssName().isEmpty()) { element.addClassName(style.getCssName()); } }
/** * @return a new icon element. We only create this when {@link #iconElement} * is null or the {@link #iconType} has changed. */ protected Element createIconElement() { Element e = Document.get().createElement(ElementTags.I); e.addClassName(Styles.FONT_AWESOME_BASE); e.addClassName(iconType.getCssName()); e.getStyle().setPaddingRight(5, Unit.PX); return e; }
private void addToDataGrid(final TableType tableType) { getTableHeadElement().getParentElement().addClassName(tableType.getCssName()); getTableBodyElement().getParentElement().addClassName(tableType.getCssName()); getTableFootElement().getParentElement().addClassName(tableType.getCssName()); }
/** * Constructs a table with the given page size with the specified * {@link Resources}. * * @param pageSize the page size * @param resources the resources to use for this widget */ public DataGrid(final int pageSize, final DataGrid.Resources resources) { super(pageSize, resources, null); getTableBodyElement().getParentElement().addClassName(TableType.DEFAULT.getCssName()); }
private void addToDataGrid(final TableType tableType) { getTableHeadElement().getParentElement().addClassName(tableType.getCssName()); getTableBodyElement().getParentElement().addClassName(tableType.getCssName()); getTableFootElement().getParentElement().addClassName(tableType.getCssName()); }
/** * Constructs a table with the given page size and the given * {@link ProvidesKey key provider}. * * @param pageSize the page size * @param keyProvider an instance of ProvidesKey, or null if the record * object should act as its own key */ public DataGrid(final int pageSize, final ProvidesKey<T> keyProvider) { super(pageSize, getDefaultResources(), keyProvider); getTableBodyElement().getParentElement().addClassName(TableType.DEFAULT.getCssName()); }
@Override public void onRowOver(int rowNum) { if(!table.isEnabled()) return; // toggle rollover tools if(rowNum<provider.getList().size()) { TableCellElement rollOverItem = table.getRowElement(rowNum).getCells().getItem(2); rollOverItem.getFirstChildElement().getFirstChildElement().addClassName("row-tools-enabled"); } }
private void applyTableStyle(boolean striped, TableType type) { if(striped) { getTableHeadElement().getParentElement().addClassName(type.get()); getTableBodyElement().getParentElement().addClassName(type.get()); getTableFootElement().getParentElement().addClassName(type.get()); } else { getTableHeadElement().getParentElement().removeClassName(type.get()); getTableBodyElement().getParentElement().removeClassName(type.get()); getTableFootElement().getParentElement().removeClassName(type.get()); } }