mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 23:18:02 -04:00
fixed a bug: undo sets the correct modified state if all modifications are undone since last save.
This commit is contained in:
parent
303318a256
commit
367c710efa
@ -1081,7 +1081,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
|
|
||||||
private void saveFile(File filename, boolean toPrefs) {
|
private void saveFile(File filename, boolean toPrefs) {
|
||||||
try {
|
try {
|
||||||
circuitComponent.getCircuit().save(filename);
|
circuitComponent.save(filename);
|
||||||
ensureModelIsStopped();
|
ensureModelIsStopped();
|
||||||
setFilename(filename, toPrefs);
|
setFilename(filename, toPrefs);
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ import java.awt.geom.AffineTransform;
|
|||||||
import java.awt.geom.NoninvertibleTransformException;
|
import java.awt.geom.NoninvertibleTransformException;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -107,6 +109,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
private ArrayList<Modification> modifications;
|
private ArrayList<Modification> modifications;
|
||||||
private Circuit initialCircuit;
|
private Circuit initialCircuit;
|
||||||
private int undoPosition;
|
private int undoPosition;
|
||||||
|
private int savedUndoPosition;
|
||||||
private Style highLightStyle = Style.HIGHLIGHT;
|
private Style highLightStyle = Style.HIGHLIGHT;
|
||||||
|
|
||||||
|
|
||||||
@ -381,6 +384,10 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
redoAction.setEnabled(true);
|
redoAction.setEnabled(true);
|
||||||
if (undoPosition == 0)
|
if (undoPosition == 0)
|
||||||
undoAction.setEnabled(false);
|
undoAction.setEnabled(false);
|
||||||
|
|
||||||
|
if (undoPosition != savedUndoPosition)
|
||||||
|
circuit.modified();
|
||||||
|
|
||||||
circuit.fireChangedEvent();
|
circuit.fireChangedEvent();
|
||||||
repaintNeeded();
|
repaintNeeded();
|
||||||
}
|
}
|
||||||
@ -414,6 +421,17 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
|||||||
return Lang.get("menu_redo_tt");
|
return Lang.get("menu_redo_tt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save the circuit
|
||||||
|
*
|
||||||
|
* @param filename the filename
|
||||||
|
* @throws IOException IOException
|
||||||
|
*/
|
||||||
|
public void save(File filename) throws IOException {
|
||||||
|
circuit.save(filename);
|
||||||
|
savedUndoPosition = undoPosition;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the main frame
|
* @return the main frame
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user