Subversion Repository Public Repository

litesoft

Diff Revisions 23 vs 49 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/datatables/AccordionTable.java

Diff revisions: vs.
  @@ -1,3 +1,4 @@
1 + // This Source Code is in the Public Domain per: http://litesoft.org/License.txt
1 2 package org.litesoft.GWT.client.widgets.datatables;
2 3
3 4 import java.util.*;
  @@ -68,7 +69,7 @@
68 69 /**
69 70 * Will be called when the data changes or the count of rendered rows
70 71 * changes. Useful for updating calulations based on the data.
71 - *
72 + *
72 73 * @see #getVisibleRowCount()
73 74 */
74 75 @Override
  @@ -80,13 +81,13 @@
80 81 public void init(TableModel<RowType> pTableModel, TableDefinitionPlus<RowType> pTableDefinition)
81 82 {
82 83 RowType prototypeRowValue = pTableDefinition.getPrototypeRowValue();
83 -
84 +
84 85 if (prototypeRowValue == null)
85 86 throw new IllegalArgumentException("TableDefinition.prototypeRowValue cannot be null for AccordionTable");
86 -
87 +
87 88 mDataSource = pTableModel;
88 89 mTableDefinition = pTableDefinition;
89 -
90 +
90 91 List<ColumnDefinition<RowType, ?>> colDefs = pTableDefinition.getVisibleColumnDefinitions();
91 92 for (int col = 0, size = colDefs.size(); col < size; col++)
92 93 {
  @@ -138,7 +139,7 @@
138 139 {
139 140 return pIndex == 0;
140 141 }
141 -
142 +
142 143 });
143 144 renderRowImpl(0, prototypeRowValue, rowView, cellView);
144 145 renderRowImpl(1, prototypeRowValue, rowView, cellView);
  @@ -155,7 +156,7 @@
