Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [databinding] How to manipulate record order in a TableViewer
[databinding] How to manipulate record order in a TableViewer [message #510909] Fri, 29 January 2010 01:56 Go to next message
Gerald Rosenberg is currently offline Gerald RosenbergFriend
Messages: 106
Registered: July 2009
Senior Member
I have a Tableviewer bound to a List using ViewerSupport - that part works fine.

The question is, how to connect up a set of Up/Down/Add/Remove buttons in the view to manipulate
the order of the rows in the table and to add and delete rows, with the result being properly
reflected in the model through the existing bindings.

getTableViewer().getInput() is a BeansObservableListDecorator
getTableViewer().getContentProvider() is a ObservableListContentProvider

Neither appears appropriate for manipulating the view side of the bindings.

Thanks...
Re: [databinding] How to manipulate record order in a TableViewer [message #511070 is a reply to message #510909] Fri, 29 January 2010 16:58 Go to previous messageGo to next message
Gerald Rosenberg is currently offline Gerald RosenbergFriend
Messages: 106
Registered: July 2009
Senior Member
In article <MPG.25cc2460ac225a659896d5@news.eclipse.org>, gerald@certiv.net says...
>
> I have a Tableviewer bound to a List using ViewerSupport - that part works fine.
>
> The question is, how to connect up a set of Up/Down/Add/Remove buttons in the view to manipulate
> the order of the rows in the table and to add and delete rows, with the result being properly
> reflected in the model through the existing bindings.
>
> getTableViewer().getInput() is a BeansObservableListDecorator
> getTableViewer().getContentProvider() is a ObservableListContentProvider
>
> Neither appears appropriate for manipulating the view side of the bindings.
>
> Thanks...

Moved to the platform group.
Re: [databinding] How to manipulate record order in a TableViewer [message #511127 is a reply to message #510909] Sat, 30 January 2010 00:36 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Gerald Rosenberg wrote:
> I have a Tableviewer bound to a List using ViewerSupport - that part works fine.
>
> The question is, how to connect up a set of Up/Down/Add/Remove buttons in the view to manipulate
> the order of the rows in the table and to add and delete rows, with the result being properly
> reflected in the model through the existing bindings.
>
> getTableViewer().getInput() is a BeansObservableListDecorator
> getTableViewer().getContentProvider() is a ObservableListContentProvider

In my applications I implement those actions by manipulating the
IObservableList directly, e.g.:

final IObservableList viewerInput = ...

upButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
int selectionIndex = table.getSelectionIndex();
if (selectionIndex > 0)
viewerInput.move(selectionIndex, selectionIndex-1);
}
});

Hope this helps,

Matthew
Re: [databinding] How to manipulate record order in a TableViewer [message #511191 is a reply to message #511127] Sat, 30 January 2010 16:48 Go to previous messageGo to next message
Gerald Rosenberg is currently offline Gerald RosenbergFriend
Messages: 106
Registered: July 2009
Senior Member
In article <hk0gcm$jq4$1@build.eclipse.org>, matthall@woodcraftmill.com says...
>
> Gerald Rosenberg wrote:
> > I have a Tableviewer bound to a List using ViewerSupport - that part works fine.
> >
> > The question is, how to connect up a set of Up/Down/Add/Remove buttons in the view to manipulate
> > the order of the rows in the table and to add and delete rows, with the result being properly
> > reflected in the model through the existing bindings.
> >
> > getTableViewer().getInput() is a BeansObservableListDecorator
> > getTableViewer().getContentProvider() is a ObservableListContentProvider
>
> In my applications I implement those actions by manipulating the
> IObservableList directly, e.g.:
>
> final IObservableList viewerInput = ...

Yes, but isn't that the model side of the binding?

IObservableList viewerInput = BeansObservables.observeList(realm, bean, property);

My model is not available in my view - the binding is performed elsewhere through an abstraction
mechanism. Not a purist, but it would seem to be cleaner if these actions could be implemented
using the view side of the binding. Any support for this?

Thanks...
Re: [databinding] How to manipulate record order in a TableViewer [message #511823 is a reply to message #511191] Wed, 03 February 2010 01:14 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Gerald Rosenberg wrote:
> Yes, but isn't that the model side of the binding?

Yes, that's correct. I've found this model to work pretty well in practice.

> My model is not available in my view - the binding is performed elsewhere through an abstraction
> mechanism. Not a purist, but it would seem to be cleaner if these actions could be implemented
> using the view side of the binding. Any support for this?

If you are binding a model list to a viewer list then you could just as
well apply these changes to the viewer list. As long as you apply the
changes to an IObservableList it will be picked up by Databinding.

Or am I missing something?

Matthew
Re: [databinding] How to manipulate record order in a TableViewer [message #512107 is a reply to message #511823] Wed, 03 February 2010 22:45 Go to previous message
Gerald Rosenberg is currently offline Gerald RosenbergFriend
Messages: 106
Registered: July 2009
Senior Member
In article <hkb3k8$49n$1@build.eclipse.org>, matthall@woodcraftmill.com
says...
>
> Gerald Rosenberg wrote:
> > Yes, but isn't that the model side of the binding?
>
> Yes, that's correct. I've found this model to work pretty well in practice.
>
> > My model is not available in my view - the binding is performed elsewhere through an abstraction
> > mechanism. Not a purist, but it would seem to be cleaner if these actions could be implemented
> > using the view side of the binding. Any support for this?
>
> If you are binding a model list to a viewer list then you could just as
> well apply these changes to the viewer list. As long as you apply the
> changes to an IObservableList it will be picked up by Databinding.
>
> Or am I missing something?
>
> Matthew

Actually I was missing something.

Just realized you *can* get a usable IObservableList from a bound
TableViewer.

TableViewer#getInput returns a BeanObservableListDecorator which is
internal, a decorator of other internal type stuff, and (insert other
good reasons for not looking closer).

But, turns out that it also implements an IObservableList. Haven't
tried it yet, but as you say it should work.

Thanks,
Gerald
Previous Topic:MS Excel like spreadsheet features
Next Topic:[Databinding] How to manipulate record order in a TableViewer
Goto Forum:
  


Current Time: Thu Apr 25 08:07:47 GMT 2024

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

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

Back to the top