Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Custom ISelectionProvider and checkEnabled for Visibility of commands does not work properly
Custom ISelectionProvider and checkEnabled for Visibility of commands does not work properly [message #333984] Thu, 15 January 2009 09:49 Go to next message
Adam Lucarz is currently offline Adam LucarzFriend
Messages: 518
Registered: July 2009
Senior Member
Hello,

i have a View which contains several sections with widgets. So I had to
write my own ISelectionProvider in order to provide the current
selection. My implementation seems to be fine so far because the
enablement and commands are handled properly. My problem is, that I want
to make menuContributions invisible when they are disabled. So I used
the "checkEnabled" attribute for the visibility of the menuContribution.
The wrong behavior appears when the user changes the view and returns to
the view with the custom ISelectionProvider. The mentioned
menuContributions are invisible although they are enabled. I made a
proof using a view toolbar contribution with the same command which do
not use the "checkEnabled" attribute. So I could see that the enablement
works fine.

public void addSelectionChangedListener(ISelectionChangedListener listener) {
if (!selectionChangedListeners.contains(listener)) {
selectionChangedListeners.add(listener);
}
}

public void removeSelectionChangedListener(ISelectionChangedListener listener) {
if (selectionChangedListeners.contains(listener)) {
selectionChangedListeners.remove(listener);
}
}

public void setSelection(ISelection selection) {
currentSelection = selection;
notifySelectionChangedListeners();
}

private void notifySelectionChangedListeners() {
for (int i = 0; i < selectionChangedListeners.size(); i++) {
final SelectionChangedEvent event = new SelectionChangedEvent(this, currentSelection);
final ISelectionChangedListener l = selectionChangedListeners.get(i);
SafeRunnable.run(new SafeRunnable() {
public void run() {
l.selectionChanged(event);
}
});
}
}

public ISelection getSelection() {
return currentSelection;
}

The current selection is set by a selectionChangedListener registered at the several widgets.

widget.addSelectionChangedListener(new ISelectionChangedListener(){

public void selectionChanged(SelectionChangedEvent event) {
setSelection(event.getSelection());
}

});

Does anyone have an idea or a hint what I did wrong? Have I forgotten to request an expression evaluation or something like that?

Greetings
Adam
Re: Custom ISelectionProvider and checkEnabled for Visibility of commands does not work properly [message #334079 is a reply to message #333984] Mon, 19 January 2009 15:52 Go to previous message
Adam Lucarz is currently offline Adam LucarzFriend
Messages: 518
Registered: July 2009
Senior Member
Adam Lucarz schrieb:
> Hello,
>
> i have a View which contains several sections with widgets. So I had to
> write my own ISelectionProvider in order to provide the current
> selection. My implementation seems to be fine so far because the
> enablement and commands are handled properly. My problem is, that I want
> to make menuContributions invisible when they are disabled. So I used
> the "checkEnabled" attribute for the visibility of the menuContribution.
> The wrong behavior appears when the user changes the view and returns to
> the view with the custom ISelectionProvider. The mentioned
> menuContributions are invisible although they are enabled. I made a
> proof using a view toolbar contribution with the same command which do
> not use the "checkEnabled" attribute. So I could see that the enablement
> works fine.
>
> public void addSelectionChangedListener(ISelectionChangedListener
> listener) {
> if (!selectionChangedListeners.contains(listener)) {
> selectionChangedListeners.add(listener);
> }
> }
>
> public void removeSelectionChangedListener(ISelectionChangedListener
> listener) {
> if (selectionChangedListeners.contains(listener)) {
> selectionChangedListeners.remove(listener);
> }
> }
>
> public void setSelection(ISelection selection) {
> currentSelection = selection;
> notifySelectionChangedListeners();
> }
>
> private void notifySelectionChangedListeners() {
> for (int i = 0; i < selectionChangedListeners.size(); i++) {
> final SelectionChangedEvent event = new
> SelectionChangedEvent(this, currentSelection);
> final ISelectionChangedListener l =
> selectionChangedListeners.get(i);
> SafeRunnable.run(new SafeRunnable() {
> public void run() {
> l.selectionChanged(event);
> }
> });
> }
> }
>
> public ISelection getSelection() {
> return currentSelection;
> }
>
> The current selection is set by a selectionChangedListener
> registered at the several widgets.
>
> widget.addSelectionChangedListener(new ISelectionChangedListener(){
>
> public void selectionChanged(SelectionChangedEvent event) {
> setSelection(event.getSelection());
> }
>
> });
>
> Does anyone have an idea or a hint what I did wrong? Have I forgotten to
> request an expression evaluation or something like that?
>
> Greetings
> Adam

Hi,

this bug is fixed for the next eclipse release 3.5M4. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=249442.
Previous Topic:[Databinding] Validating at least one selection in a Checkbox Table Viewer
Next Topic:Turning on key bindings in an editor
Goto Forum:
  


Current Time: Wed Jul 17 19:37:19 GMT 2024

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

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

Back to the top