WorkItem.GetSmartPartInfo(object smartPart)

Topics: CAB & Smart Client Software Factory
Jul 8, 2006 at 2:17 AM
originally posted by: Jochen_Dedte

I wish to retrieve the SmartPartInfo currently used for a certain smartpart.

I found no Workspace method or property which could help me out. The WorkItem does seem to provide that functionality through
WorkItem.GetSmartPartInfo<TSmartPartInfo>(object smartPart).

However, after a few tests with some different Workspaces, the result of GetSmartPartInfo always is null.

My test workitem instantiates and displays the smartpart as follows:

protected override void OnRunStarted()
{
base.OnRunStarted();

view = this.SmartParts.AddNew<TestView>();

SmartPartInfo spi = new SmartPartInfo("Test workitem " + id.ToString(), "Just a view on workitem " + id.ToString() + '.');

this.WorkspacesWORKSPACE.Show(view, spi);
}

Clearly, a SmartPartInfo is used.

I tried this on a DeckWorkspace, a TabWorkspace and a custom made Workspace. The result always is the same:

RootWorkItem.SmartPartInfos.Count == 0 (Which results in GetSmartPartInfo returning null.)

Does anybody have a clue how to make sure the smartpartinfos are registered? Or is there another way to retrieve the currently used smartpartinfo for a certain smartpart?

Thanks for any help!

Jochen
Jul 9, 2006 at 2:39 PM
originally posted by: jburkholder

You can implement ISmartPartInfoProvider in your smart parts. You then will not have to pass SmartPartInfo when you do a Workspace.Show and can pull the SmartPartInfo out of the smart part by using the interface.
Jul 10, 2006 at 9:19 PM
originally posted by: Jochen_Dedte

Yes, that is true, but it is a workaround and does not solve the problem.

The question still is why my SmartPartInfos aren't registered in the RootWorkItem. Or, formulated differently: how can you make WorkItem.GetSmartPartInfo work?

I don't get any results using my own custom Workspace, nor by using the standard CAB Workspaces...

Jochen
Jul 11, 2006 at 4:37 AM
originally posted by: juemue

Hi,

which kind of Workspace are you using?
All Workspaces of CAB which need a SmartPartInfo provide a component which you can drop on your control (e.g. TabSmartPartInfo or ZoneSmartPartInfo). If you do that, some code will be generated to provide access to the ISmartPartInfo object.

Regards

Jürgen
Jul 11, 2006 at 9:09 PM
originally posted by: Jochen_Dedte

Yes, but that is again modifying the SmartPart. I would have guessed that the Workspace would be responsible for storing the currently used SmartPartInfo for a certain SmartPart.

Maybe I should ask my question this way:

I there any link between a SmartPart being shown with Workspace.Show(object smartPart, ISmartPartInfo spi) and retrieving SmartParts using WorkItem.GetSmartPartInfo(object smartPart)?

Does a SmartPart need to be an ISmartPartInfoProvider for this to work?

Thanks,

Jochen
Jul 12, 2006 at 6:49 AM
originally posted by: juemue

> Yes, but that is again modifying the SmartPart.
Why is it a probelem for you to modify your SmartParts?

> I would have guessed that the Workspace would be responsible for storing the currently used SmartPartInfo for a certain SmartPart.
ISmartPartInfo can be stored at the SmartPart and it is used by the Workspace any time the Smartpart is shown in the Workspace.
If you want to save property values of your SmartPart and restore tehm the next time your app starts (e.g. window size and location) you have to add some code to your Workspace. The Workspaces provided by the CAB doesn't support this.

> Maybe I should ask my question this way:
>
> I there any link between a SmartPart being shown with Workspace.Show(object smartPart, ISmartPartInfo spi) and retrieving SmartParts using WorkItem.GetSmartPartInfo(object smartPart)?

Sorry. I didn't get you.....


> Does a SmartPart need to be an ISmartPartInfoProvider for this to work?
A SmartPart doesn't have to implement ISmartPartInfoProvider. But thats a good way to store and provide the information a Worspace needs (or expects) to show the SmartPart in a proper way (e.g. Caption, Location, Size...)

Thanks,

Jochen
Jul 18, 2006 at 5:23 PM
originally posted by: askew

Here's an example of using the interface and registering smartparts with the rootworkitem, from Matais.

http://staff.southworks.net/blogs/matiaswoloski/default.aspx
Jul 26, 2006 at 5:58 AM
originally posted by: JKraft4PIT

I think you can only get the smart part info from the Wrokspaces collection.

Have you tried Rootworkitem.Workspaces("my workspace i want info from").getsmartpartinfo()?