I'd like to be able to create portlets at runtime by dragging items onto a portal layout like shown in http://www.smartclient.com/#portletContentsDragging & http://www.smartclient.com/#portal on the examples site. But It won't work.
I've created a menu button with a menu that contains a couple MenuItems for testing. Then in the PortalLayout I've overriden getDropPortlet to create a portlet based on which menu item was dragged. The problem is that the MenuItem is not whats being dragged instead its the entire menu, so in getDropPortlet I have no idea which type of portlet to create. I can create an empty portlet and add it but its not related to the menuItem. I've tried menu.getDragData() but that either returns null or all of the records of a menu. Any advice or suggestions would be appreciated.
GWT 2.4, SmartGWTEE 3.0p
Thanks,
Chris
I've created a menu button with a menu that contains a couple MenuItems for testing. Then in the PortalLayout I've overriden getDropPortlet to create a portlet based on which menu item was dragged. The problem is that the MenuItem is not whats being dragged instead its the entire menu, so in getDropPortlet I have no idea which type of portlet to create. I can create an empty portlet and add it but its not related to the menuItem. I've tried menu.getDragData() but that either returns null or all of the records of a menu. Any advice or suggestions would be appreciated.
GWT 2.4, SmartGWTEE 3.0p
Thanks,
Chris
Code:
public Canvas getDropPortlet(Canvas dragTarget, Integer colNum, Integer rowNum, Integer dropPosition) {
if (dragTarget.getID() == "ConfigureMenu") {
//In here I need to know what menu Item was dragged into the PortalLayout but right now its just the entire menu
Menu dragMenu = (Menu)dragTarget;
Record[] recs = dragMenu.getDragData();
return new Portlet();
}
else
return super.getDropPortlet(dragTarget, colNum, rowNum, dropPosition);
}
Code:
MenuButton menuBtn = new MenuButton("Configure Layout");
menuBtn.setSnapTo("BR");
Menu configureMenu = new Menu();
configureMenu.setID("ConfigureMenu");
configureMenu.setDragType("Portlet");
configureMenu.setAnimateFadeTime(250);
configureMenu.setShowAnimationEffect("slide");
configureMenu.setCanDragRecordsOut(true);
configureMenu.setSelectionType(SelectionStyle.SIMPLE);
MenuItem mi = new MenuItem("Chart");
mi.setCanDrag(true); //this has no affect
MenuItem mi2 = new MenuItem("Table");
configureMenu.addItem(mi);
configureMenu.addItem(mi2);
configureMenu.setDragDataAction(DragDataAction.COPY);
configureMenu.addDragStartHandler(new DragStartHandler() {
@Override
public void onDragStart(DragStartEvent event) {
Menu menu = (Menu)event.getSource();
//menu.selectRecord(0);
menu.animateHide(AnimationEffect.FADE, new AnimationCallback () {
@Override
public void execute(boolean earlyFinish) {
Menu.hideAllMenus();
}
});
}
});
menuBtn.setMenu(configureMenu);
Comment