Example usage for javax.swing JOptionPane showOptionDialog

List of usage examples for javax.swing JOptionPane showOptionDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showOptionDialog.

Prototype

@SuppressWarnings("deprecation")
public static int showOptionDialog(Component parentComponent, Object message, String title, int optionType,
        int messageType, Icon icon, Object[] options, Object initialValue) throws HeadlessException 

Source Link

Document

Brings up a dialog with a specified icon, where the initial choice is determined by the initialValue parameter and the number of choices is determined by the optionType parameter.

Usage

From source file:se.trixon.jota.client.ui.MainFrame.java

private void showOptions() {
    OptionsPanel optionsPanel = new OptionsPanel();
    SwingHelper.makeWindowResizable(optionsPanel);

    int retval = JOptionPane.showOptionDialog(this, optionsPanel, Dict.OPTIONS.toString(),
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);

    if (retval == JOptionPane.OK_OPTION) {
        optionsPanel.save();/*from w  ww.  j a v a  2 s.c  om*/
    }
}

From source file:se.trixon.mapollage.ui.MainFrame.java

private void showOptions() {
    OptionsPanel optionsPanel = new OptionsPanel();
    SwingHelper.makeWindowResizable(optionsPanel);

    Object[] options = new Object[] { AlmondOptionsPanel.getGlobalOptionsButton(optionsPanel), new JSeparator(),
            Dict.CANCEL, Dict.OK };//from  w  w w  . ja v  a  2 s . co m
    int retval = JOptionPane.showOptionDialog(this, optionsPanel, Dict.OPTIONS.toString(),
            JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, Dict.OK);

    if (retval == Arrays.asList(options).indexOf(Dict.OK)) {
        optionsPanel.save();
    }
}

From source file:se.trixon.pacoma.ui.MainFrame.java

private void editCollage(Collage collage) {
    String title = Dict.Dialog.TITLE_EDIT_PROPERTIES.toString();
    boolean existing = true;
    if (collage == null) {
        collage = new Collage();
        collage.addPropertyChangeListener(mCollagePropertyChangeListener);
        title = mBundleUI.getString("create_new_collage");
        existing = false;/* w ww.  ja v a  2  s. c  o m*/
    }

    PropertiesPanel propertiesPanel = new PropertiesPanel(collage);
    SwingHelper.makeWindowResizable(propertiesPanel);

    int result = JOptionPane.showOptionDialog(this, propertiesPanel, title, JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE, null, null, null);

    if (result == JOptionPane.YES_OPTION) {
        propertiesPanel.store();
        mCollage = collage;

        if (!existing) {
            mActionManager.setEnabledDocumentActions(true);
            mCollage.setName(String.format("%s %d", Dict.UNTITLED.toString(), ++sDocumentCounter));
        }
    }
}

From source file:skoa.helpers.ConfiguracionGraficas.java

