Smartpart Placeholder vs WorkItem isolation

Topics: CAB & Smart Client Software Factory
Mar 30, 2006 at 9:55 AM
originally posted by: turmelma


I am trying to figure out how to design my WorkItems now that I have found that SmartPartPlaceHolder requires the SmartPart to be held by the same WorkItem as the view where the PlaceHolder is found.

I've been building a CAB module which displays several views for various business entities relevant to the module (customers, invoices, etc.).
Each set of view(s) is currently encapsulated in a workitem so it can be reused eventually in other modules. So I got a CustomerWorkItem, InvoiceHistoryWorkItem, etc.
I have a kind of a "master" WorkItem that is run when the module is loaded. That workitem basically initializes some module-level services and launches child workitems for the default screen to be built up (i.e. by default the customer views are available from the start, so I run the CustomerWorkItem)

Now I'd like to put the CustomerView in a smartpart placeholder on my main workspace, which is a DockWorkspace (from Infragistics). Previously I coded a Show method on my "child" workitems (like CustomerWorkItem) to which I would pass the workspace on which to show smartparts. It seemed a good practice, I saw it widely used in community samples. That had the only disadvantage to let the workspace control where the smartpart is shown in it.

Then I tried using the place holder. Now I would have to do this kind of code in my CustomerWorkItem:


Which I feel is not a good practice, as it implies now that my CustomerWorkItem has a parent that would make use of the view. Moreover, my presenter would not be linked to the CustomerWorkItem anymore but to its parent, whatever it be.

I'd like to get some design tips and advice here.
- Should I go designing my WorkItems in a less granular way, so I can take advantage of the placeholders ? However I might get less Use-Case oriented, which I would much dislike.
- Maybe I should focus on reusability for Views (and presenters) rather than WorkItemsViewsPresenters ?
- Should the PlaceHolder be able to lookup through child workitem's smartparts ?

Any input welcome.
Mar 30, 2006 at 10:55 AM
originally posted by: matiaswoloski

Have you considered using the ZoneWorkspace. Personally I found it powerful than the SmartPartPlaceHolder because the SmartParts are replaced in the PlaceHolder during initialization and you can't do something like Workspace.Show( sp ) with SmartPartPlaceHolder. The ZoneWorkspace will give you that flexibility.

Here you have an implementation of a sample app using the ZoneWorkspace

Let me know if it helped,
Mar 30, 2006 at 11:07 AM
originally posted by: turmelma

Hi Matias,

In fact, I'm already using the Infragistics UltraDockWorkspace, because I want the docking behavior, which I won't get from ZoneWorkspace.

Inside the DockWorkspace, I want to be able to specify how a smartpart is to be displayed. For example, Customer is docked on the left, etc.

I could possibly do it through code but I fear it will take a great deal of it to accomplish the goal. That is why I turned to SmartPartPlaceholder. I can, at design time, put a placeholder for the CustomerView, for example, and dock it to the left on my DockWorkspace.

At least this way I can setup the app defaults for all my dockable panels without much effort. However I ended up with the reflections I presented in my previous post of this thread.

Mar 30, 2006 at 11:33 AM
originally posted by: matiaswoloski

Hi Marc-Andre,

I hven't used the UltraDockWorkspace from Infragistics, but I know it has a UltraDockSmartPartInfo which will allow you to define where in the DockWorkspace the SmartPart will be shown.

It has a DefaultLocation property of type DockedLocation (Left, Right, Bottom, Up). It also has a PreferredGroup which seems to be something to group DockPanes and show a SmartPart in the group.

So, you use this as follow:

UltraDockSmartPartInfo info = new UltraDockSmartPartInfo();
info.DefaultLocation = DockedLocation.Left;
WorkItem.Workspaces"MyDockWorkspace".Show( mySmartPart, info );

Alternatively, you can delegate to the View itself how it would be shown in the workspace

public class MyView : IMyView, ISmartPartInfoProvider
public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType) {
// if we are being shown inside a UltraDockWorkspace
if ( smartPartInfoType is UltraDockSmartPartInfo ) {
UltraDockSmartPartInfo info = new UltraDockSmartPartInfo();
info.DefaultLocation = DockedLocation.Left;
info.Title = "MyView";
return info;
} else {
// we are being shown in any other workspace
return new SmartPartInfo( "MyView", "MyView" );

Is that helps?

Mar 30, 2006 at 11:41 AM
originally posted by: turmelma

Hi Matias,

I had noticed the UltraDockSmartPartInfo, and could certainly make good use of it, however I'd have to programmatically create my dock groups beforehand. The control does not allow to create empty dock groups with the designer.

I know it sounds like being lazy, and it is, honestly. I'd hoped I could plug placeholders at design time and magic would have happened. :)

On the other side, modifying CAB so the smartpart lookup drills down the work item tree sounds like a bad idea and would probably destroy initialization performance, at best.

I'll continue studying my WorkItem architecture and also take a while looking at what I can do with UltraDockSmartPartInfo.

Any thoughts on WorkItem structure in this context ?
Mar 31, 2006 at 5:09 AM
originally posted by: matiaswoloski

I think that reusing at View level is a good approach. When designing a Smart Client application I separate them in logical applications. Each logical app is a container for modules, views, client side business logic and services.

My solution explorer looks like this

- Logical App1 (Solution Folder)
|- Module1
|- Module2
|- LogicalApp1Views
|- LogicalApp1BusinessRules
|- LogicalApp1Services
- Logical App2

The module is a set of WorkItems which are light weight containers that will orchestrate Views.

Anyway, I think that you should take a further look at the UltraDockWorkspace. Maybe the Infragistics guys want to jump here?

Mar 31, 2006 at 7:39 AM
originally posted by: turmelma

After another series of discussions with colleagues I am rethinking about WorkItem isolation and possible reuse (in certain situations but not at all costs).

Thanks for your input about how you divide your things in your projects.

I've passed a few moments trying to make the UltraDockSmartPartInfo to work; it's working for most of what I use, except for the Pinned status that is not exposed by it. Might figure out a way to work around it.
Definitely getting Infragistics people in the loop at this point.