Skip to content

Commit

Permalink
reordered the menu entries in the simulation and analysis menu
Browse files Browse the repository at this point in the history
  • Loading branch information
hneemann committed Jun 9, 2024
1 parent e80dd4c commit bc25efa
Showing 1 changed file with 56 additions and 56 deletions.
112 changes: 56 additions & 56 deletions src/main/java/de/neemann/digital/gui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1141,31 +1141,6 @@ public void actionPerformed(ActionEvent e) {
}
}.setToolTip(Lang.get("menu_runAllTests_tt")).setAccelerator("F11");

ToolTipAction speedTest = new ToolTipAction(Lang.get("menu_speedTest")) {
private final NumberFormat format = new DecimalFormat("0.0");

@Override
public void actionPerformed(ActionEvent e) {
try {
Model model = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false);
try {
model.setWindowPosManager(windowPosManager);
SpeedTest speedTest = new SpeedTest(model);
String frequency = format.format(speedTest.calculate() / 1000);
circuitComponent.getCircuit().clearState();
SwingUtilities.invokeLater(() -> {
windowPosManager.closeAll();
JOptionPane.showMessageDialog(Main.this, Lang.get("msg_frequency_N", frequency));
});
} finally {
model.close();
}
} catch (Exception e1) {
showError(Lang.get("msg_speedTestError"), e1);
}
}
}.setToolTip(Lang.get("menu_speedTest_tt"));

showMeasurementDialog = new ToolTipAction(Lang.get("menu_showDataTable")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Expand Down Expand Up @@ -1201,33 +1176,6 @@ public void actionPerformed(ActionEvent actionEvent) {
}
});

ToolTipAction stats = new ToolTipAction(Lang.get("menu_stats")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try {
model = new ModelCreator(getCircuitComponent().getCircuit(), library).createModel(false);
Statistics stats = new Statistics(model);
new StatsDialog(Main.this, stats.getTableModel()).setVisible(true);
} catch (ElementNotFoundException | PinException | NodeException e) {
new ErrorMessage(Lang.get("msg_couldNotCreateStats")).addCause(e).show(Main.this);
}
}
}.setToolTip(Lang.get("menu_stats_tt"));

ToolTipAction pathLen = new ToolTipAction(Lang.get("menu_calcMaxPathLen")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try {
Model model = new ModelCreator(getCircuitComponent().getCircuit(), library).createModel(false);
ModelAnalyser ma = new ModelAnalyser(model);
int depth = ma.calcMaxPathLen();
JOptionPane.showMessageDialog(Main.this, Lang.get("msg_maxPathLen", depth));
} catch (ElementNotFoundException | PinException | NodeException | AnalyseException | BacktrackException e) {
new ErrorMessage(Lang.get("msg_couldNotCalculateMaxPathLen")).addCause(e).show(Main.this);
}
}
}.setToolTip(Lang.get("menu_calcMaxPathLen_tt"));

JMenu run = new JMenu(Lang.get("menu_sim"));
menuBar.add(run);
run.add(showMeasurementDialog.createJMenuItem());
Expand All @@ -1243,10 +1191,6 @@ public void actionPerformed(ActionEvent actionEvent) {
run.addSeparator();
run.add(runTests.createJMenuItem());
run.add(runAllTests.createJMenuItem());
run.addSeparator();
run.add(speedTest.createJMenuItem());
run.add(stats.createJMenuItem());
run.add(pathLen.createJMenuItem());

toolBar.add(runModelState.setIndicator(runModelAction.createJButtonNoText()));
toolBar.add(runToBreakAction.createJButtonNoText());
Expand Down Expand Up @@ -1335,6 +1279,8 @@ public void actionPerformed(ActionEvent e) {
.setToolTip(Lang.get("menu_expression_tt"))
.createJMenuItem());

analyse.addSeparator();

analyse.add(new ToolTipAction(Lang.get("menu_fsm")) {
@Override
public void actionPerformed(ActionEvent e) {
Expand All @@ -1356,6 +1302,60 @@ public void actionPerformed(ActionEvent e) {
}
.setToolTip(Lang.get("menu_fsm_tt"))
.createJMenuItem());

analyse.addSeparator();

analyse.add(new ToolTipAction(Lang.get("menu_speedTest")) {
private final NumberFormat format = new DecimalFormat("0.0");

@Override
public void actionPerformed(ActionEvent e) {
try {
Model model = new ModelCreator(circuitComponent.getCircuit(), library).createModel(false);
try {
model.setWindowPosManager(windowPosManager);
SpeedTest speedTest = new SpeedTest(model);
String frequency = format.format(speedTest.calculate() / 1000);
circuitComponent.getCircuit().clearState();
SwingUtilities.invokeLater(() -> {
windowPosManager.closeAll();
JOptionPane.showMessageDialog(Main.this, Lang.get("msg_frequency_N", frequency));
});
} finally {
model.close();
}
} catch (Exception e1) {
showError(Lang.get("msg_speedTestError"), e1);
}
}
}.setToolTip(Lang.get("menu_speedTest_tt")).createJMenuItem());

analyse.add(new ToolTipAction(Lang.get("menu_stats")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try {
model = new ModelCreator(getCircuitComponent().getCircuit(), library).createModel(false);
Statistics stats = new Statistics(model);
new StatsDialog(Main.this, stats.getTableModel()).setVisible(true);
} catch (ElementNotFoundException | PinException | NodeException e) {
new ErrorMessage(Lang.get("msg_couldNotCreateStats")).addCause(e).show(Main.this);
}
}
}.setToolTip(Lang.get("menu_stats_tt")).createJMenuItem());

analyse.add(new ToolTipAction(Lang.get("menu_calcMaxPathLen")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
try {
Model model = new ModelCreator(getCircuitComponent().getCircuit(), library).createModel(false);
ModelAnalyser ma = new ModelAnalyser(model);
int depth = ma.calcMaxPathLen();
JOptionPane.showMessageDialog(Main.this, Lang.get("msg_maxPathLen", depth));
} catch (ElementNotFoundException | PinException | NodeException | AnalyseException | BacktrackException e) {
new ErrorMessage(Lang.get("msg_couldNotCalculateMaxPathLen")).addCause(e).show(Main.this);
}
}
}.setToolTip(Lang.get("menu_calcMaxPathLen_tt")).createJMenuItem());
}

private void orderMeasurements() {
Expand Down

0 comments on commit bc25efa

Please sign in to comment.