I am in bad need of some guided assistance. I have been able to work through and get to work code examples of Tables and TableViewers. But I am not finding any examples to help me with my particle setup.
Please guide me in the right direction.
My classes:
AHandler.java - This allows the user to select data from a Right Mouse Click. During the execution I am calling a singleton class to add user selected data to a arraylist.
ASelectedData.getInstance().add(tcRevision, selectedDataset);
ASelectedData.java - is singleton class where the user selections is added to a ArrayList.
ABase.java - this dialog opens with a menu click. The dialog should display a table with the values from the ArrayList. Some buttons that preform other actions.
The way I have it right now is the table and tableviewer is being created in the ABase.java class. I am pulling the information for the table from.
viewer.setContentProvider(new ArrayContentProvider());
viewer.setInput(AplotSelectedDataTable.getInstance().getArrayData());
This will populate the table with the correct data.
But the ABase.java class is MODELESS. So why that dialog is open the user can continue to pick data using the right mouse button and adding to the arraylist. But the way I have the table coded the I have to reopen the window to update the data.
* EDIT **** In my main GUI I have created a TableViewer. The TableViewer creates a table that displays data from a arraylist in a separate class. The problem is that the user is still able to go to the Main Application GUI ( not my Application GUI ) and select more data while my GUI is still open. They expect to see the new data added to the table as they select it.
The problem is there is no way that I know of to tell the table new data has arrived so refresh the table. The Add method that takes the data and adds it to the ArrayList is in the ASelectedData class. Not the class the tableviewer is created in.
When the Add Method is executed, I need a way to tell the table to refresh. The problem is the Table and the Method is in two separate classes.
Hope this makes more sense
EDIT*
my main GUI with the TableViewer
public AplotBaseDialog(Shell shell, TCSession theSession) Constructor
//////////////////////////////////////////////////////////////////////////
// createTableViewer() //
//////////////////////////////////////////////////////////////////////////
private TableViewer createTableViewer(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
createColumns(parent, viewer);
Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setInput(AplotSelectedDataTable.getInstance().getArrayData());
// Layout the viewer
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 2;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
viewer.getControl().setLayoutData(gridData);
return viewer;
}
//////////////////////////////////////////////////////////////////////////
// updateTableViewer() //
//////////////////////////////////////////////////////////////////////////
public void updateTableViewer() {
viewer.refresh();
}
The code added to other class
AplotBaseDialog abd = new AplotBaseDialog(null, null);
public void add(TCComponentItemRevision tcRevision, TCComponentDataset selectedDataset) {
AplotDatasetData pp = new AplotDatasetData(tcRevision, selectedDataset);
if (!dataArrayList.contains(pp)) {
dataArrayList.add(pp);
}
abd.updateTableViewer();
}// end add()
YOURCLASS.updateTableViewer()method from theaddmethod of the model containing the list, which will refresh your tableviewer. - Baz