Home » Eclipse Projects » JFace » Bind TableViewer to Multiple Objects?
Bind TableViewer to Multiple Objects? [message #22351] |
Tue, 21 July 2009 14:00 |
Stephen Panosian Messages: 7 Registered: July 2009 |
Junior Member |
|
|
First off a little background of what I'm trying to do. I have an RCP that
is modeling a spacecraft trajectory. The trajectory is broken into
sections (Class TrajSection) and each section has its own planet (Class
Planet) and much other stuff. For many sections the Planet will be
"Earth". I have a view that opens to show the details about the planet
which includes tables. I have been able to bind the tables to the planet
using the methods in snippet 13
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.e xamples.databinding/src/org/eclipse/jface/examples/databindi ng/snippets/Snippet013TableViewerEditing.java?view=markup
My problem arises because I only want one view to be open at a time for
each planet name, (AKA only one for Earth, Mars etc), but if "Earth" is
open I want that View to be bound to all planets with name "Earth". I have
been able to loop through all the sections and bind the planets components
for items using Text widgets but when I try to bind the tables to multiple
planets I get null pointer exceptions or this
assertion failed: Getter called on disposed observable
org.eclipse.core.internal.databinding.beans.BeanObservableMa pDecorator @58aa17c3
Here is a little code to show what I have. (I'm using SWT forms as well)
grav_cTable = toolkit.createTable(planetClient, SWT.BORDER);
grav_cTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
6));
grav_cNames = new String[] {"one", "two", "three"};
grav_cViewer = new TableViewer(grav_cTable);
...
...
for(int i = 0; i < sectionList.size(); i++) {
if
(planet.getName().equals(sectionList.get(i).getPlanet().getN ame())) {
if (grav_cTable.getColumnCount() < 1) {
for (int j = 0; j < 3; j++) {
grav_cColumn = new TableViewerColumn(grav_cViewer,
SWT.NONE);
grav_cColumn.setEditingSupport(new
InlineEditingSupport(grav_cViewer, bindingContext, grav_cNames[j]));
grav_cColumn.getColumn().setWidth(100);
}
ViewerSupport.bind(grav_cViewer, new
WritableList(TrajectoryGUI.getDefault().getActiveTrajectory( ).planetList.get(i).getGrav_c(),
Grav_C.class),BeanProperties.values(Grav_C.class, grav_cNames));
}
else {
ViewerSupport.bind(grav_cViewer, new
WritableList(TrajectoryGUI.getDefault().getActiveTrajectory( ).planetList.get(i).getGrav_c(),
Grav_C.class),BeanProperties.values(Grav_C.class, grav_cNames));
}
}
I would like to keep the same structure of Section having an instance of
Planet because I use a TreeView to show the breakdown of the trajectory
structure, Unless there is another way of doing that. I'm not sure if this
is possible or if this is the best way of doing this. If you couldn't tell
I'm Aerospace not Computer Science so if you have any ideas I open for
advice. Thanks in advance for any help and let me know if you need more
code or explanation.
Stephen
|
|
|
Re: Bind TableViewer to Multiple Objects? [message #23030 is a reply to message #22351] |
Wed, 22 July 2009 19:49 |
Will Horn Messages: 265 Registered: July 2009 |
Senior Member |
|
|
If two sections have an "Earth" planet reference, are they both pointing to
the same planet instance? If so, you only need to bind once. If not, i.e.
if the two "Earth" planets can have different properties, then I don't see
why you would want to bind them to the same viewer.
"Stephen Panosian" <stephen.panosian@gmail.com> wrote in message
news:2c5400ecc886fa3d23e000c5d86317aa$1@www.eclipse.org...
> First off a little background of what I'm trying to do. I have an RCP that
> is modeling a spacecraft trajectory. The trajectory is broken into
> sections (Class TrajSection) and each section has its own planet (Class
> Planet) and much other stuff. For many sections the Planet will be
> "Earth". I have a view that opens to show the details about the planet
> which includes tables. I have been able to bind the tables to the planet
> using the methods in snippet 13
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.e xamples.databinding/src/org/eclipse/jface/examples/databindi ng/snippets/Snippet013TableViewerEditing.java?view=markup
>
> My problem arises because I only want one view to be open at a time for
> each planet name, (AKA only one for Earth, Mars etc), but if "Earth" is
> open I want that View to be bound to all planets with name "Earth". I have
> been able to loop through all the sections and bind the planets components
> for items using Text widgets but when I try to bind the tables to multiple
> planets I get null pointer exceptions or this
> assertion failed: Getter called on disposed observable
> org.eclipse.core.internal.databinding.beans.BeanObservableMa pDecorator @58aa17c3
>
> Here is a little code to show what I have. (I'm using SWT forms as well)
>
> grav_cTable = toolkit.createTable(planetClient, SWT.BORDER);
> grav_cTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
> 6));
> grav_cNames = new String[] {"one", "two", "three"};
> grav_cViewer = new TableViewer(grav_cTable);
>
> ..
> ..
>
> for(int i = 0; i < sectionList.size(); i++) {
> if (planet.getName().equals(sectionList.get(i).getPlanet().getN ame()))
> {
> if (grav_cTable.getColumnCount() < 1) {
> for (int j = 0; j < 3; j++) {
> grav_cColumn = new TableViewerColumn(grav_cViewer,
> SWT.NONE);
> grav_cColumn.setEditingSupport(new
> InlineEditingSupport(grav_cViewer, bindingContext, grav_cNames[j]));
> grav_cColumn.getColumn().setWidth(100);
> }
>
> ViewerSupport.bind(grav_cViewer, new
> WritableList(TrajectoryGUI.getDefault().getActiveTrajectory( ).planetList.get(i).getGrav_c(),
> Grav_C.class),BeanProperties.values(Grav_C.class, grav_cNames));
> }
> else {
> ViewerSupport.bind(grav_cViewer, new
> WritableList(TrajectoryGUI.getDefault().getActiveTrajectory( ).planetList.get(i).getGrav_c(),
> Grav_C.class),BeanProperties.values(Grav_C.class, grav_cNames));
> }
> }
>
>
> I would like to keep the same structure of Section having an instance of
> Planet because I use a TreeView to show the breakdown of the trajectory
> structure, Unless there is another way of doing that. I'm not sure if this
> is possible or if this is the best way of doing this. If you couldn't tell
> I'm Aerospace not Computer Science so if you have any ideas I open for
> advice. Thanks in advance for any help and let me know if you need more
> code or explanation.
>
> Stephen
>
|
|
| |
Goto Forum:
Current Time: Thu Apr 18 12:59:15 GMT 2024
Powered by FUDForum. Page generated in 0.01980 seconds
|