mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-25 14:08:27 -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) {
|
||||
try {
|
||||
circuitComponent.getCircuit().save(filename);
|
||||
circuitComponent.save(filename);
|
||||
ensureModelIsStopped();
|
||||
setFilename(filename, toPrefs);
|
||||
|
||||
|
@ -30,6 +30,8 @@ import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.NoninvertibleTransformException;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -107,6 +109,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
private ArrayList<Modification> modifications;
|
||||
private Circuit initialCircuit;
|
||||
private int undoPosition;
|
||||
private int savedUndoPosition;
|
||||
private Style highLightStyle = Style.HIGHLIGHT;
|
||||
|
||||
|
||||
@ -381,6 +384,10 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
redoAction.setEnabled(true);
|
||||
if (undoPosition == 0)
|
||||
undoAction.setEnabled(false);
|
||||
|
||||
if (undoPosition != savedUndoPosition)
|
||||
circuit.modified();
|
||||
|
||||
circuit.fireChangedEvent();
|
||||
repaintNeeded();
|
||||
}
|
||||
@ -414,6 +421,17 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user