Missing main toolbar contributions after migration to Eclipse 4.4 [message #1486786] |
Tue, 25 November 2014 04:36  |
Eclipse User |
|
|
|
We have switched to Eclipse 4.4 and we are now missing main toolbar items with visibility expressions considering the selection. When I first start the RCP application and select an item in a tree view, I am missing the toolbar contributions, although the visibility expression should successfully evaluate. When I open the editor for this item, the toolbar refreshes and the missing contributions are visible. After some time and a couple of selection changes in the tree view, the toolbar contributions are gone again until I open the editor.
I have noticed, that there are some issues with the toolbar item states, e.g. the save button is not enabled. We fixed that be calling the event broker and requesting the enabledment update. But I have no idea how to do this when the selection changes.
[Updated on: Tue, 25 November 2014 04:37] by Moderator
|
|
|
Re: Missing items in main toolbar [message #1487012 is a reply to message #1486786] |
Tue, 25 November 2014 08:32   |
Eclipse User |
|
|
|
Karl,
I've been playing quite a bit lately with toolbar item visibility (for
Oomph). There appears to be a bug that when that when all the items in
a toolbar are invisible (according to the "visibleWhen" expression) the
toolbar itself becomes invisible (which is okay), but when an item on
the toolbar becomes visible again, the toolbar itself doesn't become
visible until there is a layout change. So I have code like this:
public static void requestEvaluation(final String id, final boolean
layout)
{
UIUtil.syncExec(new Runnable()
{
public void run()
{
if (PlatformUI.isWorkbenchRunning())
{
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null)
{
IEvaluationService service =
(IEvaluationService)workbench.getService(IEvaluationService.class);
if (service != null)
{
service.requestEvaluation(id);
if (layout)
{
for (IWorkbenchWindow workbenchWindow :
workbench.getWorkbenchWindows())
{
Shell shell = workbenchWindow.getShell();
if (shell != null)
{
shell.layout(true, true);
}
}
}
}
}
}
}
});
}
It requests re-evaluation when some property changes, and as a "hack" it
forces a layout which helps make the toolbars show up again.
On 25/11/2014 10:36 AM, Karl Puperze wrote:
> We have switched to Eclipse 4.4 and we are now missing main toolbar
> items with visibility expressions considering the selection. When I
> first start the RCP application and select an item in a tree view, I
> am missing the toolbar contributions, although the visibility
> expression should successfully evaluate. When I open the editor for
> this item, the toolbar refreshes and the missing contributions are
> visible. After some time and a couple of selection changes in the tree
> view, the toolbar contributions are gone again until I open the editor.
>
> I have noticed, that there are some issues with the toolbar item
> states, e.g. the save button is not enabled. We fixed that be calling
> the event broker and requesting the enabledment update. But I have no
> idea how to do this when the selection changes.
|
|
|
|
Re: Missing items in main toolbar [message #1487166 is a reply to message #1487083] |
Tue, 25 November 2014 11:17   |
Eclipse User |
|
|
|
Karl,
No, I didn't file a bug. It's a fair bit of work to create the test
case... :-(
In my case, I wanted the visibility to be affected by a preference so I
wrote the class below. See how I add a preference listener in the
constructor. So if something sets the preference, the visibility of the
toolbar item will be refreshed accordingly. But I'm not sure in your
case what's changing that should update the visibility...
public class UIPropertyTester extends PropertyTester
{
public static final String SHOW_OFFLINE = "showOffline";
private static final Preferences PREFERENCES =
UIPlugin.INSTANCE.getInstancePreferences();
public static void requestEvaluation(final String id, final boolean
layout)
{
UIUtil.syncExec(new Runnable()
{
public void run()
{
if (PlatformUI.isWorkbenchRunning())
{
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null)
{
IEvaluationService service =
(IEvaluationService)workbench.getService(IEvaluationService.class);
if (service != null)
{
service.requestEvaluation(id);
if (layout)
{
for (IWorkbenchWindow workbenchWindow :
workbench.getWorkbenchWindows())
{
Shell shell = workbenchWindow.getShell();
if (shell != null)
{
shell.layout(true, true);
}
}
}
}
}
}
}
});
}
public UIPropertyTester()
{
((IEclipsePreferences)PREFERENCES).addPreferenceChangeListener(new
IEclipsePreferences.IPreferenceChangeListener()
{
public void preferenceChange(final
IEclipsePreferences.PreferenceChangeEvent event)
{
if (SHOW_OFFLINE.equals(event.getKey()))
{
requestEvaluation("org.eclipse.oomph.ui." + SHOW_OFFLINE,
"true".equals(event.getNewValue()));
}
}
});
}
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue)
{
if (expectedValue == null)
{
expectedValue = Boolean.TRUE;
}
if (SHOW_OFFLINE.equals(property))
{
return expectedValue.equals(PREFERENCES.getBoolean(SHOW_OFFLINE,
false));
}
return false;
}
}
On 25/11/2014 3:47 PM, Karl Puperze wrote:
> You are right. We´ve added two toolbars to the main toolbar. One
> contains items, which are always visible (e.g. refresh tool item). One
> contains a set of items, which are visible, if the selection is of
> type XY. When I add a tool item to the always visible toolbar with the
> same visible when expression like the others, everything works fine.
> Did you file a bug? Where do you call your requestEvaluation method?
|
|
|
|
|
Re: Missing items in main toolbar [message #1494599 is a reply to message #1494530] |
Mon, 01 December 2014 10:56  |
Eclipse User |
|
|
|
I've implemented a startup job, which registers a post selection listener with the selection service. Everytime the selection changes, it forces the revaluationRequest and layouts the toolbar. But after the revaluationRequest the toolbar is still missing the expected items, so it is not a layout problem. When I open the editor of my selection, everything is fine. I looks like an issue with the ToolBarManager or ToolBarManagerRenderer, but this is very hard to debug.
|
|
|
Powered by
FUDForum. Page generated in 0.07252 seconds