Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Dynamic updating of Enable/Disabled UI Element
Dynamic updating of Enable/Disabled UI Element [message #719517] Sat, 27 August 2011 15:15 Go to next message
Eclipse UserFriend
Originally posted by: rkwright

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.36">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Verdana}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Verdana; min-height: 17.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Lucida Sans Typewriter'}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px 'Lucida Sans Typewriter'; color: #471cfe}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 17.0px; font: 14.0px Verdana; min-height: 17.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 17.0px; font: 14.0px Verdana}
span.s1 {color: #900868}
span.s2 {color: #000000}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1">I implemented some menu/toolbar items via commands and menu contributions.<span class="Apple-converted-space">  </span>The commands were implemented via AbstractHandler.<span class="Apple-converted-space">  </span>All works as expected EXCEPT that I can't seem to dynamically update the "enabled" status.<span class="Apple-converted-space">  </span>I have defined both enabled and disabled icons.<span class="Apple-converted-space">  </span>I have also implemented the isHandled and isEnabled.<span class="Apple-converted-space">  </span>isHandled always returns true, but isEnabled returns a boolean based on the state of my model.</p>
<p class="p2"><br></p>
<p class="p1">When the command is executed, I call<span class="Apple-converted-space"> </span></p>
<p class="p2"><br></p>
<p class="p3"><span class="Apple-tab-span"> </span>ICommandService service = (ICommandService) PlatformUI.<i>getWorkbench</i>().getService(ICommandService.<span class="s1"><b>class</b></span>);</p>
<p class="p4"><span class="s2"><span class="Apple-tab-span"> </span>service.refreshElements(</span>"com.geofx.gms.commands.StartSim"<span class="s2">, </span><span class="s1"><b>null</b></span><span class="s2">);</span></p>
<p class="p5"><br></p>
<p class="p6">which triggers the call to updateElement.</p>
<p class="p5"><br></p>
<p class="p6">The odd thing is that no matter whether I return true or false from isEnabled(), the menu/toolbar item remains enabled.<span class="Apple-converted-space">  </span>If I explicitly set the return from isEnabled to false (initially), then the item is never enabled (i.e. the right icon is show and the handler is not called - as expected).</p>
<p class="p5"><br></p>
<p class="p6">Is there some other refresh or call that I am expected to make?<span class="Apple-converted-space">  </span>Am I supposed to something explicit in the body of updateElement?<span class="Apple-converted-space">  </span>If so, what?<span class="Apple-converted-space">  </span>I'll keep poking, but if someone has advice, I would be appreciative.</p>
<p class="p5"><br></p>
<p class="p6">TIA Ric</p>
</body>
</html>
Re: Dynamic updating of Enable/Disabled UI Element [message #720047 is a reply to message #719517] Mon, 29 August 2011 18:00 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
Not really a "newcomers" question. Try asking in the Platform forum group.


On 8/27/11 11:15 AM, rkwright wrote:
> I implemented some menu/toolbar items via commands and menu
> contributions.The commands were implemented via AbstractHandler.All
> works as expected EXCEPT that I can't seem to dynamically update the
> "enabled" status.I have defined both enabled and disabled icons.I have
> also implemented the isHandled and isEnabled.isHandled always returns
> true, but isEnabled returns a boolean based on the state of my model.
>
>
> When the command is executed, I call
>
>
> ICommandService service = (ICommandService)
> PlatformUI./getWorkbench/().getService(ICommandService.*class*);
>
> service.refreshElements("com.geofx.gms.commands.StartSim", *null*);
>
>
> which triggers the call to updateElement.
>
>
> The odd thing is that no matter whether I return true or false from
> isEnabled(), the menu/toolbar item remains enabled.If I explicitly set
> the return from isEnabled to false (initially), then the item is never
> enabled (i.e. the right icon is show and the handler is not called - as
> expected).
>
>
> Is there some other refresh or call that I am expected to make?Am I
> supposed to something explicit in the body of updateElement?If so,
> what?I'll keep poking, but if someone has advice, I would be appreciative.
>
>
> TIA Ric
>
Previous Topic:Cannot connect to keystore when installing plugins
Next Topic:Eclipse search results window will not move
Goto Forum:
  


Current Time: Thu Apr 25 08:11:29 GMT 2024

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

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

Back to the top