public ConfiguracionGraficas(JFrame i) {
    //Inicializamos los directorios correspondientes a partir de donde se encuentra el .jar
    File dir_inicial = new File("./");
    ruta_jar = System.getProperty("user.dir");
    String os = System.getProperty("os.name");
    //En Windows las barras son \ y en Linux /.
    String busca, reemp;//from   w w w.jav a2s  .  c o m
    //if (os.indexOf("Win")>=0) {
    ruta_destino = ruta_jar + File.separator + "Consultas" + File.separator;
    ruta_lista2 = ruta_jar + File.separator + "lista.txt";
    //busca="\\";
    //reemp="\\\\";
    //}
    //else{
    //ruta_destino=ruta_jar+File.separator+"Consultas"+File.separator;
    //ruta_lista2=ruta_jar+File.separator+"lista.txt";
    //busca="/";
    //reemp="//";  //La doble barra es por MySQL, en Linux no s si hace falta.
    //}
    //String aux=ruta_jar,aux2="";
    //Cuando se usa una ruta en la base de datos, debe tener doble barra, es decir \\\\
    /*while(aux.length()!=0){
    if (aux.indexOf(busca)>=0) {
        aux2=aux2+aux.substring(0,aux.indexOf(busca));
        aux=aux.substring(aux.indexOf(busca)+1);
    }
    else {
        aux2=aux2+aux.substring(0);
        aux="";
    }
    aux2=aux2+reemp;
    }*/
    ruta_lista = ruta_lista2;
    //if (os.indexOf("Win")>=0) ruta_lista=aux2+"\\\\lista.txt";
    //else ruta_lista=aux2+"//lista.txt";

    //-----------------------------------
    interfaz = i;
    String g1 = " 1 "; //titulo del boton por defecto
    String g4 = " 4 ";
    Object[] options = { g1, g4 }; //titulo de los botones
    int n = JOptionPane.showOptionDialog(interfaz, "Cantas grficas desea visualizar?", "Visualizacin",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, g1);
    if (n == JOptionPane.YES_OPTION)
        g = 1;
    else if (n == JOptionPane.NO_OPTION)
        g = 4;
    vg = g;//N de graficas a visualizar. Variable usada en el procedimiento colocarGraficos()
    inicializarPaneles();
    inicial();
    iniciarConexiones2();
}

From source file:storybook.SbApp.java

