Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » TableViewer refresh does not work
TableViewer refresh does not work [message #460848] Sat, 30 December 2006 18:38
Eclipse UserFriend
Originally posted by: m.jeske.web.de

Hi,

as a newbie I have a question regarding the update mechanism of a
tableviewer. Please find below my question the relevant part of my code
(ugly code at this point of time...).
I have navigation view with a tree showing many product categories.
Clicking on one product should cause that the table on an other view
adds the selected product to its content. Debugging my code proves, that
the model for the tableviewer receives the new product but the table
itself does not show it. I tried to call the refresh method but this has
no effect. How would I be able to perform an update on the view?

thanx for any hints, Mirco

--- code snippet ----

public class View extends ViewPart {

public static final String ID = "PartyserviceInvoiceManager.view";

private ProductTableElement[] data = new ProductTableElement[] {};

private ISelectionListener listener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart sourcepart, ISelection
selection) {
// we ignore our own selections
if (sourcepart != View.this) {
showSelection(sourcepart, selection);
}
}
};

[...]

public void createPartControl(Composite parent) {

parent.setLayout(new FillLayout());
top = new Composite(parent, SWT.NONE);
top.setLayout(new FillLayout());
createScrolledForm();

getSite().getWorkbenchWindow().getSelectionService().addSele ctionListener(listener);

selectedProducts = new ArrayList<Product>();
}

[...]

public void showSelection(IWorkbenchPart sourcepart, ISelection selection) {
setContentDescription(sourcepart.getTitle() + " (" +
selection.getClass().getName() + ")");
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
registerProduct(ss.toArray()[0]);
}
}

private void registerProduct(Object object) {
if(object != null && object instanceof TreeObject) {
TreeObject to = (TreeObject) object;
if( to.getProduct() instanceof Product) {
selectedProducts.add(to.getProduct());
System.out.println(selectedProducts.size());
tableViewer.setContentProvider(new ProductsContentProvider());
tableViewer.setInput(selectedProducts.toArray());
tableViewer.refresh();
}
}
}

private void createScrolledForm() {
scrolledForm = getFormToolkit().createScrolledForm(top);
table = getFormToolkit().createTable(scrolledForm.getBody(), SWT.NONE);

[...]

tableViewer = new TableViewer(table);
tableViewer.setContentProvider(new ProductsContentProvider());
tableViewer.setLabelProvider(new ViewLabelProvider());
tableViewer.setInput(data);
}
Previous Topic:Problem restoring the treeViewer state.
Next Topic:ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
Goto Forum:
  


Current Time: Fri Apr 19 23:16:35 GMT 2024

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

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

Back to the top