if (state == STATE_BEAN_HOVER) {
Component hovered = designer.componentAt(p, 0);
if (hovered != null) {
WidgetAdapter adapter = WidgetAdapter.getWidgetAdapter(hovered);
if (isDroppingPopup()) {
IDesignOperation design = (IDesignOperation) adapter.getAdapter(IDesignOperation.class);
design.drop(adapter.convertToLocal(p));
} else {
if (!(adapter instanceof CompositeAdapter)) {
adapter = adapter.getParentAdapter();
}
CompositeAdapter compositeAdapter = (CompositeAdapter) adapter;
hoveredAdapter = compositeAdapter;
IDesignOperation design = (IDesignOperation) hoveredAdapter.getAdapter(IDesignOperation.class);
if (design != null && design.drop(compositeAdapter.convertToLocal(p))) {
if (lastParent != null) {
IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
List<Component> children = new ArrayList<Component>();
List<Object> new_constraints = new ArrayList<Object>();
for (WidgetAdapter wa : designer.getSelectedWidget()) {
Component child = wa.getParentContainer();
children.add(child);
new_constraints.add(compositeAdapter.getChildConstraints(child));
}
IUndoableOperation operation = new MoveResizeOperation(lastParent, compositeAdapter, children, lastConstraints, new_constraints);
operation.addContext(designer.getUndoContext());
try {
operationHistory.execute(operation, null, null);
} catch (ExecutionException e) {
VisualSwingPlugin.getLogger().error(e);
}
for (WidgetAdapter wa : designer.getSelectedWidget()) {
WidgetEvent we = new WidgetEvent(lastParent, compositeAdapter, wa);
for (IWidgetListener listener : widgetListeners) {
listener.widgetMoved(we);
}
}
} else {
for (WidgetAdapter wa : designer.getSelectedWidget()) {
WidgetEvent we = new WidgetEvent(compositeAdapter, wa);
for (IWidgetListener listener : widgetListeners) {
listener.widgetAdded(we);
}
}
}
designer.fireDirty();
adapter.addNotify();
} else {
if (lastParent != null) {
List<WidgetAdapter> selectedWidget = designer.getSelectedWidget();
for (int i = 0; i < selectedWidget.size(); i++) {
WidgetAdapter wa = selectedWidget.get(i);
Object constraints = lastConstraints.get(i);
lastParent.addChildByConstraints(wa.getWidget(), constraints);
}
}
}
}
} else {
glassPlane.setHotspotPoint(null);
if (lastParent != null) {
IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
List<Component> children = new ArrayList<Component>();
for (WidgetAdapter wa : designer.getSelectedWidget()) {
children.add(wa.getParentContainer());
}
IUndoableOperation operation = new DragDropOperation(lastParent, children, lastConstraints);
operation.addContext(designer.getUndoContext());
try {
operationHistory.execute(operation, null, null);
} catch (ExecutionException e) {
VisualSwingPlugin.getLogger().error(e);
}
lastParent.setDirty(true);
designer.fireDirty();
for (WidgetAdapter wa : designer.getSelectedWidget()) {
WidgetEvent we = new WidgetEvent(lastParent, wa);
for (IWidgetListener listener : widgetListeners) {
listener.widgetRemoved(we);
}
}
}
}
} else if (currentAdapters != null) {
WidgetAdapter adapter = currentAdapters.get(0);
hoveredAdapter = adapter;
IDesignOperation design = (IDesignOperation) hoveredAdapter.getAdapter(IDesignOperation.class);
if (design != null && design.drop(adapter.convertToLocal(p))) {
if (lastParent != null) {
IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
List<Component> children = new ArrayList<Component>();
List<Object> new_constraints = new ArrayList<Object>();
for (WidgetAdapter wa : designer.getSelectedWidget()) {