Mercurial > hg > STI-GWT
comparison src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java @ 44:5db587ba4b0f CellTable
background and border color of CellTable for selection and hover
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 07 Dec 2012 18:57:02 +0100 |
parents | fad6fb60a2db |
children | 169bf48359e2 |
comparison
equal
deleted
inserted
replaced
43:fad6fb60a2db | 44:5db587ba4b0f |
---|---|
16 import com.google.gwt.user.client.ui.Label; | 16 import com.google.gwt.user.client.ui.Label; |
17 import com.google.gwt.user.client.ui.HTML; | 17 import com.google.gwt.user.client.ui.HTML; |
18 import com.google.gwt.user.client.ui.HasHorizontalAlignment; | 18 import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
19 import com.google.gwt.user.client.ui.TextBox; | 19 import com.google.gwt.user.client.ui.TextBox; |
20 import com.google.gwt.view.client.ListDataProvider; | 20 import com.google.gwt.view.client.ListDataProvider; |
21 import com.google.gwt.view.client.Range; | |
21 import com.google.gwt.core.client.GWT; | 22 import com.google.gwt.core.client.GWT; |
23 import com.google.gwt.dom.client.NodeList; | |
24 import com.google.gwt.dom.client.Style.BorderStyle; | |
25 import com.google.gwt.dom.client.TableCellElement; | |
22 import com.google.gwt.event.dom.client.ClickHandler; | 26 import com.google.gwt.event.dom.client.ClickHandler; |
23 import com.google.gwt.event.dom.client.ClickEvent; | 27 import com.google.gwt.event.dom.client.ClickEvent; |
24 import com.google.gwt.event.dom.client.MouseOutEvent; | 28 import com.google.gwt.event.dom.client.MouseOutEvent; |
25 import com.google.gwt.event.dom.client.MouseOverEvent; | 29 import com.google.gwt.event.dom.client.MouseOverEvent; |
26 import com.google.gwt.event.dom.client.MouseOverHandler; | 30 import com.google.gwt.event.dom.client.MouseOverHandler; |
333 } | 337 } |
334 | 338 |
335 //if the dataProvider already exists, refresh the | 339 //if the dataProvider already exists, refresh the |
336 //displayed data | 340 //displayed data |
337 if (this.dataProvider != null) { | 341 if (this.dataProvider != null) { |
342 | |
343 //refresh data | |
338 this.dataProvider.refresh(); | 344 this.dataProvider.refresh(); |
339 | |
340 this.elementsTable.setRowCount(this.actualObjectSet.size()); | 345 this.elementsTable.setRowCount(this.actualObjectSet.size()); |
346 | |
347 this.updateView(false); | |
341 } | 348 } |
342 | 349 |
343 if (dataSetWasEmpty) | 350 if (dataSetWasEmpty) |
344 return false; | 351 return false; |
345 else | 352 else |
427 currentDataObject.setPercentage(1); | 434 currentDataObject.setPercentage(1); |
428 else | 435 else |
429 currentDataObject.setPercentage(0); | 436 currentDataObject.setPercentage(0); |
430 } | 437 } |
431 | 438 |
432 setActualObjectSet(); | 439 updateView(false); |
433 } | 440 } |
434 | 441 |
435 /** | 442 /** |
436 * Updates all cells of the actual page | 443 * Updates all cells of the actual page |
437 * | 444 * |
440 public void updateView(boolean hover){ | 447 public void updateView(boolean hover){ |
441 if( !hover && this.viewAll == -1 ){ | 448 if( !hover && this.viewAll == -1 ){ |
442 showSelected.removeStyleName("selectedView"); | 449 showSelected.removeStyleName("selectedView"); |
443 this.viewAll = 0; | 450 this.viewAll = 0; |
444 } | 451 } |
445 /* | 452 |
446 for( int i=0; i<this.displayedObjects.length; i++ ){ | 453 //redraw colors of elements (selected/unselected) |
447 for( int j=0; j<this.displayedObjects[i].length; j++ ){ | 454 int start = this.elementsTable.getVisibleRange().getStart(); |
448 if( this.displayedObjects[i][j] != null && this.displayedObjects[i][j].getStatus() ){ | 455 for (int i=0; i<this.elementsTable.getPageSize(); i++) { |
449 updateCell(i,j); | 456 |
450 } | 457 if ((start+i) >= dataProvider.getList().size()) |
451 } | 458 break; |
452 } | 459 |
453 */ | 460 DataObject object = dataProvider.getList().get(start+i); |
461 | |
462 boolean selected = object.isSelected(); | |
463 if (hover) | |
464 selected = object.getHover(); | |
465 | |
466 double percentage = (new Double(object.getPercentage()).doubleValue()); | |
467 String borderColor = StiCore.getBorderColor(this.index,selected); | |
468 String cellColor = StiCore.getCellColor(this.index,percentage); | |
469 | |
470 //TODO: das RowElement ist ein TR. Das hat kein Border, weswegen es | |
471 //auch keine Farbe bekommt. Erst einmal allen sub-Elementen die | |
472 // border-Color geben. Das sollte verbessert werden. | |
473 | |
474 NodeList<TableCellElement> cells = this.elementsTable.getRowElement(i).getCells(); | |
475 | |
476 for (int cellIndex=0; cellIndex < cells.getLength(); cellIndex++){ | |
477 cells.getItem(cellIndex).getStyle().setBorderColor(borderColor); | |
478 } | |
479 | |
480 this.elementsTable.getRowElement(i).getStyle().setBorderColor(borderColor); | |
481 this.elementsTable.getRowElement(i).getStyle().setBackgroundColor(cellColor); | |
482 } | |
454 } | 483 } |
455 | 484 |
456 public String getTermIdentifier() { | 485 public String getTermIdentifier() { |
457 return this.dataSet.getTermIdentifier(); | 486 return this.dataSet.getTermIdentifier(); |
458 } | 487 } |