In my application, I doesn't need global commands. So I removed all the defined global commands
from the command manager definition :
When I use the TextComponentPopupInterceptorFactory like in the Petclinic sample,Code:<bean id="commandManager" class="org.springframework.richclient.command.support.DefaultCommandManager"> <property name="globalCommandIds"> <list> <value>startCommand</value> <value>stopCommand</value> <value>executeCommand</value> </list> </property> </bean>
my dialog doesn't show because of a NullPointerException in org.springframework.richclient.text.TextComponentP opup :
I put "if (command != null)" before each keymap.addActionForKeyStroke(...). My dialog shows and works butCode:public void registerAccelerators() { CommandManager commandManager = getCommandManager(); Keymap keymap = textComponent.getKeymap(); ActionCommand command = commandManager.getActionCommand( GlobalCommandIds.UNDO); keymap.addActionForKeyStroke(command.getAccelerator(), command.getSwingActionAdapter()); command = commandManager.getActionCommand( GlobalCommandIds.REDO); keymap.addActionForKeyStroke(command.getAccelerator(), command.getSwingActionAdapter()); command = commandManager.getActionCommand( GlobalCommandIds.COPY); keymap.addActionForKeyStroke(command.getAccelerator(), command.getSwingActionAdapter()); command = commandManager.getActionCommand( GlobalCommandIds.CUT); keymap.addActionForKeyStroke(command.getAccelerator(), command.getSwingActionAdapter()); command = commandManager.getActionCommand( GlobalCommandIds.PASTE); keymap.addActionForKeyStroke(command.getAccelerator(), command.getSwingActionAdapter()); command = commandManager.getActionCommand( GlobalCommandIds.SELECT_ALL); keymap.addActionForKeyStroke(command.getAccelerator(), command.getSwingActionAdapter()); }
I get a series of complaints about commands not found.
I think it would be a good idea not considering that the predifined global commands must exists. Or define
them automatically.


Reply With Quote