use of org.concord.energy3d.undo.RemoveMultipleShuttersCommand in project energy3d by concord-consortium.
the class Scene method removeAllWindowShutters.
public void removeAllWindowShutters() {
final ArrayList<Window> windows = new ArrayList<Window>();
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart != null) {
final Foundation foundation = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
for (final HousePart part : parts) {
if (part instanceof Window && !part.getLockEdit() && part.getTopContainer() == foundation) {
final Window w = (Window) part;
if (w.getLeftShutter() || w.getRightShutter()) {
windows.add(w);
}
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof Window && !part.getLockEdit()) {
final Window w = (Window) part;
if (w.getLeftShutter() || w.getRightShutter()) {
windows.add(w);
}
}
}
}
if (windows.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no window shutter to remove.", "No Shutter", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + windows.size() + " window shutters" + (selectedPart != null ? " of the selected building" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultipleShuttersCommand c = new RemoveMultipleShuttersCommand(windows);
for (final HousePart part : windows) {
final Window w = (Window) part;
w.setLeftShutter(false);
w.setRightShutter(false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
Aggregations