diff --git a/src/org/klesun_model/SnapshotStorage.java b/src/org/klesun_model/SnapshotStorage.java index 1d52fed..54c205c 100755 --- a/src/org/klesun_model/SnapshotStorage.java +++ b/src/org/klesun_model/SnapshotStorage.java @@ -6,6 +6,7 @@ import com.google.common.collect.EvictingQueue; import org.json.JSONObject; +import org.shmidusic.sheet_music.SheetMusic; import java.util.ArrayDeque; import java.util.Deque; @@ -34,11 +35,13 @@ public void add(JSONObject snapshot) public Explain undo() { - if (snapshots.size() >= 2) { + if (!snapshots.isEmpty()) { JSONObject current = snapshots.pollLast(); redoSnapshots.add(current); - return new Explain<>(snapshots.peekLast()); + return new Explain<>(!snapshots.isEmpty() + ? snapshots.peekLast() + : new SheetMusic().getJsonRepresentation()); } else { return new Explain<>(false, "Here History Starts"); } diff --git a/src/org/shmidusic/MajesticWindow.java b/src/org/shmidusic/MajesticWindow.java index d3d5430..cb592c6 100755 --- a/src/org/shmidusic/MajesticWindow.java +++ b/src/org/shmidusic/MajesticWindow.java @@ -20,6 +20,7 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.KeyEvent; import java.util.*; import java.util.List; @@ -116,7 +117,12 @@ private JMenuItem makeActionMenuItem(Combo key, ContextAction action, Class cls) // the Great idea behind this is to refresh menu bar each time we change focus // i.e. when we're pointing note we have Menus: [BlockSpace, Scroll, staff, chord, note], when Paragraph - [BlockSpace, Scroll, article, Paragraph] etc - public void updateMenuBar() { - + public void updateMenuBar() + { menus.values().forEach(m -> { m.setEnabled(false); m.setToolTipText("Instance Not Focused");