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