155 156 sizeOrDataChanged();
156 157 }
157 158 });
158 -
159 +
159 160 mTable.addClickHandler(new TableHelper.GridClickHandler<RowType>(1, mTable.getGridHelper(), colDefs)
160 161 {
161 162 @Override
  @@ -192,16 +193,16 @@
192 193 }
193 194 });
194 195 }
195 -
196 +
196 197 private boolean isSizeInitialized()
197 198 {
198 - return mViewportHeight > 0 &&
199 - mHeaderRowHeight > 0 &&
200 - mFooterRowHeight > 0 &&
201 - mPrototypeDetailRowHeight > 0 &&
199 + return mViewportHeight > 0 &&
200 + mHeaderRowHeight > 0 &&
201 + mFooterRowHeight > 0 &&
202 + mPrototypeDetailRowHeight > 0 &&
202 203 mPrototypeNormalRowHeight > 0;
203 204 }
204 -
205 +
205 206 private void sizeOrDataChanged()
206 207 {
207 208 if (isSizeInitialized())
  @@ -257,13 +258,13 @@
257 258 }
258 259
259 260 /**
260 - * @param pCount negative or 0 will be NOOP
261 + * @param pCount negative or 0 will be NOOP
261 262 */
262 263 private void renderRows(int pStartRow, int pCount)
263 264 {
264 265 if (pCount <= 0)
265 266 return;
266 -
267 +
267 268 AccordionTable.AccordionTableTable.RowView<RowType> rowView = mTable.new RowView<RowType>();
268 269 AccordionTable.AccordionTableTable.CellView<RowType> cellView = mTable.new CellView<RowType>(mPrototypeNormalRowHeight, mDetailRowModel);
269 270 for (int row = pStartRow, terminus = pStartRow + pCount; row < terminus; row++)
  @@ -337,7 +338,7 @@
337 338 {
338 339 return mModel.get(pRow);
339 340 }
340 -
341 +
341 342 public int getVisibleRowCount()
342 343 {
343 344 return Math.min(mModel.size(), mMaxWholeRows);
  @@ -347,12 +348,12 @@
347 348 {
348 349 return mModel.size();
349 350 }
350 -
351 +
351 352 public TableRowCountCallback getRowCountCallback()
352 353 {
353 354 return mRowCountCallback;
354 355 }
355 -
356 +
356 357 public void setRowCountCallback(TableRowCountCallback pRowCountCallback)
357 358 {
358 359 mRowCountCallback = pRowCountCallback;
  @@ -361,13 +362,13 @@
361 362 private class HoverController implements HighlightHandler<Integer>
362 363 {
363 364 private final HoverTimer mHoverTimer = new HoverTimer();
364 -
365 +
365 366 @Override
366 367 public void onHighlight(HighlightEvent<Integer> pEvent)
367 368 {
368 369 mHoverTimer.setHoverRow(pEvent.getHighlighted());
369 370 }
370 -
371 +
371 372 private void doHighlight(int pNewRow)
372 373 {
373 374 int oldRow = mDetailRowModel.getDetailRow();
  @@ -386,14 +387,14 @@
386 387 }
387 388 }
388 389 }
389 -
390 +
390 391 private class HoverTimer extends Timer
391 392 {
392 393 /**
393 - * This is -1 if not running, a valid value if running.
394 + * This is -1 if not running, a valid value if running.
394 395 */
395 396 private int mRow = -1;
396 -
397 +
397 398 public void setHoverRow(int pRow)
398 399 {
399 400 if (mRow != -1)
  @@ -406,7 +407,7 @@
406 407 schedule(250);
407 408 }
408 409 }
409 -
410 +
410 411 @Override
411 412 public void run()
412 413 {
  @@ -423,7 +424,7 @@
423 424 private final TableHelper.GridHelper mGridHelper;
424 425
425 426 private int mFooterRow = -1;
426 -
427 +
427 428 /**
428 429 * The row that is currently under the mouse. Used for highlight. Not
429 430 * necessarily the detail row due to delay in setting the detail row.
  @@ -447,7 +448,7 @@
447 448 {
448 449 return AccordionTableTable.this.getRowIndex(pRowElement);
449 450 }
450 -
451 +
451 452 @Override
452 453 protected int getCellIndex(Element pRowElement, Element pCellElement)
453 454 {
  @@ -471,26 +472,26 @@
471 472 {
472 473 return mGridHelper;
473 474 }
474 -
475 +
475 476 @Override
476 477 protected Element getBodyElement()
477 478 {
478 479 return super.getBodyElement();
479 480 }
480 -
481 +
481 482 /**
482 - * Get the element for the normal row (index is adjusted to account for header row).
483 + * Get the element for the normal row (index is adjusted to account for header row).
483 484 */
484 485 public Element getRowElement(int pRow)
485 486 {
486 487 return getRowFormatter().getElement(pRow + 1);
487 488 }
488 -
489 +
489 490 public Element getHeaderRowElement()
490 491 {
491 492 return getRowFormatter().getElement(HEADER_ROW);
492 493 }
493 -
494 +
494 495 public Element getFooterRowElement()
495 496 {
496 497 ensureFooter();
  @@ -504,7 +505,7 @@
504 505 Element innerTbody = innerTr.getParentElement().cast();
505 506 Element innerTable = innerTbody.getParentElement().cast();
506 507 Element outerTd = innerTable.getParentElement().cast();
507 -
508 +
508 509 // set the style name on the containing td so background styles will be 100% row height
509 510 UIObject.setStylePrimaryName(outerTd, "AccordionTable-headerCell");
510 511 if (pAlign != null)
  @@ -582,7 +583,7 @@
582 583 mHilightedRow = -1;
583 584 }
584 585 }
585 -
586 +
586 587 /**
587 588 * Have to override super method to append div to td
588 589 */
  @@ -593,11 +594,11 @@
593 594 addCells(getBodyElement(), pRow + 1, pNum);
594 595 clearIdealWidths0();
595 596 }
596 -
597 +
597 598 private native void clearIdealWidths0() /*-{
598 599 this.@com.google.gwt.gen2.table.client.FixedWidthFlexTable::clearIdealWidths()();
599 600 }-*/;
600 -
601 +
601 602 private static native void addCells(Element table, int row, int num) /*-{
602 603 var rowElem = table.rows[row];
603 604 for(var i = 0; i < num; i++)
  @@ -605,7 +606,7 @@
605 606 var cell = $doc.createElement("td");
606 607 cell['colSpan'] = 1;
607 608 cell['rowSpan'] = 1;
608 -
609 +
609 610 var innerCell = $doc.createElement("td");
610 611 innerCell.style["overflow"]="hidden";
611 612 var tr = $doc.createElement("tr");
  @@ -618,11 +619,11 @@
618 619 table["cellSpacing"]=0;
619 620 table["cellPadding"]=0;
620 621 cell.appendChild(table);
621 -
622 +
622 623 rowElem.appendChild(cell);
623 624 }
624 625 }-*/;
625 -
626 +
626 627 @Override
627 628 public void onBrowserEvent( Event pEvent )
628 629 {
  @@ -637,7 +638,7 @@
637 638 int row = mGridHelper.getRowForEvent(pEvent);
638 639 updateHighlightedRow(row);
639 640 break;
640 -
641 +
641 642 case Event.ONMOUSEOUT:
642 643 // only process mouse out if exiting the widget
643 644 Element toElement = pEvent.getRelatedEventTarget().cast();
  @@ -763,7 +764,7 @@
763 764 {
764 765 private final DetailRowModel<RowType> mDetailRowModel;
765 766 private final int mNormalRowHeight;
766 -
767 +
767 768 private Element mViewTableElement; // the inner TD in each TD
768 769
769 770 public CellView(int normalRowHeight, DetailRowModel<RowType> detailRowModel)