mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 14:56:29 -04:00
disables undo/redo if model is running
This commit is contained in:
parent
58d7d00d40
commit
064aeae14f
@ -1267,6 +1267,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
runToBreakAction.setEnabled(false);
|
||||
runToBreakMicroAction.setEnabled(false);
|
||||
runTests.setEnabled(true);
|
||||
circuitComponent.enableUndoRedo();
|
||||
// keep errors
|
||||
if (circuitComponent.getHighLightStyle() != Style.ERROR)
|
||||
circuitComponent.removeHighLighted();
|
||||
@ -1281,6 +1282,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
showMeasurementDialog.setEnabled(true);
|
||||
showMeasurementGraph.setEnabled(true);
|
||||
stoppedState.getAction().setEnabled(true);
|
||||
circuitComponent.disableUndoRedo();
|
||||
runTests.setEnabled(false);
|
||||
if (createAndStartModel(false, ModelEvent.MICROSTEP, null))
|
||||
circuitComponent.setManualChangeObserver(new MicroStepObserver(model));
|
||||
@ -1319,6 +1321,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
stoppedState.getAction().setEnabled(true);
|
||||
showMeasurementDialog.setEnabled(true);
|
||||
showMeasurementGraph.setEnabled(true);
|
||||
circuitComponent.disableUndoRedo();
|
||||
runTests.setEnabled(false);
|
||||
if (createAndStartModel(runRealTime, ModelEvent.STEP, modelModifier))
|
||||
circuitComponent.setManualChangeObserver(new FullStepObserver(model));
|
||||
|
@ -99,7 +99,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
private final ElementLibrary library;
|
||||
private final HashSet<Drawable> highLighted;
|
||||
private final ToolTipAction deleteAction;
|
||||
|
||||
private final MouseController mouseNormal;
|
||||
private final MouseControllerInsertElement mouseInsertElement;
|
||||
private final MouseControllerMoveElement mouseMoveElement;
|
||||
@ -139,7 +138,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
private boolean toolTipHighlighted = false;
|
||||
private NetList toolTipNetList;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
@ -159,7 +157,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
}
|
||||
}.setEnabledChain(false).setAccelerator("R").enableAcceleratorIn(this);
|
||||
|
||||
|
||||
cutAction = createCutAction(shapeFactory);
|
||||
copyAction = createCopyAction(shapeFactory);
|
||||
pasteAction = createPasteAction(shapeFactory);
|
||||
@ -212,7 +209,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
}
|
||||
}.setAccelerator("S").enableAcceleratorIn(this);
|
||||
|
||||
|
||||
createAdditionalShortcuts(shapeFactory);
|
||||
|
||||
getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), DEL_ACTION);
|
||||
@ -320,7 +316,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
}
|
||||
}.setAcceleratorCTRLplus('D').enableAcceleratorIn(this);
|
||||
|
||||
|
||||
ToolTipAction plus = new PlusMinusAction(1).setAccelerator("PLUS").enableAcceleratorIn(this);
|
||||
// enable [+] which is SHIFT+[=] on english keyboard layout
|
||||
getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, 0, false), plus);
|
||||
@ -905,10 +900,25 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
@Override
|
||||
public void hasChanged() {
|
||||
graphicHasChanged();
|
||||
enableUndoRedo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables undo and redo if possible
|
||||
*/
|
||||
public void enableUndoRedo() {
|
||||
redoAction.setEnabled(undoManager.redoAvailable());
|
||||
undoAction.setEnabled(undoManager.undoAvailable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables undo and redo
|
||||
*/
|
||||
public void disableUndoRedo() {
|
||||
redoAction.setEnabled(false);
|
||||
undoAction.setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* forces a immediately repaint
|
||||
* Is called from {@link de.neemann.digital.gui.GuiModelObserver} if the models data has changed.
|
||||
@ -1199,7 +1209,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
return redoAction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes actual input values to the default value
|
||||
*/
|
||||
@ -1440,7 +1449,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//MouseController can not be final because its overridden. Maybe checkstyle has a bug?
|
||||
@ -1818,10 +1826,8 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
public void escapePressed() {
|
||||
mouseNormal.activate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private final class MouseControllerWireDiag extends MouseController {
|
||||
private Wire wire;
|
||||
|
||||
@ -2326,13 +2332,11 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private interface Actor {
|
||||
boolean interact(CircuitComponent cc, Point p, Vector posInComponent, SyncAccess modelSync);
|
||||
}
|
||||
|
||||
private final class MouseControllerRun extends MouseController {
|
||||
|
||||
private VisualElement draggedElement;
|
||||
|
||||
private MouseControllerRun(Cursor cursor) {
|
||||
@ -2435,7 +2439,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
}
|
||||
|
||||
private final class MouseControllerWizard extends MouseController {
|
||||
|
||||
private final WizardNotification wizardNotification;
|
||||
|
||||
private MouseControllerWizard(WizardNotification wizardNotification) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user