mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 23:36:27 -04:00
moved settings from menu to a settings dialog
This commit is contained in:
parent
76aab0b31c
commit
b391377e2c
@ -28,7 +28,11 @@ public class AttributeKey<VALUE> {
|
||||
public static final AttributeKey<Integer> TermHeight = new AttributeKey<>("termHeight", Lang.get("key_termHeight"), 25);
|
||||
public static final AttributeKey<Integer> Cycles = new AttributeKeyInteger("Cycles", Lang.get("key_cycles"), 100000).setComboBoxValues(new Integer[]{1000, 10000, 100000, 1000000});
|
||||
public static final AttributeKey<Boolean> ValueIsProbe = new AttributeKey<>("valueIsProbe", Lang.get("key_valueIsProbe"), false);
|
||||
public static final AttributeKey<Boolean> ShowList = new AttributeKey<>("showList", Lang.get("key_showList"), false);
|
||||
public static final AttributeKey<Boolean> ShowListing = new AttributeKey<>("showList", Lang.get("key_showListing"), false);
|
||||
|
||||
public static final AttributeKey<Boolean> ShowDataTable = new AttributeKey<>("showDataTable", Lang.get("key_showDataTable"), false);
|
||||
public static final AttributeKey<Boolean> ShowDataGraph = new AttributeKey<>("showDataGraph", Lang.get("key_showDataGraph"), false);
|
||||
public static final AttributeKey<Boolean> StartTimer = new AttributeKey<>("startTimer", Lang.get("key_startTimer"), false);
|
||||
|
||||
private final String key;
|
||||
private final VALUE def;
|
||||
|
@ -21,7 +21,7 @@ public class ROM extends Node implements Element {
|
||||
.addAttribute(AttributeKey.Bits)
|
||||
.addAttribute(AttributeKey.AddrBits)
|
||||
.addAttribute(AttributeKey.Label)
|
||||
.addAttribute(AttributeKey.ShowList)
|
||||
.addAttribute(AttributeKey.ShowListing)
|
||||
.addAttribute(AttributeKey.Data);
|
||||
|
||||
private final DataField data;
|
||||
@ -40,7 +40,7 @@ public class ROM extends Node implements Element {
|
||||
output = new ObservableValue("D", bits, true);
|
||||
data = attr.get(AttributeKey.Data);
|
||||
addrBits = attr.get(AttributeKey.AddrBits);
|
||||
showList = attr.get(AttributeKey.ShowList);
|
||||
showList = attr.get(AttributeKey.ShowListing);
|
||||
if (showList)
|
||||
listFile = attr.getFile("lastDataFile");
|
||||
else
|
||||
|
@ -132,7 +132,7 @@ public class Circuit {
|
||||
* @param parent the parent component
|
||||
*/
|
||||
public void editAttributes(Component parent) {
|
||||
if (new AttributeDialog(parent, null, ATTR_LIST, getAttributes()).showDialog()) {
|
||||
if (new AttributeDialog(parent, ATTR_LIST, getAttributes()).showDialog()) {
|
||||
if (attributes.isEmpty())
|
||||
attributes = null;
|
||||
modified();
|
||||
|
@ -6,7 +6,7 @@ import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.gui.components.CircuitComponent;
|
||||
|
||||
/**
|
||||
* This observer is added to the model if rial time timers are started.
|
||||
* This observer is added to the model if real time timers are started.
|
||||
* Its paints the CircuitComponent after a step is calculated.
|
||||
* It is registered to all elements which visual representation depends on a model value.
|
||||
* This listener method only sets a flag if there was a change.
|
||||
|
@ -1,6 +1,8 @@
|
||||
package de.neemann.digital.gui;
|
||||
|
||||
import de.neemann.digital.core.*;
|
||||
import de.neemann.digital.core.element.AttributeKey;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.memory.ROM;
|
||||
import de.neemann.digital.core.wiring.Clock;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
@ -11,10 +13,7 @@ import de.neemann.digital.draw.library.ElementLibrary;
|
||||
import de.neemann.digital.draw.model.ModelDescription;
|
||||
import de.neemann.digital.draw.model.RealTimeClock;
|
||||
import de.neemann.digital.draw.shapes.ShapeFactory;
|
||||
import de.neemann.digital.gui.components.CircuitComponent;
|
||||
import de.neemann.digital.gui.components.ElementOrderer;
|
||||
import de.neemann.digital.gui.components.OrderMerger;
|
||||
import de.neemann.digital.gui.components.ProbeDialog;
|
||||
import de.neemann.digital.gui.components.*;
|
||||
import de.neemann.digital.gui.components.data.DataSetDialog;
|
||||
import de.neemann.digital.gui.components.listing.ROMListingDialog;
|
||||
import de.neemann.digital.gui.state.State;
|
||||
@ -41,6 +40,14 @@ import java.util.prefs.Preferences;
|
||||
*/
|
||||
public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
private static final Preferences PREFS = Preferences.userRoot().node("dig");
|
||||
private static final ArrayList<AttributeKey> ATTR_LIST = new ArrayList<>();
|
||||
|
||||
static {
|
||||
ATTR_LIST.add(AttributeKey.ShowDataTable);
|
||||
ATTR_LIST.add(AttributeKey.ShowDataGraph);
|
||||
ATTR_LIST.add(AttributeKey.ShowListing);
|
||||
ATTR_LIST.add(AttributeKey.StartTimer);
|
||||
}
|
||||
private static final String MESSAGE = Lang.get("message");
|
||||
private static final Icon ICON_RUN = IconCreator.create("run.gif");
|
||||
private static final Icon ICON_MICRO = IconCreator.create("micro.gif");
|
||||
@ -58,10 +65,6 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
private final ToolTipAction doStep;
|
||||
private final ToolTipAction runToBreak;
|
||||
private final ElementLibrary library;
|
||||
private final JCheckBoxMenuItem runClock;
|
||||
private final JCheckBoxMenuItem showProbes;
|
||||
private final JCheckBoxMenuItem showGraph;
|
||||
private final JCheckBoxMenuItem showListing;
|
||||
private final LibrarySelector librarySelector;
|
||||
private final ShapeFactory shapeFactory;
|
||||
private final SavedListener savedListener;
|
||||
@ -77,6 +80,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
private State selectState;
|
||||
private State runModelState;
|
||||
private State runModelMicroState;
|
||||
private ElementAttributes settings = new ElementAttributes();
|
||||
|
||||
private Main() {
|
||||
this(null, null, null);
|
||||
@ -300,23 +304,18 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_speedTest_tt"));
|
||||
|
||||
showListing = new JCheckBoxMenuItem(Lang.get("menu_listing"));
|
||||
showListing.setToolTipText(Lang.get("menu_listing_tt"));
|
||||
showProbes = new JCheckBoxMenuItem(Lang.get("menu_probe"));
|
||||
showProbes.setToolTipText(Lang.get("menu_probe_tt"));
|
||||
showGraph = new JCheckBoxMenuItem(Lang.get("menu_graph"));
|
||||
showGraph.setToolTipText(Lang.get("menu_graph_tt"));
|
||||
runClock = new JCheckBoxMenuItem(Lang.get("menu_runClock"));
|
||||
runClock.setToolTipText(Lang.get("menu_runClock_tt"));
|
||||
ToolTipAction editRunAttributes = new ToolTipAction(Lang.get("menu_editRunAttributes")) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new AttributeDialog(Main.this, ATTR_LIST, settings).showDialog();
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_editRunAttributes_tt"));
|
||||
|
||||
run.add(runModelAction.createJMenuItem());
|
||||
run.add(runModelMicroAction.createJMenuItem());
|
||||
run.add(doStep.createJMenuItem());
|
||||
run.add(runToBreak.createJMenuItem());
|
||||
run.add(showProbes);
|
||||
run.add(showGraph);
|
||||
run.add(showListing);
|
||||
run.add(runClock);
|
||||
run.add(editRunAttributes.createJMenuItem());
|
||||
doStep.setEnabled(false);
|
||||
|
||||
JToolBar toolBar = new JToolBar();
|
||||
@ -371,7 +370,7 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
@Override
|
||||
public void enter() {
|
||||
super.enter();
|
||||
if (createAndStartModel(runClock.isSelected(), ModelEvent.Event.STEP))
|
||||
if (createAndStartModel(settings.get(AttributeKey.StartTimer), ModelEvent.Event.STEP))
|
||||
circuitComponent.setManualChangeObserver(new FullStepObserver(model));
|
||||
}
|
||||
});
|
||||
@ -436,14 +435,13 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave {
|
||||
runToBreak.setEnabled(!runClock && model.isFastRunModel());
|
||||
|
||||
List<String> ordering = circuitComponent.getCircuit().getMeasurementOrdering();
|
||||
if (showProbes.isSelected()) {
|
||||
if (settings.get(AttributeKey.ShowDataTable))
|
||||
new ProbeDialog(this, model, updateEvent, ordering).setVisible(true);
|
||||
}
|
||||
|
||||
if (showGraph.isSelected())
|
||||
if (settings.get(AttributeKey.ShowDataGraph))
|
||||
new DataSetDialog(this, model, updateEvent, ordering).setVisible(true);
|
||||
|
||||
if (showListing.isSelected())
|
||||
if (settings.get(AttributeKey.ShowListing))
|
||||
for (ROM rom : model.getRoms())
|
||||
try {
|
||||
new ROMListingDialog(this, rom).setVisible(true);
|
||||
|
@ -18,6 +18,10 @@ public class AttributeDialog extends JDialog {
|
||||
private final ArrayList<EditorHolder> editors;
|
||||
private boolean changed = false;
|
||||
|
||||
public AttributeDialog(Component parent, ArrayList<AttributeKey> list, ElementAttributes elementAttributes) {
|
||||
this(parent, null, list, elementAttributes);
|
||||
}
|
||||
|
||||
public AttributeDialog(Component parent, Point pos, ArrayList<AttributeKey> list, ElementAttributes elementAttributes) {
|
||||
super(SwingUtilities.getWindowAncestor(parent), Lang.get("attr_dialogTitle"), ModalityType.APPLICATION_MODAL);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
@ -31,8 +31,11 @@ key_width=Breite
|
||||
key_cycles=Timeout Zyklen
|
||||
key_termWidth=Zeichen pro Zeile
|
||||
key_termHeight=Zeilen
|
||||
key_valueIsProbe=Als Messwert anzeigen
|
||||
key_showList=Zeige Listing an, wenn verf\u00FCgbar
|
||||
key_valueIsProbe=Als Messwert verwenden
|
||||
key_showListing=Zeige Listing an, wenn verf\u00FCgbar
|
||||
key_showDataTable=Zeige Messwertetabelle
|
||||
key_showDataGraph=Zeige Measurement Graph
|
||||
key_startTimer=Starte Timer
|
||||
|
||||
|
||||
rot_0=0\u00B0
|
||||
@ -123,7 +126,7 @@ menu_orderOutputs=Sortieren der Ausg\u00E4nge
|
||||
menu_orderOutputs_tt=Sortiert die Ausg\u00E4nge f\u00FCr die Verwendung als eingebettetes Model
|
||||
menu_orderMeasurements=Sortiert die Messwerte
|
||||
menu_orderMeasurements_tt=Sortiert die Messwerte für die grafische Anzeige und die Tabellenansicht
|
||||
menu_run=Starten
|
||||
menu_run=Start
|
||||
menu_run_tt=Startet das Modell
|
||||
menu_step=Schritt
|
||||
menu_step_tt=F\u00FChrt einen Mikroschritt aus
|
||||
@ -150,6 +153,8 @@ menu_listing=Zeige Listing
|
||||
menu_listing_tt=Zeigt ein ROM-Listing mit der aktuellen Adresse markiert in eine eigenen Fenster an.
|
||||
menu_graph=Messwerte grafisch darstellen
|
||||
menu_graph_tt=Zeigt eine Grafik mit dem Messwerten \u00FCber der Zeit.
|
||||
menu_editRunAttributes=Simulationseinstellungen
|
||||
menu_editRunAttributes_tt=Einstellungen f\u00FCr den Start der Simulation
|
||||
|
||||
menu_about=\u00DCber Digital
|
||||
|
||||
|
@ -31,8 +31,11 @@ key_width=Width
|
||||
key_cycles=Timeout cycles
|
||||
key_termWidth=Characters per line
|
||||
key_termHeight=Lines
|
||||
key_valueIsProbe=Is measurment value
|
||||
key_showList=Show fist file if there
|
||||
key_valueIsProbe=Use as measurment value
|
||||
key_showListing=Show list file if available
|
||||
key_showDataTable=Show measurement values
|
||||
key_showDataGraph=Show measurement graph
|
||||
key_startTimer=Start timer
|
||||
|
||||
rot_0=0\u00B0
|
||||
rot_90=90\u00B0
|
||||
@ -150,6 +153,8 @@ menu_listing=Show Listing
|
||||
menu_listing_tt=Shows a ROM listing with actual position marked in a separate window
|
||||
menu_graph=Show Graph
|
||||
menu_graph_tt=Shows a graph containing the measurement values
|
||||
menu_editRunAttributes=Simulation Settings
|
||||
menu_editRunAttributes_tt=Settings used to start the simulation
|
||||
|
||||
win_saveChanges=Save Changes?
|
||||
win_confirmExit=Confirm Exit!
|
||||
|
Loading…
x
Reference in New Issue
Block a user