diff --git a/core/resources/pix/icons/refresh_sim.png b/core/resources/pix/icons/refresh_sim.png new file mode 100644 index 000000000..66c8e8c48 Binary files /dev/null and b/core/resources/pix/icons/refresh_sim.png differ diff --git a/core/resources/pix/icons/sim_cantrun.png b/core/resources/pix/icons/sim_cantrun.png new file mode 100644 index 000000000..0cfd58596 Binary files /dev/null and b/core/resources/pix/icons/sim_cantrun.png differ diff --git a/core/resources/pix/icons/tick.png b/core/resources/pix/icons/tick.png new file mode 100644 index 000000000..a9925a06a Binary files /dev/null and b/core/resources/pix/icons/tick.png differ diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java index 2aa9c4448..99263ec7c 100644 --- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -239,12 +239,24 @@ public class SimulationPanel extends JPanel { } if (e.getButton() == MouseEvent.BUTTON1) { - // Edit the simulation or plot/export - if (e.getClickCount() == 2) { + if (e.getClickCount() == 1) { + if (column == 0) { + int selected = simulationTable.convertRowIndexToModel(selectedRow); + Simulation sim = document.getSimulations().get(selected); + Status status = sim.getStatus(); + + if (status == Status.NOT_SIMULATED || status == Status.OUTDATED) { + runSimulation(); + } + } + } else if (e.getClickCount() == 2) { int selected = simulationTable.convertRowIndexToModel(selectedRow); + // Show the warnings for the simulation if (column == 0) { SimulationWarningDialog.showWarningDialog(SimulationPanel.this, document.getSimulations().get(selected)); - } else { + } + // Edit the simulation or plot/export + else { simulationTable.clearSelection(); simulationTable.addRowSelectionInterval(selectedRow, selectedRow); diff --git a/swing/src/net/sf/openrocket/gui/util/Icons.java b/swing/src/net/sf/openrocket/gui/util/Icons.java index 2d8a34ac4..cdc7c997e 100644 --- a/swing/src/net/sf/openrocket/gui/util/Icons.java +++ b/swing/src/net/sf/openrocket/gui/util/Icons.java @@ -29,13 +29,17 @@ public class Icons { */ public static final Map SIMULATION_STATUS_ICON_MAP; static { + final String SIM_UPTODATE = "pix/icons/tick.png"; + final String SIM_CANTRUN = "pix/icons/sim_cantrun.png"; + final String SIM_OUTDATED = "pix/icons/refresh_sim.png"; + HashMap map = new HashMap(); - map.put(Simulation.Status.NOT_SIMULATED, loadImageIcon("pix/spheres/gray-16x16.png", "Not simulated")); - map.put(Simulation.Status.CANT_RUN, loadImageIcon("pix/spheres/yellow-16x16.png", "Can't run, no motors assigned.")); - map.put(Simulation.Status.UPTODATE, loadImageIcon("pix/spheres/green-16x16.png", "Up to date")); - map.put(Simulation.Status.LOADED, loadImageIcon("pix/spheres/blue-16x16.png", "Loaded from File")); - map.put(Simulation.Status.OUTDATED, loadImageIcon("pix/spheres/red-16x16.png", "Out-of-date")); - map.put(Simulation.Status.EXTERNAL, loadImageIcon("pix/spheres/blue-16x16.png", "Imported data")); + map.put(Simulation.Status.NOT_SIMULATED, loadImageIcon(SIM_OUTDATED, "Not simulated")); + map.put(Simulation.Status.CANT_RUN, loadImageIcon(SIM_CANTRUN, "Can't run, no motors assigned.")); + map.put(Simulation.Status.UPTODATE, loadImageIcon(SIM_UPTODATE, "Up to date")); + map.put(Simulation.Status.LOADED, loadImageIcon(SIM_UPTODATE, "Loaded from File")); + map.put(Simulation.Status.OUTDATED, loadImageIcon(SIM_OUTDATED, "Out-of-date")); + map.put(Simulation.Status.EXTERNAL, loadImageIcon(SIM_UPTODATE, "Imported data")); SIMULATION_STATUS_ICON_MAP = Collections.unmodifiableMap(map); } @@ -139,6 +143,17 @@ public class Icons { return new ImageIcon(url, name); } + /** + * Loads an ImageIcon with a new name. + * + * @param icon the original ImageIcon to load. + * @param newName the new name for the ImageIcon. + * @return the loaded ImageIcon with the new name. + */ + public static ImageIcon loadImageIconWithNewName(ImageIcon icon, String newName) { + return new ImageIcon(icon.getImage(), newName); + } + /** * Scales an ImageIcon to the specified scale. * @param icon icon to scale