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"/>