setEnabled(!selection.isEmpty()&& !rootAdapter.isSelected());
}
@Override
public void run() {
VisualDesigner designer = getDesigner();
if(designer==null)
return;
CompositeAdapter rootAdapter = (CompositeAdapter) WidgetAdapter.getWidgetAdapter(designer.getRoot());
designer.getClipboard().clear();
for (Component child : designer.getSelectedComponents()) {
WidgetAdapter adapter = WidgetAdapter.getWidgetAdapter(child);
adapter.setHotspotPoint(new Point(child.getWidth()/2, child.getHeight()/2));
designer.getClipboard().add(adapter);
}
IOperationHistory operationHistory = PlatformUI.getWorkbench()
.getOperationSupport().getOperationHistory();
IUndoableOperation operation = new CutOperation(designer.getSelectedComponents());
operation.addContext(designer.getUndoContext());
try {
operationHistory.execute(operation, null, null);
} catch (ExecutionException e) {
VisualSwingPlugin.getLogger().error(e);
}
rootAdapter.doLayout();
designer.getRoot().validate();
designer.publishSelection();
designer.repaint();
}