Populate huge data dynamically in SWT widget table
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I want to populate huge data in SWT Table. After searching the internet, I found the below code. But this code populates the hardcode data.
public static void main( String args ) {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new FillLayout() );
final Table table = new Table( shell, SWT.VIRTUAL );
table.setItemCount( 10000 );
table.addListener( SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
item.setText("Item" + table.indexOf( item ) ); // should be replaced
// by below for loop
}
} );
shell.setSize( 300, 500 );
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() ) {
display.sleep();
}
}
display.dispose();
}
I want to populate something like below inside the table.addListener handle event. Please help me in this. Thanks in advance!
for (int i = 0; i < informationList.size(); i++) {
TableItem item = new TableItem(informationTable, SWT.CENTER);
item.setText(1, informationList.get(i).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+informationList.get(i).getId());
}
java swt eclipse-rcp
|
show 2 more comments
I want to populate huge data in SWT Table. After searching the internet, I found the below code. But this code populates the hardcode data.
public static void main( String args ) {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new FillLayout() );
final Table table = new Table( shell, SWT.VIRTUAL );
table.setItemCount( 10000 );
table.addListener( SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
item.setText("Item" + table.indexOf( item ) ); // should be replaced
// by below for loop
}
} );
shell.setSize( 300, 500 );
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() ) {
display.sleep();
}
}
display.dispose();
}
I want to populate something like below inside the table.addListener handle event. Please help me in this. Thanks in advance!
for (int i = 0; i < informationList.size(); i++) {
TableItem item = new TableItem(informationTable, SWT.CENTER);
item.setText(1, informationList.get(i).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+informationList.get(i).getId());
}
java swt eclipse-rcp
Use a Virtual Table
– greg-449
Jan 3 at 8:19
Trying on a Virtual Table will be really useful.
– Nipuna Priyamal
Jan 3 at 8:40
I think he already tried virtual table, as you see he use SWT.VIRTUAL.
– Milen Grigorov
Jan 3 at 9:08
What is the question? You are not sure how to populate the data or the data populates too slow?
– Milen Grigorov
Jan 3 at 9:10
@MilenGrigorov Just specifying SWT.VIRTUAL is not enough to make it a proper virtual table, you have to listen for the SWT.SetData event as well as described in the link.
– greg-449
Jan 3 at 9:56
|
show 2 more comments
I want to populate huge data in SWT Table. After searching the internet, I found the below code. But this code populates the hardcode data.
public static void main( String args ) {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new FillLayout() );
final Table table = new Table( shell, SWT.VIRTUAL );
table.setItemCount( 10000 );
table.addListener( SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
item.setText("Item" + table.indexOf( item ) ); // should be replaced
// by below for loop
}
} );
shell.setSize( 300, 500 );
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() ) {
display.sleep();
}
}
display.dispose();
}
I want to populate something like below inside the table.addListener handle event. Please help me in this. Thanks in advance!
for (int i = 0; i < informationList.size(); i++) {
TableItem item = new TableItem(informationTable, SWT.CENTER);
item.setText(1, informationList.get(i).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+informationList.get(i).getId());
}
java swt eclipse-rcp
I want to populate huge data in SWT Table. After searching the internet, I found the below code. But this code populates the hardcode data.
public static void main( String args ) {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new FillLayout() );
final Table table = new Table( shell, SWT.VIRTUAL );
table.setItemCount( 10000 );
table.addListener( SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
item.setText("Item" + table.indexOf( item ) ); // should be replaced
// by below for loop
}
} );
shell.setSize( 300, 500 );
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() ) {
display.sleep();
}
}
display.dispose();
}
I want to populate something like below inside the table.addListener handle event. Please help me in this. Thanks in advance!
for (int i = 0; i < informationList.size(); i++) {
TableItem item = new TableItem(informationTable, SWT.CENTER);
item.setText(1, informationList.get(i).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+informationList.get(i).getId());
}
java swt eclipse-rcp
java swt eclipse-rcp
asked Jan 3 at 8:12
KuttyKutty
3871217
3871217
Use a Virtual Table
– greg-449
Jan 3 at 8:19
Trying on a Virtual Table will be really useful.
– Nipuna Priyamal
Jan 3 at 8:40
I think he already tried virtual table, as you see he use SWT.VIRTUAL.
– Milen Grigorov
Jan 3 at 9:08
What is the question? You are not sure how to populate the data or the data populates too slow?
– Milen Grigorov
Jan 3 at 9:10
@MilenGrigorov Just specifying SWT.VIRTUAL is not enough to make it a proper virtual table, you have to listen for the SWT.SetData event as well as described in the link.
– greg-449
Jan 3 at 9:56
|
show 2 more comments
Use a Virtual Table
– greg-449
Jan 3 at 8:19
Trying on a Virtual Table will be really useful.
– Nipuna Priyamal
Jan 3 at 8:40
I think he already tried virtual table, as you see he use SWT.VIRTUAL.
– Milen Grigorov
Jan 3 at 9:08
What is the question? You are not sure how to populate the data or the data populates too slow?
– Milen Grigorov
Jan 3 at 9:10
@MilenGrigorov Just specifying SWT.VIRTUAL is not enough to make it a proper virtual table, you have to listen for the SWT.SetData event as well as described in the link.
– greg-449
Jan 3 at 9:56
Use a Virtual Table
– greg-449
Jan 3 at 8:19
Use a Virtual Table
– greg-449
Jan 3 at 8:19
Trying on a Virtual Table will be really useful.
– Nipuna Priyamal
Jan 3 at 8:40
Trying on a Virtual Table will be really useful.
– Nipuna Priyamal
Jan 3 at 8:40
I think he already tried virtual table, as you see he use SWT.VIRTUAL.
– Milen Grigorov
Jan 3 at 9:08
I think he already tried virtual table, as you see he use SWT.VIRTUAL.
– Milen Grigorov
Jan 3 at 9:08
What is the question? You are not sure how to populate the data or the data populates too slow?
– Milen Grigorov
Jan 3 at 9:10
What is the question? You are not sure how to populate the data or the data populates too slow?
– Milen Grigorov
Jan 3 at 9:10
@MilenGrigorov Just specifying SWT.VIRTUAL is not enough to make it a proper virtual table, you have to listen for the SWT.SetData event as well as described in the link.
– greg-449
Jan 3 at 9:56
@MilenGrigorov Just specifying SWT.VIRTUAL is not enough to make it a proper virtual table, you have to listen for the SWT.SetData event as well as described in the link.
– greg-449
Jan 3 at 9:56
|
show 2 more comments
2 Answers
2
active
oldest
votes
A virtual table asks via the listener for the contents of the currently visible rows. That's what the virtual table is all about: "Don't call us, we'll call you!"
table.addListener(SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
int index = table.indexOf(item);
item.setText(1, informationList.get(index).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, "" + informationList.get(index).getId());
}
});
See also Javadoc of the Table
widget which also contains an example (highlighting by me):
Style
VIRTUAL
is used to create a Table whose TableItems are to be
populated by the client on an on-demand basis instead of up-front.
This can provide significant performance improvements for tables that
are very large or for which TableItem population is expensive (for
example, retrieving values from an external source).
Here is an example of using a Table with style
VIRTUAL
:
...
add a comment |
I achieved it by implementing it like
final String names = new String [informationList.size()];
final int ids = new int [informationList.size()];
table.setItemCount(informationList);
for (int i = 0; i < informationList.size(); i++) {
names [i] = informationList.get(i).getName();
}
for (int i = 0; i < informationList.size(); i++) {
ids [i] = informationList.get(i).getId();
}
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem)event.item;
int index = event.index;
item.setText(1, names [index]);
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+ids [index]);
}
});
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54018518%2fpopulate-huge-data-dynamically-in-swt-widget-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
A virtual table asks via the listener for the contents of the currently visible rows. That's what the virtual table is all about: "Don't call us, we'll call you!"
table.addListener(SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
int index = table.indexOf(item);
item.setText(1, informationList.get(index).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, "" + informationList.get(index).getId());
}
});
See also Javadoc of the Table
widget which also contains an example (highlighting by me):
Style
VIRTUAL
is used to create a Table whose TableItems are to be
populated by the client on an on-demand basis instead of up-front.
This can provide significant performance improvements for tables that
are very large or for which TableItem population is expensive (for
example, retrieving values from an external source).
Here is an example of using a Table with style
VIRTUAL
:
...
add a comment |
A virtual table asks via the listener for the contents of the currently visible rows. That's what the virtual table is all about: "Don't call us, we'll call you!"
table.addListener(SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
int index = table.indexOf(item);
item.setText(1, informationList.get(index).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, "" + informationList.get(index).getId());
}
});
See also Javadoc of the Table
widget which also contains an example (highlighting by me):
Style
VIRTUAL
is used to create a Table whose TableItems are to be
populated by the client on an on-demand basis instead of up-front.
This can provide significant performance improvements for tables that
are very large or for which TableItem population is expensive (for
example, retrieving values from an external source).
Here is an example of using a Table with style
VIRTUAL
:
...
add a comment |
A virtual table asks via the listener for the contents of the currently visible rows. That's what the virtual table is all about: "Don't call us, we'll call you!"
table.addListener(SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
int index = table.indexOf(item);
item.setText(1, informationList.get(index).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, "" + informationList.get(index).getId());
}
});
See also Javadoc of the Table
widget which also contains an example (highlighting by me):
Style
VIRTUAL
is used to create a Table whose TableItems are to be
populated by the client on an on-demand basis instead of up-front.
This can provide significant performance improvements for tables that
are very large or for which TableItem population is expensive (for
example, retrieving values from an external source).
Here is an example of using a Table with style
VIRTUAL
:
...
A virtual table asks via the listener for the contents of the currently visible rows. That's what the virtual table is all about: "Don't call us, we'll call you!"
table.addListener(SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
int index = table.indexOf(item);
item.setText(1, informationList.get(index).getName());
item.setText(2, "");
item.setText(3, "");
item.setText(4, "" + informationList.get(index).getId());
}
});
See also Javadoc of the Table
widget which also contains an example (highlighting by me):
Style
VIRTUAL
is used to create a Table whose TableItems are to be
populated by the client on an on-demand basis instead of up-front.
This can provide significant performance improvements for tables that
are very large or for which TableItem population is expensive (for
example, retrieving values from an external source).
Here is an example of using a Table with style
VIRTUAL
:
...
edited Jan 3 at 9:57
answered Jan 3 at 9:41
howlgerhowlger
12.2k52043
12.2k52043
add a comment |
add a comment |
I achieved it by implementing it like
final String names = new String [informationList.size()];
final int ids = new int [informationList.size()];
table.setItemCount(informationList);
for (int i = 0; i < informationList.size(); i++) {
names [i] = informationList.get(i).getName();
}
for (int i = 0; i < informationList.size(); i++) {
ids [i] = informationList.get(i).getId();
}
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem)event.item;
int index = event.index;
item.setText(1, names [index]);
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+ids [index]);
}
});
add a comment |
I achieved it by implementing it like
final String names = new String [informationList.size()];
final int ids = new int [informationList.size()];
table.setItemCount(informationList);
for (int i = 0; i < informationList.size(); i++) {
names [i] = informationList.get(i).getName();
}
for (int i = 0; i < informationList.size(); i++) {
ids [i] = informationList.get(i).getId();
}
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem)event.item;
int index = event.index;
item.setText(1, names [index]);
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+ids [index]);
}
});
add a comment |
I achieved it by implementing it like
final String names = new String [informationList.size()];
final int ids = new int [informationList.size()];
table.setItemCount(informationList);
for (int i = 0; i < informationList.size(); i++) {
names [i] = informationList.get(i).getName();
}
for (int i = 0; i < informationList.size(); i++) {
ids [i] = informationList.get(i).getId();
}
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem)event.item;
int index = event.index;
item.setText(1, names [index]);
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+ids [index]);
}
});
I achieved it by implementing it like
final String names = new String [informationList.size()];
final int ids = new int [informationList.size()];
table.setItemCount(informationList);
for (int i = 0; i < informationList.size(); i++) {
names [i] = informationList.get(i).getName();
}
for (int i = 0; i < informationList.size(); i++) {
ids [i] = informationList.get(i).getId();
}
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem)event.item;
int index = event.index;
item.setText(1, names [index]);
item.setText(2, "");
item.setText(3, "");
item.setText(4, ""+ids [index]);
}
});
answered Jan 4 at 4:40
KuttyKutty
3871217
3871217
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54018518%2fpopulate-huge-data-dynamically-in-swt-widget-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use a Virtual Table
– greg-449
Jan 3 at 8:19
Trying on a Virtual Table will be really useful.
– Nipuna Priyamal
Jan 3 at 8:40
I think he already tried virtual table, as you see he use SWT.VIRTUAL.
– Milen Grigorov
Jan 3 at 9:08
What is the question? You are not sure how to populate the data or the data populates too slow?
– Milen Grigorov
Jan 3 at 9:10
@MilenGrigorov Just specifying SWT.VIRTUAL is not enough to make it a proper virtual table, you have to listen for the SWT.SetData event as well as described in the link.
– greg-449
Jan 3 at 9:56