Refreshing org.eclipse.ui.part.ViewPart [message #449459] |
Mon, 24 January 2005 20:51 |
Eclipse User |
|
|
|
Originally posted by: rafaelcunha.veloxmail.com.br
Hi,
I am trying to create a Eclipse View to show the contents of an array
(list, collection). The trouble is: the view is not being refreshed,
however if I maximize and minimize the view the view is refreshed
magically. The source code is:
public class DateCompareView extends ViewPart {
private ResourceListBean resourceListBean;
private Composite viewParent;
private ViewContentProvider viewContentProvider;
private ViewLabelProvider viewLabelProvider;
public TableViewer viewer;
private Table table;
private TableLayout layout;
public DateCompareView() {
super();
}
public void setFocus() {
}
public void createPartControl(Composite parent)
{
System.out.println("Enter TabularResultView:createPartControl()");
// Save a copy of the parent of this view
viewParent = parent;
// Determine if data is already set to be loaded into a view
if(resourceListBean != null && resourceListBean.size() != 0)
{
// Create the table
createTable();
// Create the viewer
viewer = new TableViewer(table);
}
else
{
// Create blank data and an empty table
//tabularDataManager = new TabularDataManager();
table = new Table(viewParent,
SWT.H_SCROLL | SWT.V_SCROLL |
SWT.MULTI | SWT.FULL_SELECTION);
// Create the viewer
viewer = new TableViewer(table);
}
viewContentProvider = new ViewContentProvider();
viewLabelProvider = new ViewLabelProvider();
viewer.setContentProvider(viewContentProvider);
viewer.setLabelProvider(viewLabelProvider);
viewer.setInput(resourceListBean);
viewer.refresh();
System.out.println("Leave TabularResultView:createPartControl()");
}
private void createTable()
{
Vector columnHeadings = new Vector();
columnHeadings.add("teste - 1");
columnHeadings.add("teste - 2");
System.out.println("columnHeadings.size() = " + columnHeadings.size());
System.out.println("class of first element" +
columnHeadings.firstElement().getClass());
table = new Table(viewParent,
SWT.H_SCROLL | SWT.V_SCROLL |
SWT.MULTI | SWT.FULL_SELECTION);
layout = new TableLayout();
table.setLayout(layout);
table.setLinesVisible(true);
table.setHeaderVisible(true);
for( int i = 0; i < columnHeadings.size(); i++ )
{
String columnHeading = (String)columnHeadings.elementAt(i);
layout.addColumnData(new ColumnWeightData(50,100,true));
TableColumn newColumn = new TableColumn(table, SWT.NONE);
newColumn.setText(columnHeading);
newColumn.setResizable(true);
}
}
public void recreateWithData(ResourceListBean _resourceListBean, String
tabName)
{
// Update the underlying data model
resourceListBean = _resourceListBean;
// Create a table using the new underlying data model
createTable();
viewer.getTable().dispose();
// Assign the viewer an new TableViewer that uses the new table.
// Keep the old content and label providers but update the view's
// input.
viewer = new TableViewer(table);
viewer.setContentProvider(viewContentProvider);
viewer.setLabelProvider(viewLabelProvider);
viewer.setInput(resourceListBean);
viewer.refresh();
}
}
Waiting for help....thanks
|
|
|
Re: Refreshing org.eclipse.ui.part.ViewPart [message #449560 is a reply to message #449459] |
Wed, 26 January 2005 14:33 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Rafael,
You may get more response if you ask on the eclipse.platform newsgroup,
since your snippet is using a lot of jface.
Grant
"Rafael MC" <rafaelcunha@veloxmail.com.br> wrote in message
news:ct3n58$219$1@www.eclipse.org...
> Hi,
>
> I am trying to create a Eclipse View to show the contents of an array
> (list, collection). The trouble is: the view is not being refreshed,
> however if I maximize and minimize the view the view is refreshed
> magically. The source code is:
>
> public class DateCompareView extends ViewPart {
>
> private ResourceListBean resourceListBean;
>
> private Composite viewParent;
> private ViewContentProvider viewContentProvider;
> private ViewLabelProvider viewLabelProvider;
> public TableViewer viewer;
> private Table table;
> private TableLayout layout;
>
>
> public DateCompareView() {
> super();
> }
>
> public void setFocus() {
> }
>
> public void createPartControl(Composite parent)
> {
> System.out.println("Enter TabularResultView:createPartControl()");
>
> // Save a copy of the parent of this view
> viewParent = parent;
>
> // Determine if data is already set to be loaded into a view
> if(resourceListBean != null && resourceListBean.size() != 0)
> {
> // Create the table
> createTable();
>
> // Create the viewer
> viewer = new TableViewer(table);
> }
> else
> {
> // Create blank data and an empty table
> //tabularDataManager = new TabularDataManager();
> table = new Table(viewParent,
> SWT.H_SCROLL | SWT.V_SCROLL |
> SWT.MULTI | SWT.FULL_SELECTION);
>
> // Create the viewer
> viewer = new TableViewer(table);
> }
>
> viewContentProvider = new ViewContentProvider();
> viewLabelProvider = new ViewLabelProvider();
>
> viewer.setContentProvider(viewContentProvider);
> viewer.setLabelProvider(viewLabelProvider);
> viewer.setInput(resourceListBean);
>
> viewer.refresh();
>
> System.out.println("Leave TabularResultView:createPartControl()");
> }
>
>
> private void createTable()
> {
> Vector columnHeadings = new Vector();
> columnHeadings.add("teste - 1");
> columnHeadings.add("teste - 2");
> System.out.println("columnHeadings.size() = " + columnHeadings.size());
> System.out.println("class of first element" +
> columnHeadings.firstElement().getClass());
>
> table = new Table(viewParent,
> SWT.H_SCROLL | SWT.V_SCROLL |
> SWT.MULTI | SWT.FULL_SELECTION);
>
> layout = new TableLayout();
> table.setLayout(layout);
>
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
>
> for( int i = 0; i < columnHeadings.size(); i++ )
> {
> String columnHeading = (String)columnHeadings.elementAt(i);
>
> layout.addColumnData(new ColumnWeightData(50,100,true));
> TableColumn newColumn = new TableColumn(table, SWT.NONE);
> newColumn.setText(columnHeading);
> newColumn.setResizable(true);
> }
> }
>
>
> public void recreateWithData(ResourceListBean _resourceListBean, String
> tabName)
> {
> // Update the underlying data model
> resourceListBean = _resourceListBean;
>
> // Create a table using the new underlying data model
> createTable();
> viewer.getTable().dispose();
> // Assign the viewer an new TableViewer that uses the new table.
> // Keep the old content and label providers but update the view's
> // input.
> viewer = new TableViewer(table);
> viewer.setContentProvider(viewContentProvider);
> viewer.setLabelProvider(viewLabelProvider);
> viewer.setInput(resourceListBean);
> viewer.refresh();
> }
> }
>
>
> Waiting for help....thanks
>
|
|
|
Powered by
FUDForum. Page generated in 0.03318 seconds