Upload files to "src/openonyx/history"
This commit is contained in:
1 parent
57f447491e
commit
e781057f68
4 files changed
+111
No files matched your search
@@ -0,0 +1,16 @@
|
|||||||
|
package openonyx.history;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TabbedSettingGroup extends SettingGroup {
|
||||||
|
private final List<String> strings;
|
||||||
|
|
||||||
|
public List<String> getStrings() {
|
||||||
|
return this.strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TabbedSettingGroup(String string, String... strings) {
|
||||||
|
super(string);
|
||||||
|
this.strings = List.of(stringsx);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package openonyx.history;
|
||||||
|
|
||||||
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Deque;
|
||||||
|
|
||||||
|
public final class UndoManager {
|
||||||
|
private static boolean I;
|
||||||
|
private static final int d = 96;
|
||||||
|
private static final Deque<UndoManagerData> UNDO_MANAGER_DATAS = new ArrayDeque<>();
|
||||||
|
private static final long f = 450L;
|
||||||
|
private static final Deque<UndoManagerData> UNDO_MANAGER_DATAS2 = new ArrayDeque<>();
|
||||||
|
private static boolean e;
|
||||||
|
|
||||||
|
public static void L(Runnable runnable) {
|
||||||
|
Runnable runnable1 = runnable;
|
||||||
|
boolean bl = I;
|
||||||
|
I = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
runnable1.run();
|
||||||
|
} finally {
|
||||||
|
I = bl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private UndoManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean d() {
|
||||||
|
if (UNDO_MANAGER_DATAS2.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UndoManagerData undoManagerData;
|
||||||
|
L((undoManagerData = UNDO_MANAGER_DATAS2.pop()).undo()::L);
|
||||||
|
UNDO_MANAGER_DATAS.push(undoManagerData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void L(Object undoManagerData, UndoManagerListener undoManagerListener, UndoManagerListener undoManagerListener1) {
|
||||||
|
Object object = undoManagerData;
|
||||||
|
if (e && !I) {
|
||||||
|
long l = System.currentTimeMillis();
|
||||||
|
if ((undoManagerData = UNDO_MANAGER_DATAS2.peek()) != null
|
||||||
|
&& object != null
|
||||||
|
&& undoManagerData.owner() == object
|
||||||
|
&& l - undoManagerData.stamp() <= 450L) {
|
||||||
|
UNDO_MANAGER_DATAS2.pop();
|
||||||
|
UNDO_MANAGER_DATAS2.push(new UndoManagerData(object, undoManagerData.undo(), undoManagerListener1, l));
|
||||||
|
} else {
|
||||||
|
UNDO_MANAGER_DATAS2.push(new UndoManagerData(object, undoManagerListener, undoManagerListener1, l));
|
||||||
|
|
||||||
|
while (UNDO_MANAGER_DATAS2.size() > 96) {
|
||||||
|
UNDO_MANAGER_DATAS2.removeLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UNDO_MANAGER_DATAS.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean L() {
|
||||||
|
if (UNDO_MANAGER_DATAS.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UndoManagerData undoManagerData;
|
||||||
|
L((undoManagerData = UNDO_MANAGER_DATAS.pop()).redo()::L);
|
||||||
|
UNDO_MANAGER_DATAS2.push(undoManagerData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void D() {
|
||||||
|
UNDO_MANAGER_DATAS2.clear();
|
||||||
|
UNDO_MANAGER_DATAS.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void d() {
|
||||||
|
e = false;
|
||||||
|
D();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void L() {
|
||||||
|
e = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package openonyx.history;
|
||||||
|
|
||||||
|
record UndoManagerData(Object owner, UndoManagerListener undo, UndoManagerListener redo, long stamp) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package openonyx.history;
|
||||||
|
|
||||||
|
public interface UndoManagerListener {
|
||||||
|
void L();
|
||||||
|
}
|
||||||
Reference in new issue
Block a user