diff options
| author | njames <nkskjames@gmail.com> | 2016-09-07 09:59:40 -0500 |
|---|---|---|
| committer | njames <nkskjames@gmail.com> | 2016-09-07 09:59:40 -0500 |
| commit | a3adb6d7ef2176100d3286547f4459eb184e8584 (patch) | |
| tree | 0e49fdd026a182a5ca4baf2c15777f61dc757558 /src/com | |
| parent | 4b28e19da8aaedb0d477797f2e17cb4be1230c21 (diff) | |
| download | serverwiz-a3adb6d7ef2176100d3286547f4459eb184e8584.tar.gz serverwiz-a3adb6d7ef2176100d3286547f4459eb184e8584.zip | |
Add comments
Norman James <nkskjames@gmail.com>
Diffstat (limited to 'src/com')
| -rw-r--r-- | src/com/ibm/ServerWizard2/ServerWizard2.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/com/ibm/ServerWizard2/ServerWizard2.java b/src/com/ibm/ServerWizard2/ServerWizard2.java index 4bb1099..e469616 100644 --- a/src/com/ibm/ServerWizard2/ServerWizard2.java +++ b/src/com/ibm/ServerWizard2/ServerWizard2.java @@ -91,28 +91,25 @@ public class ServerWizard2 { } view.open(); } + + // Load preferences file. + // Contains git repository location and repositories to manage. private static void getPreferences() { Display display = new Display(); Shell shell = new Shell(display); try { - boolean newFile = false; + Properties p = new Properties(); File f = new File(ServerWizard2.PROPERTIES_FILE); if (!f.exists()) { + //File doesn't exist, so create; prompt user for git location ServerWizard2.LOGGER.info("Preferences file doesn't exist, creating..."); - f.createNewFile(); - newFile = true; - } - FileInputStream propFile = new FileInputStream(ServerWizard2.PROPERTIES_FILE); - Properties p = new Properties(); - p.load(propFile); - propFile.close(); - - if (newFile) { DirectoryDialog fdlg = new DirectoryDialog(shell, SWT.OPEN); + fdlg.setMessage("Select location of GIT repositories:"); fdlg.setFilterPath(ServerWizard2.getWorkingDir()); String libPath = fdlg.open(); - if (libPath.isEmpty()) { - libPath = "git"; + if (libPath == null || libPath.isEmpty()) { + ServerWizard2.LOGGER.warning("No directory selected; exiting..."); + System.exit(0); } p.setProperty("git_location", libPath); p.setProperty("repositories", ServerWizard2.DEFAULT_REMOTE_URL); @@ -122,7 +119,17 @@ public class ServerWizard2 { p.store(out, ""); out.close(); } - ServerWizard2.GIT_LOCATION = p.getProperty("git_location"); + FileInputStream propFile = new FileInputStream(ServerWizard2.PROPERTIES_FILE); + p.load(propFile); + propFile.close(); + String loc = p.getProperty("git_location"); + if (loc !=null && !loc.isEmpty()) { + ServerWizard2.GIT_LOCATION = loc; + } else { + ServerWizard2.LOGGER.severe(ServerWizard2.PROPERTIES_FILE+" does not contain a repository location.\nPlease correct or delete."); + System.exit(0); + } + } catch (Exception e) { e.printStackTrace(); |

