I have the same problem as vjr… I have the same exception when I remove my DefaultSingleCDockable of the CController… I am using the version 1.0.8… So I have downloaded the last version…
I add my dockable using the add method of the CGrid in order to stack my dockable windows. And I use the remove method of the CController… OK, I no longer have the exception!
But if I want to add a second time the dockable with the same ID, 2 dockable windows are displayed with the same title tab… :mad:. When I remove the dockable, I wouldn’t like references in the CControl or something like that… Is it possible?
It could be, that you only remove the Dockable from the CControl, but missed to make it invisible (call “setVisible(false)”). The Dockable would remain in the tree, just without any meta information.
If there are two tabs than there have to be two Dockables. But the framework should not allow you to register two Dockables with the same id, so this is a contradiction.
I would need to know exactly which methods you call in which order to give you a better answer.
where my class is an instance of CGrid and closeable equals to true
Then, to remove the dockable, I am using this code:
DefaultSingleCDockable dock = null;
//Go throw my dockable
for(int i=0; i<controller.getCDockableCount(); i++) {
CDockable dockable = controller.getCDockable(i);
//Search the dockable that I want to close
if(((DefaultSingleCDockable)dockable).getUniqueId().equals(confSet.getID())) {
//dockable found
dock = (DefaultSingleCDockable)dockable;
break;
}
}
//Hide the dockable and remove it of the CController
dock.setVisible(false);
controller.remove(dock);
Then, the second time where I add the dockable, two tabs are opened. The first one can not be closeable but the second can be.
Are you using the same CGrid again to add the Dockable? If yes: the first Dockable is still in the grid, but it is no longer registered at the CControl because you removed it. But if you deploy the CGrid again, it gets visible again. Don’t use a CGrid for anything else then building the initial layout, it does never get cleared.
To precize my last post, I create my CController, I initialize my CGrid with 2 dockables and I deploy the my CGrid using the method getContentArea().deploy(grid) where grid is my CGrid instance. That’s the code for the setup of my application.
After, I need to add and remove dockables dynamically. If I had correctly understood your last post, I must not deploy a second time the CGrid. But, I don’t know how I can add new dockable to my initial CControlller… is it possible to give a little example?
DefaultSingleCDockable dockable = new MyDockable...
// find the CControl of your application
CControl control = ...
// register the dockable, allow control to collect and store meta data for "dockable"
control.addDockable( dockable );
// (optional) set the initial location, for example in the normalized area at the north end taking 25% space
dockable.setLocation( CLocation.base().normalNorth( 0.25 ) );
// make the dockable visible
dockable.setVisible( true );
After using the addDockable in myCControl, how can I update the SingleCDockableListMenuPiece associated to my CControl in order to show the new menu associated to my Dockable? The SingleCDockableListMenuPiece was added to the initialization to my frame into a RootMenuPiece…
I have forgot something in my last thread… For the moment, I call the method setControll on my SingleCDockableListMenuPiece. The menu item is updated!!!
But when I close my dockable using the red cross, if I want to display it again using the SingleCDockableListMenuPiece, nothing append… The dockable is not displayed…
Have you an idea?
There is no difference with your code except the initialization of the SingleCDockableListMenuPiece. When the SingleCDockableListMenuPiece is invoked, my CControl is not instantiated. So I invoke the constructor with null as parameter and when I create a new dockable, I add it to the CControl and set the CControl to the SingleCDockableListMenuPiece using the setControl method of the SingleCDockableListMenuPiece class…
Sorry for not answering so long. Calling “setControl” later does not change the behavior of my application. Currently I don’t know what is going wrong.
Can you write me a small example that reproduces the bug, or somehow extract the code from your application? It looks as if some listeners are not installed correctly, are you perhaps using some unfortunate combination of submenus?