PDA

View Full Version : Problem with splitting panels.



Daniels
28 Aug 2009, 9:31 AM
Hi folks. I have a problem and I don't know where it is.

I have a Viewport. In some point of the application, I must split the viewport area in two distinct areas, where the first area will contain the old Panels and the second will contain a new Panel. Both areas have same size. What I did to solve this problem? Well, my idea was create a new Panel, put the old Panels there, put this Panel in a center of Viewport, put the old Panel in the west and set height and width to 50%. I thought it'd have worked fine, but don't. The code I've used is this:



var owner = Ext.getCmp('viewport');
var compLayout = owner.getLayout()[dropRegion];
if(compLayout == undefined) {
var split = new Ext.Panel({
region: 'center'
});
var tam = owner.items.length;
for(i = 0; i < tam; i++) {
split.add(owner.getComponent(0));
}
owner.add(comp);
comp.height = "50%";
comp.width = "50%";
comp.region = dropRegion;
owner.add(split);
owner.contentChanged = true;
owner.doLayout();


This code results in a var split filling the whole area, and comp is doesn't displayed... The value of split.x is 5, when should be 50% of viewport +1. Anyone knows why it happens?

Ps.: Sorry for my bad English.

Animal
28 Aug 2009, 10:49 AM
What do the "Notes" say in the API docs for BorderLayout?

Daniels
28 Aug 2009, 11:21 AM
What do the "Notes" say in the API docs for BorderLayout?

The only item which maybe I'm doing wrong...


The regions of a BorderLayout are fixed at render time and thereafter, its child Components may not be removed or added. To add/remove Components within a BorderLayout, have them wrapped by an additional Container which is directly managed by the BorderLayout. If the region is to be collapsible, the Container used directly by the BorderLayout manager should be a Panel. In the following example a Container (an Ext.Panel) is added to the west region:

I put all components in the Viewport on a additional Container(wrapped in a var split). I create a new Panel, where i have sure which doesn't have any component in this region, because the test in third line guarantees me this. It's a Panel too.

I really don't see what is my mistake...

Animal
28 Aug 2009, 11:23 AM
Well you lost me there. Rewrite your code not to add new components to the Viewport, and try to explain what you want.

Daniels
28 Aug 2009, 11:46 AM
Well you lost me there. Rewrite your code not to add new components to the Viewport, and try to explain what you want.
I have a Viewport with your normal regions filled by Panels. If user wants, he can drag one of this Panels. What must occur when drop happens? All Panels(except the drop Panel) will going have just half of your original size. The other half is for dropped Panel.

Let me show an example:In figure A, if I drag the Panel 4 and drop him in right side(east), the Viewport must look like the figure B



EDIT(the forum trim the blanks, I add a attach file)

Any idea?

Animal
28 Aug 2009, 11:49 AM
Eclipse style panel dragging to drag a Panel and "dock" it into the north, south, east or west of an existing Panel?

It's a very difficult excercise that. Very.

Daniels
28 Aug 2009, 11:52 AM
Eclipse style panel dragging to drag a Panel and "dock" it into the north, south, east or west of an existing Panel?

It's a very difficult excercise that. Very.

Exactly. I need implement like Eclipse.

Daniels
28 Aug 2009, 12:06 PM
The Dock is almost complete, just need implement this part, which doesn't fit on the rest of logic.

Daniels
28 Aug 2009, 12:35 PM
Well, I did make some changes and now it works, but no 100%. Now the split occurs, but the Panel which suffer dnd don't is showed. Any idea for force a layout show the Panel? The code below doesn't work:



owner.add(split);
owner.add(comp);
owner.contentChanged = true;
owner.doLayout();