- Timestamp:
- 10/20/09 13:46:39 (15 years ago)
- Location:
- trunk/de.ugoe.cs.swe.exercises
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.exercises/.classpath
r14 r31 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <classpath> 3 <classpathentry exported="true" kind="lib" path="lib/xpp3_min-1.1.4c.jar"/> 4 <classpathentry exported="true" kind="lib" path="lib/xstream-1.3.1.jar"/> 3 5 <classpathentry exported="true" kind="lib" path="lib/org.eclipse.nebula.widgets.formattedtext_1.0.0.HEAD.jar"/> 4 6 <classpathentry exported="true" kind="lib" path="lib/org.eclipse.nebula.widgets.datechooser_1.0.0.HEAD.jar"/> -
trunk/de.ugoe.cs.swe.exercises/META-INF/MANIFEST.MF
r16 r31 22 22 lib/trilead.jar, 23 23 lib/org.eclipse.nebula.widgets.datechooser_1.0.0.HEAD.jar, 24 lib/org.eclipse.nebula.widgets.formattedtext_1.0.0.HEAD.jar 24 lib/org.eclipse.nebula.widgets.formattedtext_1.0.0.HEAD.jar, 25 lib/xpp3_min-1.1.4c.jar, 26 lib/xstream-1.3.1.jar 25 27 Bundle-Vendor: Software Engineering for Distributed Systems Group, Uni Goettingen 26 28 Export-Package: de.ugoe.cs.swe.exercises, -
trunk/de.ugoe.cs.swe.exercises/build.properties
r26 r31 15 15 lib/org.eclipse.nebula.widgets.formattedtext_1.0.0.HEAD.jar,\ 16 16 epl-v10.html,\ 17 epl-v10.txt 17 epl-v10.txt,\ 18 lib/xpp3_min-1.1.4c.jar,\ 19 lib/xstream-1.3.1.jar 18 20 source.. = src/ -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/Application.java
r20 r31 37 37 public Object start(IApplicationContext context) { 38 38 Display display = PlatformUI.createDisplay(); 39 Settings.getInstance().load(); 39 40 SettingsDialog settingsDialog = new SettingsDialog(new Shell()); 40 /* try{ */ 41 if (!Settings.getInstance().isInitialized()) 41 if (!Settings.getInstance().isInitialized()) { 42 42 settingsDialog.open(); 43 /* 44 * } catch (NullPointerException ex){ settingsDialog.open(); } catch 45 * (IllegalArgumentException ex) { settingsDialog.open(); } catch 46 * (Exception ex) { settingsDialog.open(); } 47 */ 43 } 44 48 45 try { 49 46 DAVRepositoryFactory.setup(); -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/misc/FileUtils.java
r3 r31 1 1 package de.ugoe.cs.swe.exercises.misc; 2 2 3 import java.io.BufferedReader; 4 import java.io.BufferedWriter; 3 5 import java.io.File; 4 6 import java.io.FileInputStream; 5 7 import java.io.FileOutputStream; 8 import java.io.FileWriter; 6 9 import java.io.IOException; 10 import java.io.InputStreamReader; 7 11 import java.nio.channels.FileChannel; 8 12 … … 27 31 28 32 public static void renameFile(String oldName, String newName) { 29 30 File oldFile = new File(ExerciseSVN.SVNpath + "exercisesheets/" + oldName); 31 File newFile = new File(ExerciseSVN.SVNpath + "exercisesheets/" + newName); 32 33 34 File oldFile = new File(ExerciseSVN.SVNpath + "exercisesheets/" 35 + oldName); 36 File newFile = new File(ExerciseSVN.SVNpath + "exercisesheets/" 37 + newName); 38 33 39 try { 34 40 copyFile(oldFile, newFile); … … 40 46 } 41 47 48 public static String readFileAsString(String filePath) throws IOException { 49 BufferedReader br = new BufferedReader(new InputStreamReader( 50 new FileInputStream(filePath))); 51 StringBuffer contentOfFile = new StringBuffer(); 52 String line; 53 while ((line = br.readLine()) != null) { 54 contentOfFile.append(line); 55 } 56 return contentOfFile.toString(); 57 } 58 59 public static void writeStringAsFile(String filePath, String content) 60 throws IOException { 61 try { 62 BufferedWriter out = new BufferedWriter(new FileWriter(filePath)); 63 out.write(content); 64 out.close(); 65 } catch (IOException e) { 66 e.printStackTrace(); 67 } 68 } 69 42 70 } -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/settings/Settings.java
r20 r31 1 1 package de.ugoe.cs.swe.exercises.settings; 2 3 import java.io.File; 4 import java.io.IOException; 5 import com.thoughtworks.xstream.XStream; 6 import de.ugoe.cs.swe.exercises.misc.FileUtils; 2 7 3 8 public class Settings { … … 37 42 } 38 43 44 private String nullCheck(String str) { 45 if (str == null) 46 return ""; 47 else 48 return str; 49 50 } 51 39 52 public String getSvnLocation() { 40 return svnLocation;53 return nullCheck(svnLocation); 41 54 } 42 55 … … 46 59 47 60 public String getWorkingDirectory() { 48 return workingDirectory;61 return nullCheck(workingDirectory); 49 62 } 50 63 … … 54 67 55 68 public String getSvnUsername() { 56 return svnUsername;69 return nullCheck(svnUsername); 57 70 } 58 71 … … 62 75 63 76 public String getSvnPassword() { 64 return svnPassword;77 return nullCheck(svnPassword); 65 78 } 66 79 … … 70 83 71 84 public String getMysqlHost() { 72 return mysqlHost;85 return nullCheck(mysqlHost); 73 86 } 74 87 … … 78 91 79 92 public String getMysqlDb() { 80 return mysqlDb;93 return nullCheck(mysqlDb); 81 94 } 82 95 … … 86 99 87 100 public String getMysqlUsername() { 88 return mysqlUsername;101 return nullCheck(mysqlUsername); 89 102 } 90 103 … … 94 107 95 108 public String getMysqlPassword() { 96 return mysqlPassword;109 return nullCheck(mysqlPassword); 97 110 } 98 111 … … 102 115 103 116 public String getPdfLatexPath() { 104 return pdfLatexPath;117 return nullCheck(pdfLatexPath); 105 118 } 106 119 … … 110 123 111 124 public String getResearchGroup() { 112 return researchGroup;125 return nullCheck(researchGroup); 113 126 } 114 127 … … 118 131 119 132 public String getResearchGroupUrl() { 120 return researchGroupUrl;133 return nullCheck(researchGroupUrl); 121 134 } 122 135 … … 133 146 } 134 147 148 public void load() { 149 File file = new File(System.getProperty("user.home") 150 + "/exercises_settings.xml"); 151 if (file.exists()) { 152 try { 153 String content = FileUtils.readFileAsString(file.getAbsolutePath()); 154 XStream xstream = new XStream(); 155 xstream.alias("ExercisesSettings", Settings.class); 156 settings = (Settings) xstream.fromXML(content); 157 } catch (IOException e) { 158 e.printStackTrace(); 159 } 160 } 161 } 162 163 public void save() { 164 File file = new File(System.getProperty("user.home") 165 + "/exercises_settings.xml"); 166 167 XStream xstream = new XStream(); 168 xstream.alias("ExercisesSettings", Settings.class); 169 String xml = xstream.toXML(settings); 170 try { 171 FileUtils.writeStringAsFile(file.getAbsolutePath(), xml); 172 } catch (IOException e) { 173 e.printStackTrace(); 174 } 175 } 176 177 @Override 178 public String toString() { 179 StringBuilder builder = new StringBuilder(); 180 builder.append("Settings [mysqlDb="); 181 builder.append(mysqlDb); 182 builder.append(", mysqlHost="); 183 builder.append(mysqlHost); 184 builder.append(", mysqlPassword="); 185 builder.append(mysqlPassword); 186 builder.append(", mysqlSSL="); 187 builder.append(mysqlSSL); 188 builder.append(", mysqlUsername="); 189 builder.append(mysqlUsername); 190 builder.append(", pdfLatexPath="); 191 builder.append(pdfLatexPath); 192 builder.append(", researchGroup="); 193 builder.append(researchGroup); 194 builder.append(", researchGroupUrl="); 195 builder.append(researchGroupUrl); 196 builder.append(", svnLocation="); 197 builder.append(svnLocation); 198 builder.append(", svnPassword="); 199 builder.append(svnPassword); 200 builder.append(", svnUsername="); 201 builder.append(svnUsername); 202 builder.append(", workingDirectory="); 203 builder.append(workingDirectory); 204 builder.append("]"); 205 return builder.toString(); 206 } 207 208 209 135 210 } -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/settings/SettingsDialog.java
r23 r31 1 1 package de.ugoe.cs.swe.exercises.settings; 2 2 3 import java.io.File;4 import java.io.FileInputStream;5 import java.io.FileNotFoundException;6 import java.io.FileOutputStream;7 import java.io.IOException;8 3 import java.sql.DriverManager; 9 4 import java.sql.SQLException; 10 import java.util.Properties;11 5 12 6 import org.eclipse.jface.dialogs.IMessageProvider; … … 52 46 public SettingsDialog(Shell parentShell) { 53 47 super(parentShell); 54 this.getFileContents(); 55 setTitle("Settings"); 48 Settings.getInstance().load(); 56 49 } 57 50 … … 259 252 return; 260 253 } 261 setFileContents();254 Settings.getInstance().save(); 262 255 close(); 263 256 … … 278 271 } 279 272 280 private void getFileContents() {281 Properties properties = new Properties();282 File file = new File(System.getProperty("user.home")283 + "/.exerciseSettings");284 if (file.exists()) {285 try {286 properties.load(new FileInputStream(file));287 } catch (FileNotFoundException e) {288 e.printStackTrace();289 } catch (IOException e) {290 e.printStackTrace();291 }292 try {293 Settings settings = Settings.getInstance();294 settings.setSvnLocation(properties.getProperty("svnLocation"));295 settings.setWorkingDirectory(properties.getProperty("workingDirectory"));296 settings.setSvnUsername(properties.getProperty("svnUsername"));297 settings.setSvnPassword(properties.getProperty("svnPassword"));298 settings.setMysqlHost(properties.getProperty("mySQLHost"));299 settings.setMysqlDb(properties.getProperty("mySQLDb"));300 settings.setMysqlUsername(properties.getProperty("mySQLUsername"));301 settings.setMysqlPassword(properties.getProperty("mySQLPassword"));302 settings.setMysqlSSL(Boolean.parseBoolean(properties303 .getProperty("mySQLcheckSSL")));304 settings.setPdfLatexPath(properties.getProperty("pdfLatexPath"));305 settings.setResearchGroup(properties.getProperty("researchGroup"));306 settings.setResearchGroupUrl(properties.getProperty("researchGroupUrl"));307 } catch (Exception ex) {308 }309 }310 }311 312 private void setFileContents() {313 Properties properties = new Properties();314 File file = new File(System.getProperty("user.home")315 + "/.exerciseSettings");316 if (!file.exists()) {317 try {318 file.createNewFile();319 } catch (IOException e) {320 e.printStackTrace();321 return;322 }323 }324 Settings settings = Settings.getInstance();325 326 properties.setProperty("svnLocation", settings.getSvnLocation());327 properties.setProperty("workingDirectory", settings.getWorkingDirectory());328 properties.setProperty("svnUsername", settings.getSvnUsername());329 properties.setProperty("svnPassword", settings.getSvnPassword());330 properties.setProperty("mySQLHost", settings.getMysqlHost());331 properties.setProperty("mySQLDb", settings.getMysqlDb());332 properties.setProperty("mySQLUsername", settings.getMysqlUsername());333 properties.setProperty("mySQLPassword", settings.getMysqlPassword());334 properties.setProperty("mySQLcheckSSL", String.valueOf(settings.isMysqlSSL()));335 properties.setProperty("pdfLatexPath", settings.getPdfLatexPath());336 properties.setProperty("researchGroup", settings.getResearchGroup());337 properties.setProperty("researchGroupUrl", settings.getResearchGroupUrl());338 339 try {340 properties.store(new FileOutputStream(file),341 "SVN and other Settings included");342 } catch (FileNotFoundException e) {343 e.printStackTrace();344 } catch (IOException e) {345 e.printStackTrace();346 }347 }348 349 273 } -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/settings/SettingsDialog2.java
r23 r31 16 16 public SettingsDialog2(Shell parentShell) { 17 17 super(parentShell); 18 Settings.getInstance().load(); 18 19 } 19 20
Note: See TracChangeset
for help on using the changeset viewer.