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 05:32 Go to next message
Ben Wecker is currently offline Ben Wecker
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 07:47 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
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 08:35 Go to previous messageGo to next message
Ben Wecker is currently offline Ben Wecker
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 11:11 Go to previous messageGo to next message
Ben Wecker is currently offline Ben Wecker
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 09:21 Go to previous messageGo to next message
Arian Fornaris is currently offline Arian Fornaris
Messages: 2
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 14:55 Go to previous messageGo to next message
Catalin Gerea is currently offline Catalin Gerea
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.
Re: Default value for radio button [message #1256728 is a reply to message #1255759] Tue, 25 February 2014 13:43 Go to previous message
Arian Fornaris is currently offline Arian Fornaris
Messages: 2
Registered: February 2014
Junior Member
Ok thanks a lot Catalin.
Previous Topic:E4 user authentication, session, and authorization based presentation logic
Next Topic:Add a console view in RCP(eclipse indigo-3.7)
Goto Forum:
  


Current Time: Thu Apr 17 05:47:16 EDT 2014

Powered by FUDForum. Page generated in 0.03503 seconds