Changeset 14 for trunk/de.ugoe.cs.swe.exercises/src
- Timestamp:
- 10/19/09 16:51:14 (15 years ago)
- Location:
- trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/ExerciseSheet.java
r3 r14 21 21 public class ExerciseSheet extends Model { 22 22 private int number, revisionNumber, complexityValue, lectureEventId, 23 exerciseMaxRevision, numOfExercises ;23 exerciseMaxRevision, numOfExercises, dueDate; 24 24 private boolean examination; 25 25 … … 42 42 43 43 public ExerciseSheet(int id, int number, int revisionNumber, 44 int complexityValue, boolean examination, LectureEvent lectureEvent, int numOfExercises ) {44 int complexityValue, boolean examination, LectureEvent lectureEvent, int numOfExercises, int dueDate) { 45 45 super(id); 46 46 this.number = number; … … 50 50 this.lectureEventId = lectureEvent.getId(); 51 51 this.numOfExercises = numOfExercises; 52 this.dueDate = dueDate; 52 53 } 53 54 54 55 public ExerciseSheet(int number, int revisionNumber, int complexityValue, 55 boolean examination, LectureEvent lectureEvent, int numOfExercises ) {56 boolean examination, LectureEvent lectureEvent, int numOfExercises, int dueDate) { 56 57 super(); 57 58 this.number = number; … … 61 62 this.lectureEventId = lectureEvent.getId(); 62 63 this.numOfExercises = numOfExercises; 64 this.dueDate = dueDate; 63 65 } 64 66 … … 71 73 this.lectureEventId = lectureEvent.getId(); 72 74 this.examination = false; 75 long currentTime = (System.currentTimeMillis() / 1000); 76 this.dueDate = (int) currentTime; 73 77 } 74 78 … … 118 122 @Override 119 123 protected void update() throws SQLException { 120 PreparedStatement statement = prepareStatement("UPDATE exercisesheet SET number=?, examination=?, revisionnumber=?, complexityvalue=?, lectureevent=?, numOfExercises=? WHERE id=?");121 statement.setInt( 7, this.getId());124 PreparedStatement statement = prepareStatement("UPDATE exercisesheet SET number=?, examination=?, revisionnumber=?, complexityvalue=?, lectureevent=?, numOfExercises=?, dueDate=? WHERE id=?"); 125 statement.setInt(8, this.getId()); 122 126 executeSaveQuery(statement); 123 127 } … … 125 129 @Override 126 130 protected PreparedStatement insert() throws SQLException { 127 PreparedStatement statement = prepareStatement("INSERT INTO exercisesheet (number, examination, revisionnumber, complexityvalue, lectureevent, numOfExercises ) VALUES (?,?,?,?,?,?)");131 PreparedStatement statement = prepareStatement("INSERT INTO exercisesheet (number, examination, revisionnumber, complexityvalue, lectureevent, numOfExercises, dueDate) VALUES (?,?,?,?,?,?,?)"); 128 132 executeSaveQuery(statement); 129 133 return statement; … … 142 146 statement.setInt(5, this.lectureEventId); 143 147 statement.setInt(6, this.numOfExercises); 148 statement.setInt(7, this.dueDate); 144 149 statement.executeUpdate(); 145 150 } … … 176 181 resultset.getInt("complexityvalue"), resultset 177 182 .getBoolean("examination"), LectureEvent 178 .get(resultset.getInt("lectureevent")), resultset.getInt("numOfExercises") ));183 .get(resultset.getInt("lectureevent")), resultset.getInt("numOfExercises"), resultset.getInt("dueDate"))); 179 184 } 180 185 return lectures; … … 316 321 317 322 } 323 324 public int getDueDate() { 325 return dueDate; 326 } 327 328 public void setDueDate(int dueDate) { 329 this.dueDate = dueDate; 330 } 331 332 318 333 } -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/ExerciseSheetComposite.java
r8 r14 3 3 import java.io.File; 4 4 import java.util.ArrayList; 5 import java.util.Calendar; 6 import java.util.GregorianCalendar; 5 7 6 8 import org.eclipse.core.filesystem.EFS; 7 9 import org.eclipse.core.filesystem.IFileStore; 10 import org.eclipse.nebula.widgets.datechooser.DateChooserCombo; 8 11 import org.eclipse.swt.SWT; 9 12 import org.eclipse.swt.custom.SashForm; … … 26 29 import org.eclipse.swt.widgets.Composite; 27 30 import org.eclipse.swt.widgets.FileDialog; 28 import org.eclipse.swt.widgets.Group;29 31 import org.eclipse.swt.widgets.Label; 30 32 import org.eclipse.swt.widgets.Shell; … … 60 62 private TableColumn possibleTitle; 61 63 private TableColumn possibleComplexity; 62 private Group group;64 private Composite lectureEventFields; 63 65 private SashForm sashForm; 64 66 private Button generateButton; … … 70 72 private Button previewButton; 71 73 private Button solutionButton; 74 private Label lblLecureEvent; 75 private Label lblDueDate; 76 private DateChooserCombo dueDateChooserCombo; 72 77 73 78 class ExerciseDragger implements DragSourceListener { … … 154 159 setLayout(new GridLayout(4, true)); 155 160 156 group = new Group(this, SWT.NONE); 157 group.setLayout(new GridLayout(2, false)); 158 group.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 159 2, 6)); 160 161 Label sheetLabel = new Label(group, SWT.NONE); 162 sheetLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, 163 true, 1, 1)); 161 lectureEventFields = new Composite(this, SWT.NONE); 162 lectureEventFields.setLayout(new GridLayout(2, false)); 163 GridData gridData_1 = new GridData(SWT.FILL, SWT.TOP, false, false, 164 2, 6); 165 gridData_1.heightHint = 201; 166 lectureEventFields.setLayoutData(gridData_1); 167 168 Label sheetLabel = new Label(lectureEventFields, SWT.NONE); 169 sheetLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, 170 false, 1, 1)); 164 171 sheetLabel.setText("Sheet #"); 165 172 166 sheetNumberText = new Text( group, SWT.BORDER);167 sheetNumberText.setLayoutData(new GridData(SWT. LEFT, SWT.BOTTOM, false,173 sheetNumberText = new Text(lectureEventFields, SWT.BORDER); 174 sheetNumberText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, 168 175 false, 1, 1)); 169 170 lectureEventLabel = new Label(group, SWT.NONE); 171 lectureEventLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, 172 false, false, 2, 1)); 173 lectureEventLabel.setText("Lecture Event"); 174 175 Label complexityLabel = new Label(group, SWT.NONE); 176 complexityLabel.setText("maximal complexity:"); 177 178 complexityText = new Text(group, SWT.BORDER); 179 180 lblOfExercises = new Label(group, SWT.NONE); 176 177 lblLecureEvent = new Label(lectureEventFields, SWT.NONE); 178 lblLecureEvent.setText("Lecure Event:"); 179 180 lectureEventLabel = new Label(lectureEventFields, SWT.NONE); 181 lectureEventLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, 182 true, false, 1, 1)); 183 lectureEventLabel.setText("Lecture Event"); 184 185 Label complexityLabel = new Label(lectureEventFields, SWT.NONE); 186 complexityLabel.setText("Maximum Complexity:"); 187 188 complexityText = new Text(lectureEventFields, SWT.BORDER); 189 complexityText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); 190 191 lblOfExercises = new Label(lectureEventFields, SWT.NONE); 181 192 lblOfExercises.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, 182 193 false, 1, 1)); 183 194 lblOfExercises.setText("# of exercises"); 184 195 185 numOfExercisesText = new Text( group, SWT.BORDER);186 numOfExercisesText.setLayoutData(new GridData(SWT. LEFT, SWT.CENTER,196 numOfExercisesText = new Text(lectureEventFields, SWT.BORDER); 197 numOfExercisesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, 187 198 true, false, 1, 1)); 188 189 examinationCheck = new Button(group, SWT.CHECK); 199 200 lblDueDate = new Label(lectureEventFields, SWT.NONE); 201 lblDueDate.setText("Due Date:"); 202 203 dueDateChooserCombo = new DateChooserCombo(lectureEventFields, SWT.NONE); 204 dueDateChooserCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 205 206 examinationCheck = new Button(lectureEventFields, SWT.CHECK); 190 207 examinationCheck.addSelectionListener(new SelectionAdapter() { 191 208 @Override … … 196 213 examinationCheck.setSelection(true); 197 214 examinationCheck.setText("is Examination"); 198 new Label( group, SWT.NONE);199 200 sashForm = new SashForm( group, SWT.NONE);215 new Label(lectureEventFields, SWT.NONE); 216 217 sashForm = new SashForm(lectureEventFields, SWT.NONE); 201 218 sashForm.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 202 219 2, 1)); … … 265 282 sashForm.setWeights(new int[] { 1, 1 }); 266 283 267 sashForm_1 = new SashForm( group, SWT.NONE);284 sashForm_1 = new SashForm(lectureEventFields, SWT.NONE); 268 285 sashForm_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, 269 286 false, 2, 1)); … … 336 353 } 337 354 }); 338 previewButton.setText("PDF preview");355 previewButton.setText("PDF Preview"); 339 356 340 357 sashForm_1.setWeights(new int[] { 1, 1 }); … … 366 383 367 384 Label currentExerciseLabel = new Label(this, SWT.NONE); 368 currentExerciseLabel.setText(" current Exercises:");385 currentExerciseLabel.setText("Current Exercises:"); 369 386 370 387 generateButton = new Button(this, SWT.NONE); … … 380 397 } 381 398 }); 382 generateButton.setText(" GenerateExercises");399 generateButton.setText("Auto-Assign Exercises"); 383 400 384 401 Label possibleExerciseLabel = new Label(this, SWT.NONE); 385 possibleExerciseLabel.setText(" possible Exercises:");402 possibleExerciseLabel.setText("Possible Exercises:"); 386 403 new Label(this, SWT.NONE); 387 404 … … 454 471 selected.setNumOfExercises(Integer.parseInt(numOfExercisesText 455 472 .getText())); 473 String[] dateComponents = dueDateChooserCombo.getText().split("\\."); 474 if (dateComponents.length == 3) { 475 String year = dateComponents[2].trim(); 476 String month = dateComponents[1].trim(); 477 String day = dateComponents[0].trim(); 478 if ((year.length() > 0) && (month.length() > 0) && (day.length() > 0)) { 479 Calendar dueDate = new GregorianCalendar(); 480 dueDate.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day)); 481 dueDate.set(Calendar.MONTH, Integer.parseInt(month)-1); 482 dueDate.set(Calendar.YEAR, Integer.parseInt(year)); 483 long timestamp = (dueDate.getTimeInMillis() / 1000); 484 int dueDateTimestamp = (int) timestamp; 485 486 selected.setDueDate(dueDateTimestamp); 487 } 488 } 456 489 selected.save(); 457 490 } … … 462 495 sheetNumberText.setText("" + exerciseSheet.getNumber()); 463 496 complexityText.setText("" + exerciseSheet.getComplexityValue()); 497 498 Calendar dueDate = new GregorianCalendar(); 499 long timestamp = ((long) exerciseSheet.getDueDate()) * 1000; 500 dueDate.setTimeInMillis(timestamp); 501 dueDateChooserCombo.setValue(dueDate.getTime()); 464 502 numOfExercisesText.setText(String.valueOf(exerciseSheet 465 503 .getNumOfExercises())); -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/exercisesheet/PdfGenerator.java
r13 r14 9 9 import java.io.InputStreamReader; 10 10 import java.io.OutputStreamWriter; 11 import java.text.DateFormat; 11 12 import java.util.ArrayList; 13 import java.util.Calendar; 14 import java.util.GregorianCalendar; 15 import java.util.Locale; 12 16 import java.util.Scanner; 13 17 import java.util.regex.Matcher; … … 112 116 templatePath = templatePath.replace('\\','/'); 113 117 114 String deliveryDate = "todo..."; 118 long dueDateTimeStamp = ((long)exercisesheet.getDueDate()) * 1000; 119 Calendar dueDate = new GregorianCalendar(); 120 dueDate.setTimeInMillis(dueDateTimeStamp); 121 DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMANY); 122 String deliveryDate = dateFormat.format(dueDate.getTime()); 115 123 116 124 template = template.replaceAll("(\\W)LECTURE(\\W)", "$1" -
trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/lecture/GUITreeView.java
r3 r14 186 186 btnSaveChanges.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, 187 187 false, 1, 1)); 188 btnSaveChanges.setText("Save changes");188 btnSaveChanges.setText("Save Changes"); 189 189 switchComposite(); 190 190 }
Note: See TracChangeset
for help on using the changeset viewer.