1 184 185 186 package swingwtx.swing; 187 188 import swingwtx.swing.table.*; 189 import swingwtx.swing.table.TableColumn; 190 import swingwtx.swing.event.*; 191 import swingwt.awt.event.MouseEvent; 192 193 import org.eclipse.swt.widgets.*; 194 import org.eclipse.swt.*; 195 196 import java.util.*; 197 198 199 200 public class JTable extends swingwtx.swing.JComponent implements TableModelListener, 201 TableColumnModelListener, 202 ListSelectionListener, 203 CellEditorListener { 204 205 public static final int AUTO_RESIZE_OFF = 0; 206 public static final int AUTO_RESIZE_NEXT_COLUMN = 1; 207 public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2; 208 public static final int AUTO_RESIZE_LAST_COLUMN = 3; 209 public static final int AUTO_RESIZE_ALL_COLUMNS = 4; 210 211 protected Table ppeer = null; 212 protected JTableHeader header = null; 213 private TableModel model = null; 214 protected TableColumnModel columnModel = null; 215 protected ListSelectionModel listSelectionModel = null; 216 protected TableCellEditor cellEditor = null; 217 protected int pRowHeight = 20; 218 protected swingwt.awt.Dimension pIntercell = null; 219 220 protected boolean pLines = true; 221 protected int pSelRow = -1; 222 protected int pSelCol = -1; 223 224 protected int editingColumn = -1; 225 protected int editingRow = -1; 226 protected TableCellEditor editingEditor = null; 227 protected swingwt.awt.Component editingComponent = null; 228 229 protected boolean cellSelectionEnabled = true; 230 231 protected org.eclipse.swt.custom.TableEditor swtEditor = null; 232 233 protected org.eclipse.swt.custom.TableCursor swtCursor = null; 234 235 241 protected boolean tableDrawnOnce = false; 242 243 245 private boolean modelDirty = true; 246 private boolean columnModelDirty = true; 247 248 public JTable() { 249 this(null); 250 } 251 public JTable(int numRows, int numCols) { 252 this(new DefaultTableModel(numRows, numCols)); 253 } 254 public JTable(Object [][] rowData, Object [] columnNames) { 255 this(new DefaultTableModel(rowData, columnNames)); 256 } 257 public JTable(Vector rowData, Vector columnNames) { 258 this(new DefaultTableModel(rowData, columnNames)); 259 } 260 public JTable(TableModel dm) { 261 this(dm, null); 262 } 263 public JTable(TableModel dm, TableColumnModel columnModel) { 264 this(dm, columnModel, null); 265 } 266 public JTable(TableModel dm, TableColumnModel columnModel, ListSelectionModel selectionModel) { 267 268 if (dm == null) 269 dm = new DefaultTableModel(); 270 271 if (columnModel == null) { 272 model = dm; 273 generateDefaultColumnModel(); 274 columnModel = this.columnModel; 275 } 276 277 if (selectionModel == null) 278 selectionModel = new DefaultListSelectionModel(this); 279 280 setModel(dm); 281 setColumnModel(columnModel); 282 setSelectionModel(selectionModel); 283 setCellEditor(new DefaultCellEditor(new JTextField())); 284 285 } 286 287 public TableModel getModel() { return model; } 288 public void setModel(TableModel dm, boolean noRefresh) { 289 if (model == dm) return; 290 model = dm; 291 generateDefaultColumnModel(); 292 model.addTableModelListener(this); 293 } 294 public void setModel(TableModel dm) { 295 setModel(dm, true); 296 modelDirty = true; 297 refreshTable(); 298 } 299 public void clearSelection() { if (!SwingWTUtils.isSWTControlAvailable(ppeer)) return; ppeer.deselectAll(); } 300 public void doLayout() { refreshTable(); } 301 public int getColumnCount() { return model.getColumnCount(); } 302 public String getColumnName(int index) { return model.getColumnName(index); } 303 public swingwtx.swing.table.TableColumn getColumn(Object identifier) { return columnModel.getColumn(columnModel.getColumnIndex(identifier)); } 304 public swingwtx.swing.table.TableColumn getColumn(int index) { return columnModel.getColumn(index); } 305 public int getRowCount() { return model.getRowCount(); } 306 307 public int getSelectedColumn() { if (!SwingWTUtils.isSWTControlAvailable(ppeer)) return pSelCol; else return -1; } 308 309 public int getSelectedColumnCount() { return 0; } 310 311 public int[] getSelectedColumns() { return null; } 312 public int getSelectedRow() { 313 final int[] sel = new int[1]; 314 SwingUtilities.invokeSync(new Runnable () { 315 public void run() { 316 if (!SwingWTUtils.isSWTControlAvailable(ppeer)) 317 sel[0] = pSelRow; 318 else 319 sel[0] = ppeer.getSelectionIndex(); 320 } 321 }); 322 return sel[0]; 323 } 324 public int getSelectedRowCount() { 325 final int[] sel = new int[1]; 326 SwingUtilities.invokeSync(new Runnable () { 327 public void run() { 328 if (!SwingWTUtils.isSWTControlAvailable(ppeer)) 329 sel[0] = 0; 330 else 331 sel[0] = ppeer.getSelectionCount(); 332 } 333 }); 334 return sel[0]; 335 } 336 private int[] selRows = new int[0]; 337 public int[] getSelectedRows() { 338 SwingUtilities.invokeSync(new Runnable () { 339 public void run() { 340 if (!SwingWTUtils.isSWTControlAvailable(ppeer)) 341 selRows = null; 342 else 343 selRows = ppeer.getSelectionIndices(); 344 } 345 }); 346 return selRows; 347 } 348 public boolean getShowHorizontalLines() { return isShowGrid(); } 349 public boolean isShowHorizontalLines() { return isShowGrid(); } 350 public boolean getShowVerticalLines() { return isShowGrid(); } 351 public boolean isShowVerticalLines() { return isShowGrid(); } 352 public boolean getShowGrid() { return isShowGrid(); } 353 public boolean isShowGrid() { 354 final boolean[] ret = new boolean[1]; 355 SwingUtilities.invokeSync(new Runnable () { 356 public void run() { 357 if (!SwingWTUtils.isSWTControlAvailable(ppeer)) 358 ret[0] = false; 359 else 360 ret[0] = ppeer.getLinesVisible(); 361 } 362 }); 363 return ret[0]; 364 } 365 public void setShowHorizontalLines(boolean b) { setShowGrid(b); } 366 public void setShowVerticalLines(boolean b) { setShowGrid(b); } 367 public void setShowGrid(final boolean b) { 368 SwingUtilities.invokeSync(new Runnable () { 369 public void run() { 370 if (!SwingWTUtils.isSWTControlAvailable(ppeer)) 371 pLines = b; 372 else 373 ppeer.setLinesVisible(b); 374 } 375 }); 376 } 377 public Object getValueAt(int row, int col) { return model.getValueAt(row, col); } 378 public void resizeAndRepaint() { refreshTable(); } 379 public void selectAll() { if (SwingWTUtils.isSWTControlAvailable(ppeer)) ppeer.selectAll(); } 380 public void setValueAt(Object value, int row, int col) { model.setValueAt(value, row, col); } 381 public TableColumnModel getColumnModel() { return columnModel; } 382 383 public void setAutoCreateColumnsFromModel(boolean b) {} 384 public void setColumnModel(TableColumnModel model) { 385 if (columnModel == model) return; 386 columnModel = model; 387 modelDirty = true; 388 refreshTable(); 389 columnModel.addColumnModelListener(this); 390 } 391 392 public void setRowSelectionAllowed(boolean b) { } 393 394 public void setColumnSelectionAllowed(boolean b) { } 395 public boolean getRowSelectionAllowed(boolean b) { return true; } 396 public void setCellSelectionEnabled(boolean b) { cellSelectionEnabled = b; modelDirty = true; refreshTable(); } 397 public boolean getCellSelectionEnabled(boolean b) { return cellSelectionEnabled; } 398 public boolean getColumnSelectionAllowed(boolean b) { return false; } 399 400 public swingwt.awt.Color getSelectionBackground() { return swingwt.awt.Color.BLUE; } 401 402 public swingwt.awt.Color getSelectionForeground() { return swingwt.awt.Color.WHITE; } 403 404 public void setSelectionBackground(swingwt.awt.Color c) {} 405 406 public void setSelectionForeground(swingwt.awt.Color c) {} 407 408 public void setIntercellSpacing(swingwt.awt.Dimension d) { pIntercell = d; } 409 public swingwt.awt.Dimension getIntercellSpacing() { if (pIntercell == null) return new swingwt.awt.Dimension(0, 0); else return pIntercell; } 410 public int getRowHeight() { return pRowHeight; } 411 412 public void setRowHeight(int height) { pRowHeight = height; } 413 414 public void setRowHeight(int row, int height) { setRowHeight(height); } 415 416 public int rowAtPoint(swingwt.awt.Point p) { return -1; } 417 418 public int getAutoResizeMode() { return 0; } 419 420 public void setAutoResizeMode(int size) {} 421 422 public ListSelectionModel getSelectionModel() { return listSelectionModel; } 423 public void setSelectionModel(ListSelectionModel l) { 424 if (l != null) { 425 listSelectionModel = l; 426 l.addListSelectionListener(this); 427 } 428 } 429 430 public void setSelectionMode(int mode) { 431 listSelectionModel.setSelectionMode(mode); 432 } 433 434 public TableCellRenderer getCellRenderer(int row, int column) { 435 return columnModel.getColumn(column).getCellRenderer(); 436 } 437 438 public swingwt.awt.Component prepareRenderer(TableCellRenderer renderer, int row, int column) { 439 return renderer.getTableCellRendererComponent( this, 440 getValueAt(row,column), 441 isCellSelected(row,column), 442 false , 443 row, 444 column); 445 } 446 447 public boolean isCellSelected(int row, int col) { 448 int srow = -1; 449 int scol = -1; 450 try { 451 srow = ((Integer ) swtCursor.getRow().getData("rowindex")).intValue(); 452 scol = swtCursor.getColumn(); 453 } 454 catch (Exception e) {} 455 if (srow == row && scol == col) return true; 456 if (getSelectedRow() == row) return true; 457 return false; 458 } 459 460 466 public void setModelDirty(boolean b) { 467 modelDirty = b; 468 } 469 470 public void changeSelection(final int row, final int col, final boolean toggle, final boolean extend) { 471 pSelRow = row; 472 pSelCol = col; 473 SwingUtilities.invokeSync(new Runnable () { 474 public void run() { 475 if (SwingWTUtils.isSWTControlAvailable(ppeer)) 476 ppeer.setSelection(row); 477 } 478 }); 479 } 480 481 482 public void showSelection() { 483 SwingUtilities.invokeSync(new Runnable () { 484 public void run() { 485 if (SwingWTUtils.isSWTControlAvailable(ppeer)) 486 ppeer.showSelection(); 487 } 488 }); 489 } 490 491 494 public int convertColumnIndexToModel(int index) { 495 return index; 496 } 497 498 502 private void generateDefaultColumnModel() { 503 columnModel = new DefaultTableColumnModel(); 504 for (int i = 0; i < model.getColumnCount(); i++) { 505 506 swingwtx.swing.table.TableColumn tc = new swingwtx.swing.table.TableColumn(); 507 508 int colWidth = 0; 511 tc.setWidth(colWidth); 513 tc.setPreferredWidth(colWidth); 514 tc.setMaxWidth(colWidth); 515 tc.setMinWidth(colWidth); 516 tc.setHeaderValue(model.getColumnName(i)); 517 tc.setIdentifier(model.getColumnName(i)); 518 tc.setCellRenderer(new DefaultTableCellRenderer()); 519 tc.setCellEditor(cellEditor); tc.setModelIndex(i); 521 tc.setResizable(true); 522 523 columnModel.addColumn(tc); 524 } 525 } 526 527 public JTableHeader getTableHeader() { 528 if (header == null) 529 header = new JTableHeader(this); 530 return header; 531 } 532 533 538 public void setSwingWTParent(swingwt.awt.Container parent) throws Exception { 539 descendantHasPeer = true; 540 ppeer = new Table(parent.getComposite(), SWT.BORDER ); 541 peer = ppeer; 542 this.parent = parent; 543 544 ppeer.setLinesVisible(pLines); 546 547 if (!tableDrawnOnce) 552 tableDrawnOnce = true; 553 else 554 setDirty(true); 555 556 if (modelDirty) refreshTable(); 558 559 if (pSelRow != -1) ppeer.setSelection(pSelRow); 561 } 562 563 566 public void setDirty(boolean b) { 567 modelDirty = b; 568 } 569 570 574 public void refreshTable() { 575 576 if (!modelDirty) return; 578 modelDirty = false; 579 580 final JTable table = this; 581 SwingUtilities.invokeSync(new Runnable () { 582 public void run() { 583 if (!SwingWTUtils.isSWTControlAvailable(ppeer)) { modelDirty = true; return; } 586 587 ppeer.removeAll(); 589 ppeer.setHeaderVisible(true); 590 591 593 ppeer.dispose(); 595 596 if (parent.getLayout() != null) 598 parent.getLayout().removeLayoutComponent(table); 599 600 ppeer = new Table(parent.getComposite(), SWT.BORDER | 601 (listSelectionModel.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ? SWT.MULTI : SWT.SINGLE) | 602 (!cellSelectionEnabled ? SWT.FULL_SELECTION : SWT.NONE) | 603 SWT.VIRTUAL 604 ); 605 606 parent.addComponentToLayout(table); 607 ppeer.setHeaderVisible(true); 608 peer = ppeer; 609 610 parent.invalidate(); 612 613 for (int i = 0; i < columnModel.getColumnCount(); i++) { 614 615 org.eclipse.swt.widgets.TableColumn tc = 616 new org.eclipse.swt.widgets.TableColumn(ppeer, 0); 617 618 tc.setText(columnModel.getColumn(i).getHeaderValue().toString()); 619 tc.setResizable(columnModel.getColumn(i).isResizable()); 620 621 if (columnModel.getColumn(i).getWidth() == 0) { 625 int colwidth = SwingWTUtils.getRenderStringWidth(columnModel.getColumn(i).getHeaderValue().toString()); 626 int contentwidth = 0; 627 for (int z = 0; z < model.getRowCount(); z++) { 628 Object value = model.getValueAt(z, i); 629 if (value == null) value = ""; 630 contentwidth = (SwingWTUtils.getRenderStringWidth(value.toString())); 631 if (contentwidth > colwidth) colwidth = contentwidth; 632 } 633 tc.setWidth(colwidth); 634 } 635 else 636 tc.setWidth(columnModel.getColumn(i).getWidth()); 637 638 final int index = i; 640 tc.addSelectionListener( new org.eclipse.swt.events.SelectionListener() { 641 public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { 642 processColumnClick(index); 643 } 644 public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {} 645 }); 646 } 647 648 ppeer.setLinesVisible(pLines); 650 setCachedProperties(); 651 registerEvents(); 652 653 if (model.getRowCount() > 0) { 657 boolean hasOneEditableColumn = false; 658 for (int i = 0; i < model.getColumnCount(); i++) 659 if (model.isCellEditable(0, i)) hasOneEditableColumn = true; 660 if (hasOneEditableColumn) { 661 swtEditor = new org.eclipse.swt.custom.TableEditor(ppeer); 662 createTableCursor(); 663 } 664 } 665 666 ppeer.setItemCount(model.getRowCount()); 668 669 ppeer.addListener (SWT.SetData, new Listener () { 672 public void handleEvent (Event event) { 673 674 TableItem ti = (TableItem) event.item; 675 int i = ppeer.indexOf(ti); 676 677 ti.setData("rowindex", new Integer (i)); 679 680 for (int z = 0; z < model.getColumnCount(); z++) { 681 682 swingwt.awt.Component cr = 684 columnModel.getColumn(z).getCellRenderer().getTableCellRendererComponent( 685 table, model.getValueAt(i, z), 686 getSelectedRow() == i, 687 true, 688 i, z); 689 690 if (cr instanceof JLabel) { 691 692 JLabel renderer = (JLabel) cr; 693 694 ti.setText(z, renderer.getText() ); 696 697 if (renderer.getIcon() != null) 699 ti.setImage(z, SwingWTUtils.getSWTImageFromSwingIcon(table, renderer.getIcon())); 700 701 if (renderer.getBackground() != null) 703 if (renderer.getBackground().getSWTColor() != null) 704 ti.setBackground(z, renderer.getBackground().getSWTColor()); 705 if (renderer.getForeground() != null) 706 if (renderer.getForeground().getSWTColor() != null) 707 ti.setForeground(z, renderer.getForeground().getSWTColor()); 708 709 if (renderer.hasSetFont()) 711 ti.setFont(z, renderer.getFont().getSWTFont()); 712 713 } 714 else 715 ti.setText(z,"CellRenderer not JLabel: " + cr.getClass().getName()); 716 } 717 } 718 }); 719 } 720 }); 721 } 722 723 728 public void refreshTable(final int rowFrom, final int rowTo) { 729 730 if (!modelDirty) return; 732 modelDirty = false; 733 734 final JTable table = this; 735 SwingUtilities.invokeAsync(new Runnable () { 736 public void run() { 737 if (!SwingWTUtils.isSWTControlAvailable(ppeer)) return; 739 for (int i = rowFrom; i < model.getRowCount() && i < rowTo; i++) { 742 TableItem ti = ppeer.getItem(i); 743 for (int z = 0; z < model.getColumnCount(); z++) { 744 745 swingwt.awt.Component cr = 747 columnModel.getColumn(z).getCellRenderer().getTableCellRendererComponent( 748 table, model.getValueAt(i, z), 749 getSelectedRow() == i, 750 true, 751 i, z); 752 753 if (cr instanceof JLabel) { 754 755 JLabel renderer = (JLabel) cr; 756 757 ti.setText(z, renderer.getText() ); 759 760 if (renderer.getIcon() != null) 762 ti.setImage(z, SwingWTUtils.getSWTImageFromSwingIcon(table, renderer.getIcon())); 763 764 if (renderer.getBackground() != null) 766 if (renderer.getBackground().getSWTColor() != null) 767 ti.setBackground(z, renderer.getBackground().getSWTColor()); 768 if (renderer.getForeground() != null) 769 if (renderer.getForeground().getSWTColor() != null) 770 ti.setForeground(z, renderer.getForeground().getSWTColor()); 771 772 if (renderer.hasSetFont()) 774 ti.setFont(z, renderer.getFont().getSWTFont()); 775 } 776 else 777 ti.setText("CellRenderer must descend JLabel"); 778 } 779 } 780 } 781 }); 782 783 } 784 785 789 protected void registerSelectionEvents() { 790 final JTable pthis = this; 791 swtCursor.addSelectionListener( new org.eclipse.swt.events.SelectionAdapter() { 792 public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { 793 processListSelection(); 794 processCellEdit(); 795 796 } 797 }); 798 } 799 800 804 protected void processListSelection() { 805 if (listSelectionModel instanceof DefaultListSelectionModel) { 807 if (listSelectionModel.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { 808 int lowest = ppeer.getSelectionIndex(); int highest = ppeer.getSelectionIndex(); 809 int sel[] = ppeer.getSelectionIndices(); 810 for (int i = 0; i < sel.length; i++) { 811 if (lowest > sel[i]) lowest = sel[i]; 812 if (highest < sel[i]) highest = sel[i]; 813 } 814 ((DefaultListSelectionModel) listSelectionModel).fireListSelectionEvent(JTable.this, lowest, highest); 815 } 816 else { 817 ((DefaultListSelectionModel) listSelectionModel).fireListSelectionEvent(JTable.this, ppeer.getSelectionIndex(), 818 ppeer.getSelectionIndex()); 819 } 820 } 821 } 822 823 824 828 protected void processCellEdit() { 829 830 if (!cellSelectionEnabled) return; 832 833 if (swtCursor != null) { 836 if (swtCursor.isDisposed()) { 837 createTableCursor(); 838 return; 839 } 840 } 841 else { 842 return; 845 } 846 847 editingRow = ((Integer ) swtCursor.getRow().getData("rowindex")).intValue(); 849 editingColumn = swtCursor.getColumn(); 850 851 if (!model.isCellEditable(editingRow, editingColumn)) return; 853 854 editingEditor = columnModel.getColumn(editingColumn).getCellEditor(); 856 if (editingEditor == null) editingEditor = cellEditor; 857 editingComponent = editingEditor.getTableCellEditorComponent(this, model.getValueAt(editingRow, editingColumn), true, editingRow, editingColumn); 858 859 if (editingEditor instanceof DefaultCellEditor) 861 if (((DefaultCellEditor) editingEditor).getCellEditorListeners() == null) 862 editingEditor.addCellEditorListener(this); 863 864 if (swtEditor != null) { 866 if (swtEditor.getEditor() != null) 867 swtEditor.getEditor().dispose(); 868 swtEditor.dispose(); 869 swtEditor = null; 870 } 871 872 TableItem item = ppeer.getItem(editingRow); 874 875 try { 880 editingComponent.setSwingWTParent(new TableEditorContainer(this)); 881 editingComponent.registerEvents(); 882 } 883 catch (Exception e) { 884 e.printStackTrace(); 885 } 886 887 swtCursor.dispose(); 889 890 swtEditor = new org.eclipse.swt.custom.TableEditor(ppeer); 892 swtEditor.horizontalAlignment = SWT.LEFT; 893 swtEditor.grabHorizontal = true; 894 swtEditor.minimumWidth = 50; 895 swtEditor.setEditor(editingComponent.getPeer(), item, editingColumn); 896 897 if (editingEditor instanceof DefaultCellEditor) { 899 ((DefaultCellEditor) editingEditor).getHandler().setValue(model.getValueAt(editingRow, editingColumn)); 900 } 901 902 editingComponent.grabFocus(); 904 905 } 906 907 908 public void editingCanceled(ChangeEvent e) { 909 createTableCursor(); 910 } 911 912 915 public void editingStopped(ChangeEvent e) { 916 Object value = editingEditor.getCellEditorValue(); 918 919 model.setValueAt(value, editingRow, editingColumn); 921 modelDirty = true; 924 refreshTable(editingRow, editingRow + 1); 925 926 createTableCursor(); 928 } 929 930 936 protected void processColumnClick(int index) { 937 938 if (columnModel instanceof DefaultTableColumnModel) 941 ((DefaultTableColumnModel) columnModel).lastColClicked = index; 942 943 MouseEvent e = new MouseEvent(this.getTableHeader()); 944 e.eventID = MouseEvent.CLICKED; 945 e.setX(SwingWTUtils.getDisplay().getCursorLocation().x); 946 e.setY(SwingWTUtils.getDisplay().getCursorLocation().y); 947 e.setButton(SWT.BUTTON1); 948 e.clickCount = 1; 949 getTableHeader().processMouseEvent(e); 950 } 951 952 953 public TableCellEditor getCellEditor() { 954 return cellEditor; 955 } 956 957 public TableCellEditor getCellEditor(int row, int col) { 958 return cellEditor; 959 } 960 961 public void setCellEditor(TableCellEditor cell) { 962 cellEditor = cell; 963 cellEditor.addCellEditorListener(this); 964 } 965 966 public int getEditingColumn() { 967 return getSelectedColumn(); 968 } 969 970 public void setEditingColumn(int aColumn) { 971 editingColumn = aColumn; 972 } 973 974 public int getEditingRow() { 975 return getSelectedRow(); 976 } 977 978 public void setEditingRow(int aRow) { 979 editingRow = aRow; 980 changeSelection(aRow, editingColumn, false, false); 981 } 982 983 986 public void tableChanged(TableModelEvent e) { 987 modelDirty = true; 988 if (e.getColumn() == TableModelEvent.ALL_COLUMNS) 991 refreshTable(); 992 else 993 refreshTable(e.getFirstRow(), e.getLastRow()); 995 } 996 997 public void valueChanged(ListSelectionEvent e) { 998 columnSelectionChanged(e); 999 } 1000 1001 public void columnAdded(TableColumnModelEvent e) { 1002 modelDirty = true; 1003 refreshTable(); 1004 } 1005 1006 public void columnMarginChanged(ChangeEvent e) { 1007 } 1009 1010 public void columnMoved(TableColumnModelEvent e) { 1011 modelDirty = true; 1012 refreshTable(); 1013 } 1014 1015 public void columnRemoved(TableColumnModelEvent e) { 1016 modelDirty = true; 1017 refreshTable(); 1018 } 1019 1020 public void columnSelectionChanged(ListSelectionEvent e) { 1021 } 1023 1024 1025 protected void createTableCursor() { 1026 swtCursor = new org.eclipse.swt.custom.TableCursor(ppeer, SWT.NONE); 1027 registerSelectionEvents(); 1028 } 1029 1030 1034 private class TableEditorContainer extends swingwt.awt.Container { 1035 public TableEditorContainer(JTable parent) { 1036 this.peer = parent.getPeer(); 1037 this.composite = (org.eclipse.swt.widgets.Composite) parent.getPeer(); 1038 } 1039 } 1040 1041 public boolean isEditing() { 1042 boolean isEdit = false; 1043 isEdit = swtCursor != null; if (swtCursor != null) 1045 isEdit = swtCursor.isDisposed(); return isEdit; 1047 } 1048 1049 public void removeColumn(TableColumn tableColumn) { 1050 getColumnModel().removeColumn(tableColumn); 1051 } 1052 1053} 1054 | Popular Tags |