diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java b/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java index 01ba48d..98d1667 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/utils/DialogUtils.java @@ -4,8 +4,11 @@ import javax.swing.JOptionPane; import javax.swing.JTextArea; +// TODO: is errorLog the best way to send errors to JTextArea? reconsider impl for AcquisitionTable + /** - * This is primarily used in the acquisition playlist ui. + * A utility class for making dialog boxes. + * */ public class DialogUtils { @@ -15,9 +18,6 @@ public class DialogUtils { /**The component to display the errors. */ private static JTextArea errorLog = null; - public DialogUtils() { - } - /** * Sets the JTextArea to log errors. * @@ -27,11 +27,27 @@ public static void setErrorLog(final JTextArea textArea) { errorLog = textArea; } + /** + * Return the user's input or null if the action is canceled. + * + * @param frame the parent frame + * @param title the title string + * @param message the message to display + * @return the user's input or {@code null} meaning the user canceled the input + */ public static String showTextEntryDialog(final JFrame frame, final String title, final String message) { return (String) JOptionPane.showInputDialog(frame, message, title, JOptionPane.PLAIN_MESSAGE, null, null, ""); } + /** + * Return 0 if "Yes" is selected or 1 if "No" is selected. + * + * @param frame the parent frame + * @param title the title string + * @param message the message to display + * @return an int indicating the option selected by the user. + */ public static int showYesNoDialog(final JFrame frame, final String title, final String message) { return JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.YES_NO_OPTION); } @@ -40,8 +56,8 @@ public static int showYesNoDialog(final JFrame frame, final String title, final * Shows a customized message dialog box, this method does not log the error.
* This is used for reporting errors in the AcquisitionTable. * - * @param frame the frame in which the dialog is displayed - * @param title the title string for the dialog + * @param frame the parent frame + * @param title the title string * @param message the message to display */ public static void showErrorMessage(final JFrame frame, final String title, final String message) { diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java b/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java index db85270..4b95d09 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineSCAPE.java @@ -21,6 +21,7 @@ import org.micromanager.lightsheetmanager.api.data.MultiChannelMode; import org.micromanager.lightsheetmanager.api.internal.DefaultAcquisitionSettingsSCAPE; import org.micromanager.lightsheetmanager.api.internal.DefaultTimingSettings; +import org.micromanager.lightsheetmanager.gui.utils.DialogUtils; import org.micromanager.lightsheetmanager.model.DataStorage; import org.micromanager.lightsheetmanager.model.LightSheetManagerModel; import org.micromanager.lightsheetmanager.model.PLogicSCAPE; @@ -132,8 +133,16 @@ boolean run() { origSpeedX_ = xyStage.getSpeedX(); origAccelX_ = xyStage.getAccelerationX(); - // TODO: add more checks from original plugin here... - // if (origXSpeed < 0.2 && resetXaxisSpeed_) { etc... + // if X speed is less than 0.2 mm/s then it probably wasn't restored to correct speed some other time + if (origSpeedX_ < 0.2) { + final int result = DialogUtils.showYesNoDialog(frame_, "Change Speed", + "Max speed of X axis is small, perhaps it was not correctly restored after " + + "stage scanning previously. Do you want to set it to 1 mm/s now?"); + if (result == 0) { + xyStage.setSpeedX(1.0); + } + } + // TODO: add more checks from original plugin here... Z speed? } }