Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Missing main toolbar contributions after migration to Eclipse 4.4
Missing main toolbar contributions after migration to Eclipse 4.4 [message #1486786] Tue, 25 November 2014 09:36 Go to next message
Karl Puperze is currently offline Karl PuperzeFriend
Messages: 36
Registered: August 2011
Member
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 09:37]

Report message to a moderator

Re: Missing items in main toolbar [message #1487012 is a reply to message #1486786] Tue, 25 November 2014 13:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
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.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Missing items in main toolbar [message #1487083 is a reply to message #1487012] Tue, 25 November 2014 14:47 Go to previous messageGo to next message
Karl Puperze is currently offline Karl PuperzeFriend
Messages: 36
Registered: August 2011
Member
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 #1487166 is a reply to message #1487083] Tue, 25 November 2014 16:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
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?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Missing items in main toolbar [message #1494472 is a reply to message #1487166] Mon, 01 December 2014 13:56 Go to previous messageGo to next message
Karl Puperze is currently offline Karl PuperzeFriend
Messages: 36
Registered: August 2011
Member
I tried your solution, but it is not working for me. Any other ideas?
Re: Missing items in main toolbar [message #1494530 is a reply to message #1494472] Mon, 01 December 2014 14:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Karl,

It's hard to know exactly what you tried. If the layout thing is a
problem just resizing the window would make it appear. You need to do
the revaluationRequest when the state changes (not sure what causes your
state changes) and you should see (set breakpoints) that the property is
evaluated. But you describe things that are selection based, which is
quite different but again, you should see property testers being invoked...


On 01/12/2014 2:56 PM, Karl Puperze wrote:
> I tried your solution, but it is not working for me. Any other ideas?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Missing items in main toolbar [message #1494599 is a reply to message #1494530] Mon, 01 December 2014 15:56 Go to previous message
Karl Puperze is currently offline Karl PuperzeFriend
Messages: 36
Registered: August 2011
Member
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.
Previous Topic:e4 css; removing extra padding around the styled font
Next Topic:Does ECP Support LOCALIZATION?
Goto Forum:
  


Current Time: Tue Mar 19 07:12:30 GMT 2024

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

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

Back to the top