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()) {
Component child = wa.getParentContainer();
children.add(child);
new_constraints.add(((CompositeAdapter) adapter).getChildConstraints(child));
}
IUndoableOperation operation = new MoveResizeOperation(lastParent, ((CompositeAdapter) adapter), 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) adapter, wa);
for (IWidgetListener listener : widgetListeners) {
listener.widgetResized(we);
}
}
}