VHasDropHandler, FocusHandler, BlurHandler, Focusable, ActionOwner {
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";
}
/**
- * Non-immediate variable update of column resize events for a bunch of
+ * Non-immediate variable update of column widths for a collection of
* columns.
*
* @param columns
* the columns to trigger the events for.
*/
- private void enqueueColumnResizeEventsForColumns(
- Collection<HeaderCell> columns) {
+ private void sendColumnWidthUpdates(Collection<HeaderCell> columns) {
String[] newSizes = new String[columns.size()];
int ix = 0;
for (HeaderCell cell : columns) {
newSizes[ix++] = cell.getColKey() + ":" + cell.getWidth();
}
- client.updateVariable(paintableId, "columnResizeEvents", newSizes,
+ client.updateVariable(paintableId, "columnWidthUpdates", newSizes,
false);
}
public void updateCellsFromUIDL(UIDL uidl) {
Iterator<?> it = uidl.getChildIterator();
HashSet<String> updated = new HashSet<String>();
- updated.add(ROW_HEADER_COLUMN_KEY);
while (it.hasNext()) {
final UIDL col = (UIDL) it.next();
final String cid = col.getStringAttribute("cid");
ArrayList<HeaderCell> columns = new ArrayList<HeaderCell>(
availableCells.values());
columns.remove(source);
- enqueueColumnResizeEventsForColumns(columns);
+ sendColumnWidthUpdates(columns);
forceRealignColumnHeaders();
}
}
public void updateCellsFromUIDL(UIDL uidl) {
Iterator<?> columnIterator = uidl.getChildIterator();
HashSet<String> updated = new HashSet<String>();
- updated.add(ROW_HEADER_COLUMN_KEY);
while (columnIterator.hasNext()) {
final UIDL col = (UIDL) columnIterator.next();
final String cid = col.getStringAttribute("cid");
}
};
-
+
private void forceRealignColumnHeaders() {
if (BrowserInfo.get().isIE()) {
/*
- * IE does not fire onscroll event if scroll position is
- * reverted to 0 due to the content element size growth. Ensure
- * headers are in sync with content manually. Safe to use null
- * event as we don't actually use the event object in listener.
+ * IE does not fire onscroll event if scroll position is reverted to
+ * 0 due to the content element size growth. Ensure headers are in
+ * sync with content manually. Safe to use null event as we don't
+ * actually use the event object in listener.
*/
onScroll(null);
}
*/
private static final double CACHE_RATE_DEFAULT = 2;
- private static final String ROW_HEADER_COLUMN_ID = "0";
- private static final Object MAGIC_ROW_HEADER_ID = new Object();
+ private static final String ROW_HEADER_COLUMN_KEY = "0";
+ private static final Object ROW_HEADER_FAKE_PROPERTY_ID = new Object();
/* Private table extensions to Select */
if (propertyId == null) {
// Since propertyId is null, this is the row header. Use the magic
// id to store the width of the row header.
- propertyId = MAGIC_ROW_HEADER_ID;
+ propertyId = ROW_HEADER_FAKE_PROPERTY_ID;
}
if (width < 0) {
columnWidths.remove(propertyId);
if (propertyId == null) {
// Since propertyId is null, this is the row header. Use the magic
// id to retrieve the width of the row header.
- propertyId = MAGIC_ROW_HEADER_ID;
+ propertyId = ROW_HEADER_FAKE_PROPERTY_ID;
}
final Object width = columnWidths.get(propertyId);
if (width == null || !(width instanceof Integer)) {
handleClickEvent(variables);
- handleColumnResizeEvents(variables);
+ handleColumnResizeEvent(variables);
+
+ handleColumnWidthUpdates(variables);
disableContentRefreshing();
*
* @param variables
*/
- private void handleColumnResizeEvents(Map<String, Object> variables) {
- if (variables.containsKey("columnResizeEvents")) {
- handleMultipleColumnResizeEvents(variables);
- }
+ private void handleColumnResizeEvent(Map<String, Object> variables) {
if (variables.containsKey("columnResizeEventColumn")) {
- handleSingleColumnResizeEvent(variables);
- }
- }
-
- private void handleSingleColumnResizeEvent(Map<String, Object> variables) {
- Object cid = variables.get("columnResizeEventColumn");
- Object propertyId = null;
- if (cid != null) {
- propertyId = columnIdMap.get(cid.toString());
-
- Object prev = variables.get("columnResizeEventPrev");
- int previousWidth = -1;
- if (prev != null) {
- previousWidth = Integer.valueOf(prev.toString());
- }
-
- Object curr = variables.get("columnResizeEventCurr");
- int currentWidth = -1;
- if (curr != null) {
- currentWidth = Integer.valueOf(curr.toString());
- }
+ Object cid = variables.get("columnResizeEventColumn");
+ Object propertyId = null;
+ if (cid != null) {
+ propertyId = columnIdMap.get(cid.toString());
- fireColumnResizeEvent(propertyId, previousWidth, currentWidth);
- }
- }
+ Object prev = variables.get("columnResizeEventPrev");
+ int previousWidth = -1;
+ if (prev != null) {
+ previousWidth = Integer.valueOf(prev.toString());
+ }
- private void handleMultipleColumnResizeEvents(Map<String, Object> variables) {
- String[] events = (String[]) variables.get("columnResizeEvents");
- for (String str : events) {
- String[] eventDetails = str.split(":");
- Object propertyId = columnIdMap.get(eventDetails[0]);
- if (propertyId != null) {
- int curWidth = Integer.valueOf(eventDetails[1]);
- int prevWidth = getColumnWidth(propertyId);
+ Object curr = variables.get("columnResizeEventCurr");
+ int currentWidth = -1;
+ if (curr != null) {
+ currentWidth = Integer.valueOf(curr.toString());
+ }
- fireColumnResizeEvent(propertyId, prevWidth, curWidth);
+ fireColumnResizeEvent(propertyId, previousWidth, currentWidth);
}
}
}
currentWidth));
}
+ private void handleColumnWidthUpdates(Map<String, Object> variables) {
+ if (variables.containsKey("columnWidthUpdates")) {
+ String[] events = (String[]) variables.get("columnWidthUpdates");
+ for (String str : events) {
+ String[] eventDetails = str.split(":");
+ Object propertyId = columnIdMap.get(eventDetails[0]);
+ if (propertyId == null) {
+ propertyId = ROW_HEADER_FAKE_PROPERTY_ID;
+ }
+ int width = Integer.valueOf(eventDetails[1]);
+ setColumnWidth(propertyId, width);
+ }
+ }
+ }
+
/**
* Go to mode where content updates are not done. This is due we want to
* bypass expensive content for some reason (like when we know we may have
target.startTag("visiblecolumns");
if (rowHeadersAreEnabled()) {
target.startTag("column");
- target.addAttribute("cid", ROW_HEADER_COLUMN_ID);
- paintColumnWidth(target, MAGIC_ROW_HEADER_ID);
+ target.addAttribute("cid", ROW_HEADER_COLUMN_KEY);
+ paintColumnWidth(target, ROW_HEADER_FAKE_PROPERTY_ID);
target.endTag("column");
}
int i = 0;