Home » Eclipse Projects » Remote Application Platform (RAP) » Problems using swt.virtual and a lazy content provider
Problems using swt.virtual and a lazy content provider [message #89683] |
Fri, 23 May 2008 14:09 |
Hugo Ferreira Messages: 11 Registered: July 2009 |
Junior Member |
|
|
This is a multi-part message in MIME format.
--------------010603040002060106010300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi all,
I'm trying to use SWT.VIRTUAL (and lazy loading) feature on a table but
i'm having some problems. I have drawn a SWT.VIRTUAL table with a lazy
content provider. The table is designed correctly and also the data
appears as it should. But when I close the view where this table is
designed I get a javascript error saying something like this:
"Could no evaluate javascript response: TypeError: w has no properties".
If I change the type of content provider (to a
IStructuredContentProvider) everything works ok and the view is closed
without any error.
I have seen some examples and snippets code but I couldn't manage to
solve the problem.
In attachment I send the view where I have a small example of the
implementation that generates the error. It is a very simple example.
Hope it helps.
Thanks in advance for any help.
Hugo Ferreira
--------------010603040002060106010300
Content-Type: text/java;
name="TableView.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="TableView.java"
package tiago.rap.workbench.views;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.ILazyContentProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.part.ViewPart;
import tiago.rap.test.Person;
public class TableView extends ViewPart {
public static final String ID = "tiago.rap.test.tableview";
private List entityList;
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
entityList = new ArrayList<Person>();
entityList.add(new Person("A", 26, "Coimbra", "Portugal", "1982-03-19"));
entityList.add(new Person("B", 24, "Figueira Foz", "Portugal", "1984-08-20"));
entityList.add(new Person("C", 29, "Porto", "Portugal", "1978-04-09"));
entityList.add(new Person("D", 24, "Cascais", "Portugal", "1983-12-19"));
entityList.add(new Person("E", 25, "Viseu", "Portugal", "1983-10-10"));
entityList.add(new Person("F", 23, "Soure", "Portugal", "1984-09-13"));
entityList.add(new Person("G", 26, "Condeixa", "Portugal", "1982-05-13"));
entityList.add(new Person("H", 25, "Montemor-o-velho", "Portugal", "1983-12-25"));
entityList.add(new Person("I", 27, "Lisboa", "Portugal", "1981-11-30"));
entityList.add(new Person("J", 28, "Cantanhede", "Portugal", "1980-02-25"));
Table table = new Table(parent, SWT.NONE | SWT.VIRTUAL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
final TableColumn nameTC = new TableColumn(table, SWT.CENTER);
nameTC.setText("Name");
nameTC.setWidth(100);
final TableColumn ageTC = new TableColumn(table, SWT.CENTER);
ageTC.setText("Age");
ageTC.setWidth(100);
final TableColumn cityTC = new TableColumn(table, SWT.CENTER);
cityTC.setText("City");
cityTC.setWidth(100);
final TableColumn countryTC = new TableColumn(table, SWT.CENTER);
countryTC.setText("Country");
countryTC.setWidth(100);
final TableColumn birthdateTC = new TableColumn(table, SWT.CENTER);
birthdateTC.setText("Birthdate");
birthdateTC.setWidth(100);
for (int i = 0; i < entityList.size(); i++) {
TableItem item = new TableItem(table, SWT.NONE);
Person p = (Person) entityList.get(i);
item.setText(0, p.getName());
item.setText(1, "" + p.getAge());
item.setText(2, p.getCity());
item.setText(3, p.getCountry());
item.setText(4, p.getBirthdate());
}
TableViewer viewer = new TableViewer(table);
if ((table.getStyle() & SWT.VIRTUAL) == SWT.VIRTUAL) {
viewer.setItemCount(entityList.size());
viewer.setContentProvider(new LazyContentProvider(entityList, viewer));
} else {
viewer.setContentProvider(getIStructuredContentProvider());
//viewer.setInput(entityList);
}
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
private IStructuredContentProvider getIStructuredContentProvider() {
return (new IStructuredContentProvider() {
public void dispose() {
}
public void inputChanged(final Viewer v, final Object oldInput, final Object newInput) {
}
public Object[] getElements(final Object inputElement) {
return entityList.toArray();
}
});
}
class LazyContentProvider implements ILazyContentProvider {
private List<Object> list;
private TableViewer viewer;
public LazyContentProvider(final List<Object> entityList, TableViewer viewer) {
this.list = entityList;
this.viewer = viewer;
}
public void inputChanged(final Viewer v, final Object oldInput, final Object newInput) {
v.setInput(newInput);
}
public void updateElement(final int index) {
viewer.replace(list.get(index), index);
}
public void dispose() {
}
}
}
--------------010603040002060106010300--
|
|
|
Re: Problems using swt.virtual and a lazy content provider [message #89761 is a reply to message #89683] |
Sun, 25 May 2008 17:49 |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Hugo,
this seems to be a bug. You could open a bugzilla to track progress
on this issue.
Cheers,
Rüdiger
Hugo Ferreira wrote:
> Hi all,
>
> I'm trying to use SWT.VIRTUAL (and lazy loading) feature on a table
> but i'm having some problems. I have drawn a SWT.VIRTUAL table with a
> lazy content provider. The table is designed correctly and also the data
> appears as it should. But when I close the view where this table is
> designed I get a javascript error saying something like this:
> "Could no evaluate javascript response: TypeError: w has no properties".
>
> If I change the type of content provider (to a
> IStructuredContentProvider) everything works ok and the view is closed
> without any error.
>
> I have seen some examples and snippets code but I couldn't manage to
> solve the problem.
>
> In attachment I send the view where I have a small example of the
> implementation that generates the error. It is a very simple example.
> Hope it helps.
>
> Thanks in advance for any help.
> Hugo Ferreira
>
|
|
| |
Re: Problems using swt.virtual and a lazy content provider [message #90162 is a reply to message #90102] |
Mon, 26 May 2008 22:47 |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Hugo,
thanks for entering the bug. Please see my comment there.
Cheers,
Rüdiger
Hugo Ferreira wrote:
> I have investigated the problem a little more and I found that when the
> view is closed the method
>
> public void inputChanged(final Viewer v, final Object oldInput, final
> Object newInput)
>
> from the lazy content provider is being called with the newInput object
> null. Since it is null it will then generate an error that results in
> the javascript error. For now I have added a small verification to see
> if the object is null. Everything works with this small verification.
>
> Nonetheless I have created a bugzilla entry with this id: 233998
>
> --
> Hugo Ferreira
>
> Rüdiger Herrmann wrote:
>> Hugo,
>>
>> this seems to be a bug. You could open a bugzilla to track progress on
>> this issue.
>>
>> Cheers,
>> Rüdiger
>>
>> Hugo Ferreira wrote:
>>> Hi all,
>>>
>>> I'm trying to use SWT.VIRTUAL (and lazy loading) feature on a
>>> table but i'm having some problems. I have drawn a SWT.VIRTUAL table
>>> with a lazy content provider. The table is designed correctly and
>>> also the data appears as it should. But when I close the view where
>>> this table is designed I get a javascript error saying something like
>>> this:
>>> "Could no evaluate javascript response: TypeError: w has no properties".
>>>
>>> If I change the type of content provider (to a
>>> IStructuredContentProvider) everything works ok and the view is
>>> closed without any error.
>>>
>>> I have seen some examples and snippets code but I couldn't manage to
>>> solve the problem.
>>>
>>> In attachment I send the view where I have a small example of the
>>> implementation that generates the error. It is a very simple example.
>>> Hope it helps.
>>>
>>> Thanks in advance for any help.
>>> Hugo Ferreira
>>>
>>
|
|
|
Goto Forum:
Current Time: Tue Apr 23 09:46:51 GMT 2024
Powered by FUDForum. Page generated in 0.03382 seconds
|