use of com.google.gwt.user.client.Element in project rstudio by rstudio.
the class MenuBar method updateSubmenuIcon.
/**
* Show or hide the icon used for items with a submenu.
*
* @param item the item with or without a submenu
*/
protected void updateSubmenuIcon(MenuItem item) {
// The submenu icon only applies to vertical menus
if (!vertical) {
return;
}
// Get the index of the MenuItem
int idx = allItems.indexOf(item);
if (idx == -1) {
return;
}
Element container = getItemContainerElement();
Element tr = DOM.getChild(container, idx);
int tdCount = DOM.getChildCount(tr);
MenuBar submenu = item.getSubMenu();
if (submenu == null || !item.isVisible()) {
// Remove the submenu indicator
if (tdCount == 2) {
DOM.removeChild(tr, DOM.getChild(tr, 1));
}
setItemColSpan(item, 2);
} else if (tdCount == 1) {
// Show the submenu indicator
setItemColSpan(item, 1);
Element td = DOM.createTD();
DOM.setElementProperty(td, "vAlign", "middle");
DOM.setInnerHTML(td, subMenuIcon.getHTML());
setStyleName(td, "subMenuIcon");
DOM.appendChild(tr, td);
}
}
use of com.google.gwt.user.client.Element in project opennms by OpenNMS.
the class GwtTerm method setColor.
/** Sets the currently selected color. */
public void setColor(String newcolor) {
// Give client-side feedback by changing the color name in the label
currentcolor.setText(newcolor);
// Obtain the DOM elements. This assumes that the <td> element
// of the HorizontalPanel is the parent of the label element.
final Element nameelement = currentcolor.getElement();
final Element cell = DOM.getParent(nameelement);
// Give feedback by changing the background color
DOM.setStyleAttribute(cell, "background", newcolor);
DOM.setStyleAttribute(nameelement, "background", newcolor);
if ("black navy maroon blue purple".indexOf(newcolor) != -1)
DOM.setStyleAttribute(nameelement, "color", "white");
else
DOM.setStyleAttribute(nameelement, "color", "black");
}
use of com.google.gwt.user.client.Element in project perun by CESNET.
the class CustomButton method setText.
/**
* Sets the text, if empty, look like "only image" icon
* @param text Text on the button
*/
@Override
public void setText(String text) {
// cleans the HTML
DOM.setInnerHTML(getElement(), "");
if (!text.equals("")) {
// set new text if present
this.text = text;
Element span = DOM.createElement("span");
span.setInnerText(text);
if (imageRight) {
span.addClassName("customButtonTextLeft");
} else {
span.addClassName("customButtonText");
}
DOM.insertChild(getElement(), span, 0);
}
// refresh image HTML
updateImage();
}
use of com.google.gwt.user.client.Element in project perun by CESNET.
the class AdvancedStackPanel method remove.
private boolean remove(Widget child, int index) {
// Make sure to call this before disconnecting the DOM.
boolean removed = super.remove(child);
if (removed) {
// Calculate which internal table elements to remove.
int rowIndex = 2 * index;
Element tr = DOM.getChild(body, rowIndex);
DOM.removeChild(body, tr);
tr = DOM.getChild(body, rowIndex);
DOM.removeChild(body, tr);
// Correct visible stack for new location.
if (visibleStack == index) {
visibleStack = -1;
} else if (visibleStack > index) {
--visibleStack;
}
// Update indices of all elements to the right.
updateIndicesFrom(index);
}
return removed;
}
use of com.google.gwt.user.client.Element in project perun by CESNET.
the class AdvancedStackPanel method setStackVisible.
private void setStackVisible(int index, boolean visible) {
// Get the first table row containing the widget's selector item.
Element tr = DOM.getChild(body, (index * 2));
if (tr == null) {
return;
}
// Style the stack selector item.
Element td = DOM.getFirstChild(tr);
setStyleName(td, DEFAULT_ITEM_STYLENAME + "-selected", visible);
// Show/hide the contained widget.
setStackContentVisible(index, visible);
// Set the style of the next header
Element trNext = DOM.getChild(body, ((index + 1) * 2));
if (trNext != null) {
Element tdNext = DOM.getFirstChild(trNext);
setStyleName(tdNext, DEFAULT_ITEM_STYLENAME + "-below-selected", visible);
}
}
Aggregations