📄 systemresources.java
字号:
boolean equeryDirExists = false; // whether the conf dir exists boolean confDirExists = false; // whether the logs dir exists boolean logsDirExists = false; // whether to copy confg files from old dir boolean copyOldFiles = false; // ------------------------------------------- // -- Check for ~/.executequery // ------------------------------------------- if (!equeryDir.exists()) { equeryDirExists = equeryDir.mkdir(); // create the conf directory confDirExists = confDir.mkdir(); } // ------------------------------------------- // -- Check for ~/.executequery/<build_number> // ------------------------------------------- else if (!confDir.exists()) { confDirExists = confDir.mkdir(); copyOldFiles = true; } else { // they exist equeryDirExists = true; confDirExists = true; } String newConfPath = confDir.getAbsolutePath() + fileSeparator; int lastBuildNumber = -1; if (copyOldFiles) { // check for old conf build number dirs int currentBuild = Integer.parseInt( System.getProperty("executequery.build")); File[] dirs = equeryDir.listFiles(); for (int i = 0; i < dirs.length; i++) { String name = dirs[i].getName(); if (MiscUtils.isValidNumber(name)) { int buildNumber = Integer.parseInt(name); if (currentBuild > buildNumber) { lastBuildNumber = Math.max(lastBuildNumber, buildNumber); } } } } // if we have a valid last build dir - use it File oldConfDir = null; if (lastBuildNumber != -1) { oldConfDir = new File(eqUserHomeDir + fileSeparator + lastBuildNumber); } else { // otherwise check for old format ~/.executequery/conf oldConfDir = new File(eqUserHomeDir + fileSeparator + "conf"); } // if an old conf dir exists, move relevant // files to the new build number dir if (copyOldFiles && oldConfDir.exists()) { String oldFromPath = oldConfDir.getAbsolutePath(); String[] oldFiles = {"eq.shortcuts.properties", "eq.user.properties", "jdbcdrivers.xml", "lookandfeel.xml", //"toolbars.xml", "print.setup", "savedconnections.xml", "sql.user.keywords"}; File file = null; // move the above files to the new build dir for (int i = 0; i < oldFiles.length; i++) { file = new File(oldFromPath, oldFiles[i]); if (file.exists()) { String path1 = file.getAbsolutePath(); file = new File(confDir, oldFiles[i]); String path2 = file.getAbsolutePath(); FileUtils.copyFile(path1, path2); } } } if (!logsDir.exists()) { logsDirExists = logsDir.mkdir(); } if (!equeryDirExists && !confDirExists && !logsDirExists) { GUIUtilities.displayErrorMessage( "Error creating profile in user's home directory.\nExiting."); System.exit(0); } boolean created = false; // ------------------------------------------- // -- Check for ~/.executequery/conf/sql.user.keywords // ------------------------------------------- File props = new File(confDir, "sql.user.keywords"); // create the user defined keywords file if (!props.exists()) { created = props.createNewFile(); } else { created = true; } if (!created) { return false; } // ------------------------------------------- // -- Check for ~/.executequery/conf/eq.user.properties // ------------------------------------------- props = new File(confDir, "eq.user.properties"); if (!props.exists()) { Log.debug("Creating user properties file eq.user.properties"); created = props.createNewFile(); } else { created = true; } if (!created) { return false; } // ------------------------------------------- // -- Check for ~/.executequery/conf/jdbcdrivers.xml // ------------------------------------------- props = new File(confDir, "jdbcdrivers.xml"); if (!props.exists()) { Log.debug("Creating user properties file jdbcdrivers.xml"); FileUtils.copyResource( "org/executequery/jdbcdrivers-default.xml", newConfPath + "jdbcdrivers.xml"); props = new File(confDir, "jdbcdrivers.xml"); created = props.exists(); } else { created = true; } if (!created) { return false; } // ------------------------------------------- // -- Check for ~/.executequery/conf/lookandfeel.xml // ------------------------------------------- props = new File(confDir, "lookandfeel.xml"); if (!props.exists()) { Log.debug("Creating user properties file lookandfeel.xml"); FileUtils.copyResource( "org/executequery/lookandfeel-default.xml", newConfPath + "lookandfeel.xml"); props = new File(confDir, "lookandfeel.xml"); created = props.exists(); } else { created = true; } if (!created) { return false; } // ------------------------------------------- // -- Check for ~/.executequery/conf/savedconnections.xml // ------------------------------------------- props = new File(confDir, "savedconnections.xml"); if (!props.exists()) { Log.debug("Creating user properties file savedconnections.xml"); FileUtils.copyResource( "org/executequery/savedconnections-default.xml", newConfPath + "savedconnections.xml"); props = new File(confDir, "savedconnections.xml"); created = props.exists(); } else { created = true; } if (!created) { return false; } // ------------------------------------------- // -- Check for ~/.executequery/conf/toolbars.xml // ------------------------------------------- props = new File(confDir, "toolbars.xml"); if (!props.exists()) { Log.debug("Creating user properties file toolbars.xml"); FileUtils.copyResource( "org/executequery/toolbars-default.xml", newConfPath + "toolbars.xml"); props = new File(confDir, "toolbars.xml"); created = props.exists(); } else { created = true; } return created; } catch (IOException exc) { exc.printStackTrace(); GUIUtilities.displayErrorMessage( "Error creating profile in user's home directory.\nExiting."); return false; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -