Skip to content

Commit

Permalink
add dialog box to reset speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon committed May 6, 2024
1 parent 04ca86a commit 0b91ea4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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.
*
Expand All @@ -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);
}
Expand All @@ -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.<P>
* 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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?
}
}

Expand Down

0 comments on commit 0b91ea4

Please sign in to comment.