Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Refreshing org.eclipse.ui.part.ViewPart
Refreshing org.eclipse.ui.part.ViewPart [message #449459] Mon, 24 January 2005 20:51 Go to next message
Eclipse UserFriend
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 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
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
>
Previous Topic:Are there any know issues with MenuManager running on RedHat Linux?
Next Topic:Canvas: How to scroll client area
Goto Forum:
  


Current Time: Fri Nov 22 15:05:14 GMT 2019

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

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

Back to the top