public static void main(String[] args) {
    String tempDir = System.getProperty("java.io.tmpdir");
    String fn = tempDir + File.separator + "storybook.lck";
    if (args.length > 0) {
        for (int i = 0; i < args.length; i++) {
            if (args[i].equalsIgnoreCase("--trace")) {
                SbApp.bTrace = true;//from ww w.  ja v a 2  s .c  om
                System.out.println("Storybook execution in trace mode");
            }
            if (args[i].equalsIgnoreCase("--hibernate")) {
                SbApp.bTraceHibernate = true;
                System.out.println("Hibernate in trace mode");
            }
            if (args[i].equalsIgnoreCase("--dev")) {
                SbApp.bDevTest = true;
                System.out.println("Development test");
            }
            if (args[i].equalsIgnoreCase("--msg")) {
                File f = new File(args[i + 1] + ".properties");
                if (!f.exists()) {
                    System.out.println("Msg test file not exists : " + args[i + 1]);
                } else {
                    SbApp.i18nFile = args[i + 1];
                    System.out.println("Msg test file is : " + SbApp.i18nFile);
                }
            }
        }
    }
    if (!lockInstance(fn)) {
        Object[] options = { I18N.getMsg("msg.running.remove"), I18N.getMsg("msg.common.cancel") };
        int n = JOptionPane.showOptionDialog(null, I18N.getMsg("msg.running.msg"),
                I18N.getMsg("msg.running.title"), JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
        if (n == 0) {
            File file = new File(fn);
            if (file.exists() && file.canWrite()) {
                if (!file.delete()) {
                    JOptionPane.showMessageDialog(null, "Delete failed",
                            "File\n" + file.getAbsolutePath() + "\ncould not be deleted.",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }
        return;
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            SbApp app = SbApp.getInstance();
            app.init();
        }
    });
}

From source file:studio.core.EntryPoint.java

public static void main(final String[] args) {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

    if (System.getProperty("mrj.version") != null) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        //     System.setProperty("apple.awt.brushMetalLook", "true");
        System.setProperty("apple.awt.showGrowBox", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Studio for kdb+");
        System.setProperty("com.apple.mrj.application.live-resize", "true");
        System.setProperty("com.apple.macos.smallTabs", "true");
        System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
    }/*from w  ww . j a  va 2s.c  o  m*/

    if (Config.getInstance().getLookAndFeel() != null) {
        try {
            UIManager.setLookAndFeel(Config.getInstance().getLookAndFeel());
        } catch (Exception ex) {
            // go on with default one
            ex.printStackTrace();
        }
    }
    final CommandLineParser cmdLineGnuParser = new GnuParser();
    try {
        CommandLine commandLine = cmdLineGnuParser.parse(constructGnuOptions(), args);
        if (commandLine.hasOption("servers")) {
            String fileName = commandLine.getOptionValue("servers");
            Config.getInstance().loadFromFile(fileName);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    studio.ui.I18n.setLocale(Locale.getDefault());

    //   studio.ui.I18n.setLocale(new Locale("zh", "cn"));

    if (!Config.getInstance().getAcceptedLicense()) {
        LicensePanel panel = new LicensePanel();
        Object[] options = new String[] { "Accept", "Do Not Accept" };
        int answer = JOptionPane.showOptionDialog(null, panel, "Studio for kdb+", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, Studio.getImage(Config.imageBase + "32x32/question.png"), //do not use a custom Icon
                options, //the titles of buttons
                options[1]); //default button title

        if (answer == JOptionPane.NO_OPTION)
            System.exit(0);

        Config.getInstance().setAcceptedLicense(Lm.buildDate);
    }

    UIManager.put("Table.font", new javax.swing.plaf.FontUIResource("Monospaced", Font.PLAIN,
            UIManager.getFont("Table.font").getSize()));
    System.setProperty("awt.useSystemAAFontSettings", "on");
    System.setProperty("swing.aatext", "true");

    ThreadGroup exceptionThreadGroup = new ExceptionGroup();

    new Thread(exceptionThreadGroup, "Init thread") {
        public void run() {
            Studio.init(args);
        }
    }.start();

}

From source file:tvbrowser.core.Settings.java

/**
 * Enables the export/*from   ww w.  jav a  2  s  .co  m*/
 */
public static void copyToSystem() {
    final File currentSettingsDir = new File(getUserSettingsDirName());
    final File currentTvDataDir = new File(getDefaultTvDataDir());

    mCopyToSystem = MainFrame.getInstance().getUserRequestCopyToSystem();

    if (mCopyToSystem) {
        Properties prop = new Properties();

        if (OperatingSystem.isMacOs()) {
            prop.setProperty("userdir", "${user.home}/Library/Preferences/TV-Browser");
            prop.setProperty("tvdatadir", "${user.home}/Library/Application Support/TV-Browser/tvdata");
            prop.setProperty("pluginsdir", "${user.home}/Library/Application Support/TV-Browser/plugins");
        } else if (OperatingSystem.isLinux()) {
            prop.setProperty("userdir", "${user.home}/.tvbrowser");
            prop.setProperty("tvdatadir", "${user.home}/.tvbrowser/tvdata");
        } else if (OperatingSystem.isWindows()) {
            prop.setProperty("userdir", "${user.appdata}/TV-Browser");
            prop.setProperty("tvdatadir", "${user.appdata}/TV-Browser/tvdata");
        }

        mDefaultSettings = new DefaultSettings(prop);

        final File targetSettingsDir = new File(getUserSettingsDirName());
        final File targetTvDataDir = new File(getDefaultTvDataDir());

        if (new File(getUserSettingsDirName(), SETTINGS_FILE).isFile()) {
            String[] options = { MainFrame.mLocalizer.msg("continue", "Continue"),
                    MainFrame.mLocalizer.msg("stop", "Cancel copying now") };
            String title = MainFrame.mLocalizer.msg("copyToSystemTitleWarning", "Settings already exists");
            String msg = MainFrame.mLocalizer.msg("copyToSystemWarningMsg",
                    "Settings already exist in the system settings directory!\nIf you continue the current settings will be overwritten!");

            mCopyToSystem = JOptionPane.showOptionDialog(MainFrame.getInstance(), msg, title,
                    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options,
                    options[1]) == JOptionPane.YES_OPTION;
        } else if (!targetSettingsDir.isDirectory()) {
            mCopyToSystem = targetSettingsDir.mkdirs();
        }

        if (!targetTvDataDir.isDirectory()) {
            mCopyToSystem = targetTvDataDir.mkdirs();
        }

        if (mCopyToSystem) {
            try {
                final CopyWaitingDlg waiting = new CopyWaitingDlg(new JFrame(),
                        CopyWaitingDlg.EXPORT_SETTINGS_MSG);

                mLog.info("Copy settings and TV data from TV-Browser transportable to system");

                mShowWaiting = true;

                Thread copyDataThread = new Thread("Copy TV data directory") {
                    public void run() {
                        try {
                            IOUtilities.copy(currentSettingsDir.listFiles(new FilenameFilter() {
                                public boolean accept(File dir, String name) {
                                    return !name.equalsIgnoreCase("tvdata")
                                            && !name.equals(targetSettingsDir.getName())
                                            && !name.equalsIgnoreCase("backup")
                                            && !name.equalsIgnoreCase("lang") && !name.equals(".lock");
                                }
                            }), targetSettingsDir);
                            sleep(5000);
                            IOUtilities.copy(currentTvDataDir.listFiles(), targetTvDataDir, true);
                        } catch (Exception e) {
                        }

                        mShowWaiting = false;
                        waiting.setVisible(false);
                    }
                };
                copyDataThread.start();

                waiting.setVisible(mShowWaiting);
            } catch (Exception e) {
                mCopyToSystem = false;
            }
        }
    }
}

From source file:tvbrowser.core.Settings.java

/**
 * Reads the settings from settings file. If there is no settings file,
 * default settings are used./*from w w w . j  ava2  s .co  m*/
 */
public static void loadSettings() {
    String oldDirectoryName = System.getProperty("user.home", "") + File.separator + ".tvbrowser";
    String newDirectoryName = getUserSettingsDirName();

    File settingsFile = new File(newDirectoryName, SETTINGS_FILE);
    File firstSettingsBackupFile = new File(getUserSettingsDirName(), SETTINGS_FILE + "_backup1");
    File secondSettingsBackupFile = new File(getUserSettingsDirName(), SETTINGS_FILE + "_backup2");

    if (settingsFile.exists() || firstSettingsBackupFile.exists() || secondSettingsBackupFile.exists()) {
        try {
            mProp.readFromFile(settingsFile);

            if (((mProp.getProperty("subscribedchannels") == null
                    || mProp.getProperty("subscribedchannels").trim().length() < 1)
                    && (mProp.getProperty("channelsWereConfigured") != null
                            && mProp.getProperty("channelsWereConfigured").equals("true")))
                    && (firstSettingsBackupFile.isFile() || secondSettingsBackupFile.isFile())) {
                throw new IOException();
            } else {
                mLog.info("Using settings from file " + settingsFile.getAbsolutePath());
            }
        } catch (IOException evt) {

            if (firstSettingsBackupFile.isFile() || secondSettingsBackupFile.isFile()) {
                Localizer localizer = Localizer.getLocalizerFor(Settings.class);
                if (JOptionPane.showConfirmDialog(null, localizer.msg("settingBroken",
                        "Settings file broken.\nWould you like to load the backup file?\n\n(If you select No, the\ndefault settings are used)"),
                        Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
                    boolean loadSecondBackup = !firstSettingsBackupFile.isFile();

                    if (firstSettingsBackupFile.isFile()) {
                        try {
                            mProp.readFromFile(firstSettingsBackupFile);

                            if ((mProp.getProperty("subscribedchannels") == null
                                    || mProp.getProperty("subscribedchannels").trim().length() < 1)
                                    && secondSettingsBackupFile.isFile()) {
                                loadSecondBackup = true;
                            } else {
                                mLog.info("Using settings from file "
                                        + firstSettingsBackupFile.getAbsolutePath());
                                loadSecondBackup = false;
                            }
                        } catch (Exception e) {
                            loadSecondBackup = true;
                        }
                    }
                    if (loadSecondBackup && secondSettingsBackupFile.isFile()) {
                        try {
                            mProp.readFromFile(secondSettingsBackupFile);
                            mLog.info("Using settings from file " + secondSettingsBackupFile.getAbsolutePath());
                            loadSecondBackup = false;
                        } catch (Exception e) {
                            loadSecondBackup = true;
                        }
                    }

                    if (loadSecondBackup) {
                        mLog.info("Could not read settings - using default user settings");
                    } else {
                        try {
                            loadWindowSettings();
                            storeSettings(true);
                        } catch (Exception e) {
                        }
                    }
                }
            } else {
                mLog.info("Could not read settings - using default user settings");
            }
        }
    }
    /*
     * If the settings file doesn't exist, we try to import the settings created
     * by a previous version of TV-Browser
     */
    else if (!oldDirectoryName.equals(newDirectoryName)) {
        File oldDir = null;
        File testFile = null;

        int countValue = 1;

        String firstDir = System.getProperty("user.home") + "/TV-Browser";

        if (Launch.isOsWindowsNtBranch()) {
            countValue = 3;
        }

        if (OperatingSystem.isWindows()) {
            File test = new File(System.getenv("appdata"), "TV-Browser");

            if (test.isDirectory()) {
                firstDir = test.getAbsolutePath();
            }
        }

        String[] directories = { getUserDirectoryName(), firstDir,
                System.getProperty("user.home") + "/TV-Browser",
                System.getProperty("user.home") + "/Library/Preferences/TV-Browser",
                System.getProperty("user.home") + "/.tvbrowser" };

        for (int j = 0; j < (TVBrowser.isTransportable() ? directories.length : countValue); j++) {
            String[] allVersions = TVBrowser.getAllVersionStrings();
            for (int i = (j == 0 ? 1 : 0); i < allVersions.length; i++) {
                testFile = new File(directories[j] + File.separator + allVersions[i], SETTINGS_FILE);

                if (testFile.isFile()) {
                    oldDir = new File(directories[j], allVersions[i]);
                    break;
                }
            }

            if (oldDir == null) {
                testFile = new File(directories[j], SETTINGS_FILE);

                if (testFile.isFile()) {
                    oldDir = new File(directories[j]);
                } else {
                    testFile = new File(oldDirectoryName, SETTINGS_FILE);

                    if (testFile.isFile()) {
                        oldDir = new File(oldDirectoryName);
                    }
                }
            }

            if (oldDir != null) {
                break;
            }
        }

        if (oldDir != null && oldDir.isDirectory() && oldDir.exists() && TVBrowser.isTransportable()
                && !oldDir.getAbsolutePath().startsWith(new File("settings").getAbsolutePath())) {
            try {
                UIManager.setLookAndFeel(getDefaultLookAndFeelClassName());
            } catch (Exception e) {
                /*ignore*/}

            String[] options = { MainFrame.mLocalizer.msg("import", "Import settings"),
                    MainFrame.mLocalizer.msg("configureNew", "Create new configuration") };
            String title = MainFrame.mLocalizer.msg("importInfoTitle", "Import settings?");
            String msg = MainFrame.mLocalizer.msg("importInfoMsg",
                    "TV-Browser has found settings for import.\nShould the settings be imported now?");

            if (JOptionPane.showOptionDialog(null, msg, title, JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[0]) == JOptionPane.NO_OPTION) {
                oldDir = null;
            }
        }

        if (oldDir != null && oldDir.isDirectory() && oldDir.exists()) {
            startImportWaitingDlg();
            mLog.info("Try to load settings from a previous version of TV-Browser: " + oldDir);

            final File newDir = new File(getUserSettingsDirName());

            File oldTvDataDir = null;

            final Properties prop = new Properties();

            try {
                StreamUtilities.inputStream(testFile, new InputStreamProcessor() {
                    public void process(InputStream input) throws IOException {
                        prop.load(input);
                    }
                });
            } catch (Exception e) {
            }

            String versionString = prop.getProperty("version", null);
            Version testVersion = null;

            if (versionString != null) {
                try {
                    int asInt = Integer.parseInt(versionString);
                    int major = asInt / 100;
                    int minor = asInt % 100;
                    testVersion = new Version(major, minor);
                } catch (NumberFormatException exc) {
                    // Ignore
                }
            }

            String temp = prop.getProperty("dir.tvdata", null);
            boolean versionTest = !TVBrowser.isTransportable() && Launch.isOsWindowsNtBranch()
                    && testVersion != null && testVersion.compareTo(new Version(3, 0, true)) < 0
                    && (temp == null || temp.replace("/", "\\")
                            .equals(System.getProperty("user.home") + "\\TV-Browser\\tvdata"));

            if ((TVBrowser.isTransportable() || versionTest)
                    && !(new File(getUserDirectoryName(), "tvdata").isDirectory())) {
                try {
                    if (temp != null) {
                        oldTvDataDir = new File(temp);
                    } else if (new File(oldDir, "tvdata").isDirectory()) {
                        oldTvDataDir = new File(oldDir, "tvdata");
                    } else if (new File(oldDir.getParent(), "tvdata").isDirectory()) {
                        oldTvDataDir = new File(oldDir.getParent(), "tvdata");
                    }

                } catch (Exception e) {
                }
            }

            if (newDir.mkdirs()) {
                try {
                    IOUtilities.copy(oldDir.listFiles(new FilenameFilter() {
                        public boolean accept(File dir, String name) {
                            return !name.equalsIgnoreCase("tvdata") && !name.equals(newDir.getName())
                                    && !name.equalsIgnoreCase("backup") && !name.equalsIgnoreCase("lang");
                        }
                    }), newDir);

                    mShowSettingsCopyWaiting = false;

                    mLog.info("settings from previous version copied successfully");
                    File newSettingsFile = new File(newDir, SETTINGS_FILE);
                    mProp.readFromFile(newSettingsFile);
                    mLog.info("settings from previous version read successfully");

                    /*
                     * This is the .tvbrowser dir, if there are settings form version
                     * 1.0 change the name to start with java.
                     */
                    if (oldDirectoryName.equals(oldDir.getAbsolutePath())) {
                        File[] settings = newDir.listFiles(new FilenameFilter() {
                            public boolean accept(File dir, String name) {
                                return (name.toLowerCase().endsWith(".prop")
                                        && name.toLowerCase().indexOf("settings") == -1)
                                        || (name.toLowerCase().endsWith(".dat")
                                                && name.toLowerCase().indexOf("tv-data-inventory") == -1);
                            }
                        });

                        boolean version1 = false;

                        if (settings != null) {
                            for (int i = 0; i < settings.length; i++) {
                                String name = "java." + settings[i].getName();

                                if (!settings[i].getName().toLowerCase().startsWith("java.")) {
                                    version1 = true;
                                    settings[i].renameTo(new File(settings[i].getParent(), name));
                                }
                            }
                        }

                        if (version1 && !(new File(oldDirectoryName, newDir.getName())).isDirectory()) {
                            oldDir.renameTo(new File(
                                    System.getProperty("user.home", "") + File.separator + "tvbrowser_BACKUP"));
                        }
                    }

                    /*
                     * Test if and copy TV data for the portable version.
                     */
                    if (oldTvDataDir != null && oldTvDataDir.isDirectory()) {
                        final File targetDir = new File(getUserDirectoryName(), "tvdata");

                        if (!oldTvDataDir.equals(targetDir)) {
                            targetDir.mkdirs();

                            final CopyWaitingDlg waiting = new CopyWaitingDlg(new JFrame(),
                                    versionTest ? CopyWaitingDlg.APPDATA_MSG : CopyWaitingDlg.IMPORT_MSG);

                            mShowWaiting = true;

                            final File srcDir = oldTvDataDir;

                            Thread copyDataThread = new Thread("Copy TV data directory") {
                                public void run() {
                                    try {
                                        IOUtilities.copy(srcDir.listFiles(), targetDir, true);
                                    } catch (Exception e) {
                                    }

                                    mShowWaiting = false;
                                    waiting.setVisible(false);
                                }
                            };
                            copyDataThread.start();

                            waiting.setVisible(mShowWaiting);
                        }
                    }

                    /*
                     * Test if a settings file exist in the user directory, move the
                     * settings to backup.
                     */
                    if ((new File(getUserDirectoryName(), SETTINGS_FILE)).isFile()) {
                        final File backupDir = new File(getUserDirectoryName(), "BACKUP");
                        if (backupDir.mkdirs()) {
                            mLog.info("moving the settings of old settings dir to backup");
                            File[] files = oldDir.listFiles(new FileFilter() {
                                public boolean accept(File pathname) {
                                    return pathname.compareTo(newDir) != 0
                                            && pathname.getName().compareToIgnoreCase("tvdata") != 0
                                            && pathname.compareTo(backupDir) != 0;
                                }
                            });

                            if (files != null) {
                                for (File file : files) {
                                    file.renameTo(new File(backupDir, file.getName()));
                                }
                            }
                        }
                    }
                } catch (IOException e) {
                    mLog.log(Level.WARNING, "Could not import user settings from '" + oldDir.getAbsolutePath()
                            + "' to '" + newDir.getAbsolutePath() + "'", e);
                }
            } else {
                mLog.info("Could not create directory '" + newDir.getAbsolutePath()
                        + "' - using default user settings");
            }
        } else {
            mLog.info("No previous version of TV-Browser found - using default user settings");
        }
    }
    mShowSettingsCopyWaiting = false;

    File settingsDir = new File(newDirectoryName);

    if (!settingsDir.exists()) {
        mLog.info("Creating " + newDirectoryName);
        settingsDir.mkdir();
    }

    loadWindowSettings();
}

From source file:tvbrowser.TVBrowser.java

private static void showTVBrowserIsAlreadyRunningMessageBox() {
    try {//from  ww w .j  av a 2s .c  o m
        UIThreadRunner.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                Object[] options = { Localizer.getLocalization(Localizer.I18N_CLOSE),
                        mLocalizer.msg("startAnyway", "start anyway") };
                if (JOptionPane.showOptionDialog(null,
                        mLocalizer.msg("alreadyRunning", "TV-Browser is already running"),
                        mLocalizer.msg("alreadyRunning", "TV-Browser is already running"),
                        JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options,
                        options[0]) != 1) {
                    System.exit(-1);
                }
            }
        });
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:tvbrowser.ui.mainframe.MainFrame.java

public void scrollToProgram(final Program program, final Runnable callback) {
    if (!getProgramFilter().accept(program)) {
        int result = JOptionPane.showOptionDialog(this, mLocalizer.msg("programFiltered",
                "The program {0} is not visible with the filter {1} being active.\nDo you want to deactivate the filter?",
                program.getTitle(), getProgramFilter().getName()),
                mLocalizer.msg("programNotVisible", "Program not visible"), JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, null, null);
        if (result == JOptionPane.YES_OPTION) {
            mStoredViewPosition = null;//from   ww  w . j  a  v a 2 s  . c o  m
            setProgramFilter(FilterManagerImpl.getInstance().getAllFilter());
        }
    }
    mProgramTableScrollPane.resetScrolledTime();
    // invoke scrolling later as the upper filter deactivation may have pending operations for the UI
    // so we currently can't scroll there yet
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            mProgramTableScrollPane.scrollToChannel(program.getChannel());
            scrollTo(program.getDate(), program.getStartTime(), callback);
        }
    });
}