Changeset 13769 in josm


Ignore:
Timestamp:
2018-05-15T02:42:22+02:00 (6 years ago)
Author:
Don-vip
Message:

don't display error dialog when loading preferences in headless mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r13647 r13769  
    77import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
    88
     9import java.awt.GraphicsEnvironment;
    910import java.io.File;
    1011import java.io.IOException;
     
    552553                Logging.warn(tr("Failed to initialize preferences. Preference directory ''{0}'' is not a directory.",
    553554                        prefDir.getAbsoluteFile()));
    554                 JOptionPane.showMessageDialog(
    555                         Main.parent,
    556                         tr("<html>Failed to initialize preferences.<br>Preference directory ''{0}'' is not a directory.</html>",
    557                                 prefDir.getAbsoluteFile()),
    558                         tr("Error"),
    559                         JOptionPane.ERROR_MESSAGE
    560                 );
     555                if (!GraphicsEnvironment.isHeadless()) {
     556                    JOptionPane.showMessageDialog(
     557                            Main.parent,
     558                            tr("<html>Failed to initialize preferences.<br>Preference directory ''{0}'' is not a directory.</html>",
     559                                    prefDir.getAbsoluteFile()),
     560                            tr("Error"),
     561                            JOptionPane.ERROR_MESSAGE
     562                    );
     563                }
    561564                return;
    562565            }
     
    565568                Logging.warn(tr("Failed to initialize preferences. Failed to create missing preference directory: {0}",
    566569                        prefDir.getAbsoluteFile()));
    567                 JOptionPane.showMessageDialog(
    568                         Main.parent,
    569                         tr("<html>Failed to initialize preferences.<br>Failed to create missing preference directory: {0}</html>",
    570                                 prefDir.getAbsoluteFile()),
    571                         tr("Error"),
    572                         JOptionPane.ERROR_MESSAGE
    573                 );
     570                if (!GraphicsEnvironment.isHeadless()) {
     571                    JOptionPane.showMessageDialog(
     572                            Main.parent,
     573                            tr("<html>Failed to initialize preferences.<br>Failed to create missing preference directory: {0}</html>",
     574                                    prefDir.getAbsoluteFile()),
     575                            tr("Error"),
     576                            JOptionPane.ERROR_MESSAGE
     577                    );
     578                }
    574579                return;
    575580            }
     
    591596        } catch (IOException e) {
    592597            Logging.error(e);
    593             JOptionPane.showMessageDialog(
    594                     Main.parent,
    595                     tr("<html>Failed to initialize preferences.<br>Failed to reset preference file to default: {0}</html>",
    596                             getPreferenceFile().getAbsoluteFile()),
    597                     tr("Error"),
    598                     JOptionPane.ERROR_MESSAGE
    599             );
     598            if (!GraphicsEnvironment.isHeadless()) {
     599                JOptionPane.showMessageDialog(
     600                        Main.parent,
     601                        tr("<html>Failed to initialize preferences.<br>Failed to reset preference file to default: {0}</html>",
     602                                getPreferenceFile().getAbsoluteFile()),
     603                        tr("Error"),
     604                        JOptionPane.ERROR_MESSAGE
     605                );
     606            }
    600607            return;
    601608        }
     
    606613            Logging.error(e);
    607614            File backupFile = new File(prefDir, "preferences.xml.bak");
    608             JOptionPane.showMessageDialog(
    609                     Main.parent,
    610                     tr("<html>Preferences file had errors.<br> Making backup of old one to <br>{0}<br> " +
    611                             "and creating a new default preference file.</html>",
    612                             backupFile.getAbsoluteFile()),
    613                     tr("Error"),
    614                     JOptionPane.ERROR_MESSAGE
    615             );
     615            if (!GraphicsEnvironment.isHeadless()) {
     616                JOptionPane.showMessageDialog(
     617                        Main.parent,
     618                        tr("<html>Preferences file had errors.<br> Making backup of old one to <br>{0}<br> " +
     619                                "and creating a new default preference file.</html>",
     620                                backupFile.getAbsoluteFile()),
     621                        tr("Error"),
     622                        JOptionPane.ERROR_MESSAGE
     623                );
     624            }
    616625            Main.platform.rename(preferenceFile, backupFile);
    617626            try {
Note: See TracChangeset for help on using the changeset viewer.