Patrick Vanhuyse
Oct 5th, 2004, 03:06 AM
In my application, I doesn't need global commands. So I removed all the defined global commands
from the command manager definition :
<bean id="commandManager" class="org.springframework.richclient.command.support.Def aultCommandManager">
<property name="globalCommandIds">
<list>
<value>startCommand</value>
<value>stopCommand</value>
<value>executeCommand</value>
</list>
</property>
</bean>
When I use the TextComponentPopupInterceptorFactory like in the Petclinic sample,
my dialog doesn't show because of a NullPointerException in org.springframework.richclient.text.TextComponentP opup :
public void registerAccelerators() {
CommandManager commandManager = getCommandManager();
Keymap keymap = textComponent.getKeymap();
ActionCommand command = commandManager.getActionCommand(
GlobalCommandIds.UNDO);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.REDO);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.COPY);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.CUT);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.PASTE);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.SELECT_ALL);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
}
I put "if (command != null)" before each keymap.addActionForKeyStroke(...). My dialog shows and works but
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.
from the command manager definition :
<bean id="commandManager" class="org.springframework.richclient.command.support.Def aultCommandManager">
<property name="globalCommandIds">
<list>
<value>startCommand</value>
<value>stopCommand</value>
<value>executeCommand</value>
</list>
</property>
</bean>
When I use the TextComponentPopupInterceptorFactory like in the Petclinic sample,
my dialog doesn't show because of a NullPointerException in org.springframework.richclient.text.TextComponentP opup :
public void registerAccelerators() {
CommandManager commandManager = getCommandManager();
Keymap keymap = textComponent.getKeymap();
ActionCommand command = commandManager.getActionCommand(
GlobalCommandIds.UNDO);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.REDO);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.COPY);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.CUT);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.PASTE);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
command = commandManager.getActionCommand(
GlobalCommandIds.SELECT_ALL);
keymap.addActionForKeyStroke(command.getAccelerato r(), command.getSwingActionAdapter());
}
I put "if (command != null)" before each keymap.addActionForKeyStroke(...). My dialog shows and works but
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.