spring-richclient开发swing应用程序 4

spring-rcp里面简单到极点(相对)的就算是菜单和导航条的配置了,当然这里面吸收了eclipse,netbean等思想。做成这样的形式以后也许可以向vb的菜单编辑器一样图形化创建菜单栏吧。

所有菜单栏和工具栏的配置都在commands-context.xml这个文件里面

1

 <bean id="windowCommandManager"
  class="org.springframework.richclient.application.support.ApplicationWindowCommandManager">
  <property name="sharedCommandIds">
   <list>
    <value>saveAsCommand</value>
    <value>propertiesCommand</value>
    <value>renameCommand</value>               
    <value>undoCommand</value>
    <value>redoCommand</value>
    <value>cutCommand</value>
    <value>copyCommand</value>
    <value>pasteCommand</value>
    <value>selectAllCommand</value>
    <value>deleteCommand</value>
   </list>
  </property>
 </bean>

统一定义所有的command,便于事件的分布传递

2

 <bean id="menuBar"
  class="org.springframework.richclient.command.CommandGroupFactoryBean">
  <property name="members">
   <list>
    <ref bean="fileMenu"/>
    <ref bean="editMenu"/>
    <ref bean="windowMenu"/>
    <ref bean="helpMenu"/>
   </list>
  </property>
 </bean>

定义菜单,菜单分四个组,也就是我们一般菜单里面的 文件,编辑 窗口 帮助

3 以其中的一个文件为例

 <bean id="fileMenu"  //文件菜单
  class="org.springframework.richclient.command.CommandGroupFactoryBean">
  <property name="members">
   <list>
    <ref bean="newMenu"/> //新建按钮
    <value>separator</value>//分割条
    <ref bean="loginCommand"/>//登陆
    <ref bean="logoutCommand"/>//登出
    <value>separator</value>//分隔条
    <value>saveAsCommand</value>//另存为
    <value>separator</value>//分隔条
    <value>propertiesCommand</value>//属性
    <value>separator</value>//分隔条
    <bean class="org.springframework.richclient.command.support.ExitCommand"/>//退出
   </list>
  </property>

 <bean id="newMenu" 上面的新建菜单还有一个子菜单里面是新建主人
  class="org.springframework.richclient.command.CommandGroupFactoryBean">
  <property name="members">
   <list>
    <ref bean="newOwnerCommand"/>
   </list>
  </property>
 </bean>
 </bean>

//这里是新建主人具体的命令,作用是调用新建主人向导框

 <bean id="newOwnerCommand"
  class="org.springframework.richclient.command.TargetableActionCommand">
  <property name="commandExecutor">
   <ref bean="newOwnerWizard"/>
  </property>
 </bean>

按照这个思路,其他的菜单都是一样的道理

 <bean id="helpContentsCommand"
  class="org.springframework.richclient.command.support.HelpContentsCommand"/>
  
 <bean id="aboutCommand"
  class="org.springframework.richclient.command.support.AboutCommand">
  <property name="aboutTextPath">
   <value>org/springframework/richclient/samples/petclinic/about.txt</value>
  </property>
 </bean>

 <bean id="preferenceCommand" class="org.springframework.richclient.preference.PreferenceCommand">
  <property name="preferenceManager">
   <ref bean="preferenceManager"/>
  </property>
 </bean>
  
 <bean id="loginCommand"
  class="org.springframework.richclient.security.LoginCommand">
  <property name="authenticationManager">
   <ref bean="authenticationManager"/>
  </property>
 </bean>
 
 <bean id="logoutCommand"
  class="org.springframework.richclient.security.LogoutCommand"/>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值