diff --git a/FormMapWithSetArtilleries.java b/FormMapWithSetArtilleries.java index 8b1f3e4..4c8e966 100644 --- a/FormMapWithSetArtilleries.java +++ b/FormMapWithSetArtilleries.java @@ -154,12 +154,14 @@ public class FormMapWithSetArtilleries extends JFrame { buttonShowDeleted.addActionListener(e -> { if (!deletedObjects.empty()) { DrawingObjectArtillery deleted = (DrawingObjectArtillery) deletedObjects.pop(); - FormArtillery dialog = new FormArtillery(deleted == null ? null : deleted.getArtillery()); + FormArtillery dialog = new FormArtillery(deleted.getArtillery()); dialog.setSize(800, 500); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); + } else { + JOptionPane.showMessageDialog(this, "Стек удалённых объектов пуст", "Провал", JOptionPane.INFORMATION_MESSAGE); } }); diff --git a/MapWithSetArtilleriesGeneric.java b/MapWithSetArtilleriesGeneric.java index 826e6d4..3c2774f 100644 --- a/MapWithSetArtilleriesGeneric.java +++ b/MapWithSetArtilleriesGeneric.java @@ -7,7 +7,7 @@ public class MapWithSetArtilleriesGeneric _setArtilleries; + public final SetArtilleriesGeneric _setArtilleries; private final U _map; public MapWithSetArtilleriesGeneric(int picWidth, int picHeight, U map) { diff --git a/MapsCollection.java b/MapsCollection.java index 95b6399..5b9f24c 100644 --- a/MapsCollection.java +++ b/MapsCollection.java @@ -30,4 +30,12 @@ public class MapsCollection { public MapWithSetArtilleriesGeneric getMap(String name) { return _mapsStorage.getOrDefault(name, null); } + + public IDrawingObject getArtillery(String mapName, int index) { + var map = _mapsStorage.getOrDefault(mapName, null); + if (map != null) { + return map._setArtilleries.get(index); + } + return null; + } }