1 /** 2 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 * 16 */ 17 18 package org.gudy.azureus2.ui.swt.views.table.impl; 19 20 import java.util.ArrayList; 21 import java.util.Iterator; 22 import java.util.Map; 23 24 import org.eclipse.swt.SWT; 25 import org.eclipse.swt.dnd.Clipboard; 26 import org.eclipse.swt.dnd.TextTransfer; 27 import org.eclipse.swt.dnd.Transfer; 28 import org.eclipse.swt.events.*; 29 import org.eclipse.swt.graphics.*; 30 import org.eclipse.swt.widgets.*; 31 32 import org.gudy.azureus2.core3.disk.DiskManagerFileInfo; 33 import org.gudy.azureus2.core3.download.DownloadManager; 34 import org.gudy.azureus2.core3.internat.MessageText; 35 import org.gudy.azureus2.core3.peer.PEPeer; 36 import org.gudy.azureus2.core3.peer.PEPiece; 37 import org.gudy.azureus2.core3.tracker.host.TRHostTorrent; 38 import org.gudy.azureus2.core3.util.*; 39 import org.gudy.azureus2.ui.swt.Utils; 40 import org.gudy.azureus2.ui.swt.mainwindow.Colors; 41 import org.gudy.azureus2.ui.swt.plugins.UISWTGraphic; 42 import org.gudy.azureus2.ui.swt.pluginsimpl.UISWTGraphicImpl; 43 import org.gudy.azureus2.ui.swt.shells.GCStringPrinter; 44 import org.gudy.azureus2.ui.swt.views.table.TableCellSWT; 45 import org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener; 46 import org.gudy.azureus2.ui.swt.views.table.TableRowSWT; 47 import org.gudy.azureus2.ui.swt.views.table.painted.TableCellPainted; 48 import org.gudy.azureus2.ui.swt.views.table.utils.TableColumnSWTUtils; 49 50 import com.aelitis.azureus.ui.common.table.TableColumnCore; 51 import com.aelitis.azureus.ui.common.table.TableRowCore; 52 import com.aelitis.azureus.ui.common.table.impl.CoreTableColumn; 53 import com.aelitis.azureus.ui.swt.utils.ColorCache; 54 55 import org.gudy.azureus2.plugins.download.DownloadException; 56 import org.gudy.azureus2.plugins.ui.Graphic; 57 import org.gudy.azureus2.plugins.ui.tables.*; 58 import org.gudy.azureus2.plugins.ui.tables.TableColumn; 59 60 import org.gudy.azureus2.pluginsimpl.local.disk.DiskManagerFileInfoImpl; 61 import org.gudy.azureus2.pluginsimpl.local.download.DownloadManagerImpl; 62 import org.gudy.azureus2.pluginsimpl.local.peers.PeerManagerImpl; 63 import org.gudy.azureus2.pluginsimpl.local.tracker.TrackerTorrentImpl; 64 65 /** 66 * @author TuxPaper 67 * @created Aug 29, 2007 68 * 69 */ 70 public class FakeTableCell 71 implements TableCellSWT, PaintListener, MouseListener, MouseMoveListener, 72 MouseTrackListener 73 { 74 private AEMonitor this_mon = new AEMonitor("FakeTableCell"); 75 76 private ArrayList refreshListeners; 77 78 private ArrayList disposeListeners; 79 80 private ArrayList tooltipListeners; 81 82 private ArrayList cellMouseListeners; 83 84 private ArrayList cellMouseMoveListeners; 85 86 private ArrayList cellVisibilityListeners; 87 88 private ArrayList<TableCellClipboardListener> cellClipboardListeners; 89 90 private Image image; 91 92 private Rectangle imageBounds; 93 94 private int marginHeight; 95 96 private int orientation; 97 98 private int marginWidth; 99 100 private Comparable sortValue; 101 102 private Object coreDataSource; 103 104 private Composite composite; 105 106 private final TableColumnCore tableColumn; 107 108 private Graphic graphic; 109 110 private String text; 111 112 private Object pluginDataSource; 113 114 private Object tooltip; 115 private Object default_tooltip; 116 117 private Rectangle cellArea; 118 119 private boolean hadMore; 120 121 private boolean wrapText = true; 122 123 private ArrayList cellSWTPaintListeners; 124 125 private boolean valid; 126 127 private TableRow fakeRow = null; 128 129 /** 130 * @param columnRateUpDown 131 */ FakeTableCell(TableColumn column, Object ds)132 public FakeTableCell(TableColumn column, Object ds) { 133 valid = false; 134 coreDataSource = ds; 135 this.tableColumn = (TableColumnCore) column; 136 setOrientationViaColumn(); 137 tableColumn.invokeCellAddedListeners(this); 138 } 139 FakeTableCell(TableColumnCore column, Object ds)140 public FakeTableCell(TableColumnCore column, Object ds) { 141 valid = false; 142 coreDataSource = ds; 143 this.tableColumn = column; 144 setOrientationViaColumn(); 145 tableColumn.invokeCellAddedListeners(this); 146 } 147 addRefreshListener(TableCellRefreshListener listener)148 public void addRefreshListener(TableCellRefreshListener listener) { 149 try { 150 this_mon.enter(); 151 152 if (refreshListeners == null) 153 refreshListeners = new ArrayList(1); 154 155 refreshListeners.add(listener); 156 157 } finally { 158 this_mon.exit(); 159 } 160 } 161 removeRefreshListener(TableCellRefreshListener listener)162 public void removeRefreshListener(TableCellRefreshListener listener) { 163 try { 164 this_mon.enter(); 165 166 if (refreshListeners == null) 167 return; 168 169 refreshListeners.remove(listener); 170 } finally { 171 172 this_mon.exit(); 173 } 174 } 175 addDisposeListener(TableCellDisposeListener listener)176 public void addDisposeListener(TableCellDisposeListener listener) { 177 try { 178 this_mon.enter(); 179 180 if (disposeListeners == null) { 181 disposeListeners = new ArrayList(1); 182 } 183 disposeListeners.add(listener); 184 } finally { 185 186 this_mon.exit(); 187 } 188 } 189 removeDisposeListener(TableCellDisposeListener listener)190 public void removeDisposeListener(TableCellDisposeListener listener) { 191 try { 192 this_mon.enter(); 193 194 if (disposeListeners == null) 195 return; 196 197 disposeListeners.remove(listener); 198 199 } finally { 200 201 this_mon.exit(); 202 } 203 } 204 addToolTipListener(TableCellToolTipListener listener)205 public void addToolTipListener(TableCellToolTipListener listener) { 206 try { 207 this_mon.enter(); 208 209 if (tooltipListeners == null) { 210 tooltipListeners = new ArrayList(1); 211 } 212 tooltipListeners.add(listener); 213 214 } finally { 215 this_mon.exit(); 216 } 217 } 218 removeToolTipListener(TableCellToolTipListener listener)219 public void removeToolTipListener(TableCellToolTipListener listener) { 220 try { 221 this_mon.enter(); 222 223 if (tooltipListeners == null) 224 return; 225 226 tooltipListeners.remove(listener); 227 } finally { 228 229 this_mon.exit(); 230 } 231 } 232 addMouseListener(TableCellMouseListener listener)233 public void addMouseListener(TableCellMouseListener listener) { 234 try { 235 this_mon.enter(); 236 237 if (cellMouseListeners == null) 238 cellMouseListeners = new ArrayList(1); 239 240 cellMouseListeners.add(listener); 241 242 } finally { 243 this_mon.exit(); 244 } 245 } 246 removeMouseListener(TableCellMouseListener listener)247 public void removeMouseListener(TableCellMouseListener listener) { 248 try { 249 this_mon.enter(); 250 251 if (cellMouseListeners == null) 252 return; 253 254 cellMouseListeners.remove(listener); 255 256 } finally { 257 this_mon.exit(); 258 } 259 } 260 addMouseMoveListener(TableCellMouseMoveListener listener)261 public void addMouseMoveListener(TableCellMouseMoveListener listener) { 262 try { 263 this_mon.enter(); 264 265 if (cellMouseMoveListeners == null) 266 cellMouseMoveListeners = new ArrayList(1); 267 268 cellMouseMoveListeners.add(listener); 269 270 } finally { 271 this_mon.exit(); 272 } 273 } 274 removeMouseMoveListener(TableCellMouseMoveListener listener)275 public void removeMouseMoveListener(TableCellMouseMoveListener listener) { 276 try { 277 this_mon.enter(); 278 279 if (cellMouseMoveListeners == null) 280 return; 281 282 cellMouseMoveListeners.remove(listener); 283 284 } finally { 285 this_mon.exit(); 286 } 287 } 288 addVisibilityListener(TableCellVisibilityListener listener)289 public void addVisibilityListener(TableCellVisibilityListener listener) { 290 try { 291 this_mon.enter(); 292 293 if (cellVisibilityListeners == null) 294 cellVisibilityListeners = new ArrayList(1); 295 296 cellVisibilityListeners.add(listener); 297 298 } finally { 299 this_mon.exit(); 300 } 301 } 302 removeVisibilityListener(TableCellVisibilityListener listener)303 public void removeVisibilityListener(TableCellVisibilityListener listener) { 304 try { 305 this_mon.enter(); 306 307 if (cellVisibilityListeners == null) 308 return; 309 310 cellVisibilityListeners.remove(listener); 311 312 } finally { 313 this_mon.exit(); 314 } 315 } 316 317 /** 318 * @param listenerObject 319 * 320 * @since 4.0.0.1 321 */ addSWTPaintListener(TableCellSWTPaintListener listener)322 private void addSWTPaintListener(TableCellSWTPaintListener listener) { 323 try { 324 this_mon.enter(); 325 326 if (cellSWTPaintListeners == null) 327 cellSWTPaintListeners = new ArrayList(1); 328 329 cellSWTPaintListeners.add(listener); 330 331 } finally { 332 this_mon.exit(); 333 } 334 } 335 invokeSWTPaintListeners(GC gc)336 public void invokeSWTPaintListeners(GC gc) { 337 if (getBounds().isEmpty()) { 338 return; 339 } 340 if (tableColumn != null) { 341 Object[] swtPaintListeners = tableColumn.getCellOtherListeners("SWTPaint"); 342 if (swtPaintListeners != null) { 343 for (int i = 0; i < swtPaintListeners.length; i++) { 344 try { 345 TableCellSWTPaintListener l = (TableCellSWTPaintListener) swtPaintListeners[i]; 346 347 l.cellPaint(gc, this); 348 349 } catch (Throwable e) { 350 Debug.printStackTrace(e); 351 } 352 } 353 } 354 } 355 356 if (cellSWTPaintListeners == null) { 357 return; 358 } 359 360 361 for (int i = 0; i < cellSWTPaintListeners.size(); i++) { 362 try { 363 TableCellSWTPaintListener l = (TableCellSWTPaintListener) (cellSWTPaintListeners.get(i)); 364 365 l.cellPaint(gc, this); 366 367 } catch (Throwable e) { 368 Debug.printStackTrace(e); 369 } 370 } 371 } 372 addCellClipboardListener(TableCellClipboardListener listener)373 private void addCellClipboardListener(TableCellClipboardListener listener) { 374 try { 375 this_mon.enter(); 376 377 if (cellClipboardListeners == null) 378 cellClipboardListeners = new ArrayList<TableCellClipboardListener>(1); 379 380 cellClipboardListeners.add(listener); 381 382 } finally { 383 this_mon.exit(); 384 } 385 } 386 getClipboardText()387 public String getClipboardText() { 388 String text = null; 389 try { 390 this_mon.enter(); 391 392 if (cellClipboardListeners != null) { 393 for (TableCellClipboardListener l : cellClipboardListeners) { 394 try { 395 text = l.getClipboardText(this); 396 } catch (Exception e) { 397 Debug.out(e); 398 } 399 if (text != null) { 400 break; 401 } 402 } 403 } 404 } finally { 405 this_mon.exit(); 406 } 407 if (text == null) { 408 text = this.getText(); 409 } 410 return text; 411 } 412 413 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#addListeners(java.lang.Object) addListeners(Object listenerObject)414 public void addListeners(Object listenerObject) { 415 if (listenerObject instanceof TableCellDisposeListener) 416 addDisposeListener((TableCellDisposeListener) listenerObject); 417 418 if (listenerObject instanceof TableCellRefreshListener) 419 addRefreshListener((TableCellRefreshListener) listenerObject); 420 421 if (listenerObject instanceof TableCellToolTipListener) 422 addToolTipListener((TableCellToolTipListener) listenerObject); 423 424 if (listenerObject instanceof TableCellMouseMoveListener) { 425 addMouseMoveListener((TableCellMouseMoveListener) listenerObject); 426 } 427 428 if (listenerObject instanceof TableCellMouseListener) { 429 addMouseListener((TableCellMouseListener) listenerObject); 430 } 431 432 if (listenerObject instanceof TableCellVisibilityListener) 433 addVisibilityListener((TableCellVisibilityListener) listenerObject); 434 435 if (listenerObject instanceof TableCellSWTPaintListener) { 436 addSWTPaintListener((TableCellSWTPaintListener) listenerObject); 437 } 438 439 if (listenerObject instanceof TableCellClipboardListener) { 440 addCellClipboardListener((TableCellClipboardListener) listenerObject); 441 } 442 } 443 invokeMouseListeners(TableCellMouseEvent event)444 public void invokeMouseListeners(TableCellMouseEvent event) { 445 if (event.cell != null && event.row == null) { 446 event.row = event.cell.getTableRow(); 447 } 448 449 try { 450 tableColumn.invokeCellMouseListeners(event); 451 } catch (Throwable e) { 452 Debug.printStackTrace(e); 453 } 454 455 ArrayList listeners = event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE 456 ? cellMouseMoveListeners : cellMouseListeners; 457 458 if (listeners == null) { 459 return; 460 } 461 462 for (int i = 0; i < listeners.size(); i++) { 463 try { 464 TableCellMouseListener l = (TableCellMouseListener) (listeners.get(i)); 465 466 l.cellMouseTrigger(event); 467 468 } catch (Throwable e) { 469 Debug.printStackTrace(e); 470 } 471 } 472 } 473 474 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getDataSource() getDataSource()475 public Object getDataSource() { 476 boolean bCoreObject = tableColumn != null && tableColumn.getUseCoreDataSource(); 477 if (bCoreObject) { 478 return coreDataSource; 479 } 480 481 if (pluginDataSource != null) { 482 return pluginDataSource; 483 } 484 485 if (coreDataSource instanceof DownloadManager) { 486 DownloadManager dm = (DownloadManager) coreDataSource; 487 if (dm != null) { 488 try { 489 pluginDataSource = DownloadManagerImpl.getDownloadStatic(dm); 490 } catch (DownloadException e) { /* Ignore */ 491 } 492 } 493 } 494 if (coreDataSource instanceof PEPeer) { 495 PEPeer peer = (PEPeer) coreDataSource; 496 if (peer != null) { 497 pluginDataSource = PeerManagerImpl.getPeerForPEPeer(peer); 498 } 499 } 500 501 if (coreDataSource instanceof PEPiece) { 502 // XXX There is no Piece object for plugins yet 503 PEPiece piece = (PEPiece) coreDataSource; 504 if (piece != null) { 505 pluginDataSource = null; 506 } 507 } 508 509 if (coreDataSource instanceof DiskManagerFileInfo) { 510 DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) coreDataSource; 511 if (fileInfo != null) { 512 try { 513 pluginDataSource = new DiskManagerFileInfoImpl( 514 DownloadManagerImpl.getDownloadStatic(fileInfo.getDownloadManager()), 515 fileInfo); 516 } catch (DownloadException e) { /* Ignore */ 517 } 518 } 519 } 520 521 if (coreDataSource instanceof TRHostTorrent) { 522 TRHostTorrent item = (TRHostTorrent) coreDataSource; 523 if (item != null) { 524 pluginDataSource = new TrackerTorrentImpl(item); 525 } 526 } 527 528 if (pluginDataSource == null) { 529 // No translation available, make pluginDataSource the same as core 530 pluginDataSource = coreDataSource; 531 } 532 533 return pluginDataSource; 534 } 535 536 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getForeground() getForeground()537 public int[] getForeground() { 538 if (composite == null || composite.isDisposed()) { 539 return null; 540 } 541 Color fg = composite.getForeground(); 542 return new int[] { 543 fg.getRed(), 544 fg.getGreen(), 545 fg.getBlue() 546 }; 547 } 548 getBackground()549 public int[] getBackground() { 550 // until we can make sure composite.getBackground is being used 551 // (background image might superceed), return 0 552 if (true) { 553 return new int[] { 554 0, 555 0, 556 0 557 }; 558 } 559 if (composite == null || composite.isDisposed()) { 560 return null; 561 } 562 Color bg = composite.getBackground(); 563 return new int[] { 564 bg.getRed(), 565 bg.getGreen(), 566 bg.getBlue() 567 }; 568 } 569 getBackgroundGraphic()570 public Graphic getBackgroundGraphic() { 571 // TODO handle cellArea 572 573 if (composite == null || composite.isDisposed()) { 574 return null; 575 } 576 577 try { 578 Rectangle bounds = composite.getBounds(); 579 580 if (bounds.isEmpty()) { 581 return null; 582 } 583 584 Image imgCap = new Image(composite.getDisplay(), bounds.width, 585 bounds.height); 586 587 // will walk up tree until it gets an image 588 Control bgControl = Utils.findBackgroundImageControl(composite); 589 Image imgBG = composite.getBackgroundImage(); 590 591 GC gc = new GC(imgCap); 592 try { 593 if (imgBG == null) { // || imgBG has alpha.. 594 gc.setBackground(composite.getBackground()); 595 gc.fillRectangle(0, 0, bounds.width, bounds.height); 596 } 597 598 if (imgBG != null) { 599 Point controlPos = new Point(0, 0); 600 if (bgControl instanceof Composite) { 601 Rectangle compArea = ((Composite) bgControl).getClientArea(); 602 controlPos.x = compArea.x; 603 controlPos.y = compArea.y; 604 } 605 Point absControlLoc = bgControl.toDisplay(controlPos.x, controlPos.y); 606 607 Rectangle shellClientArea = composite.getShell().getClientArea(); 608 Point absShellLoc = composite.getParent().toDisplay( 609 shellClientArea.x, shellClientArea.y); 610 611 Point ofs = new Point(absControlLoc.x - absShellLoc.x, 612 absControlLoc.y - absShellLoc.y); 613 Rectangle imgBGBounds = imgBG.getBounds(); 614 ofs.x = (ofs.x % imgBGBounds.width); 615 ofs.y = (ofs.y % imgBGBounds.height); 616 617 gc.drawImage(imgBG, ofs.x, ofs.y); 618 } 619 } finally { 620 gc.dispose(); 621 } 622 623 return new UISWTGraphicImpl(imgCap); 624 } catch (Exception e) { 625 Debug.out(e); 626 } 627 return null; 628 } 629 630 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getGraphic() getGraphic()631 public Graphic getGraphic() { 632 return graphic; 633 } 634 635 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getHeight() getHeight()636 public int getHeight() { 637 if (composite != null && !composite.isDisposed()) { 638 if (cellArea != null) { 639 return cellArea.height; 640 } 641 return composite.getSize().y; 642 } 643 return 0; 644 } 645 646 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getMaxLines() getMaxLines()647 public int getMaxLines() { 648 return -1; 649 } 650 651 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getSortValue() getSortValue()652 public Comparable getSortValue() { 653 if ( sortValue == null ){ 654 return( "" ); 655 } 656 return sortValue; 657 } 658 659 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getTableColumn() getTableColumn()660 public TableColumn getTableColumn() { 661 return tableColumn; 662 } 663 664 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getTableID() getTableID()665 public String getTableID() { 666 return tableColumn == null ? null : tableColumn.getTableID(); 667 } 668 669 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getTableRow() getTableRow()670 public TableRow getTableRow() { 671 if (fakeRow == null) { 672 fakeRow = new TableRow() { 673 Map<String, Object> data = new LightHashMap<String,Object>(1); 674 675 public void setForegroundToErrorColor() { 676 } 677 678 public void setForeground(int[] rgb) { 679 } 680 681 public void setForeground(int red, int green, int blue) { 682 } 683 684 public void removeMouseListener(TableRowMouseListener listener) { 685 } 686 687 public int getIndex() { 688 return 1; 689 } 690 691 public boolean isValid() { 692 return FakeTableCell.this.isValid(); 693 } 694 695 public boolean isSelected() { 696 return false; 697 } 698 699 public String getTableID() { 700 return FakeTableCell.this.getTableID(); 701 } 702 703 public TableCell getTableCell(String columnName) { 704 return null; 705 } 706 707 public Object getDataSource() { 708 return FakeTableCell.this.getDataSource(); 709 } 710 711 public void addMouseListener(TableRowMouseListener listener) { 712 } 713 714 public Object getData(String id) { 715 synchronized (data) { 716 return data.get(id); 717 } 718 } 719 720 public void setData(String id, Object val) { 721 synchronized (data) { 722 data.put(id, val); 723 } 724 } 725 }; 726 } 727 return fakeRow; 728 } 729 730 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getText() getText()731 public String getText() { 732 return text; 733 } 734 735 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getToolTip() getToolTip()736 public Object getToolTip() { 737 if (tooltip == null && hadMore) { 738 return text; 739 } 740 return tooltip; 741 } 742 743 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getWidth() getWidth()744 public int getWidth() { 745 if (!isDisposed()) { 746 if (cellArea != null) { 747 return cellArea.width - 2; 748 } 749 return composite.getSize().x; 750 } 751 return 0; 752 } 753 754 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#invalidate() invalidate()755 public void invalidate() { 756 valid = false; 757 } 758 759 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#isDisposed() isDisposed()760 public boolean isDisposed() { 761 return composite == null || composite.isDisposed(); 762 } 763 764 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#isShown() isShown()765 public boolean isShown() { 766 return true; 767 } 768 769 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#isValid() isValid()770 public boolean isValid() { 771 return valid; 772 } 773 774 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setFillCell(boolean) setFillCell(boolean fillCell)775 public void setFillCell(boolean fillCell) { 776 // TODO Auto-generated method stub 777 778 } 779 setWrapText( boolean wrap )780 public void setWrapText( boolean wrap ){ 781 wrapText = wrap; 782 } 783 784 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setForeground(int, int, int) setForeground(int red, int green, int blue)785 public boolean setForeground(int red, int green, int blue) { 786 if (isDisposed()) { 787 return false; 788 } 789 if (red < 0 || green < 0 || blue < 0) { 790 composite.setForeground(null); 791 } else { 792 composite.setForeground(ColorCache.getColor(composite.getDisplay(), red, 793 green, blue)); 794 } 795 return true; 796 } 797 798 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setForeground(int[]) setForeground(int[] rgb)799 public boolean setForeground(int[] rgb) { 800 if (rgb == null || rgb.length < 3) { 801 return setForeground(-1, -1, -1); 802 } 803 return setForeground(rgb[0], rgb[1], rgb[2]); 804 } 805 806 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setForegroundToErrorColor() setForegroundToErrorColor()807 public boolean setForegroundToErrorColor() { 808 if (isDisposed()) { 809 return false; 810 } 811 composite.setForeground(Colors.colorError); 812 return true; 813 } 814 815 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setGraphic(org.gudy.azureus2.plugins.ui.Graphic) setGraphic(Graphic img)816 public boolean setGraphic(Graphic img) { 817 Image imgSWT = null; 818 if (img instanceof UISWTGraphic) { 819 imgSWT = ((UISWTGraphic) img).getImage(); 820 } 821 822 if (imgSWT != null && imgSWT.isDisposed()) { 823 return false; 824 } 825 826 if (image == imgSWT) { 827 return false; 828 } 829 830 //System.out.println("setGraphic " + image); 831 832 image = imgSWT; 833 if (image != null) { 834 imageBounds = image.getBounds(); 835 } 836 837 if (composite != null && !composite.isDisposed()) { 838 redraw(); 839 } 840 841 graphic = img; 842 return true; 843 } 844 845 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setMarginHeight(int) setMarginHeight(int height)846 public void setMarginHeight(int height) { 847 // TODO Auto-generated method stub 848 849 } 850 851 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setMarginWidth(int) setMarginWidth(int width)852 public void setMarginWidth(int width) { 853 // TODO Auto-generated method stub 854 855 } 856 857 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setSortValue(java.lang.Comparable) setSortValue(Comparable valueToSort)858 public boolean setSortValue(Comparable valueToSort) { 859 return _setSortValue(valueToSort); 860 } 861 862 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setSortValue(float) setSortValue(float valueToSort)863 public boolean setSortValue(float valueToSort) { 864 return _setSortValue(Float.valueOf(valueToSort)); 865 } 866 867 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setText(java.lang.String) setText(String text)868 public boolean setText(String text) { 869 if (text != null && text.equals(this.text)) { 870 return false; 871 } 872 this.text = text; 873 Utils.execSWTThread(new AERunnable() { 874 public void runSupport() { 875 if (!isDisposed()) { 876 composite.redraw(); 877 } 878 } 879 }); 880 return true; 881 } 882 883 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#setToolTip(java.lang.Object) setToolTip(Object tooltip)884 public void setToolTip(Object tooltip) { 885 this.tooltip = tooltip; 886 updateTooltip(); 887 } 888 889 public void setDefaultToolTip( Object o )890 setDefaultToolTip( 891 Object o ) 892 { 893 default_tooltip = o; 894 } 895 896 public Object getDefaultToolTip()897 getDefaultToolTip() 898 { 899 return( default_tooltip ); 900 } 901 902 private void updateTooltip()903 updateTooltip() 904 { 905 if (!isDisposed()) { 906 Object target = tooltip==null?default_tooltip:tooltip; 907 908 composite.setToolTipText(target == null ? null : target.toString()); 909 } 910 } 911 _setSortValue(Comparable valueToSort)912 private boolean _setSortValue(Comparable valueToSort) { 913 if (sortValue == valueToSort) 914 return false; 915 916 if ((valueToSort instanceof String) && (sortValue instanceof String) 917 && sortValue.equals(valueToSort)) { 918 return false; 919 } 920 921 if ((valueToSort instanceof Number) && (sortValue instanceof Number) 922 && sortValue.equals(valueToSort)) { 923 return false; 924 } 925 926 sortValue = valueToSort; 927 928 return true; 929 } 930 setSortValue(long valueToSort)931 public boolean setSortValue(long valueToSort) { 932 if ((sortValue instanceof Long) 933 && ((Long) sortValue).longValue() == valueToSort) 934 return false; 935 936 return _setSortValue(new Long(valueToSort)); 937 } 938 doPaint(GC gc, Rectangle bounds)939 public void doPaint(GC gc, Rectangle bounds) { 940 if (isDisposed()) { 941 return; 942 } 943 // TODO: Cleanup and stop calling me so often! 944 945 //gc.setBackground(getBackgroundSWT()); 946 //if (DEBUG_COLORCELL) { 947 // gc.setBackground(Display.getDefault().getSystemColor( 948 // (int) (Math.random() * 16))); 949 //} 950 if (bounds == null) { 951 return; 952 } 953 //gc.fillRectangle(bounds); 954 if (!bounds.intersects(gc.getClipping())) { 955 return; 956 } 957 958 959 if (image != null && !image.isDisposed()) { 960 Point size = new Point(bounds.width, bounds.height); 961 962 int x; 963 964 int y = marginHeight; 965 y += (size.y - imageBounds.height) / 2; 966 967 if (orientation == SWT.CENTER) { 968 x = marginWidth; 969 x += (size.x - (marginWidth * 2) - imageBounds.width) / 2; 970 } else if (orientation == SWT.RIGHT) { 971 x = bounds.width - marginWidth - imageBounds.width; 972 } else { 973 x = marginWidth; 974 } 975 976 int width = Math.min(bounds.width - x - marginWidth, imageBounds.width); 977 int height = Math.min(bounds.height - y - marginHeight, 978 imageBounds.height); 979 980 if (width >= 0 && height >= 0) { 981 gc.drawImage(image, 0, 0, width, height, bounds.x + x, bounds.y + y, 982 width, height); 983 } 984 } 985 986 if (text != null && text.length() > 0) { 987 GCStringPrinter sp = new GCStringPrinter(gc, text, bounds, true, false, 988 wrapText?( orientation | SWT.WRAP ):orientation ); 989 sp.printString(); 990 hadMore = sp.isCutoff(); 991 } 992 993 invokeSWTPaintListeners(gc); 994 } 995 refresh()996 public boolean refresh() { 997 //System.out.println("refresh"); 998 Utils.execSWTThread(new AERunnable() { 999 public void runSupport() { 1000 boolean wasValid = valid; 1001 try { 1002 tableColumn.invokeCellRefreshListeners(FakeTableCell.this, false); 1003 } catch (Throwable e) { 1004 } 1005 if (refreshListeners != null) { 1006 for (int i = 0; i < refreshListeners.size(); i++) { 1007 ((TableCellRefreshListener) (refreshListeners.get(i))).refresh(FakeTableCell.this); 1008 } 1009 } 1010 if (!wasValid) { 1011 valid = true; 1012 } 1013 } 1014 }); 1015 return true; 1016 } 1017 setDataSource(Object _coreDataSource)1018 public void setDataSource(Object _coreDataSource) { 1019 coreDataSource = _coreDataSource; 1020 if (_coreDataSource != null && !isDisposed()) { 1021 invokeVisibilityListeners(TableCellVisibilityListener.VISIBILITY_SHOWN, 1022 true); 1023 } 1024 } 1025 setControl(final Composite composite)1026 public void setControl(final Composite composite) { 1027 setControl(composite, null, true); 1028 } 1029 setControl(final Composite composite, Rectangle cellArea, boolean addListeners)1030 public void setControl(final Composite composite, Rectangle cellArea, boolean addListeners) { 1031 if (composite == null) { 1032 dispose(); 1033 this.composite = null; 1034 return; 1035 } 1036 1037 this.composite = composite; 1038 this.cellArea = cellArea; 1039 1040 if (addListeners) { 1041 composite.addPaintListener(this); 1042 composite.addMouseListener(this); 1043 composite.addMouseMoveListener(this); 1044 composite.addMouseTrackListener(this); 1045 } 1046 1047 setForeground(-1, -1, -1); 1048 setText(null); 1049 setToolTip(null); 1050 1051 composite.addDisposeListener(new DisposeListener() { 1052 public void widgetDisposed(DisposeEvent e) { 1053 dispose(); 1054 } 1055 }); 1056 if (coreDataSource != null && !isDisposed()) { 1057 invokeVisibilityListeners(TableCellVisibilityListener.VISIBILITY_SHOWN, 1058 true); 1059 } 1060 } 1061 paintControl(PaintEvent e)1062 public void paintControl(PaintEvent e) { 1063 doPaint(e.gc, cellArea == null ? composite.getClientArea() : cellArea); 1064 } 1065 mouseUp(MouseEvent e)1066 public void mouseUp(MouseEvent e) { 1067 invokeMouseListeners(buildMouseEvent(e, TableCellMouseEvent.EVENT_MOUSEUP)); 1068 } 1069 mouseDown(MouseEvent e)1070 public void mouseDown(MouseEvent e) { 1071 try{ 1072 if ( composite == null || composite.getMenu() != null || 1073 ( cellMouseListeners != null && cellMouseListeners.size() > 0 ) || 1074 text == null || text.length() == 0 ){ 1075 1076 return; 1077 } 1078 1079 if (!(e.button == 3 || (e.button == 1 && e.stateMask == SWT.CONTROL))){ 1080 1081 return; 1082 } 1083 1084 Menu menu = new Menu(composite.getShell(),SWT.POP_UP); 1085 1086 MenuItem item = new MenuItem( menu,SWT.NONE ); 1087 1088 item.setText( MessageText.getString( "ConfigView.copy.to.clipboard.tooltip")); 1089 1090 item.addSelectionListener( 1091 new SelectionAdapter() 1092 { 1093 public void 1094 widgetSelected( 1095 SelectionEvent arg0) 1096 { 1097 if ( !composite.isDisposed() && text != null && text.length() > 0 ){ 1098 1099 new Clipboard(composite.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()}); 1100 } 1101 } 1102 }); 1103 1104 composite.setMenu( menu ); 1105 1106 menu.addMenuListener( 1107 new MenuAdapter() 1108 { 1109 public void 1110 menuHidden( 1111 MenuEvent arg0 ) 1112 { 1113 if ( !composite.isDisposed()){ 1114 1115 composite.setMenu( null ); 1116 } 1117 } 1118 }); 1119 1120 menu.setVisible( true ); 1121 1122 }finally{ 1123 1124 invokeMouseListeners(buildMouseEvent(e, TableCellMouseEvent.EVENT_MOUSEDOWN)); 1125 } 1126 } 1127 mouseDoubleClick(MouseEvent e)1128 public void mouseDoubleClick(MouseEvent e) { 1129 invokeMouseListeners(buildMouseEvent(e, 1130 TableCellMouseEvent.EVENT_MOUSEDOUBLECLICK)); 1131 } 1132 mouseMove(MouseEvent e)1133 public void mouseMove(MouseEvent e) { 1134 invokeMouseListeners(buildMouseEvent(e, TableCellMouseEvent.EVENT_MOUSEMOVE)); 1135 } 1136 mouseHover(MouseEvent e)1137 public void mouseHover(MouseEvent e) { 1138 invokeToolTipListeners(TOOLTIPLISTENER_HOVER); 1139 } 1140 mouseExit(MouseEvent e)1141 public void mouseExit(MouseEvent e) { 1142 invokeMouseListeners(buildMouseEvent(e, TableCellMouseEvent.EVENT_MOUSEEXIT)); 1143 } 1144 mouseEnter(MouseEvent e)1145 public void mouseEnter(MouseEvent e) { 1146 invokeMouseListeners(buildMouseEvent(e, 1147 TableCellMouseEvent.EVENT_MOUSEENTER)); 1148 } 1149 1150 /** 1151 * @param e 1152 * @return 1153 * 1154 * @since 3.0.2.1 1155 */ buildMouseEvent(MouseEvent e, int eventType)1156 protected TableCellMouseEvent buildMouseEvent(MouseEvent e, int eventType) { 1157 if (isDisposed()) { 1158 return null; 1159 } 1160 TableCellMouseEvent event = new TableCellMouseEvent(); 1161 event.cell = this; 1162 event.button = e.button; 1163 event.keyboardState = e.stateMask; 1164 event.eventType = eventType; 1165 1166 Rectangle r = composite.getBounds(); 1167 // int align = tableColumn.getAlignment(); 1168 // if (align == TableColumn.ALIGN_CENTER) { 1169 // r.x = marginWidth; 1170 // r.x += (r.width - (marginWidth * 2) - imageBounds.width) / 2; 1171 // } 1172 1173 if (cellArea != null) { 1174 r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, 1175 cellArea.height); 1176 } 1177 1178 event.x = e.x - r.x; 1179 event.y = e.y - r.y; 1180 1181 return event; 1182 } 1183 setOrientationViaColumn()1184 private void setOrientationViaColumn() { 1185 orientation = TableColumnSWTUtils.convertColumnAlignmentToSWT(tableColumn.getAlignment()); 1186 } 1187 1188 // @see com.aelitis.azureus.ui.common.table.TableCellCore#dispose() dispose()1189 public void dispose() { 1190 if (composite != null && !composite.isDisposed()) { 1191 composite.removePaintListener(this); 1192 composite.removeMouseListener(this); 1193 composite.removeMouseMoveListener(this); 1194 composite.removeMouseTrackListener(this); 1195 } 1196 1197 if (disposeListeners != null) { 1198 for (Iterator iter = disposeListeners.iterator(); iter.hasNext();) { 1199 TableCellDisposeListener listener = (TableCellDisposeListener) iter.next(); 1200 try { 1201 listener.dispose(this); 1202 } catch (Throwable e) { 1203 Debug.out(e); 1204 } 1205 } 1206 disposeListeners = null; 1207 } 1208 tableColumn.invokeCellDisposeListeners(this); 1209 tableColumn.invalidateCells(); 1210 } 1211 1212 // @see com.aelitis.azureus.ui.common.table.TableCellCore#getCursorID() getCursorID()1213 public int getCursorID() { 1214 // TODO Auto-generated method stub 1215 return 0; 1216 } 1217 1218 // @see com.aelitis.azureus.ui.common.table.TableCellCore#getObfusticatedText() getObfusticatedText()1219 public String getObfusticatedText() { 1220 return text; 1221 } 1222 1223 // @see com.aelitis.azureus.ui.common.table.TableCellCore#getTableRowCore() getTableRowCore()1224 public TableRowCore getTableRowCore() { 1225 return null; 1226 } 1227 1228 // @see com.aelitis.azureus.ui.common.table.TableCellCore#getVisuallyChangedSinceRefresh() getVisuallyChangedSinceRefresh()1229 public boolean getVisuallyChangedSinceRefresh() { 1230 return true; 1231 } 1232 1233 // @see com.aelitis.azureus.ui.common.table.TableCellCore#invalidate(boolean) invalidate(boolean mustRefresh)1234 public void invalidate(boolean mustRefresh) { 1235 valid = false; 1236 } 1237 1238 // @see com.aelitis.azureus.ui.common.table.TableCellCore#invokeToolTipListeners(int) invokeToolTipListeners(int type)1239 public void invokeToolTipListeners(int type) { 1240 if (tableColumn == null) 1241 return; 1242 1243 tableColumn.invokeCellToolTipListeners(this, type); 1244 1245 if (tooltipListeners == null) 1246 return; 1247 1248 try { 1249 if (type == TOOLTIPLISTENER_HOVER) { 1250 for (int i = 0; i < tooltipListeners.size(); i++) 1251 ((TableCellToolTipListener) (tooltipListeners.get(i))).cellHover(this); 1252 } else { 1253 for (int i = 0; i < tooltipListeners.size(); i++) 1254 ((TableCellToolTipListener) (tooltipListeners.get(i))).cellHoverComplete(this); 1255 } 1256 } catch (Throwable e) { 1257 Debug.out(e); 1258 } 1259 } 1260 1261 // @see com.aelitis.azureus.ui.common.table.TableCellCore#invokeVisibilityListeners(int, boolean) invokeVisibilityListeners(int visibility, boolean invokeColumnListeners)1262 public void invokeVisibilityListeners(int visibility, 1263 boolean invokeColumnListeners) { 1264 if (invokeColumnListeners) { 1265 tableColumn.invokeCellVisibilityListeners(this, visibility); 1266 } 1267 1268 if (cellVisibilityListeners == null) 1269 return; 1270 1271 for (int i = 0; i < cellVisibilityListeners.size(); i++) { 1272 try { 1273 TableCellVisibilityListener l = (TableCellVisibilityListener) (cellVisibilityListeners.get(i)); 1274 1275 l.cellVisibilityChanged(this, visibility); 1276 1277 } catch (Throwable e) { 1278 Debug.printStackTrace(e); 1279 } 1280 } 1281 } 1282 1283 // @see com.aelitis.azureus.ui.common.table.TableCellCore#isMouseOver() isMouseOver()1284 public boolean isMouseOver() { 1285 if (isDisposed()) { 1286 return false; 1287 } 1288 Rectangle r = composite.getBounds(); 1289 if (cellArea != null) { 1290 r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, 1291 cellArea.height); 1292 } 1293 Point ptStart = composite.toDisplay(r.x, r.y); 1294 r.x = ptStart.x; 1295 r.y = ptStart.y; 1296 Point ptCursor = composite.getDisplay().getCursorLocation(); 1297 return r.contains(ptCursor); 1298 } 1299 setMouseOver(boolean b)1300 public void setMouseOver(boolean b) { 1301 // ignored, we calc mouseover on the fly 1302 } 1303 1304 // @see com.aelitis.azureus.ui.common.table.TableCellCore#isUpToDate() isUpToDate()1305 public boolean isUpToDate() { 1306 return false; 1307 } 1308 1309 // @see com.aelitis.azureus.ui.common.table.TableCellCore#locationChanged() locationChanged()1310 public void locationChanged() { 1311 // TODO Auto-generated method stub 1312 1313 } 1314 1315 // @see com.aelitis.azureus.ui.common.table.TableCellCore#needsPainting() needsPainting()1316 public boolean needsPainting() { 1317 return true; 1318 } 1319 1320 // @see com.aelitis.azureus.ui.common.table.TableCellCore#refresh(boolean) refresh(boolean doGraphics)1321 public boolean refresh(boolean doGraphics) { 1322 return refresh(); 1323 } 1324 1325 // @see com.aelitis.azureus.ui.common.table.TableCellCore#refresh(boolean, boolean, boolean) refresh(boolean doGraphics, boolean rowVisible, boolean cellVisible)1326 public boolean refresh(boolean doGraphics, boolean rowVisible, 1327 boolean cellVisible) { 1328 return refresh(); 1329 } 1330 1331 // @see com.aelitis.azureus.ui.common.table.TableCellCore#refresh(boolean, boolean) refresh(boolean doGraphics, boolean rowVisible)1332 public boolean refresh(boolean doGraphics, boolean rowVisible) { 1333 return refresh(); 1334 } 1335 1336 // @see com.aelitis.azureus.ui.common.table.TableCellCore#setCursorID(int) setCursorID(int cursorID)1337 public boolean setCursorID(int cursorID) { 1338 // TODO Auto-generated method stub 1339 return false; 1340 } 1341 1342 // @see com.aelitis.azureus.ui.common.table.TableCellCore#setUpToDate(boolean) setUpToDate(boolean upToDate)1343 public void setUpToDate(boolean upToDate) { 1344 // TODO Auto-generated method stub 1345 1346 } 1347 1348 // @see java.lang.Comparable#compareTo(java.lang.Object) compareTo(Object arg0)1349 public int compareTo(Object arg0) { 1350 // TODO Auto-generated method stub 1351 return 0; 1352 } 1353 setOrentation(int o)1354 public void setOrentation(int o) { 1355 orientation = o; 1356 } 1357 getCellArea()1358 public Rectangle getCellArea() { 1359 return cellArea; 1360 } 1361 setCellArea(Rectangle cellArea)1362 public void setCellArea(Rectangle cellArea) { 1363 //System.out.println("SCA " + cellArea + ";" + Debug.getCompressedStackTrace()); 1364 this.cellArea = cellArea; 1365 } 1366 1367 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getMouseOffset() getMouseOffset()1368 public int[] getMouseOffset() { 1369 if (isDisposed()) { 1370 return null; 1371 } 1372 Rectangle r = composite.getBounds(); 1373 if (cellArea != null) { 1374 r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, 1375 cellArea.height); 1376 } 1377 Point ptStart = composite.toDisplay(r.x, r.y); 1378 r.x = ptStart.x; 1379 r.y = ptStart.y; 1380 Point ptCursor = composite.getDisplay().getCursorLocation(); 1381 if (!r.contains(ptCursor)) { 1382 return null; 1383 } 1384 return new int[] { ptCursor.x - r.x, ptCursor.y - r.y }; 1385 } 1386 1387 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getMarginHeight() getMarginHeight()1388 public int getMarginHeight() { 1389 return marginHeight; 1390 } 1391 1392 // @see org.gudy.azureus2.plugins.ui.tables.TableCell#getMarginWidth() getMarginWidth()1393 public int getMarginWidth() { 1394 return marginWidth; 1395 } 1396 1397 // @see com.aelitis.azureus.ui.common.table.TableCellCore#refreshAsync() refreshAsync()1398 public void refreshAsync() { 1399 refresh(); 1400 } 1401 1402 // @see com.aelitis.azureus.ui.common.table.TableCellCore#redraw() redraw()1403 public void redraw() { 1404 Utils.execSWTThread(new AERunnable() { 1405 public void runSupport() { 1406 if (!isDisposed()) { 1407 composite.redraw(); 1408 } 1409 } 1410 }); 1411 } 1412 1413 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#doPaint(org.eclipse.swt.graphics.GC) doPaint(GC gc)1414 public void doPaint(GC gc) { 1415 doPaint(gc, cellArea == null ? composite.getClientArea() : cellArea); 1416 } 1417 1418 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getBackgroundImage() getBackgroundImage()1419 public Image getBackgroundImage() { 1420 // TODO Auto-generated method stub 1421 return null; 1422 } 1423 1424 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getBackgroundSWT() getBackgroundSWT()1425 public Color getBackgroundSWT() { 1426 // TODO Auto-generated method stub 1427 return composite.getBackground(); 1428 } 1429 1430 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getBounds() getBounds()1431 public Rectangle getBounds() { 1432 return cellArea == null ? composite.getClientArea() : new Rectangle( 1433 cellArea.x, cellArea.y, cellArea.width, cellArea.height); 1434 } 1435 1436 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getForegroundSWT() getForegroundSWT()1437 public Color getForegroundSWT() { 1438 return composite.getForeground(); 1439 } 1440 1441 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getGraphicSWT() getGraphicSWT()1442 public Image getGraphicSWT() { 1443 // TODO Auto-generated method stub 1444 return null; 1445 } 1446 1447 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getIcon() getIcon()1448 public Image getIcon() { 1449 // TODO Auto-generated method stub 1450 return null; 1451 } 1452 1453 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getSize() getSize()1454 public Point getSize() { 1455 Rectangle bounds = getBounds(); 1456 if (bounds == null) { 1457 return null; 1458 } 1459 return new Point(bounds.width, bounds.height); 1460 } 1461 1462 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getTableRowSWT() getTableRowSWT()1463 public TableRowSWT getTableRowSWT() { 1464 // TODO Auto-generated method stub 1465 return null; 1466 } 1467 1468 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#getTextAlpha() getTextAlpha()1469 public int getTextAlpha() { 1470 // TODO Auto-generated method stub 1471 return 0; 1472 } 1473 1474 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#setForeground(org.eclipse.swt.graphics.Color) setForeground(Color color)1475 public boolean setForeground(Color color) { 1476 // TODO Auto-generated method stub 1477 return false; 1478 } 1479 1480 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#setGraphic(org.eclipse.swt.graphics.Image) setGraphic(Image img)1481 public boolean setGraphic(Image img) { 1482 graphic = null; 1483 1484 image = img; 1485 if (image != null) { 1486 imageBounds = image.getBounds(); 1487 } 1488 1489 if (composite != null && !composite.isDisposed()) { 1490 redraw(); 1491 } 1492 1493 return true; 1494 } 1495 1496 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#setIcon(org.eclipse.swt.graphics.Image) setIcon(Image img)1497 public boolean setIcon(Image img) { 1498 // TODO Auto-generated method stub 1499 return false; 1500 } 1501 1502 // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWT#setTextAlpha(int) setTextAlpha(int textOpacity)1503 public void setTextAlpha(int textOpacity) { 1504 // TODO Auto-generated method stub 1505 1506 } 1507 getBoundsOnDisplay()1508 public Rectangle getBoundsOnDisplay() { 1509 Rectangle bounds = getBounds(); 1510 Point pt = composite.toDisplay(bounds.x, bounds.y); 1511 bounds.x = pt.x; 1512 bounds.y = pt.y; 1513 return bounds; 1514 } 1515 getTableColumnCore()1516 public TableColumnCore getTableColumnCore() { 1517 return tableColumn; 1518 } 1519 } 1520