Mercurial > 510Connectbot
diff src/org/tn5250j/GlobalConfigure.java @ 22:e067ee54f638 tn5250
adding tn5250 files
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 03 Jun 2014 10:40:11 -0700 |
parents | 94abfc6441a4 |
children | 5949eb469a79 |
line wrap: on
line diff
--- a/src/org/tn5250j/GlobalConfigure.java Tue Jun 03 10:29:26 2014 -0700 +++ b/src/org/tn5250j/GlobalConfigure.java Tue Jun 03 10:40:11 2014 -0700 @@ -37,8 +37,6 @@ import java.util.Hashtable; import java.util.Properties; -import javax.swing.JOptionPane; - import com.five_ten_sg.connectbot.TerminalView; import org.tn5250j.interfaces.ConfigureFactory; import org.tn5250j.tools.logging.TN5250jLogFactory; @@ -66,13 +64,6 @@ static private Hashtable registry = new Hashtable(); static private Hashtable headers = new Hashtable(); //LUC GORRENS - - // Moved to ConfigureFactory - // static final public String SESSIONS = "sessions"; - static final public File ses = new File(SESSIONS); - // static final public String MACROS = "macros"; - // static final public String KEYMAP = "keymap"; - private final TN5250jLogger log = TN5250jLogFactory.getLogger (this.getClass()); /** @@ -191,7 +182,6 @@ log.info(" Information Message: " + fnfea.getMessage() + ". The file " + settingsFile() + " will be created for first time use."); - checkLegacy(); saveSettings(); } catch (IOException ioea) { @@ -206,84 +196,6 @@ } } - private void checkDirs() { - // we now check to see if the settings directory is a directory. If not then we create it - File sd = new File(settings.getProperty("emulator.settingsDirectory")); - if (!sd.isDirectory()) - sd.mkdirs(); - } - - private void checkLegacy() { - // we check if the sessions file already exists in the directory - // if it does exist we are working with an old install so we - // need to set the settings directory to the users directory - // SESSIONS is declared as a string, so we just can use the keyword here. - if(ses.exists()) { - int cfc; - cfc = JOptionPane.showConfirmDialog(null, - "Dear User,\n\n" + - "Seems you are using an old version of tn5250j.\n" + - "In meanwhile the application became multi-user capable,\n" + - "which means ALL the config- and settings-files are\n" + - "placed in your home-dir to avoid further problems in\n" + - "the near future.\n\n" + - "You have the choice to choose if you want the files\n" + - "to be copied or not, please make your choice !\n\n" + - "Shall we copy the files to the new location ?", - "Old install detected", JOptionPane.WARNING_MESSAGE, - JOptionPane.YES_NO_OPTION); - if (cfc == 0) { - // Here we do a checkdir so we know the destination-dir exists - checkDirs(); - copyConfigs(SESSIONS); - copyConfigs(MACROS); - copyConfigs(KEYMAP); - } - else { - JOptionPane.showMessageDialog(null, - "Dear User,\n\n" + - "You choosed not to copy the file.\n" + - "This means the program will end here.\n\n" + - "To use this NON-STANDARD behaviour start tn5250j\n" + - "with -Demulator.settingsDirectory=<settings-dir> \n" + - "as a parameter to avoid this question all the time.", - "Using NON-STANDARD behaviour", JOptionPane.WARNING_MESSAGE); - System.exit(0); - } - } - } - - private void copyConfigs(String sesFile) { - /** Copy the config-files to the user's home-dir */ - String srcFile = System.getProperty("user.dir") + File.separator + sesFile; - String dest = System.getProperty("user.home") + - File.separator + TN5250J_FOLDER + File.separator + sesFile; - File rmvFile = new File(sesFile); - try { - FileReader r = new FileReader(srcFile); - BufferedReader b = new BufferedReader(r); - - FileWriter w = new FileWriter(dest); - PrintWriter p = new PrintWriter(w); - String regel = b.readLine(); - while (regel != null) { - p.println(regel); - regel = b.readLine(); - } - b.close(); - p.close(); - rmvFile.delete(); - } - catch (FileNotFoundException e) { - log.warn(srcFile + " not found !"); - } - catch (IOException e) { - log.warn("Global io-error !"); - } - catch (ArrayIndexOutOfBoundsException e) { - } - } - /** * Save the settings for the global configuration */ @@ -471,9 +383,11 @@ } @Override - public Properties getProperties(String regKey,String fileName, - boolean createFile,String header, - boolean reloadIfLoaded) { + public Properties getProperties(String regKey, + String fileName, + boolean createFile, + String header, + boolean reloadIfLoaded) { if (!registry.containsKey(regKey) || reloadIfLoaded) {