Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Default value for radio button
Default value for radio button [message #516837] Thu, 25 February 2010 10:32 Go to next message
Ben Wecker is currently offline Ben WeckerFriend
Messages: 4
Registered: February 2010
Junior Member
I have a menu with a sub menu that contains three radio buttons. I want the third of the radio buttons checked by default (i.e. at program start). However, all three radio buttons are checked.
This is a snippet from my plugin.xml:
<extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="viewMenu"
               label="View">
            <menu
                  id="navigationMenu"
                  label="Connections">
	              <command
			            commandId="myApp.commands.navigationAll"
			            label="snap to road"
			            style="radio">
			         <parameter
			               name="org.eclipse.ui.commands.radioStateParameter"
			               value="all">
			         </parameter>
			      </command>
			      <command
			            commandId="myApp.commands.navigationNone"
			            label="direct connection"
			            style="radio">
			         <parameter
			               name="org.eclipse.ui.commands.radioStateParameter"
			               value="none">
			         </parameter>
			      </command>
			      <command
			            commandId="myApp.commands.navigationIndy"
			            label="individual"
			            style="radio">
			         <parameter
			               name="org.eclipse.ui.commands.radioStateParameter"
			               value="indy">
			         </parameter>
			      </command> 
            </menu>
         </menu>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
		 <command
		      defaultHandler="myApp.handlers.NavigationHandler"
		      id="myApp.commands.navigationAll"
		      name="navigationAll">
		   <commandParameter
		         id="org.eclipse.ui.commands.radioStateParameter"
		         name="navigation"
		         optional="false">
		   </commandParameter>
		   <state
		         class="org.eclipse.ui.handlers.RadioState:all"
		         id="org.eclipse.ui.commands.radioState">
		   </state>
		</command>  
		<command
		      defaultHandler="myApp.handlers.NavigationHandler"
		      id="myApp.commands.navigationNone"
		      name="navigationNone">
		   <commandParameter
		         id="org.eclipse.ui.commands.radioStateParameter"
		         name="none"
		         optional="false">
		   </commandParameter>
		   <state
		         class="org.eclipse.ui.handlers.RadioState:none"
		         id="org.eclipse.ui.commands.radioState">
		   </state>
		</command>  
		<command
		      defaultHandler="myApp.handlers.NavigationHandler"
		      id="myApp.commands.navigationIndy"
		      name="navigationIndy">
		   <commandParameter
		         id="org.eclipse.ui.commands.radioStateParameter"
		         name="indy"
		         optional="false">
		   </commandParameter>
		   <state
		         class="org.eclipse.ui.handlers.RadioState:indy"
		         id="org.eclipse.ui.commands.radioState">
		   </state>
		</command>  
   </extension>   

Re: Default value for radio button [message #516882 is a reply to message #516837] Thu, 25 February 2010 12:47 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 25/02/10 4:02 PM, Ben Wecker wrote:
> I have a menu with a sub menu that contains three radio buttons. I want
> the third of the radio buttons checked by default (i.e. at program
> start). However, all three radio buttons are checked.
> This is a snippet from my plugin.xml:

Why do you need three different commands. All you need is one command
with the parameter and three different contributions

See:
http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle- radio-menu.html

- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Default value for radio button [message #516893 is a reply to message #516882] Thu, 25 February 2010 13:35 Go to previous messageGo to next message
Ben Wecker is currently offline Ben WeckerFriend
Messages: 4
Registered: February 2010
Junior Member
Thanks for the quick answer. That's what I first thought, too. When I use only one command, no radio buttion is selected at the beginning. The snippet now looks like this:
<extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="viewMenu"
               label="View">
            <menu
                  id="navigationMenu"
                  label="Connections">
	              <command
			            commandId="myApp.commands.navigation"
			            label="snap to road"
			            style="radio">
			         <parameter
			               name="org.eclipse.ui.commands.radioStateParameter"
			               value="all">
			         </parameter>
			      </command>
			      <command
			            commandId="myApp.commands.navigation"
			            label="direct connection"
			            style="radio">
			         <parameter
			               name="org.eclipse.ui.commands.radioStateParameter"
			               value="no">
			         </parameter>
			      </command>
			      <command
			            commandId="myApp.commands.navigation"
			            label="individual"
			            style="radio">
			         <parameter
			               name="org.eclipse.ui.commands.radioStateParameter"
			               value="individual">
			         </parameter>
			      </command> 
            </menu>
         </menu>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
		 <command
		      defaultHandler="myApp.handlers.NavigationHandler"
		      id="myApp.commands.navigation"
		      name="navigationAll">
		   <commandParameter
		         id="org.eclipse.ui.commands.radioStateParameter"
		         name="navigation"
		         optional="false">
		   </commandParameter>
		   <state
		         class="org.eclipse.ui.handlers.RadioState:all"
		         id="org.eclipse.ui.commands.radioState">
		   </state>
		</command>  
   </extension>   
Re: Default value for radio button [message #517229 is a reply to message #516893] Fri, 26 February 2010 16:11 Go to previous messageGo to next message
Ben Wecker is currently offline Ben WeckerFriend
Messages: 1
Registered: February 2010
Junior Member
Does noone have an idea, what's wrong with the second XML?
Re: Default value for radio button [message #1255512 is a reply to message #517229] Mon, 24 February 2014 14:21 Go to previous messageGo to next message
Arian Fornaris is currently offline Arian FornarisFriend
Messages: 8
Registered: February 2014
Junior Member
Hi Ben Wecker

I have the same problem than you and yet I do not find a solution. Did you resolved this issue?
Re: Default value for radio button [message #1255759 is a reply to message #516837] Mon, 24 February 2014 19:55 Go to previous messageGo to next message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Hello Arian

See https://wiki.eclipse.org/Menu_Contributions/Radio_Button_Command It describes exactly how you can have a radio button checked by default.


Time is what you make of it.

[Updated on: Tue, 16 September 2014 13:30]

Report message to a moderator

Re: Default value for radio button [message #1256728 is a reply to message #1255759] Tue, 25 February 2014 18:43 Go to previous messageGo to next message
Arian Fornaris is currently offline Arian FornarisFriend
Messages: 8
Registered: February 2014
Junior Member
Ok thanks a lot Catalin.
Re: Default value for radio button [message #1424608 is a reply to message #1255759] Tue, 16 September 2014 07:11 Go to previous message
sameer degwekar is currently offline sameer degwekarFriend
Messages: 1
Registered: September 2014
Junior Member
it seems the link has been appended with terminating "." & so not working.
manually copying & removing dot makes the link work
Previous Topic:Get the eclipse application Launcher Name
Next Topic:Rest Client integration in RCP application
Goto Forum:
  


Current Time: Thu Mar 28 18:13:20 GMT 2024

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

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

Back to the top