Search in sources :

Example 6 with QuestionDialog

use of com.mucommander.ui.dialog.QuestionDialog in project mucommander by mucommander.

the class BinaryEditor method canClose.

/**
 * Checks whether file can be closed and asks for confirmation if necessary.
 *
 * @return true if the file does not have any unsaved change or if the user opted to save the changes, false if the
 *         user canceled the dialog or the save failed.
 */
public boolean canClose() {
    if (!saveNeeded) {
        return true;
    }
    QuestionDialog dialog = new QuestionDialog(windowFrame, null, Translator.get("file_editor.save_warning"), binaryComponent, Arrays.asList(BinaryEditorAction.YES, BinaryEditorAction.NO, BinaryEditorAction.CANCEL), 0);
    DialogAction ret = dialog.getActionValue();
    if (ret == BinaryEditorAction.YES && trySave(currentFile) || ret == BinaryEditorAction.NO) {
        setSaveNeeded(false);
        return true;
    }
    // User canceled or the file couldn't be properly saved
    return false;
}
Also used : QuestionDialog(com.mucommander.ui.dialog.QuestionDialog) DialogAction(com.mucommander.ui.dialog.DialogAction)

Example 7 with QuestionDialog

use of com.mucommander.ui.dialog.QuestionDialog in project mucommander by mucommander.

the class BasicFileEditor method askSave.

// Returns true if the file does not have any unsaved change or if the user refused to save the changes,
// false if the user canceled the dialog or the save failed.
public boolean askSave() {
    if (!saveNeeded) {
        return true;
    }
    QuestionDialog dialog = new QuestionDialog(getFrame(), null, Translator.get("file_editor.save_warning"), getFrame(), Arrays.asList(BasicFileAction.YES, BasicFileAction.NO, BasicFileAction.CANCEL), 0);
    DialogAction ret = dialog.getActionValue();
    if (ret == BasicFileAction.YES && trySave(getCurrentFile()) || ret == BasicFileAction.NO) {
        setSaveNeeded(false);
        return true;
    }
    // User canceled or the file couldn't be properly saved
    return false;
}
Also used : QuestionDialog(com.mucommander.ui.dialog.QuestionDialog) DialogAction(com.mucommander.ui.dialog.DialogAction)

Aggregations

QuestionDialog (com.mucommander.ui.dialog.QuestionDialog)7 DialogAction (com.mucommander.ui.dialog.DialogAction)6 MainFrame (com.mucommander.ui.main.MainFrame)2 WarnUserException (com.mucommander.viewer.WarnUserException)2 Frame (java.awt.Frame)2 CredentialsMapping (com.mucommander.auth.CredentialsMapping)1 AbstractFile (com.mucommander.commons.file.AbstractFile)1 AuthException (com.mucommander.commons.file.AuthException)1 AuthenticationType (com.mucommander.commons.file.AuthenticationType)1 FileURL (com.mucommander.commons.file.FileURL)1 AuthDialog (com.mucommander.ui.dialog.auth.AuthDialog)1 FileEditorService (com.mucommander.viewer.FileEditorService)1 FileViewerService (com.mucommander.viewer.FileViewerService)1 Cursor (java.awt.Cursor)1 MalformedURLException (java.net.MalformedURLException)1