How to access the MDIWorskpace in my Shell

Topics: CAB & Smart Client Software Factory
Oct 12, 2005 at 4:33 PM
originally posted by: Darrenarbell

Hi All
I'm having severe problems getting a reference to my mdiworkspace in my shell from workitems that are in a different module. During the LoadModules method of the CABApplication the workspace does not appear to be in the Workspaces collection, meaning I can reference it at this point.
Can anyone point me in the right direction for getting a reference to this.
Also when are the workpaces of the shell added to the wworkspaces of the workitem.

Many thanks. Its late here and if I'm being a bit simple let me know.

Cheers
Oct 13, 2005 at 5:12 AM
originally posted by: DLorenz

The Shell will send all of its Workspaces into the Module Init class of the Module. There, you send the appropraite Workspaces into the Workitem. You must use the same name you used in the Shell for the Workspace, or it won't work correctly. You may want to put a break point right before the workitem.run in the module init and check the Workspace.Count to make sure they are getting through.
Oct 13, 2005 at 7:54 AM
originally posted by: jolu1977

First off refer the the BankTellerShell of the CTP2 drop. Notice the Constructor injection. Set up your Shell using the constructor injection and then use the workitem in the constructor to manually add the workspace to the workspaces collection.

Remember to fill in the "Name" property of the MdiWorkspace after adding it to the form.

After that you can get the workspace by name.

We will be looking at a better way to do this instead of manually.

Hope this helps.
Oct 13, 2005 at 9:02 AM
originally posted by: Darrenarbell

Thanks for the help. My own solution to the problem was to add the workspace to the RootItem during the FormShellApplication override AfterShellCreated. But, your method is a superior approarch using constructor DI. Unfortunately though, I can't use the same name to add the workspace as later during the OnLoad of the Shell it fires OnContainerLoaded for the workspace which then tries to add itself to the workitem again (in this case and my original). I justed named it differently when I added it. I know this isn't eligant as I have the same item twice with different keys.
Also, as I'm sure your aware giving the form(Smartpart) knowledge of the Workitem moves away from the programming model suggested in CAB. Not that it bothers me greatly, just something that I noticed.
I have it working now, so thats great!

Cheers
Oct 13, 2005 at 10:33 AM
originally posted by: jolu1977

Yes, I realize the whole exposing a smartpart to a workitem situation. That is why my example of the BankTeller is using the Shell form. The Shell can publish well known workspaces for other workitems to use. You are correct that for smart parts this is not a good idea.

So the way I personally use the component based workspaces (window and mdi) is I add them in my workitem and not on a form or usercontrol. Since the workitem is the usecase it knows if a mdiworkspace will be needed and can add it if/when it is needed.

Some more info:
http://luifit.net/blogs/jluif/PermaLink.aspx?guid=2b17f027-c149-4cb9-a7f2-222ab7999bca

We will be looking into how the component workspace is using the OnContainerLoaded.
Oct 14, 2005 at 3:01 AM
originally posted by: Darrenarbell

Thanks for the information. It has enlightened me considerable. As suggested I've moved my worskpace directly into the Workspaces of my RootWorkItem, thus avoiding the name clash(as no longer part of the shell), which I'm a lot happier with.

Again, thankyou very much for the help and pointers. Keep up the excellant work.