private String[] getItemText( TableItem row ) { if ( row.isDisposed() ) { return null; } String[] retval = new String[table.getColumnCount() - 1]; for ( int i = 0; i < retval.length; i++ ) { retval[i] = row.getText( i + 1 ); } return retval; }
public void add( String... string ) { TableItem item = new TableItem( table, SWT.NONE ); for ( int i = 0; i < string.length && i + 1 < table.getColumnCount(); i++ ) { if ( string[i] != null ) { item.setText( i + 1, string[i] ); } } }
private boolean isEmpty( int rownr, int colnr ) { boolean empty = false; TableItem item = table.getItem( rownr ); if ( item != null ) { if ( colnr >= 0 ) { String str = item.getText( colnr ); if ( str == null || str.length() == 0 ) { empty = true; } } else { empty = true; for ( int j = 1; j < table.getColumnCount(); j++ ) { String str = item.getText( j ); if ( str != null && str.length() > 0 ) { empty = false; } } } } return empty; }
private String getSelectedText() { String selection = ""; for ( int c = 1; c < table.getColumnCount(); c++ ) { TableColumn tc = table.getColumn( c ); if ( c > 1 ) { selection += CLIPBOARD_DELIMITER; } selection += tc.getText(); } selection += Const.CR; TableItem[] items = table.getSelection(); if ( items.length == 0 ) { return null; } for ( int r = 0; r < items.length; r++ ) { TableItem ti = items[r]; for ( int c = 1; c < table.getColumnCount(); c++ ) { if ( c > 1 ) { selection += CLIPBOARD_DELIMITER; } selection += ti.getText( c ); } selection += Const.CR; } return selection; }
@Override public void handleEvent(Event event) { Rectangle clientArea = table.getClientArea(); Point pt = new Point(event.x, event.y); int index = table.getTopIndex(); int count = table.getItemCount(); while (index < count) { boolean visible = false; TableItem item = table.getItem(index); for (int i = 0; i < table.getColumnCount(); i++) { Rectangle rect = item.getBounds(i); if (rect.contains(pt)) { beforeEdit(); clickRow(item, i); return; } if (!visible && rect.intersects(clientArea)) { visible = true; } } if (!visible) return; index++; } } protected void beforeEdit() {
boolean visible = false; final TableItem item = table.getItem( index ); for ( int i = 0; i < table.getColumnCount(); i++ ) { Rectangle rect = item.getBounds( i ); if ( rect.contains( pt ) ) { if ( i == table.getColumnCount() - 1 && // last column
int maxcols = table.getColumnCount(); int maxrows = table.getItemCount();
for ( int j = 0; j < table.getColumnCount(); j++ ) { ColumnInfo colInfo; if ( j > 0 ) { Object[] r = new Object[table.getColumnCount() + 2]; for ( int j = 0; j < table.getColumnCount(); j++ ) { String data = item.getText( j ); if ( GUIResource.getInstance().getColorBlue().equals( item.getForeground( j ) ) ) {
public void optWidth( boolean header, int nrLines ) { for ( int c = 0; c < table.getColumnCount(); c++ ) { TableColumn tc = table.getColumn( c ); int max = 0;
for ( int t = 0; t < wFields.table.getColumnCount(); t++ ) { wFields.table.getColumn( t ).setWidth( 20 );
new String[][]{ beforeEdit }, new String[][]{ afterEdit }, new int[]{ activeTableRow } ); int maxcols = table.getColumnCount(); int maxrows = table.getItemCount();
int maxcols = table.getColumnCount(); int maxrows = table.getItemCount();
final void removeData( int index ) { if( data != null && data.length > index && parent.getColumnCount() > 1 ) { Data[] newData = new Data[ data.length - 1 ]; System.arraycopy( data, 0, newData, 0, index ); int offSet = data.length - index - 1; System.arraycopy( data, index + 1, newData, index, offSet ); data = newData; } }
private void removeTableColumns() { while (table.getColumnCount() > 0) { table.getColumns()[0].dispose(); } } /**
public void layout () { if (table == null || table.isDisposed()) return; if (item == null || item.isDisposed()) return; int columnCount = table.getColumnCount(); if (columnCount == 0 && column != 0) return; if (columnCount > 0 && (column < 0 || column >= columnCount)) return; super.layout(); } }
@Override public void layout () { if (table == null || table.isDisposed()) return; if (item == null || item.isDisposed()) return; int columnCount = table.getColumnCount(); if (columnCount == 0 && column != 0) return; if (columnCount > 0 && (column < 0 || column >= columnCount)) return; super.layout(); } }
void setRowColumn(int row, int column, boolean notify) { TableItem item = row == -1 ? null : table.getItem(row); TableColumn col = column == -1 || table.getColumnCount() == 0 ? null : table.getColumn(column); setRowColumn(item, col, notify); } void setRowColumn(TableItem row, TableColumn column, boolean notify) {
protected Item getItemAt(Point p) { TableItem[] selection = table.getSelection(); if( selection.length == 1 ) { int columnCount = table.getColumnCount(); for( int i = 0; i < columnCount; i++ ) { if( selection[0].getBounds(i).contains(p) ) { return selection[0]; } } } return table.getItem(p); }
private int getLeft( int index ) { int result = 0; int columnCount = parent.getColumnCount(); if( index == 0 && columnCount == 0 ) { result = getCheckWidth( index ) - parent.leftOffset; } else if( index >= 0 && index < columnCount ) { // TODO [rh] consider applying the leftOffset already in Column#getLeft() int columnLeft = parent.getColumn( index ).getLeft(); result = getCheckWidth( index ) + columnLeft - parent.getColumnLeftOffset( index ); } return result; }
public void handleCallRenderToolTipText( Table table, JsonObject properties ) { ICellToolTipAdapter adapter = CellToolTipUtil.getAdapter( table ); ICellToolTipProvider provider = adapter.getCellToolTipProvider(); if( provider != null ) { TableItem item = getItem( table, properties.get( "item" ).asString() ); int columnIndex = properties.get( "column" ).asInt(); if( item != null && ( columnIndex == 0 || columnIndex < table.getColumnCount() ) ) { provider.getToolTipText( item, columnIndex ); } } }