Search in sources :

Example 1 with RemoveMultipleShuttersCommand

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;
}
Also used : Window(org.concord.energy3d.model.Window) ArrayList(java.util.ArrayList) RemoveMultipleShuttersCommand(org.concord.energy3d.undo.RemoveMultipleShuttersCommand) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

ArrayList (java.util.ArrayList)1 Foundation (org.concord.energy3d.model.Foundation)1 HousePart (org.concord.energy3d.model.HousePart)1 Window (org.concord.energy3d.model.Window)1 RemoveMultipleShuttersCommand (org.concord.energy3d.undo.RemoveMultipleShuttersCommand)1