initialValue, true);
}
- public void showDialog(String message, String title, int optionType,
+ public void showDialog(Object message, String title, int optionType,
int messageType, Icon icon, Object[] options, Object initialValue,
boolean modal)
{
initialValue, modal);
}
- public void showDialogOnTopAsync(JFrame dialogParent, String label,
+ public void showDialogOnTopAsync(JFrame dialogParent, Object label,
String actionString, int JOPTIONPANE_OPTION,
int JOPTIONPANE_MESSAGETYPE, Icon icon, Object[] options,
Object initialValue, boolean modal)
/**
* Create a non-modal confirm dialog
*/
- public JDialog createDialog(Component parentComponent, String message,
+ public JDialog createDialog(Component parentComponent, Object message,
String title, int optionType, int messageType, Icon icon,
Object[] options, Object initialValue, boolean modal)
{
import javax.swing.JFrame;
import javax.swing.JOptionPane;
+import javax.swing.JTextPane;
import com.formdev.flatlaf.extras.FlatDesktop;
if (Cache.getDefault("WAIT_FOR_SAVE", true)
&& BackupFiles.hasSavesInProgress())
{
- /*
- Future<QResponse> waitGot = executor.submit(waitQuitCall);
- try
- {
- got = waitGot.get();
- } catch (InterruptedException | ExecutionException e)
- {
- jalview.bin.Console.debug(
- "Exception during quit handling (wait for save)", e);
- }
- */
QResponse waitResponse = waitQuit(interactive, okQuit, forceQuit,
cancelQuit);
wait = waitResponse == QResponse.QUIT;
// callback as each file finishes saving
for (CompletableFuture<Boolean> cf : BackupFiles
- .savesInProgressCompletableFutures())
+ .savesInProgressCompletableFutures(false))
{
// if this is the last one then complete filesAllSaved
cf.whenComplete((ret, e) -> {
.setResponseHandler(JOptionPane.NO_OPTION, forceQuit)
.setResponseHandler(JOptionPane.CANCEL_OPTION, cancelQuit);
+ JTextPane messagePane = new JTextPane();
+ messagePane.setBackground(waitDialog.getBackground());
+ messagePane.setBorder(null);
+ messagePane.setText(waitingForSaveMessage());
// callback as each file finishes saving
for (CompletableFuture<Boolean> cf : BackupFiles
- .savesInProgressCompletableFutures())
+ .savesInProgressCompletableFutures(false))
{
cf.whenComplete((ret, e) -> {
Console.debug("############# A FILE SAVED!");
// update the list of saving files as they save too
- waitDialog.setMessage(waitingForSaveMessage());
- waitDialog.setName("AAARGH!");
+ messagePane.setText(waitingForSaveMessage());
// if this is the last one then close the dialog
if (!BackupFiles.hasSavesInProgress())
{
- // like a click on Wait button ???
- Console.debug(
- "***** TRYING TO MAKE THE WAIT FOR SAVE DIALOG DISAPPEAR!");
+ // like a click on Wait button
waitDialog.setValue(JOptionPane.YES_OPTION);
parent.dispose();
}
});
}
- waitDialog.showDialogOnTopAsync(parent, waitingForSaveMessage(),
+ waitDialog.showDialogOnTopAsync(parent, messagePane,
MessageManager.getString("action.wait"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE, null, new Object[]
return waitResponse;
};
- public static void okk()
- {
- /*
- if (false)
- {
- if (false)
- {
-
- waitLonger = JOptionPane.showOptionDialog(dialogParent,
- waitingForSaveMessage(),
- MessageManager.getString("action.wait"),
- JOptionPane.YES_NO_CANCEL_OPTION,
- JOptionPane.WARNING_MESSAGE, null, options, wait);
- }
- else
- {
- // non-interactive
- waitLonger = iteration < NON_INTERACTIVE_WAIT_CYCLES
- ? JOptionPane.YES_OPTION
- : JOptionPane.NO_OPTION;
- }
-
- if (waitLonger == JOptionPane.YES_OPTION) // "wait"
- {
- saving = !waitForSave(waitIncrement);
- }
- else if (waitLonger == JOptionPane.NO_OPTION) // "force
- // quit"
- {
- // do a force quit
- return setResponse(QResponse.FORCE_QUIT);
- }
- else if (waitLonger == JOptionPane.CANCEL_OPTION) // cancel quit
- {
- return setResponse(QResponse.CANCEL_QUIT);
- }
- else
- {
- // Most likely got here by user dismissing the dialog with the
- // 'x'
- // -- treat as a "Cancel"
- return setResponse(QResponse.CANCEL_QUIT);
- }
- }
-
- // not sure how we got here, best be safe
- return QResponse.CANCEL_QUIT;
- */
- };
-
private static int waitForceQuitCancelQuitOptionDialog(Object message,
String title)
{
MessageManager.getString("action.force_quit"),
MessageManager.getString("action.cancel_quit") };
- // BackupFiles.setWaitForSaveDialog(dialogParent);
-
int answer = JOptionPane.showOptionDialog(dialogParent, message, title,
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, wait);
- // BackupFiles.clearWaitForSaveDialog();
-
return answer;
}
private static String waitingForSaveMessage()
{
- StringBuilder messageSB = new StringBuilder(
- MessageManager.getString("label.save_in_progress"));
- boolean any = false;
- for (File file : BackupFiles.savesInProgressFiles())
+ StringBuilder messageSB = new StringBuilder();
+
+ List<File> files = BackupFiles.savesInProgressFiles(false);
+ boolean any = files.size() > 0;
+ if (any)
{
- messageSB.append("\n- ");
- messageSB.append(file.getName());
- any = true;
+ messageSB.append(MessageManager.getString("label.save_in_progress"));
+ for (File file : files)
+ {
+ messageSB.append("\n- ").append(file.getName());
+ }
}
- if (!any)
+ else
{
- messageSB.append("\n");
- messageSB.append(MessageManager.getString("label.unknown"));
+ messageSB.append(MessageManager.getString("label.all_saved"))
+ .append("\n")
+ .append(MessageManager.getString("label.quitting_bye"));
}
-
return messageSB.toString();
}