* @see #restoreSelectedWidgetsLocation()
*/
protected void saveSelectedWidgetsLocationAndStyle() {
savedWidgetInfoMap = new HashMap();
for (Iterator iterator = context.selectedWidgets.iterator(); iterator.hasNext();) {
Widget widget = (Widget) iterator.next();
SavedWidgetInfo info = new SavedWidgetInfo();
info.initialDraggableParent = widget.getParent();
// TODO simplify after enhancement for issue 1112 provides InsertPanel interface
// http://code.google.com/p/google-web-toolkit/issues/detail?id=1112
if (info.initialDraggableParent instanceof AbsolutePanel) {
info.initialDraggableParentLocation = new WidgetLocation(widget,
info.initialDraggableParent);
} else if (info.initialDraggableParent instanceof HorizontalPanel) {
info.initialDraggableIndex = ((HorizontalPanel) info.initialDraggableParent).getWidgetIndex(widget);
} else if (info.initialDraggableParent instanceof VerticalPanel) {
info.initialDraggableIndex = ((VerticalPanel) info.initialDraggableParent).getWidgetIndex(widget);
} else if (info.initialDraggableParent instanceof FlowPanel) {
info.initialDraggableIndex = ((FlowPanel) info.initialDraggableParent).getWidgetIndex(widget);
} else if (info.initialDraggableParent instanceof SimplePanel) {
// save nothing
} else {
throw new RuntimeException(
"Unable to handle 'initialDraggableParent instanceof "
+ GWT.getTypeName(info.initialDraggableParent)
+ "'; Please create your own DragController and override saveDraggableLocationAndStyle() and restoreDraggableLocation()");
}
info.initialDraggableMargin = DOM.getStyleAttribute(widget.getElement(), "margin");
DOM.setStyleAttribute(widget.getElement(), "margin", "0px");
savedWidgetInfoMap.put(widget, info);
}
}