Home » Eclipse Projects » Remote Application Platform (RAP) » TableViewer and vertical scrolling
| |
Re: TableViewer and vertical scrolling [message #133332 is a reply to message #133324] |
Tue, 19 May 2009 08:20 |
No real name Messages: 38 Registered: July 2009 |
Member |
|
|
The table viewer isn't in a ScrolledComposite.
Here is a code snippet of my table viewer.
public static final String[] PROCESS_STATUS_ITEMS = {"jbpmInstanceId",
"tokenId","processInstanceId","parentTokenId",
"superProcessTokenId","subProcessTokenId","status","processName ",
"patchVersion","phase","phaseTimestamp","state","stateTimestamp ",
"additionalData","replacementProcessInstanceId","techId", "customerId",
"ccdId","contractId","timerInfo","lastEventTimestamp", "lastEventType",
"failedJobInfo"
};
|
|
|
Re: TableViewer and vertical scrolling [message #133345 is a reply to message #133332] |
Tue, 19 May 2009 08:26 |
No real name Messages: 38 Registered: July 2009 |
Member |
|
|
Sorry, the post was not ready.
So, here is the complete code snippet.
public static final String[] PROCESS_STATUS_ITEMS =
{"jbpmInstanceId","tokenId","processInstanceId","parentTokenId ",
"superProcessTokenId","subProcessTokenId","status","processName ",
"patchVersion","phase","phaseTimestamp","state","stateTimestamp ",
"additionalData","replacementProcessInstanceId","techId", "customerId",
"ccdId","contractId","timerInfo","lastEventTimestamp", "lastEventType",
"failedJobInfo"};
private class ViewLabelProvider
extends LabelProvider
implements ITableLabelProvider
{
public Image getColumnImage( Object element, int columnIndex ) {
return null;
}
public String getColumnText( Object element, int columnIndex ) {
String[] row = ( String[] )element;
String result = row[ columnIndex ];
return result;
}
}
private class ViewContentProvider implements IStructuredContentProvider {
public Object[] getElements( Object inputElement ) {
int s = 10;
Object[] rows = new Object[s];
for (int i = 0; i < s; i++) {
String[] row = new String[ PROCESS_STATUS_ITEMS.length ];
for( int j = 0; j < PROCESS_STATUS_ITEMS.length; j++ ) {
row[j] = "test" + i;
}
rows[i] = row ;
}
return rows;
}
public void dispose() {
}
public void inputChanged( Viewer viewer, Object oldInput,
Object newInput ) {
}
}
private String[] initColumnProperties( final Table table ) {
String[] result = new String[ PROCESS_STATUS_ITEMS.length ];
for( int i = 0; i < PROCESS_STATUS_ITEMS.length; i++ ) {
tableColumn = new TableColumn( table, SWT.CENTER);
result[ i ] = PROCESS_STATUS_ITEMS[i] ;
tableColumn.setText( result[ i ] );
tableColumn.setWidth(170);
}
return result;
}
public void createPartControl(Composite parent) {
tableViewer = new TableViewer( parent, SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL);
tableViewer.setContentProvider( new ViewContentProvider() );
tableViewer.setLabelProvider( new ViewLabelProvider() );
final Table table = tableViewer.getTable();
tableViewer.setColumnProperties( initColumnProperties( table ) );
tableViewer.setInput(this);
tableViewer.getTable().setHeaderVisible( true );
tableViewer.getTable().setLinesVisible(true);
}
kristin
|
|
|
Re: TableViewer and vertical scrolling [message #133358 is a reply to message #133345] |
Tue, 19 May 2009 09:05 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Kristin,
your snippet is running fine. What I do not understand where is the
vertical scrollbar? How to make the header to cut off? Any steps to
reproduce it?
Best,
Ivan
Kristin Polenz wrote:
> Sorry, the post was not ready.
> So, here is the complete code snippet.
>
> public static final String[] PROCESS_STATUS_ITEMS =
> {"jbpmInstanceId","tokenId","processInstanceId","parentTokenId ",
> "superProcessTokenId","subProcessTokenId","status","processName ",
> "patchVersion","phase","phaseTimestamp","state","stateTimestamp ",
> "additionalData","replacementProcessInstanceId","techId", "customerId",
> "ccdId","contractId","timerInfo","lastEventTimestamp", "lastEventType",
> "failedJobInfo"};
>
> private class ViewLabelProvider extends LabelProvider
> implements ITableLabelProvider
> {
> public Image getColumnImage( Object element, int columnIndex ) {
> return null;
> }
> public String getColumnText( Object element, int columnIndex ) {
> String[] row = ( String[] )element;
> String result = row[ columnIndex ];
> return result;
> }
> }
>
> private class ViewContentProvider implements IStructuredContentProvider {
> public Object[] getElements( Object inputElement ) {
> int s = 10;
> Object[] rows = new Object[s];
> for (int i = 0; i < s; i++) {
> String[] row = new String[ PROCESS_STATUS_ITEMS.length ];
> for( int j = 0; j < PROCESS_STATUS_ITEMS.length; j++ ) {
> row[j] = "test" + i;
> }
> rows[i] = row ;
>
> }
> return rows;
> }
> public void dispose() {
> }
> public void inputChanged( Viewer viewer, Object oldInput,
> Object newInput ) {
> }
> }
>
> private String[] initColumnProperties( final Table table ) {
> String[] result = new String[ PROCESS_STATUS_ITEMS.length ];
> for( int i = 0; i < PROCESS_STATUS_ITEMS.length; i++ ) {
> tableColumn = new TableColumn( table, SWT.CENTER);
> result[ i ] = PROCESS_STATUS_ITEMS[i] ;
> tableColumn.setText( result[ i ] );
> tableColumn.setWidth(170);
> }
> return result;
> }
>
> public void createPartControl(Composite parent) {
> tableViewer = new TableViewer( parent, SWT.MULTI |
> SWT.V_SCROLL | SWT.H_SCROLL);
> tableViewer.setContentProvider( new ViewContentProvider() );
> tableViewer.setLabelProvider( new ViewLabelProvider() );
> final Table table = tableViewer.getTable();
> tableViewer.setColumnProperties( initColumnProperties( table ) );
> tableViewer.setInput(this);
> tableViewer.getTable().setHeaderVisible( true );
> tableViewer.getTable().setLinesVisible(true);
> }
>
>
> kristin
>
|
|
| | | | | | | | |
Goto Forum:
Current Time: Mon Sep 23 17:43:34 GMT 2024
Powered by FUDForum. Page generated in 0.03393 seconds
|