|| (items.size() == 1
&& !(items.get(0) instanceof Compass))) {
// Always use selection mode after a drop or a paste operation
getPlanController().setMode(PlanController.Mode.SELECTION);
// Start a compound edit that adds walls, furniture, rooms, dimension lines and labels to home
UndoableEditSupport undoSupport = getUndoableEditSupport();
undoSupport.beginUpdate();
List<HomePieceOfFurniture> addedFurniture = Home.getFurnitureSubList(items);
// If magnetism is enabled, adjust furniture size and elevation
if (this.preferences.isMagnetismEnabled()) {
for (HomePieceOfFurniture piece : addedFurniture) {
if (piece.isResizable()) {
piece.setWidth(this.preferences.getLengthUnit().getMagnetizedLength(piece.getWidth(), 0.1f));
piece.setDepth(this.preferences.getLengthUnit().getMagnetizedLength(piece.getDepth(), 0.1f));
piece.setHeight(this.preferences.getLengthUnit().getMagnetizedLength(piece.getHeight(), 0.1f));
}
piece.setElevation(this.preferences.getLengthUnit().getMagnetizedLength(piece.getElevation(), 0.1f));
}
}
getPlanController().moveItems(items, dx, dy);
if (isDropInPlanView
&& this.preferences.isMagnetismEnabled()
&& items.size() == 1
&& addedFurniture.size() == 1) {
// Adjust piece when it's dropped in plan view
getPlanController().adjustMagnetizedPieceOfFurniture((HomePieceOfFurniture)items.get(0), dx, dy);
}
getPlanController().addFurniture(addedFurniture);
getPlanController().addWalls(Home.getWallsSubList(items));
getPlanController().addRooms(Home.getRoomsSubList(items));
getPlanController().addDimensionLines(Home.getDimensionLinesSubList(items));
getPlanController().addLabels(Home.getLabelsSubList(items));
this.home.setSelectedItems(items);
// Add a undoable edit that will select all the items at redo
undoSupport.postEdit(new AbstractUndoableEdit() {
@Override
public void redo() throws CannotRedoException {
super.redo();
home.setSelectedItems(items);
}
@Override
public String getPresentationName() {
return preferences.getLocalizedString(HomeController.class, presentationNameKey);
}
});
// End compound edit
undoSupport.endUpdate();
}
}