How to use multi tableviewers as SelectionProvider? [message #453429] |
Mon, 31 July 2006 05:15  |
Eclipse User |
|
|
|
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 06:30   |
Eclipse User |
|
|
|
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 #453570 is a reply to message #453432] |
Thu, 03 August 2006 01:17  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03435 seconds