Changeset 20 for trunk/de.ugoe.cs.swe.exercises/src/de/ugoe
- Timestamp:
- 10/19/09 22:48:43 (15 years ago)
- Location:
- trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises
- Files:
-
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/Application.java
r16 r20 21 21 import de.ugoe.cs.swe.exercises.exercise.ExerciseSVN; 22 22 import de.ugoe.cs.swe.exercises.misc.Model; 23 import de.ugoe.cs.swe.exercises.settings.Settings; 23 24 import de.ugoe.cs.swe.exercises.settings.SettingsDialog; 24 25 … … 38 39 SettingsDialog settingsDialog = new SettingsDialog(new Shell()); 39 40 /* try{ */ 40 if (! settingsDialog.hasSettings())41 if (!Settings.getInstance().isInitialized()) 41 42 settingsDialog.open(); 42 43 /* … … 47 48 try { 48 49 DAVRepositoryFactory.setup(); 49 SVNURL url = SVNURL 50 . parseURIDecoded(settingsDialog.getSVNLocation());50 SVNURL url = SVNURL.parseURIDecoded(Settings.getInstance() 51 .getSvnLocation()); 51 52 SVNRepository repository = SVNRepositoryFactory.create(url); 52 53 ISVNAuthenticationManager authManager = SVNWCUtil 53 .createDefaultAuthenticationManager(settingsDialog 54 .getSVNUsername(), settingsDialog.getSVNPassword()); 54 .createDefaultAuthenticationManager(Settings.getInstance() 55 .getSvnUsername(), Settings.getInstance() 56 .getSvnPassword()); 55 57 ((SVNRepository) repository).setAuthenticationManager(authManager); 56 58 repository.testConnection(); … … 59 61 try { 60 62 DAVRepositoryFactory.setup(); 61 SVNURL url = SVNURL.parseURIDecoded(settingsDialog 62 .getSVNLocation()); 63 SVNURL url = SVNURL.parseURIDecoded(Settings.getInstance().getSvnLocation()); 63 64 SVNRepository repository = SVNRepositoryFactory.create(url); 64 65 ISVNAuthenticationManager authManager = SVNWCUtil 65 .createDefaultAuthenticationManager(settingsDialog 66 .getSVNUsername(), settingsDialog 67 .getSVNPassword()); 66 .createDefaultAuthenticationManager(Settings.getInstance().getSvnUsername(), 67 Settings.getInstance().getSvnPassword()); 68 68 ((SVNRepository) repository) 69 69 .setAuthenticationManager(authManager); … … 74 74 } 75 75 76 System.setProperty("javax.net.ssl.trustStorePassword", settingsDialog 77 .getMySQLPassword()); 76 System.setProperty("javax.net.ssl.trustStorePassword", Settings.getInstance().getMysqlPassword()); 78 77 String path = Model.class.getProtectionDomain().getCodeSource() 79 78 .getLocation().getPath(); … … 87 86 Class.forName("com.mysql.jdbc.Driver").newInstance(); 88 87 // Step 2: Establish the connection to the database. 89 String url = "jdbc:mysql://" + settingsDialog.getMySQLHost() + "/"90 + settingsDialog.getMySQLDb() + "?useSSL="91 + String.valueOf( settingsDialog.isMySQLcheckSSL());92 DriverManager.getConnection(url, settingsDialog93 .getMySQLUsername(), settingsDialog.getMySQLPassword());88 String url = "jdbc:mysql://" + Settings.getInstance().getMysqlHost() + "/" 89 + Settings.getInstance().getMysqlDb() + "?useSSL=" 90 + String.valueOf(Settings.getInstance().isMysqlSSL()); 91 DriverManager.getConnection(url, Settings.getInstance().getMysqlUsername(), 92 Settings.getInstance().getMysqlPassword()); 94 93 } catch (SQLException ex) { 95 94 settingsDialog.open(); … … 98 97 Class.forName("com.mysql.jdbc.Driver").newInstance(); 99 98 // Step 2: Establish the connection to the database. 100 String url = "jdbc:mysql://" + settingsDialog.getMySQLHost() 101 + "/" + settingsDialog.getMySQLDb() + "?useSSL=" 102 + String.valueOf(settingsDialog.isMySQLcheckSSL()); 103 DriverManager.getConnection(url, 104 settingsDialog.getMySQLUsername(), settingsDialog 105 .getMySQLPassword()); 99 String url = "jdbc:mysql://" + Settings.getInstance().getMysqlHost() 100 + "/" + Settings.getInstance().getMysqlDb() + "?useSSL=" 101 + String.valueOf(Settings.getInstance().isMysqlSSL()); 102 DriverManager.getConnection(url, Settings.getInstance().getMysqlUsername(), Settings.getInstance().getMysqlPassword()); 106 103 } catch (SQLException ex2) { 107 104 return null; -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercise/Exercise.java
r3 r20 20 20 import de.ugoe.cs.swe.exercises.lecture.Lecture; 21 21 import de.ugoe.cs.swe.exercises.misc.Model; 22 import de.ugoe.cs.swe.exercises.settings.Settings; 22 23 23 24 public class Exercise extends Model { … … 300 301 301 302 SVNClientManager ourClientManager = SVNClientManager.newInstance( 302 options, ExerciseSVN.getUserName(), ExerciseSVN.getPassWord());303 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 303 304 304 305 SVNWCClient ourWCClient = new SVNWCClient(ourClientManager, options); -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercise/ExerciseSVN.java
r16 r20 3 3 import java.io.File; 4 4 import java.io.IOException; 5 import org.eclipse.swt.widgets.Shell; 5 6 6 import org.tmatesoft.svn.core.SVNCommitInfo; 7 7 import org.tmatesoft.svn.core.SVNDepth; … … 19 19 20 20 import de.ugoe.cs.swe.exercises.misc.FileUtils; 21 import de.ugoe.cs.swe.exercises.settings. *;21 import de.ugoe.cs.swe.exercises.settings.Settings; 22 22 23 23 public class ExerciseSVN { 24 private static SettingsDialog svnSettings = new SettingsDialog(new Shell());25 private static String url = svnSettings.getSVNLocation();26 private static String userName = svnSettings.getSVNUsername();27 private static String passWord = svnSettings.getSVNPassword();28 24 public static String SVNpathRev = System.getProperty("user.home") + "/" 29 + svnSettings.getWorkingDirectory() + "-REVISION";25 + Settings.getInstance().getWorkingDirectory() + "-REVISION"; 30 26 public static String SVNpath = System.getProperty("user.home") + "/" 31 + svnSettings.getWorkingDirectory() + "/";27 + Settings.getInstance().getWorkingDirectory() + "/"; 32 28 33 29 public static void SVNCheckout(int revnumber) { … … 38 34 39 35 SVNClientManager ourClientManager = SVNClientManager.newInstance( 40 options, userName, passWord);36 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 41 37 SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); 42 38 … … 47 43 try { 48 44 49 updateClient.doCheckout(SVNURL.parseURIDecoded( url), dstPath,45 updateClient.doCheckout(SVNURL.parseURIDecoded(Settings.getInstance().getSvnLocation()), dstPath, 50 46 SVNRevision.parse(tmp), SVNRevision.parse(tmp), 51 47 SVNDepth.INFINITY, true); … … 62 58 63 59 SVNClientManager ourClientManager = SVNClientManager.newInstance( 64 options, userName, passWord);60 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 65 61 SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); 66 62 … … 70 66 71 67 updateClient 72 .doCheckout(SVNURL.parseURIDecoded( url), dstPath,68 .doCheckout(SVNURL.parseURIDecoded(Settings.getInstance().getSvnLocation()), dstPath, 73 69 SVNRevision.HEAD, SVNRevision.HEAD, 74 70 SVNDepth.INFINITY, true); … … 88 84 89 85 SVNClientManager ourClientManager = SVNClientManager.newInstance( 90 options, userName, passWord);86 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 91 87 92 88 SVNCommitClient commitClient = ourClientManager.getCommitClient(); … … 118 114 119 115 SVNClientManager ourClientManager = SVNClientManager.newInstance( 120 options, userName, passWord);116 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 121 117 122 118 SVNWCClient ourWCClient = new SVNWCClient(ourClientManager, options); … … 157 153 158 154 SVNClientManager ourClientManager = SVNClientManager.newInstance( 159 options, userName, passWord);155 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 160 156 161 157 SVNWCClient ourWCClient = new SVNWCClient(ourClientManager, options); … … 178 174 179 175 SVNClientManager ourClientManager = SVNClientManager.newInstance( 180 options, userName, passWord);176 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 181 177 SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); 182 178 … … 198 194 199 195 SVNClientManager ourClientManager = SVNClientManager.newInstance( 200 options, userName, passWord);196 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 201 197 SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); 202 198 … … 212 208 e.printStackTrace(); 213 209 } 214 }215 216 public static void setPassWord(String passWord) {217 ExerciseSVN.passWord = passWord;218 }219 220 public static String getPassWord() {221 return passWord;222 }223 224 public static void setUserName(String userName) {225 ExerciseSVN.userName = userName;226 }227 228 public static String getUserName() {229 return userName;230 }231 232 public static void setUrl(String url) {233 ExerciseSVN.url = url;234 }235 236 public static String getUrl() {237 return url;238 210 } 239 211 -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercise/ViewExercise.java
r16 r20 4 4 import java.util.ArrayList; 5 5 import java.util.Iterator; 6 import org.eclipse.swt.widgets.Composite; 7 import org.eclipse.ui.IWorkbenchPage; 8 import org.eclipse.ui.PlatformUI; 9 import org.eclipse.ui.ide.FileStoreEditorInput; 10 import org.eclipse.ui.part.ViewPart; 11 import org.eclipse.swt.layout.GridLayout; 12 import org.eclipse.swt.widgets.Label; 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.widgets.Text; 15 import org.eclipse.swt.layout.GridData; 16 import org.eclipse.swt.widgets.Shell; 17 import org.eclipse.swt.widgets.Table; 18 import org.eclipse.swt.widgets.MessageBox; 19 import org.eclipse.swt.widgets.TableItem; 20 import org.eclipse.swt.widgets.TableColumn; 21 import org.eclipse.swt.widgets.Button; 22 import org.eclipse.swt.events.SelectionAdapter; 23 import org.eclipse.swt.events.SelectionEvent; 6 24 7 import org.eclipse.core.filesystem.EFS; 25 8 import org.eclipse.core.filesystem.IFileStore; … … 29 12 import org.eclipse.jface.viewers.StructuredSelection; 30 13 import org.eclipse.jface.viewers.TableViewer; 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.custom.CCombo; 16 import org.eclipse.swt.custom.SashForm; 31 17 import org.eclipse.swt.events.KeyAdapter; 32 18 import org.eclipse.swt.events.KeyEvent; 33 import org.eclipse.swt.custom.CCombo; 19 import org.eclipse.swt.events.SelectionAdapter; 20 import org.eclipse.swt.events.SelectionEvent; 21 import org.eclipse.swt.layout.GridData; 22 import org.eclipse.swt.layout.GridLayout; 23 import org.eclipse.swt.widgets.Button; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Label; 26 import org.eclipse.swt.widgets.MessageBox; 27 import org.eclipse.swt.widgets.Table; 28 import org.eclipse.swt.widgets.TableColumn; 29 import org.eclipse.swt.widgets.TableItem; 30 import org.eclipse.swt.widgets.Text; 31 import org.eclipse.ui.IWorkbenchPage; 32 import org.eclipse.ui.PlatformUI; 33 import org.eclipse.ui.ide.FileStoreEditorInput; 34 import org.eclipse.ui.part.ViewPart; 35 34 36 import de.ugoe.cs.swe.exercises.lecture.Lecture; 35 37 import de.ugoe.cs.swe.exercises.lecture.LectureLabelProvider; 36 38 import de.ugoe.cs.swe.exercises.misc.CKeyword; 37 39 import de.ugoe.cs.swe.exercises.misc.KeywordLabelProvider; 38 import de.ugoe.cs.swe.exercises.settings.SettingsDialog; 39 40 import org.eclipse.swt.custom.SashForm; 40 import de.ugoe.cs.swe.exercises.settings.Settings; 41 41 42 42 public class ViewExercise extends ViewPart { … … 279 279 @Override 280 280 public void widgetSelected(SelectionEvent e) { 281 SettingsDialog settings = new SettingsDialog(new Shell());282 281 PlatformUI.getWorkbench().getActiveWorkbenchWindow() 283 282 .getActivePage().setEditorAreaVisible(true); 284 283 File file = new File(System.getProperty("user.home") + "/" 285 + settings.getWorkingDirectory() + "/exercises/"284 + Settings.getInstance().getWorkingDirectory() + "/exercises/" 286 285 + String.valueOf(selected.getId()) + "solution.tex"); 287 286 if (file != null) { … … 301 300 302 301 file = new File(String.valueOf(System.getProperty("user.home") 303 + "/" + settings.getWorkingDirectory() + "/exercises/"302 + "/" + Settings.getInstance().getWorkingDirectory() + "/exercises/" 304 303 + selected.getId()) 305 304 + ".tex"); -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/ExerciseSheet.java
r14 r20 18 18 import de.ugoe.cs.swe.exercises.lectureevent.LectureEvent; 19 19 import de.ugoe.cs.swe.exercises.misc.Model; 20 import de.ugoe.cs.swe.exercises.settings.Settings; 20 21 21 22 public class ExerciseSheet extends Model { … … 297 298 298 299 SVNClientManager ourClientManager = SVNClientManager.newInstance( 299 options, ExerciseSVN.getUserName(), ExerciseSVN.getPassWord());300 options, Settings.getInstance().getSvnUsername(), Settings.getInstance().getSvnPassword()); 300 301 301 302 SVNWCClient ourWCClient = new SVNWCClient(ourClientManager, options); -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/PdfGenerator.java
r17 r20 18 18 19 19 import org.eclipse.jface.util.Util; 20 import org.eclipse.swt.widgets.Shell;21 20 22 21 import de.ugoe.cs.swe.exercises.exercise.Exercise; … … 25 24 import de.ugoe.cs.swe.exercises.lecturer.Lecturer; 26 25 import de.ugoe.cs.swe.exercises.misc.FileUtils; 27 import de.ugoe.cs.swe.exercises.settings.Settings Dialog;26 import de.ugoe.cs.swe.exercises.settings.Settings; 28 27 29 28 public class PdfGenerator { … … 35 34 path += ".pdf"; 36 35 37 SettingsDialog settings = new SettingsDialog(new Shell());38 36 ArrayList<String> cmdList = new ArrayList<String>(); 39 37 40 String cmd = "\"" + settings.getmyPDFLatexPath() + "\""38 String cmd = "\"" + Settings.getInstance().getPdfLatexPath() + "\"" 41 39 + " -halt-on-error -output-directory=\""; 42 40 try { 43 41 File latexFile = File.createTempFile("exercise", ".tex"); 44 42 45 cmdList.add( settings.getmyPDFLatexPath());43 cmdList.add(Settings.getInstance().getPdfLatexPath()); 46 44 cmdList.add("-halt-on-error"); 47 45 cmdList.add("-output-directory=" + latexFile.getParent()); … … 140 138 + Matcher.quoteReplacement(dueDateString) + "$2"); 141 139 template = template.replaceAll("(\\W)RESEARCHGROUP(\\W)", "$1" 142 + Matcher.quoteReplacement( settings.getMyResearchGroup()) + "$2");140 + Matcher.quoteReplacement(Settings.getInstance().getResearchGroup()) + "$2"); 143 141 template = template.replaceAll("(\\W)RESEARCHGROUPURL(\\W)", "$1" 144 + Matcher.quoteReplacement( settings.getMyResearchGroupUrl()) + "$2");142 + Matcher.quoteReplacement(Settings.getInstance().getResearchGroupUrl()) + "$2"); 145 143 146 144 // write temporary .tex file to temp directory -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/misc/Model.java
r16 r20 2 2 3 3 import java.sql.Connection; 4 import java.sql.SQLException;5 6 4 import java.sql.DatabaseMetaData; 7 5 import java.sql.DriverManager; 8 6 import java.sql.PreparedStatement; 9 7 import java.sql.ResultSet; 8 import java.sql.SQLException; 10 9 import java.sql.Statement; 11 import org.eclipse.swt.widgets.Shell;12 10 13 11 import de.ugoe.cs.swe.exercises.exercise.Exercise; 14 import de.ugoe.cs.swe.exercises.settings. *;12 import de.ugoe.cs.swe.exercises.settings.Settings; 15 13 16 14 public abstract class Model { 17 private static SettingsDialog mysqlSettings = new SettingsDialog(new Shell());18 15 public static int UNDEFINED = -1; 19 16 private int id = Model.UNDEFINED; … … 37 34 // connect to DB 38 35 // -Djavax.net.ssl.trustStorePassword=datenbank -Djavax.net.ssl.trustStore=${project_loc}/keystore 39 System.setProperty("javax.net.ssl.trustStorePassword", mysqlSettings.getMySQLPassword());36 System.setProperty("javax.net.ssl.trustStorePassword", Settings.getInstance().getMysqlPassword()); 40 37 String path = Model.class.getProtectionDomain().getCodeSource().getLocation().getPath(); 41 38 if (path.endsWith("bin/")) … … 52 49 // Step 2: Establish the connection to the database. 53 50 //System.out.println("jdbc:mysql://" + mysqlSettings.getMySQLHost() + "/" + mysqlSettings.getMySQLDb() + "test?useSSL="+mysqlSettings.isMySQLcheckSSL()); 54 String url = "jdbc:mysql://" + mysqlSettings.getMySQLHost() + "/" + mysqlSettings.getMySQLDb() + "test";//?useSSL="+mysqlSettings.isMySQLcheckSSL();51 String url = "jdbc:mysql://" + Settings.getInstance().getMysqlHost() + "/" + Settings.getInstance().getMysqlDb() + "test";//?useSSL="+mysqlSettings.isMySQLcheckSSL(); 55 52 56 Connection conn = DriverManager.getConnection(url, mysqlSettings.getMySQLUsername(),57 mysqlSettings.getMySQLPassword());53 Connection conn = DriverManager.getConnection(url, Settings.getInstance().getMysqlUsername(), 54 Settings.getInstance().getMysqlPassword()); 58 55 System.out.println("Connection successful"); 59 56 //url.wait(500); … … 69 66 70 67 // Step 2: Establish the connection to the database. 71 String url = "jdbc:mysql://" + mysqlSettings.getMySQLHost() + "/" + mysqlSettings.getMySQLDb() + "?useSSL="+mysqlSettings.isMySQLcheckSSL();72 Connection conn = DriverManager.getConnection(url, mysqlSettings.getMySQLUsername(),73 mysqlSettings.getMySQLPassword());68 String url = "jdbc:mysql://" + Settings.getInstance().getMysqlHost() + "/" + Settings.getInstance().getMysqlDb() + "?useSSL="+Settings.getInstance().isMysqlSSL(); 69 Connection conn = DriverManager.getConnection(url, Settings.getInstance().getMysqlUsername(), 70 Settings.getInstance().getMysqlPassword()); 74 71 return conn; 75 72 } catch (Exception e) { … … 157 154 DatabaseMetaData metaData; 158 155 metaData = Model.getConnection().getMetaData(); 159 ResultSet rs = metaData.getTables( mysqlSettings.getMySQLDb()+"test", null, null, null);156 ResultSet rs = metaData.getTables(Settings.getInstance().getMysqlDb()+"test", null, null, null); 160 157 PreparedStatement statement; 161 158 while (rs.next()) { -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/settings/Settings.java
r16 r20 1 1 package de.ugoe.cs.swe.exercises.settings; 2 2 3 import org.eclipse.core.commands.AbstractHandler; 4 import org.eclipse.core.commands.ExecutionEvent; 5 import org.eclipse.core.commands.ExecutionException; 6 import org.eclipse.ui.IWorkbenchWindow; 7 import org.eclipse.ui.handlers.HandlerUtil; 3 public class Settings { 4 private String svnLocation; 5 private String workingDirectory; 6 private String svnUsername; 7 private String svnPassword; 8 private String mysqlHost; 9 private String mysqlDb; 10 private String mysqlUsername; 11 private String mysqlPassword; 12 private String pdfLatexPath; 13 private String researchGroup; 14 private String researchGroupUrl; 15 private boolean mysqlSSL = false; 16 private static Settings settings; 8 17 9 public class Settings extends AbstractHandler { 18 private Settings() { 19 } 10 20 11 @Override 12 public Object execute(ExecutionEvent event) throws ExecutionException { 13 IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); 14 SettingsDialog dialog = new SettingsDialog(window.getShell()); 15 dialog.setTitle("Settings"); 16 dialog.open(); 17 return null; 21 public static Settings getInstance() { 22 if (settings == null) 23 settings = new Settings(); 24 25 return settings; 26 } 27 28 public boolean isInitialized() { 29 if (svnLocation == "" || workingDirectory == "" || svnUsername == "" 30 || svnPassword == "" || mysqlHost == "" || mysqlDb == "" 31 || mysqlUsername == "" || mysqlPassword == "" 32 || pdfLatexPath == "") { 33 return false; 34 } 35 return true; 36 37 } 38 39 public String getSvnLocation() { 40 return svnLocation; 41 } 42 43 public void setSvnLocation(String svnLocation) { 44 this.svnLocation = svnLocation; 45 } 46 47 public String getWorkingDirectory() { 48 return workingDirectory; 49 } 50 51 public void setWorkingDirectory(String workingDirectory) { 52 this.workingDirectory = workingDirectory; 53 } 54 55 public String getSvnUsername() { 56 return svnUsername; 57 } 58 59 public void setSvnUsername(String svnUsername) { 60 this.svnUsername = svnUsername; 61 } 62 63 public String getSvnPassword() { 64 return svnPassword; 65 } 66 67 public void setSvnPassword(String svnPassword) { 68 this.svnPassword = svnPassword; 69 } 70 71 public String getMysqlHost() { 72 return mysqlHost; 73 } 74 75 public void setMysqlHost(String mysqlHost) { 76 this.mysqlHost = mysqlHost; 77 } 78 79 public String getMysqlDb() { 80 return mysqlDb; 81 } 82 83 public void setMysqlDb(String mysqlDb) { 84 this.mysqlDb = mysqlDb; 85 } 86 87 public String getMysqlUsername() { 88 return mysqlUsername; 89 } 90 91 public void setMysqlUsername(String mysqlUsername) { 92 this.mysqlUsername = mysqlUsername; 93 } 94 95 public String getMysqlPassword() { 96 return mysqlPassword; 97 } 98 99 public void setMysqlPassword(String mysqlPassword) { 100 this.mysqlPassword = mysqlPassword; 101 } 102 103 public String getPdfLatexPath() { 104 return pdfLatexPath; 105 } 106 107 public void setPdfLatexPath(String pdfLatexPath) { 108 this.pdfLatexPath = pdfLatexPath; 109 } 110 111 public String getResearchGroup() { 112 return researchGroup; 113 } 114 115 public void setResearchGroup(String researchGroup) { 116 this.researchGroup = researchGroup; 117 } 118 119 public String getResearchGroupUrl() { 120 return researchGroupUrl; 121 } 122 123 public void setResearchGroupUrl(String researchGroupUrl) { 124 this.researchGroupUrl = researchGroupUrl; 125 } 126 127 public boolean isMysqlSSL() { 128 return mysqlSSL; 129 } 130 131 public void setMysqlSSL(boolean mysqlSSL) { 132 this.mysqlSSL = mysqlSSL; 18 133 } 19 134 -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/settings/SettingsDialog.java
r17 r20 49 49 private Text textResearchGroupUrl; 50 50 private Combo cboUseSSL; 51 private String svnLocation = "";52 private String workingDirectory = "";53 private String svnUsername = "";54 private String svnPassword = "";55 private String mySQLHost = "";56 private String mySQLDb = "";57 private String mySQLUsername = "";58 private String mySQLPassword = "";59 private String myPDFLatexPath = "";60 private String myResearchGroup = "";61 private String myResearchGroupUrl = "";62 private boolean mySQLcheckSSL = false;63 64 public boolean hasSettings() {65 if (svnLocation == "" || workingDirectory == "" || svnUsername == ""66 || svnPassword == "" || mySQLHost == "" || mySQLDb == ""67 || mySQLUsername == "" || mySQLPassword == ""68 || myPDFLatexPath == "") {69 return false;70 }71 return true;72 }73 74 public String getmyPDFLatexPath() {75 return myPDFLatexPath;76 }77 78 public void setmyPDFLatexPath(String myPDFLatexPath) {79 this.myPDFLatexPath = myPDFLatexPath;80 }81 82 public String getSVNLocation() {83 return svnLocation;84 }85 86 public String getWorkingDirectory() {87 return workingDirectory;88 }89 90 public String getSVNUsername() {91 return svnUsername;92 }93 94 public String getSVNPassword() {95 return svnPassword;96 }97 98 public String getMySQLHost() {99 return mySQLHost;100 }101 102 public String getMySQLDb() {103 return mySQLDb;104 }105 106 public String getMySQLUsername() {107 return mySQLUsername;108 }109 110 public String getMySQLPassword() {111 return mySQLPassword;112 }113 114 public boolean isMySQLcheckSSL() {115 return mySQLcheckSSL;116 }117 51 118 52 public SettingsDialog(Shell parentShell) { … … 220 154 GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); 221 155 222 if (mySQLcheckSSL) 156 Settings settings = Settings.getInstance(); 157 if (settings.isMysqlSSL()) 223 158 cboUseSSL.select(1); 224 159 else 225 160 cboUseSSL.select(0); 226 161 227 textSVNLocation.setText(s vnLocation);228 textWorkingDirectory.setText( workingDirectory);229 textSVNUsername.setText(s vnUsername);230 textSVNPassword.setText(s vnPassword);231 textMySQLHost.setText( mySQLHost);232 textMySQLDb.setText( mySQLDb);233 textMySQLUsername.setText( mySQLUsername);234 textMySQLPassword.setText( mySQLPassword);235 textPdflatex.setText( myPDFLatexPath);236 textResearchGroup.setText( myResearchGroup);237 textResearchGroupUrl.setText( myResearchGroupUrl);162 textSVNLocation.setText(settings.getSvnLocation()); 163 textWorkingDirectory.setText(settings.getWorkingDirectory()); 164 textSVNUsername.setText(settings.getSvnUsername()); 165 textSVNPassword.setText(settings.getSvnPassword()); 166 textMySQLHost.setText(settings.getMysqlHost()); 167 textMySQLDb.setText(settings.getMysqlDb()); 168 textMySQLUsername.setText(settings.getMysqlUsername()); 169 textMySQLPassword.setText(settings.getMysqlPassword()); 170 textPdflatex.setText(settings.getPdfLatexPath()); 171 textResearchGroup.setText(settings.getResearchGroup()); 172 textResearchGroupUrl.setText(settings.getResearchGroupUrl()); 238 173 239 174 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END); … … 261 196 && textSVNUsername.getText().length() != 0 262 197 && textSVNPassword.getText().length() != 0) { 263 svnLocation = textSVNLocation.getText(); 264 workingDirectory = textWorkingDirectory.getText(); 265 svnUsername = textSVNUsername.getText(); 266 svnPassword = textSVNPassword.getText(); 267 mySQLHost = textMySQLHost.getText(); 268 mySQLDb = textMySQLDb.getText(); 269 mySQLUsername = textMySQLUsername.getText(); 270 mySQLPassword = textMySQLPassword.getText(); 271 myPDFLatexPath = textPdflatex.getText(); 272 myResearchGroup = textResearchGroup.getText(); 273 myResearchGroupUrl = textResearchGroupUrl.getText(); 274 198 199 Settings settings = Settings.getInstance(); 200 201 settings.setSvnLocation(textSVNLocation.getText()); 202 settings.setWorkingDirectory(textWorkingDirectory.getText()); 203 settings.setSvnUsername(textSVNUsername.getText()); 204 settings.setSvnPassword(textSVNPassword.getText()); 205 settings.setMysqlHost(textMySQLHost.getText()); 206 settings.setMysqlDb(textMySQLDb.getText()); 207 settings.setMysqlUsername(textMySQLUsername.getText()); 208 settings.setMysqlPassword(textMySQLPassword.getText()); 209 settings.setPdfLatexPath(textPdflatex.getText()); 210 settings.setResearchGroup(textResearchGroup.getText()); 211 settings.setResearchGroupUrl(textResearchGroupUrl.getText()); 212 275 213 if (cboUseSSL.getSelectionIndex() == 1) 276 mySQLcheckSSL = true;214 settings.setMysqlSSL(true); 277 215 else 278 mySQLcheckSSL = false;216 settings.setMysqlSSL(false); 279 217 280 218 try { 281 219 DAVRepositoryFactory.setup(); 282 SVNURL url = SVNURL.parseURIDecoded(s vnLocation);220 SVNURL url = SVNURL.parseURIDecoded(settings.getSvnLocation()); 283 221 SVNRepository repository = SVNRepositoryFactory 284 222 .create(url); 285 223 ISVNAuthenticationManager authManager = SVNWCUtil 286 224 .createDefaultAuthenticationManager( 287 s vnUsername, svnPassword);225 settings.getSvnUsername(), settings.getSvnPassword()); 288 226 ((SVNRepository) repository) 289 227 .setAuthenticationManager(authManager); … … 296 234 297 235 System.setProperty("javax.net.ssl.trustStorePassword", 298 mySQLPassword);236 settings.getMysqlPassword()); 299 237 String path = Model.class.getProtectionDomain() 300 238 .getCodeSource().getLocation().getPath(); … … 308 246 Class.forName("com.mysql.jdbc.Driver").newInstance(); 309 247 // Step 2: Establish the connection to the database. 310 String url = "jdbc:mysql://" + mySQLHost+ "/"311 + mySQLDb+ "?useSSL="312 + String.valueOf( mySQLcheckSSL);313 DriverManager.getConnection(url, mySQLUsername,314 mySQLPassword);248 String url = "jdbc:mysql://" + settings.getMysqlHost() + "/" 249 + settings.getMysqlDb() + "?useSSL=" 250 + String.valueOf(settings.isMysqlSSL()); 251 DriverManager.getConnection(url, settings.getMysqlUsername(), 252 settings.getMysqlPassword()); 315 253 } catch (SQLException ex) { 316 254 setErrorMessage(ex.getMessage()); … … 340 278 341 279 private void getFileContents() { 342 Properties settings = new Properties();280 Properties properties = new Properties(); 343 281 File file = new File(System.getProperty("user.home") 344 282 + "/.exerciseSettings"); 345 if (!file.exists()) { 346 svnLocation = ""; 347 workingDirectory = ""; 348 svnUsername = ""; 349 svnPassword = ""; 350 mySQLHost = ""; 351 mySQLDb = ""; 352 mySQLUsername = ""; 353 mySQLPassword = ""; 354 mySQLcheckSSL = false; 355 myPDFLatexPath = ""; 356 myResearchGroup = ""; 357 myResearchGroupUrl = ""; 358 } else { 283 if (file.exists()) { 359 284 try { 360 settings.load(new FileInputStream(file));285 properties.load(new FileInputStream(file)); 361 286 } catch (FileNotFoundException e) { 362 287 e.printStackTrace(); … … 365 290 } 366 291 try { 367 if (settings.getProperty("svnLocation") != null) 368 svnLocation = settings.getProperty("svnLocation"); 369 if (settings.getProperty("workingDirectory") != null) 370 workingDirectory = settings.getProperty("workingDirectory"); 371 if (settings.getProperty("svnUsername") != null) 372 svnUsername = settings.getProperty("svnUsername"); 373 if (settings.getProperty("svnPassword") != null) 374 svnPassword = settings.getProperty("svnPassword"); 375 if (settings.getProperty("mySQLHost") != null) 376 mySQLHost = settings.getProperty("mySQLHost"); 377 if (settings.getProperty("mySQLDb") != null) 378 mySQLDb = settings.getProperty("mySQLDb"); 379 if (settings.getProperty("mySQLUsername") != null) 380 mySQLUsername = settings.getProperty("mySQLUsername"); 381 if (settings.getProperty("mySQLPassword") != null) 382 mySQLPassword = settings.getProperty("mySQLPassword"); 383 if (settings.getProperty("mySQLcheckSSL") != null) 384 mySQLcheckSSL = Boolean.parseBoolean(settings 385 .getProperty("mySQLcheckSSL")); 386 if (settings.getProperty("mySQLcheckSSL") != null) 387 myPDFLatexPath = settings.getProperty("myPDFLatexPath"); 388 if (settings.getProperty("myResearchGroup") != null) 389 myResearchGroup = settings.getProperty("myResearchGroup"); 390 if (settings.getProperty("myResearchGroupUrl") != null) 391 myResearchGroupUrl = settings 392 .getProperty("myResearchGroupUrl"); 393 292 Settings settings = Settings.getInstance(); 293 settings.setSvnLocation(properties.getProperty("svnLocation")); 294 settings.setWorkingDirectory(properties.getProperty("workingDirectory")); 295 settings.setSvnUsername(properties.getProperty("svnUsername")); 296 settings.setSvnPassword(properties.getProperty("svnPassword")); 297 settings.setMysqlHost(properties.getProperty("mySQLHost")); 298 settings.setMysqlDb(properties.getProperty("mySQLDb")); 299 settings.setMysqlUsername(properties.getProperty("mySQLUsername")); 300 settings.setMysqlPassword(properties.getProperty("mySQLPassword")); 301 settings.setMysqlSSL(Boolean.parseBoolean(properties 302 .getProperty("mySQLcheckSSL"))); 303 settings.setPdfLatexPath(properties.getProperty("pdfLatexPath")); 304 settings.setResearchGroup(properties.getProperty("researchGroup")); 305 settings.setResearchGroupUrl(properties.getProperty("researchGroupUrl")); 394 306 } catch (Exception ex) { 395 svnLocation = "";396 workingDirectory = "";397 svnUsername = "";398 svnPassword = "";399 mySQLHost = "";400 mySQLDb = "";401 mySQLUsername = "";402 mySQLPassword = "";403 mySQLcheckSSL = false;404 myPDFLatexPath = "";405 myResearchGroup = "";406 myResearchGroupUrl = "";407 307 } 408 308 } … … 410 310 411 311 private void setFileContents() { 412 Properties settings = new Properties();312 Properties properties = new Properties(); 413 313 File file = new File(System.getProperty("user.home") 414 314 + "/.exerciseSettings"); … … 421 321 } 422 322 } 423 424 settings.setProperty("svnLocation", svnLocation); 425 settings.setProperty("workingDirectory", workingDirectory); 426 settings.setProperty("svnUsername", svnUsername); 427 settings.setProperty("svnPassword", svnPassword); 428 settings.setProperty("mySQLHost", mySQLHost); 429 settings.setProperty("mySQLDb", mySQLDb); 430 settings.setProperty("mySQLUsername", mySQLUsername); 431 settings.setProperty("mySQLPassword", mySQLPassword); 432 settings.setProperty("mySQLcheckSSL", String.valueOf(mySQLcheckSSL)); 433 settings.setProperty("myPDFLatexPath", myPDFLatexPath); 434 settings.setProperty("myResearchGroup", myResearchGroup); 435 settings.setProperty("myResearchGroupUrl", myResearchGroupUrl); 323 Settings settings = Settings.getInstance(); 324 325 properties.setProperty("svnLocation", settings.getSvnLocation()); 326 properties.setProperty("workingDirectory", settings.getWorkingDirectory()); 327 properties.setProperty("svnUsername", settings.getSvnUsername()); 328 properties.setProperty("svnPassword", settings.getSvnPassword()); 329 properties.setProperty("mySQLHost", settings.getMysqlHost()); 330 properties.setProperty("mySQLDb", settings.getMysqlDb()); 331 properties.setProperty("mySQLUsername", settings.getMysqlUsername()); 332 properties.setProperty("mySQLPassword", settings.getMysqlPassword()); 333 properties.setProperty("mySQLcheckSSL", String.valueOf(settings.isMysqlSSL())); 334 properties.setProperty("pdfLatexPath", settings.getPdfLatexPath()); 335 properties.setProperty("researchGroup", settings.getResearchGroup()); 336 properties.setProperty("researchGroupUrl", settings.getResearchGroupUrl()); 436 337 437 338 try { 438 settings.store(new FileOutputStream(file),339 properties.store(new FileOutputStream(file), 439 340 "SVN and other Settings included"); 440 341 } catch (FileNotFoundException e) { … … 445 346 } 446 347 447 public String getMyResearchGroup() {448 return myResearchGroup;449 }450 451 public String getMyResearchGroupUrl() {452 return myResearchGroupUrl;453 }454 455 348 } -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/settings/SettingsHandler.java
r17 r20 7 7 import org.eclipse.ui.handlers.HandlerUtil; 8 8 9 public class Settings extends AbstractHandler {9 public class SettingsHandler extends AbstractHandler { 10 10 11 11 @Override
Note: See TracChangeset
for help on using the changeset viewer.