diff --git a/FormMapWithSetArtilleries.java b/FormMapWithSetArtilleries.java index 2491a0c..552512b 100644 --- a/FormMapWithSetArtilleries.java +++ b/FormMapWithSetArtilleries.java @@ -155,15 +155,12 @@ 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()); - dialog.setSize(800, 500); - dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); - dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + FormArtillery dialog = new FormArtillery(deletedObjects.empty() ? null : ((DrawingObjectArtillery)deletedObjects.pop()).getArtillery()); + dialog.setSize(800, 500); + dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - dialog.setVisible(true); - } + dialog.setVisible(true); }); buttonLeft.addActionListener(e -> { 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; + } }