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

  • Commands

    Hi all

    Ok so now I am trying to get the global command framework to work. I need to be able to set the commands when different view gains the focus. Here are my questions:

    1. Is the AbstractView handling focus gained and lost or do I need to add a FocusListener to my component and in it call componentFocusGained()a and
    componentFocusLost() ?

    2. Should it be enough to register commands in registerLocalCommandExecutors and then let the rich client framework handle enable/disable of commands. For example I did:
    protected void registerLocalCommandExecutors(PageComponentContext context) {
    context.register(GlobalCommandIds.DELETE, new DeleteExecutor());
    context.register(GlobalCommandIds.PROPERTIES, null);
    }
    I would expect GlobalCommandIds.DELETE to be enabled when view is in focus

    3. Any tips and ticks when it comes to focus handling and tab between views


    Cheers
    Magnus

  • #2
    Anyone?

    Hi

    I've gone throught the samples to find what it is I am missing but still no luck.
    I have the following code in my view

    protected void registerLocalCommandExecutors(PageComponentContext context) {
    context.register(GlobalCommandIds.DELETE, new DeleteCommandExecutor());
    }

    private class DeleteCommandExecutor extends AbstractActionCommandExecutor {
    public void execute() {
    }
    }

    And I can see it runs the registerLocalCommandExecutors. I am guessing here a little bit but I am expecting the delete command to be enabled when
    this view gains the focus but it's not. So first I tried finding if the componentFocusGained(); method is being called when the view gains the focus but it's not. Then I guessed the the AbstractView should add a focus listener to the component returned by the public JComponent createControl();
    method, but it dont. So Im just confused how this is supposed to work...any hints?

    Cheers
    Magnus

    Comment


    • #3
      Magnus,

      what you are doing with registering the executor appears fine. You don't need to bother with focus listeners etc.

      The gotcha, I think, is that executors that extend AbstractActionCommandExecutor are not enabled by default. Override isEnabled and return true to always enable, or implement any view specific logic.

      Jonny

      Comment


      • #4
        Hi Johnny

        Great thanks I will try that out. Another thing about the focus handling. How does the view know it is in focus. I can not seem to find where it gets the focus event from the control it creates?

        Also another general question how do you handle tab order between views?


        Thx
        Magnus

        Comment


        • #5
          Magnus,

          I think, if I remember correctly, the focus control is handled via the ApplicationPage and the giveFocusTo method, which transfers the focus to the control of the page component (ie the view implementation).

          As for tab ordering, I'm afraid I've never handled it. I personally don't use view tabbing very much (eg in eclipse) so I've never thought about it in my applications. Probably not the best answer eh, but then not one user has brought it up either.

          Jonny

          Comment


          • #6
            Jonny

            Still no luck with returning true from isEnabled. Is there anyway to get a source package for rich client. I guess maven has some task for it but do spring rich client support it?

            It f****ing frustating looking for all this issues when all you wanna do is program the damn thing, but i guess its away of learning :-) Buy the way have you noticed that spring rich client seems less active lately? It would be bad if it died out thats why I am asking

            Comment


            • #7
              Try calling setEnable(true) on your executor. The following code works for me:

              Code:
              protected void registerLocalCommandExecutors(PageComponentContext context) {
                  DeletCommandExecutor deleteExecutor = new DeleteCommandExecutor();
                  deleteExecutor.setEnabled(true);
                  context.register(GlobalCommandIds.DELETE, deleteExecutor);
              }
              Also, make sure you are not installing any guards that (unintentionally) disable the executor.


              hope this helps,

              Andrius

              Comment


              • #8
                Hi

                It was a foolish mistake from my side.

                1. I had a command named copyCommand
                2. In my Jide integration I forgott to fire focus changed when workspace was enabled.

                This leads me to the next question. I want my global commands to be set under security constraints. Where can I set that?

                Guys, thanks for your input it always helps alot. Especilly trying to get into something as complicated as spring rcp.

                Cheers
                Magnus

                Comment


                • #9
                  Take a look at org.springframewor.richclient.security package, there are classes that can be used to control activation of commands based on security context.

                  I think you should specify a securityControllerId for a command, and also define a security controller (for example, UserRoleSecurityController). A SecurityControllerManager instance should probably be created, too.

                  I have not used that myself yet, so it would be interesting to know whether it worked for you.

                  good luck,

                  Andrius

                  Comment


                  • #10
                    Andrius

                    Yes Im allready using that fior my other commands but I did not get it to work with AbstractActionCommandExecutor yet. But I'll get there. By the way it works excellent enabling/disabling commands using the Acegi security and Spring rich client. Just tell me if you want some hints.

                    Magnus

                    Comment


                    • #11
                      Magnus,

                      glad to hear you got it working but I have a question. Where, and why, do you have to fire a focus changed to get this to work with the JIDE integration? I don't have to fire any focus events to get the executor stuff to work fine.

                      Another point. Did you download the new JIDE integration code I committed last week (see http://forum.springframework.org/showthread.php?t=32115) as it contains some bug fixes specifically related to focus events. The executors are effected by these changes.

                      I've never uses the security integration with shared commands, but I guess I'd start with having an entry in the securityControllerMap of the securityControllerManager with the key being the shared command ID.

                      As for the getting the source, I usually connect to subversion directly and download from there.

                      Jonny

                      Comment


                      • #12
                        Jonny

                        I'll check out your changes but since I altered your integration alot, I dont have the editors at all only a workspace that is permanent, I don't know if it gives me to much.

                        The change I made is not really a change it was more a mistake from me where I had commented out some code I needed. It was in the ApplicationPage in the createDockableFrame method where you fire focus lost/gained when you docking frame receives the event. One thing though, I was expecting the view method registerLocalCommandExecutors(); to be enough to get the functionality I wanted where the commands are changed when the view looses/gains the focus. But it does not seem to work. Instead I have to register and unregister them in the focus lost/gained methods in each view. I remember a note about this before where the exact same behavior was wanted so i also did it that way. Thats also the reason the application page must fire focus lost/gained.


                        Yes I also get the source from subversion but i would like to include the source in my intellij roject so I can step into the code. So if there was a mvn src:src task it would be great.

                        About the security I thought that it would work the same for all commands since they implements the Security interfaces. I've noticed that the ObjectConfigurer is acctually using he security id to authorize the command but it does not work proper anyway. As I said I'l get there eventually I'll tell you when.

                        Magnus

                        Comment


                        • #13
                          Magnus,

                          Overriding the registerLocalCommandExecutors in your views should be enough, it's all I do. I certainly don't register and unregister the executors in the focus method and they work fine. This was tricky to get to work with the JIDE docking though, so maybe your modifications have effected that?

                          By the way, I'm curious, what functionality did you need that made you change the integration?

                          See what you mean about Maven and src:src. I'm not an Maven expert so can't really help you there.

                          Jonny

                          Comment


                          • #14
                            Jonny

                            I dont want editors at all I just want a workspace that is permanent. Offcause I could keep the editors and let all my selection end up in the same editor but the customer just wants a simple layout without the editors.

                            Ok maybe I managed to destroy the expected functionality when I changed your integration. In the ApllicationPage I haven't really changed anything when it comes to fireing focus hanged events. I expected the registerLocalCommandExecutors to work in such a way that when a view get the focus the framework will shift the local commands to the active view. Is there anything else you have done to get this to work that I have missed then?

                            Yeeah the mvn src:src would be helpfull but I haven't seen it working. We are working hard on getting the project structure in perfect condition so we can let the customers developers into it. As it is now it's impossible since spring rcp is changing alot and I need to keep up with the changes since so much new cool and usefull stuff keeps coming all the time. I just hope that spring rcp want die out because that would hurt us alot. I'm tinking about puttig some of so4it's (my company) people on it to get a higher understanding. We have seen that rich clients with Java Web start is a revlution for the customers and we are aiming at becoming the best suppliers on the technology in Stockholm/Sweden

                            Cheers
                            Magnus

                            Comment


                            • #15
                              Magnus,

                              I guess I still don't see why you need a workspace at all in this situation. Couldn't you turn off the workspace and use a normal view in it's place?

                              Your expectation with regards to registerLocalCommandExecutors and focus changing is correct, and that is what happens in my application, and the demo application.

                              It's hard to know where to look since I'm not sure what changes you made. As I mentioned, this took some effort to get working initially, but that was quite a while ago. The changes I submitted last week did change things as JIDE changes their focus event model a little. Also, I'm running against the release version (0.2.1) and not the 0.3 snapshot, I don't know if that makes a difference?

                              I'll dig into the code a little to refresh my memory and let you know what's needed to get this to work.

                              Jonny

                              Comment

                              Working...
                              X