Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » jface table viewer (columns and content)
jface table viewer (columns and content) [message #438690] Wed, 30 June 2004 11:03 Go to next message
Andreas Broeker is currently offline Andreas BroekerFriend
Messages: 22
Registered: July 2009
Junior Member
Hello,

i try to use a jface table viewer to show a table. What is the right way
to add the columns and the content.

Thanks for any help in advance.

Regards

Andreas
Re: jface table viewer (columns and content) [message #438921 is a reply to message #438690] Sat, 03 July 2004 22:05 Go to previous messageGo to next message
Davide is currently offline DavideFriend
Messages: 28
Registered: July 2009
Junior Member
Columns must be added to the undelying table instance; contents
is provided using ContentProvider and LabelProviders

Have a look to:
http://www.eclipse.org/articles/Article-Table-viewer/table_v iewer.html

this is targetted to content editing, but content providing is
covered as weel.

Sani
d.

Andreas Bröker wrote:

> Hello,

> i try to use a jface table viewer to show a table. What is the right way
> to add the columns and the content.

> Thanks for any help in advance.

> Regards

> Andreas
Re: jface table viewer (columns and content) [message #439113 is a reply to message #438921] Tue, 06 July 2004 05:09 Go to previous message
Eclipse UserFriend
Originally posted by: john.rmts.donpac.ru

> Columns must be added to the undelying table instance; contents
> is provided using ContentProvider and LabelProviders

IMHO, it's jface design lack.

I wrote simple classes corecting this:

public class ExtendedTableViewer extends TableViewer {
private ITableColumnProvider provider;
public ExtendedTableViewer(Composite arg0) {
super(arg0);
}
public ExtendedTableViewer(Composite arg0, int arg1) {
super(arg0, arg1);
}
public ExtendedTableViewer(Table arg0) {
super(arg0);
}
public void setColumnProvider(ITableColumnProvider provider) {
this.provider = provider;
}
protected void internalRefresh(Object element) {
if (provider != null)
columnsFill();
super.internalRefresh(element);
pack();
}
protected void inputChanged(Object newInput, Object oldInput) {
if (newInput != null && provider != null)
provider.inputChanged(this, oldInput, newInput);
super.inputChanged(newInput, oldInput);
pack();
}
protected void columnsFill(){
String columns[] = provider.getColumns();
if (columns != null) {
int count = getTable().getColumnCount();
for (int i=0;i<count;i++)
getTable().getColumn(0).dispose();
for (int i=0;i<columns.length;i++) {
final TableColumn tableColumn = new TableColumn(getTable(), SWT.NONE);
tableColumn.setText(columns[i]);
}
setColumnProperties(columns);
}
}
public void pack() {
for (int i=0;i<getTable().getColumnCount();i++)
getTable().getColumn(i).pack();
}
}

public interface ITableColumnProvider {
public String[] getColumns() ;
public void inputChanged(Viewer viewer, Object oldInput, Object newInput);
}
Previous Topic:swt 3.0 gtk bug: table header disappearing
Next Topic:create and post an event
Goto Forum:
  


Current Time: Fri Apr 19 21:08:21 GMT 2024

Powered by FUDForum. Page generated in 0.02767 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top