Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
ObjEditor.java
....@@ -282,6 +282,12 @@
282282 client = inClient;
283283 copy = client;
284284
285
+ if (copy.versions == null)
286
+ {
287
+ copy.versions = new byte[100][];
288
+ copy.versionindex = -1;
289
+ }
290
+
285291 // "this" is not called: SetupUI2(objEditor);
286292 }
287293
....@@ -295,6 +301,12 @@
295301 client = inClient;
296302 copy = client;
297303
304
+ if (copy.versions == null)
305
+ {
306
+ copy.versions = new byte[100][];
307
+ copy.versionindex = -1;
308
+ }
309
+
298310 SetupUI2(callee.GetEditor());
299311 }
300312
....@@ -327,6 +339,12 @@
327339 copy = localCopy;
328340 copy.editWindow = this;
329341
342
+ if (copy.versions == null)
343
+ {
344
+ copy.versions = new byte[100][];
345
+ copy.versionindex = -1;
346
+ }
347
+
330348 SetupMenu();
331349
332350 //SetupName(objEditor); // new
....@@ -3731,18 +3749,42 @@
37313749 cButton replaceButton;
37323750 cButton redoButton;
37333751
3752
+ boolean muteSlider;
3753
+
3754
+ int VersionCount()
3755
+ {
3756
+ int count = 0;
3757
+
3758
+ for (int i = copy.versions.length; --i >= 0;)
3759
+ {
3760
+ if (copy.versions[i] != null)
3761
+ count++;
3762
+ }
3763
+
3764
+ return count;
3765
+ }
3766
+
37343767 void SetUndoStates()
37353768 {
37363769 cRadio tab = GetCurrentTab();
37373770
37383771 restoreButton.setEnabled(copy.versionindex != -1);
37393772 replaceButton.setEnabled(copy.versionindex != -1);
3773
+
37403774 undoButton.setEnabled(copy.versionindex > 0);
37413775 redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3776
+
3777
+ muteSlider = true;
3778
+ versionSlider.setMaximum(VersionCount() - 1);
3779
+ versionSlider.setInteger(copy.versionindex);
3780
+ muteSlider = false;
37423781 }
37433782
37443783 public boolean Undo()
37453784 {
3785
+ // Option?
3786
+ Replace();
3787
+
37463788 System.err.println("Undo");
37473789
37483790 cRadio tab = GetCurrentTab();
....@@ -3809,6 +3851,9 @@
38093851
38103852 public void Redo()
38113853 {
3854
+ // Option?
3855
+ Replace();
3856
+
38123857 cRadio tab = GetCurrentTab();
38133858
38143859 if (copy.versions[copy.versionindex + 1] == null)
....@@ -4118,14 +4163,17 @@
41184163 //copy.Touch();
41194164 }
41204165
4121
- cNumberSlider versionField;
4166
+ cNumberSlider versionSlider;
41224167
41234168 public void stateChanged(ChangeEvent e)
41244169 {
41254170 // assert(false);
4126
- if (e.getSource() == versionField)
4171
+ if (e.getSource() == versionSlider)
41274172 {
4128
- int version = versionField.getInteger();
4173
+ if (muteSlider)
4174
+ return;
4175
+
4176
+ int version = versionSlider.getInteger();
41294177
41304178 if (copy.versions[version] != null)
41314179 {
....@@ -4857,7 +4905,13 @@
48574905 copy.versions = readobj.versions;
48584906 copy.versionindex = readobj.versionindex;
48594907
4860
- SetUndoStates();
4908
+ if (copy.versions == null)
4909
+ {
4910
+ copy.versions = new byte[100][];
4911
+ copy.versionindex = -1;
4912
+ }
4913
+
4914
+ //? SetUndoStates();
48614915
48624916 ResetModel();
48634917 copy.HardTouch(); // recompile?