I am using SC_SNAPSHOT-2011-01-04/PowerEdition.
I am trying to override the getDropComponent method of PortalLayout to create a new Window to add rather than the button I drag to the layout. I can get this to work with I override the method in Layout, but cannot get it to work in PortalLayout.
Here is code to reproduce the problem:
When I drag the "drag me" button to the Layout canvas, it creates a new Window. When I drag the "drag me" button to the PortalLayout canvas, it drops the button. It seems to ignore the getDropComponent override.
I am trying to override the getDropComponent method of PortalLayout to create a new Window to add rather than the button I drag to the layout. I can get this to work with I override the method in Layout, but cannot get it to work in PortalLayout.
Here is code to reproduce the problem:
Code:
public void onModuleLoad()
{
final Canvas mainCanvas = new Canvas();
mainCanvas.setHeight100();
mainCanvas.setWidth100();
mainCanvas.setBackgroundColor("palegreen");
mainCanvas.addChild(createDragDropTester());
mainCanvas.draw();
}
private HLayout createDragDropTester()
{
final VLayout left = new VLayout();
left.setHeight100();
left.setWidth("20%");
left.setBackgroundColor("whitesmoke");
left.setMembersMargin(10);
IButton button = new IButton("drag me");
button.setCanDrag(true);
button.setCanDrop(true);
button.setDragAppearance(DragAppearance.OUTLINE);
button.setDragType("Portlet");
left.addMember(button);
final VLayout right = new VLayout();
right.setHeight100();
right.setWidth("*");
final Layout layout = new Layout() {
@Override
protected Canvas getDropComponent(Canvas dragTarget, int dropPosition) {
Canvas canvas = super.getDropComponent(dragTarget, dropPosition);
SC.logWarn("layout gDc:" + canvas.getClass());
final Window window = new Window();
window.setWidth(100);
return window;
// return canvas;
}
};
layout.setWidth100();
layout.setHeight100();
layout.setCanAcceptDrop(true);
layout.setCanDropComponents(true);
layout.setBackgroundColor("azure");
right.addMember(layout);
final PortalLayout playout = new PortalLayout(2) {
@Override
protected Canvas getDropComponent(Canvas dragTarget, int dropPosition) {
Canvas canvas = super.getDropComponent(dragTarget, dropPosition);
SC.logWarn("PLAYOUT gDc:" + canvas.getClass());
final Window window = new Window();
return window;
// return canvas;
}
};
playout.setWidth100();
playout.setHeight100();
playout.setCanAcceptDrop(true);
playout.setCanDropComponents(true);
playout.setBackgroundColor("beige");
right.addMember(playout);
final HLayout hlayout = new HLayout();
hlayout.setMargin(10);
hlayout.setWidth100();
hlayout.setHeight100();
hlayout.addMember(left);
hlayout.addMember(right);
return hlayout;
}
}
Comment