Announcement Announcement Module
Collapse
No announcement yet.
Global commands and TextComponentPopupInterceptorFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Global commands and TextComponentPopupInterceptorFactory

    In my application, I doesn't need global commands. So I removed all the defined global commands
    from the command manager definition :

    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>
    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 :

    Code:
        public void registerAccelerators&#40;&#41; &#123;
            CommandManager commandManager = getCommandManager&#40;&#41;;        
            Keymap keymap = textComponent.getKeymap&#40;&#41;;
            ActionCommand command = commandManager.getActionCommand&#40;
                    GlobalCommandIds.UNDO&#41;;
            keymap.addActionForKeyStroke&#40;command.getAccelerator&#40;&#41;, command.getSwingActionAdapter&#40;&#41;&#41;;
            command = commandManager.getActionCommand&#40;
                    GlobalCommandIds.REDO&#41;;
            keymap.addActionForKeyStroke&#40;command.getAccelerator&#40;&#41;, command.getSwingActionAdapter&#40;&#41;&#41;;
            command = commandManager.getActionCommand&#40;
                    GlobalCommandIds.COPY&#41;;
            keymap.addActionForKeyStroke&#40;command.getAccelerator&#40;&#41;, command.getSwingActionAdapter&#40;&#41;&#41;;
            command = commandManager.getActionCommand&#40;
                    GlobalCommandIds.CUT&#41;;
            keymap.addActionForKeyStroke&#40;command.getAccelerator&#40;&#41;, command.getSwingActionAdapter&#40;&#41;&#41;;
            command = commandManager.getActionCommand&#40;
                    GlobalCommandIds.PASTE&#41;;
            keymap.addActionForKeyStroke&#40;command.getAccelerator&#40;&#41;, command.getSwingActionAdapter&#40;&#41;&#41;;
            command = commandManager.getActionCommand&#40;
                    GlobalCommandIds.SELECT_ALL&#41;;
            keymap.addActionForKeyStroke&#40;command.getAccelerator&#40;&#41;, command.getSwingActionAdapter&#40;&#41;&#41;;
        &#125;
    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.

  • #2
    Patrick,

    I've fixed it. I think... can you test this out. You may have to wait for CVS to update.

    Ollie

    Comment


    • #3
      Ollie,

      It works. Great job.

      Patrick

      Comment

      Working...
      X