private static final String ROW_HEADER_COLUMN_KEY = "0";
- public static final String CLASSNAME = "v-table";
- public static final String CLASSNAME_SELECTION_FOCUS = CLASSNAME + "-focus";
-
private static final double CACHE_RATE_DEFAULT = 2;
/**
public VScrollTable() {
setMultiSelectMode(MULTISELECT_MODE_DEFAULT);
- scrollBodyPanel.addStyleName(CLASSNAME + "-body-wrapper");
scrollBodyPanel.addFocusHandler(this);
scrollBodyPanel.addBlurHandler(this);
scrollBodyPanel.addScrollHandler(this);
- scrollBodyPanel.addStyleName(CLASSNAME + "-body");
/*
* Firefox auto-repeat works correctly only if we use a key press
}
}, ContextMenuEvent.getType());
- setStyleName(CLASSNAME);
+ setStyleName("v-table");
add(tHead);
add(scrollBodyPanel);
rowRequestHandler = new RowRequestHandler();
}
+ @Override
+ public void setStyleName(String style) {
+ scrollBodyPanel
+ .removeStyleName(getStylePrimaryName() + "-body-wrapper");
+ scrollBodyPanel.removeStyleName(getStylePrimaryName() + "-body");
+
+ super.setStyleName(style);
+
+ scrollBodyPanel.addStyleName(getStylePrimaryName() + "-body-wrapper");
+ scrollBodyPanel.addStyleName(getStylePrimaryName() + "-body");
+
+ tHead.updateStyleNames(getStylePrimaryName());
+ tFoot.updateStyleNames(getStylePrimaryName());
+ }
+
+
public void init(ApplicationConnection client) {
this.client = client;
// Add a handler to clear saved context menu details when the menu
void sizeInit() {
sizeNeedsInit = false;
+ // Ensure stylenames are set
+ setStyleName(getStyleName());
+
scrollBody.setContainerHeight();
/*
private void announceScrollPosition() {
if (scrollPositionElement == null) {
scrollPositionElement = DOM.createDiv();
- scrollPositionElement.setClassName(CLASSNAME + "-scrollposition");
+ scrollPositionElement.setClassName(getStylePrimaryName()
+ + "-scrollposition");
scrollPositionElement.getStyle().setPosition(Position.ABSOLUTE);
scrollPositionElement.getStyle().setDisplay(Display.NONE);
getElement().appendChild(scrollPositionElement);
public HeaderCell(String colId, String headerText) {
cid = colId;
- DOM.setElementProperty(colResizeWidget, "className", CLASSNAME
- + "-resizer");
-
setText(headerText);
DOM.appendChild(td, colResizeWidget);
- DOM.setElementProperty(sortIndicator, "className", CLASSNAME
- + "-sort-indicator");
- DOM.appendChild(td, sortIndicator);
-
- DOM.setElementProperty(captionContainer, "className", CLASSNAME
- + "-caption-container");
-
// ensure no clipping initially (problem on column additions)
DOM.setStyleAttribute(captionContainer, "overflow", "visible");
setAlign(ALIGN_LEFT);
}
+ protected void updateStyleNames(String primaryStyleName) {
+ colResizeWidget.setClassName(primaryStyleName + "-resizer");
+ sortIndicator.setClassName(primaryStyleName + "-sort-indicator");
+ captionContainer.setClassName(primaryStyleName + "-sort-indicator");
+ if (sorted) {
+ if (sortAscending) {
+ setStyleName(primaryStyleName + "-header-cell-asc");
+ } else {
+ setStyleName(primaryStyleName + "-header-cell-desc");
+ }
+ } else {
+ setStyleName(primaryStyleName + "-header-cell");
+ }
+
+ final String ALIGN_PREFIX = primaryStyleName
+ + "-caption-container-align-";
+ captionContainer.removeClassName(ALIGN_PREFIX + "center");
+ captionContainer.removeClassName(ALIGN_PREFIX + "right");
+ captionContainer.removeClassName(ALIGN_PREFIX + "left");
+ switch (align) {
+ case ALIGN_CENTER:
+ captionContainer.addClassName(ALIGN_PREFIX + "center");
+ break;
+ case ALIGN_RIGHT:
+ captionContainer.addClassName(ALIGN_PREFIX + "right");
+ break;
+ default:
+ captionContainer.addClassName(ALIGN_PREFIX + "left");
+ break;
+ }
+ }
+
public void disableAutoWidthCalculation() {
definedWidth = true;
expandRatio = 0;
private void setSorted(boolean sorted) {
this.sorted = sorted;
- if (sorted) {
- if (sortAscending) {
- this.setStyleName(CLASSNAME + "-header-cell-asc");
- } else {
- this.setStyleName(CLASSNAME + "-header-cell-desc");
- }
- } else {
- this.setStyleName(CLASSNAME + "-header-cell");
- }
+ updateStyleNames(VScrollTable.this.getStylePrimaryName());
}
/**
floatingCopyOfHeaderCell = DOM
.getChild(floatingCopyOfHeaderCell, 2);
DOM.setElementProperty(floatingCopyOfHeaderCell, "className",
- CLASSNAME + "-header-drag");
+ VScrollTable.this.getStylePrimaryName() + "-header-drag");
// otherwise might wrap or be cut if narrow column
DOM.setStyleAttribute(floatingCopyOfHeaderCell, "width", "auto");
updateFloatingCopysPosition(DOM.getAbsoluteLeft(td),
}
public void setAlign(char c) {
- final String ALIGN_PREFIX = CLASSNAME + "-caption-container-align-";
- if (align != c) {
- captionContainer.removeClassName(ALIGN_PREFIX + "center");
- captionContainer.removeClassName(ALIGN_PREFIX + "right");
- captionContainer.removeClassName(ALIGN_PREFIX + "left");
- switch (c) {
- case ALIGN_CENTER:
- captionContainer.addClassName(ALIGN_PREFIX + "center");
- break;
- case ALIGN_RIGHT:
- captionContainer.addClassName(ALIGN_PREFIX + "right");
- break;
- default:
- captionContainer.addClassName(ALIGN_PREFIX + "left");
- break;
- }
- }
align = c;
+ updateStyleNames(VScrollTable.this.getStylePrimaryName());
}
public char getAlign() {
RowHeadersHeaderCell() {
super(ROW_HEADER_COLUMN_KEY, "");
- this.setStyleName(CLASSNAME + "-header-cell-rowheader");
+ }
+
+ @Override
+ protected void updateStyleNames(String primaryStyleName) {
+ super.updateStyleNames(primaryStyleName);
+ setStyleName(primaryStyleName + "-header-cell-rowheader");
}
@Override
}
DOM.setStyleAttribute(hTableWrapper, "overflow", "hidden");
- DOM.setElementProperty(hTableWrapper, "className", CLASSNAME
- + "-header");
-
- // TODO move styles to CSS
- DOM.setElementProperty(columnSelector, "className", CLASSNAME
- + "-column-selector");
DOM.setStyleAttribute(columnSelector, "display", "none");
DOM.appendChild(table, headerTableBody);
DOM.appendChild(div, columnSelector);
setElement(div);
- setStyleName(CLASSNAME + "-header-wrap");
-
DOM.sinkEvents(columnSelector, Event.ONCLICK);
availableCells.put(ROW_HEADER_COLUMN_KEY,
new RowHeadersHeaderCell());
+
+ updateStyleNames(VScrollTable.this.getStylePrimaryName());
+ }
+
+ protected void updateStyleNames(String primaryStyleName) {
+ hTableWrapper.setClassName(primaryStyleName + "-header");
+ columnSelector.setClassName(primaryStyleName + "-column-selector");
+ setStyleName(primaryStyleName + "-header-wrap");
+ for (HeaderCell c : availableCells.values()) {
+ c.updateStyleNames(primaryStyleName);
+ }
}
public void resizeCaptionContainer(HeaderCell cell) {
private void focusSlot(int index) {
removeSlotFocus();
if (index > 0) {
- DOM.setElementProperty(
- DOM.getFirstChild(DOM.getChild(tr, index - 1)),
- "className", CLASSNAME + "-resizer " + CLASSNAME
- + "-focus-slot-right");
+ Element child = tr.getChild(index - 1).getFirstChild().cast();
+ child.setClassName(VScrollTable.this.getStylePrimaryName()
+ + "-resizer");
+ child.addClassName(VScrollTable.this.getStylePrimaryName()
+ + "-focus-slot-right");
} else {
- DOM.setElementProperty(
- DOM.getFirstChild(DOM.getChild(tr, index)),
- "className", CLASSNAME + "-resizer " + CLASSNAME
- + "-focus-slot-left");
+ Element child = tr.getChild(index).getFirstChild().cast();
+ child.setClassName(VScrollTable.this.getStylePrimaryName()
+ + "-resizer");
+ child.addClassName(VScrollTable.this.getStylePrimaryName()
+ + "-focus-slot-left");
}
focusedSlot = index;
}
return;
}
if (focusedSlot == 0) {
- DOM.setElementProperty(
- DOM.getFirstChild(DOM.getChild(tr, focusedSlot)),
- "className", CLASSNAME + "-resizer");
+ Element child = tr.getChild(focusedSlot).getFirstChild().cast();
+ child.setClassName(VScrollTable.this.getStylePrimaryName()
+ + "-resizer");
} else if (focusedSlot > 0) {
- DOM.setElementProperty(
- DOM.getFirstChild(DOM.getChild(tr, focusedSlot - 1)),
- "className", CLASSNAME + "-resizer");
+ Element child = tr.getChild(focusedSlot - 1).getFirstChild()
+ .cast();
+ child.setClassName(VScrollTable.this.getStylePrimaryName()
+ + "-resizer");
}
focusedSlot = -1;
}
setText(headerText);
- DOM.setElementProperty(captionContainer, "className", CLASSNAME
- + "-footer-container");
-
// ensure no clipping initially (problem on column additions)
DOM.setStyleAttribute(captionContainer, "overflow", "visible");
| Event.ONCONTEXTMENU);
setElement(td);
+
+ updateStyleNames(VScrollTable.this.getStylePrimaryName());
+ }
+
+ protected void updateStyleNames(String primaryStyleName) {
+ captionContainer.setClassName(primaryStyleName
+ + "-footer-container");
}
/**
public TableFooter() {
DOM.setStyleAttribute(hTableWrapper, "overflow", "hidden");
- DOM.setElementProperty(hTableWrapper, "className", CLASSNAME
- + "-footer");
DOM.appendChild(table, headerTableBody);
DOM.appendChild(headerTableBody, tr);
DOM.appendChild(div, hTableWrapper);
setElement(div);
- setStyleName(CLASSNAME + "-footer-wrap");
-
availableCells.put(ROW_HEADER_COLUMN_KEY,
new RowHeadersFooterCell());
+
+ updateStyleNames(VScrollTable.this.getStylePrimaryName());
+ }
+
+ protected void updateStyleNames(String primaryStyleName) {
+ hTableWrapper.setClassName(primaryStyleName + "-footer");
+ setStyleName(primaryStyleName + "-footer-wrap");
+ for (FooterCell c : availableCells.values()) {
+ c.updateStyleNames(primaryStyleName);
+ }
}
@Override
}
private void constructDOM() {
- DOM.setElementProperty(table, "className", CLASSNAME + "-table");
if (BrowserInfo.get().isIE()) {
table.setPropertyInt("cellSpacing", 0);
}
- DOM.setElementProperty(preSpacer, "className", CLASSNAME
- + "-row-spacer");
- DOM.setElementProperty(postSpacer, "className", CLASSNAME
- + "-row-spacer");
table.appendChild(tBodyElement);
DOM.appendChild(container, preSpacer);
"translate3d(0,0,0)");
}
}
+ updateStyleNames(VScrollTable.this.getStylePrimaryName());
+ }
+ protected void updateStyleNames(String primaryStyleName) {
+ table.setClassName(primaryStyleName + "-table");
+ preSpacer.setClassName(primaryStyleName + "-row-spacer");
+ postSpacer.setClassName(primaryStyleName + "-row-spacer");
+ for (Widget w : renderedRows) {
+ VScrollTableRow row = (VScrollTableRow) w;
+ row.updateStyleNames(primaryStyleName);
+ }
}
public int getAvailableWidth() {
private final TableRowElement rowElement;
private int index;
private Event touchStart;
- private static final String ROW_CLASSNAME_EVEN = CLASSNAME + "-row";
- private static final String ROW_CLASSNAME_ODD = CLASSNAME
- + "-row-odd";
+ // private static final String ROW_CLASSNAME_EVEN = CLASSNAME +
+ // "-row";
+ // private static final String ROW_CLASSNAME_ODD = CLASSNAME
+ // + "-row-odd";
private static final int TOUCH_CONTEXT_MENU_TIMEOUT = 500;
private Timer contextTouchTimeout;
private Timer dragTouchTimeout;
String rowStyle = uidl.getStringAttribute("rowstyle");
if (rowStyle != null) {
- addStyleName(CLASSNAME + "-row-" + rowStyle);
+ addStyleName(VScrollTable.this.getStylePrimaryName()
+ + "-row-" + rowStyle);
}
String rowDescription = uidl.getStringAttribute("rowdescr");
}
}
+ protected void updateStyleNames(String primaryStyleName) {
+
+ }
+
public TooltipInfo getTooltipInfo() {
return tooltipInfo;
}
*/
public VScrollTableRow() {
this(0);
- addStyleName(CLASSNAME + "-row");
+ addStyleName(VScrollTable.this.getStylePrimaryName() + "-row");
addCell(null, "_", 'b', "", true, false);
}
//
// First remove any old styles so that both styles aren't
// applied when indexes are updated.
- removeStyleName(ROW_CLASSNAME_ODD);
- removeStyleName(ROW_CLASSNAME_EVEN);
+ String primaryStyleName = getStylePrimaryName();
+ if (primaryStyleName != null && !primaryStyleName.equals("")) {
+ removeStyleName(getStylePrimaryName());
+ }
if (!isOdd) {
- addStyleName(ROW_CLASSNAME_ODD);
+ addStyleName(VScrollTable.this.getStylePrimaryName()
+ + "-row-odd");
} else {
- addStyleName(ROW_CLASSNAME_EVEN);
+ addStyleName(VScrollTable.this.getStylePrimaryName()
+ + "-row");
}
}
String style, boolean textIsHTML, boolean sorted,
String description, final TableCellElement td) {
final Element container = DOM.createDiv();
- String className = CLASSNAME + "-cell-content";
+ String className = VScrollTable.this.getStylePrimaryName()
+ + "-cell-content";
if (style != null && !style.equals("")) {
- className += " " + CLASSNAME + "-cell-content-" + style;
+ className += " " + VScrollTable.this.getStylePrimaryName()
+ + "-cell-content-" + style;
}
if (sorted) {
- className += " " + CLASSNAME + "-cell-content-sorted";
+ className += " " + VScrollTable.this.getStylePrimaryName()
+ + "-cell-content-sorted";
}
td.setClassName(className);
- container.setClassName(CLASSNAME + "-cell-wrapper");
+ container.setClassName(VScrollTable.this.getStylePrimaryName()
+ + "-cell-wrapper");
if (textIsHTML) {
container.setInnerHTML(text);
} else {
protected void initCellWithWidget(Widget w, char align,
String style, boolean sorted, final TableCellElement td) {
final Element container = DOM.createDiv();
- String className = CLASSNAME + "-cell-content";
+ String className = VScrollTable.this.getStylePrimaryName()
+ + "-cell-content";
if (style != null && !style.equals("")) {
- className += " " + CLASSNAME + "-cell-content-" + style;
+ className += " " + VScrollTable.this.getStylePrimaryName()
+ + "-cell-content-" + style;
}
if (sorted) {
- className += " " + CLASSNAME + "-cell-content-sorted";
+ className += " " + VScrollTable.this.getStylePrimaryName()
+ + "-cell-content-sorted";
}
td.setClassName(className);
- container.setClassName(CLASSNAME + "-cell-wrapper");
+ container.setClassName(VScrollTable.this.getStylePrimaryName()
+ + "-cell-wrapper");
// TODO most components work with this, but not all (e.g.
// Select)
// Old comment: make widget cells respect align.
}
private void deEmphasis() {
- UIObject.setStyleName(getElement(), CLASSNAME + "-drag", false);
+ UIObject.setStyleName(getElement(),
+ VScrollTable.this.getStylePrimaryName() + "-drag", false);
if (lastEmphasized == null) {
return;
}
*/
private void emphasis(TableDDDetails details) {
deEmphasis();
- UIObject.setStyleName(getElement(), CLASSNAME + "-drag", true);
+ UIObject.setStyleName(getElement(),
+ VScrollTable.this.getStylePrimaryName() + "-drag", true);
// iterate old and new emphasized row
for (Widget w : scrollBody.renderedRows) {
VScrollTableRow row = (VScrollTableRow) w;
// Remove previous selection
if (focusedRow != null && focusedRow != row) {
- focusedRow.removeStyleName(CLASSNAME_SELECTION_FOCUS);
+ focusedRow.removeStyleName(getStylePrimaryName());
}
if (row != null) {
// Apply focus style to new selection
- row.addStyleName(CLASSNAME_SELECTION_FOCUS);
+ row.addStyleName(getStylePrimaryName() + "-focus");
/*
* Trying to set focus on already focused row