Adding a new SingleCDockablePerspective to an existing CPerspective

Hi Beni,

A ‘How to’ question on perspectives. How do I dynamically add a newly created SingleCDockablePerspective after the application launch is complete, and doing so without disturbing any of the existing docakbles /perspective locations?

The idea is that once the application is up and running, the user has the option to load a new custom module that requires a new dockable and perspective to be created and installed inside a target CPerspective. Also, the user has the option to remove this module and therefore its associated dockable /perspective from the target CPerspective at a later time. Both these activities need to be achieved without disturbing the status quo within DF.

The ‘Perspectives (History)’ example under ‘Examples from the guide’ of Common API in the Tutorials is an excellent example and very similar to my current approach. All works well when my application fires up, but when I later add a new dockable along with its new perspective using similar concepts to the mentioned example, the dockable does show up correctly inside its target CPerspective, but some of the other existing dockables now change form ‘normalized’ to their ‘minimized’ locations. The second observation is that the same new dockable /perspective also shows up inside another different CPerspective when it should not.

I am very close to what I need to achieve, so any advice would be greatly appreciated. Thank you.

That’s a use case I never even considered. I’ll have to try this myself (probably during the next weekend). I would have assumed getting new CPerspectives from the CControl, modify them, and write them back should do the trick. You do something similar? You have any code that shows how you modify the existing perspectives?

About the showing up in the wrong perspective: the new Dockables are closeable?

Currently I have no idea why existing Dockables should change their state (normalized to minimized). Are you updating their position as well? Are they perhaps two times stored in the perspective? Are you rewriting their history? Are they stacked (grouped) with other Dockables? An example would really help here.

Thanks Beni.

Your check list helped me find and fix the issue which was in my code. After firing up the application, I wrongly created a new SingleCDockablePerspective to re-set the the dockables of interest:

Vorformatierter TextCMinimizePerspective launchCurrentSouthMinimize = explorerPerspective.getContentArea().getSouth();
SingleCDockablePerspective searchDockPerspective = new SingleCDockablePerspective(InitializeSingleCDock.SEARCH_DOCK_ID); //Wrong! Leads to unwanted result.Vorformatierter Text

The fix in my case is instead of creating a new SingleCDockablePerspective, I should have refereced the original SingleCDockablePerspective objects used during the application launch:

Vorformatierter TextCMinimizePerspective launchCurrentSouthMinimize = explorerPerspective.getContentArea().getSouth();
launchCurrentSouthMinimize.add(searchDockPerspective); //Correct! Reference the original ‚searchDockPerspective‘ instead of creating a new one.Vorformatierter Text

I have two other use cases related to this area (dynamic loading /unloading of custom modules) which I will need to test later on when my development reaches there (4 to 6 weeks). :slight_smile:

As always, thank you for your help.

Glad to help, especially when you do all the hard work yourself :grin: