Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to use multi tableviewers as SelectionProvider?
How to use multi tableviewers as SelectionProvider? [message #453429] Mon, 31 July 2006 09:15 Go to next message
Jian Lee is currently offline Jian LeeFriend
Messages: 21
Registered: July 2009
Junior Member
In my RCP application, there is a CTabFolder in the view, containing
three CTabItems: bookstore,category and books, and each CTabItem has a
Composite as its control, also, each Composite contains a TableViewer to
show some informations.

There is some menuitems in the menu such as: "add bookstore","delete
bookstore","add category","delete category",etc.

And, what I want to implement is: if I click the content of
bookstoreTable, the "delete bookstore" action should be enabled, and If
I click the content of categoryTable, the "delete catagory" action
should be enabled and "delete bookstore" action should be disabled, etc.

If there's only one CTabItem, I can easily deal with it by
add a line:
getSite().setSelectionProvider(tableviewer)
to the view class and implement a ISelectionListener together with the
selectionChanged() method.

But there're three tableviewers, I don't know what to do now.

Thank you very much.
Re: How to use multi tableviewers as SelectionProvider? [message #453432 is a reply to message #453429] Mon, 31 July 2006 10:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tom.seidel.spiritlink.de

Chandler Li wrote:
> In my RCP application, there is a CTabFolder in the view, containing
> three CTabItems: bookstore,category and books, and each CTabItem has a
> Composite as its control, also, each Composite contains a TableViewer to
> show some informations.
>
> There is some menuitems in the menu such as: "add bookstore","delete
> bookstore","add category","delete category",etc.
>
> And, what I want to implement is: if I click the content of
> bookstoreTable, the "delete bookstore" action should be enabled, and If
> I click the content of categoryTable, the "delete catagory" action
> should be enabled and "delete bookstore" action should be disabled, etc.
>
> If there's only one CTabItem, I can easily deal with it by
> add a line:
> getSite().setSelectionProvider(tableviewer)
> to the view class and implement a ISelectionListener together with the
> selectionChanged() method.
>
> But there're three tableviewers, I don't know what to do now.
>
> Thank you very much.
Hi,

define your own ISelectionChangedListener with the scope of one TableViewer
something like:

myBookStoreTable.addSelectionChangedListener(new
ISelectionChangedListener() {
public void selectionChanged(event) {
if (!event.getSelection().isEmpty() {
deleteBookstoreAction.setEnabled(true);
myOtherAction.setEnabled(false);
//disable other actions...
} else {
//handle deselect
}
}
});

--
Cheerz,
Tom
Re: How to use multi tableviewers as SelectionProvider? [message #453490 is a reply to message #453432] Tue, 01 August 2006 01:40 Go to previous messageGo to next message
Jian Lee is currently offline Jian LeeFriend
Messages: 21
Registered: July 2009
Junior Member
Tom Seidel wrote:
> Hi,
>
> define your own ISelectionChangedListener with the scope of one TableViewer
> something like:
>
> myBookStoreTable.addSelectionChangedListener(new
> ISelectionChangedListener() {
> public void selectionChanged(event) {
> if (!event.getSelection().isEmpty() {
> deleteBookstoreAction.setEnabled(true);
> myOtherAction.setEnabled(false);
> //disable other actions...
> } else {
> //handle deselect
> }
> }
> });
>
Yeah! I'll try it.
Thanks a lot!
Re: How to use multi tableviewers as SelectionProvider? [message #453491 is a reply to message #453432] Tue, 01 August 2006 02:00 Go to previous messageGo to next message
Jian Lee is currently offline Jian LeeFriend
Messages: 21
Registered: July 2009
Junior Member
Tom Seidel wrote:
> Hi,
>
> define your own ISelectionChangedListener with the scope of one TableViewer
> something like:
>
> myBookStoreTable.addSelectionChangedListener(new
> ISelectionChangedListener() {
> public void selectionChanged(event) {
> if (!event.getSelection().isEmpty() {
> deleteBookstoreAction.setEnabled(true);
> myOtherAction.setEnabled(false);
> //disable other actions...
> } else {
> //handle deselect
> }
> }
> });
>

Sorry, I have another problem, as the actions are initialized in
ApplicationActionBarAdvisor.

If I define ISelectionChangedListener with the scope of one TableView,
maybe this solution tightly coupled the actions with TableViews, because
I have to expose the references to the actions to the TableViews.
Isn't it?

Thanks.

Best Regards

Chandler
Re: How to use multi tableviewers as SelectionProvider? [message #453570 is a reply to message #453432] Thu, 03 August 2006 05:17 Go to previous message
Jian Lee is currently offline Jian LeeFriend
Messages: 21
Registered: July 2009
Junior Member
Tom Seidel wrote:
> Hi,
>
> define your own ISelectionChangedListener with the scope of one
TableViewer
> something like:
>
> myBookStoreTable.addSelectionChangedListener(new
ISelectionChangedListener() {
> public void selectionChanged(event) {
> if (!event.getSelection().isEmpty() {
> deleteBookstoreAction.setEnabled(true);
> myOtherAction.setEnabled(false);
> //disable other actions...
> } else {
> //handle deselect
> }
> }
> });
>

Sorry, I have another problem, as the actions are initialized in
ApplicationActionBarAdvisor.

If I define ISelectionChangedListener with the scope of one TableView,
maybe this solution tightly coupled the actions with TableViews, because
I have to expose the references to the actions to the TableViews.
Isn't it?

Thanks.

Best Regards

Chandler
Previous Topic:How to Manage User session in RCP application
Next Topic:How to open a popup window?
Goto Forum:
  


Current Time: Sat Dec 21 16:40:52 GMT 2024

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

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

Back to the top