mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-17 00:44:40 -04:00
shows modified status in the window title
This commit is contained in:
parent
34ada97add
commit
6fd75f5705
@ -79,14 +79,17 @@ public class TruthTableTableModel implements TableModel {
|
||||
else
|
||||
setValue(rowIndex, columnIndex, 2);
|
||||
}
|
||||
fireModelEvent(rowIndex);
|
||||
}
|
||||
|
||||
private void setValue(int rowIndex, int columnIndex, int val) {
|
||||
try {
|
||||
undoManager.apply(truthTable -> truthTable.setValue(rowIndex, columnIndex, val));
|
||||
} catch (ModifyException e) {
|
||||
e.printStackTrace();
|
||||
int actVal = undoManager.getActual().getValue(rowIndex, columnIndex);
|
||||
if (actVal != val) {
|
||||
try {
|
||||
undoManager.apply(truthTable -> truthTable.setValue(rowIndex, columnIndex, val));
|
||||
} catch (ModifyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
fireModelEvent(rowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,14 +327,17 @@ public class TableDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
}.setAcceleratorCTRLplus("Y");
|
||||
|
||||
edit.add(undo.createJMenuItem());
|
||||
edit.add(redo.createJMenuItem());
|
||||
undoManager.addListener(() -> {
|
||||
undo.setEnabled(undoManager.undoAvailable());
|
||||
redo.setEnabled(undoManager.redoAvailable());
|
||||
});
|
||||
undo.setEnabled(undoManager.undoAvailable());
|
||||
redo.setEnabled(undoManager.redoAvailable());
|
||||
if (undoManager.isModified())
|
||||
setTitle("*" + Lang.get("win_table"));
|
||||
else
|
||||
setTitle(Lang.get("win_table"));
|
||||
}).hasChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,7 @@ public class UndoManager<A extends Copyable<A>> {
|
||||
modifications = new ArrayList<>();
|
||||
modificationCounter = 0;
|
||||
savedCounter = 0;
|
||||
fireChangedEvent();
|
||||
}
|
||||
|
||||
|
||||
@ -187,9 +188,11 @@ public class UndoManager<A extends Copyable<A>> {
|
||||
* Adds a listener
|
||||
*
|
||||
* @param listener the listener to add
|
||||
* @return the given listener for chained calls.
|
||||
*/
|
||||
public void addListener(ChangedListener listener) {
|
||||
public ChangedListener addListener(ChangedListener listener) {
|
||||
listeners.add(listener);
|
||||
return listener;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user