Skip to content

Commit 332d2cd

Browse files
committed
Merge pull request #45 from caiusb/bugfixes
Many many bugfixes
2 parents 449faa6 + a394f7b commit 332d2cd

12 files changed

Lines changed: 109 additions & 61 deletions

File tree

edu.oregonstate.cope.clientrecorder/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Clientrecorder
44
Bundle-SymbolicName: edu.oregonstate.cope.clientrecorder
5-
Bundle-Version: 0.3.1.qualifier
5+
Bundle-Version: 0.4.0.qualifier
66
Bundle-ClassPath: clientrecorder.jar,
77
thirdParty/json-simple-1.1.1.jar,
88
thirdParty/logback-classic-1.0.13.jar,

edu.oregonstate.cope.eclipse.branding/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: COPE Branding
44
Bundle-SymbolicName: edu.oregonstate.cope.eclipse.branding;singleton:=true
5-
Bundle-Version: 0.3.0.qualifier
5+
Bundle-Version: 0.4.0.qualifier
66
Bundle-Vendor: Oregon State University
77
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
88
Require-Bundle: org.eclipse.ui;bundle-version="3.105.0"
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
source.. = src/
2-
output.. = bin/
31
bin.includes = META-INF/,\
42
.,\
5-
plugin.xml
3+
plugin.xml,\
4+
icons/

edu.oregonstate.cope.eclipse.feature/feature.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<feature
33
id="edu.oregonstate.cope.eclipse.feature"
44
label="COPE Client Recorder"
5-
version="0.3.1.qualifier">
5+
version="0.4.0.qualifier">
66

77
<description url="http://www.example.com/description">
88
[Enter Feature Description here.]
@@ -29,4 +29,18 @@
2929
version="0.0.0"
3030
unpack="false"/>
3131

32+
<plugin
33+
id="edu.oregonstate.cope.eclipse.ui"
34+
download-size="0"
35+
install-size="0"
36+
version="0.0.0"
37+
unpack="false"/>
38+
39+
<plugin
40+
id="edu.oregonstate.cope.eclipse.branding"
41+
download-size="0"
42+
install-size="0"
43+
version="0.0.0"
44+
unpack="false"/>
45+
3246
</feature>

edu.oregonstate.cope.eclipse.tests/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Tests
44
Bundle-SymbolicName: edu.oregonstate.cope.eclipse.tests
5-
Bundle-Version: 0.3.1.qualifier
5+
Bundle-Version: 0.4.0.qualifier
66
Bundle-Vendor: Oregon State University
7-
Fragment-Host: edu.oregonstate.cope.eclipse;bundle-version="0.3.0"
7+
Fragment-Host: edu.oregonstate.cope.eclipse;bundle-version="0.4.0"
88
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
99
Require-Bundle: org.junit;bundle-version="4.11.0",
1010
org.eclipse.jdt.core;bundle-version="3.9.1"

edu.oregonstate.cope.eclipse.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Ui
44
Bundle-SymbolicName: edu.oregonstate.cope.eclipse.ui;singleton:=true
5-
Bundle-Version: 1.0.0.qualifier
5+
Bundle-Version: 0.4.0.qualifier
66
Bundle-Activator: edu.oregonstate.cope.eclipse.ui.Activator
77
Require-Bundle: org.eclipse.ui,
88
org.eclipse.core.runtime,

edu.oregonstate.cope.eclipse.ui/src/edu/oregonstate/cope/eclipse/ui/SurveyManager.java

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package edu.oregonstate.cope.eclipse.ui;
2-
import java.util.*;
2+
33
import java.io.IOException;
4-
import java.nio.charset.Charset;
5-
import java.nio.file.*;
4+
import java.nio.file.Files;
5+
import java.nio.file.Path;
6+
import java.nio.file.Paths;
7+
import java.nio.file.StandardOpenOption;
68

79
import org.eclipse.jface.window.Window;
810
import org.eclipse.jface.wizard.WizardDialog;
@@ -14,8 +16,6 @@
1416
public class SurveyManager {
1517

1618

17-
private static final String SAMPLE_SURVEY = "Question Number: 0 answer:-1 Question Number: 1 answer:-1";
18-
1919
public SurveyManager(){
2020

2121
}
@@ -24,9 +24,7 @@ public void checkAndRunSurvey(String WorkspaceDir,String BundleDir,Shell parent)
2424
boolean workspaceFileExists = false;
2525
boolean bundleFileExists = false;
2626
Path workspaceSurveyPath = Paths.get(WorkspaceDir,"survey.txt");
27-
Path workspaceEmailPath = Paths.get(WorkspaceDir,"email.txt");
2827
Path bundleSurveyPath = Paths.get(BundleDir,"survey.txt") ;
29-
Path bundleEmailPath = Paths.get(BundleDir, "email.txt");
3028

3129

3230
if(Files.exists(workspaceSurveyPath)){
@@ -60,29 +58,19 @@ public void checkAndRunSurvey(String WorkspaceDir,String BundleDir,Shell parent)
6058
System.out.println("NO FILE EXISTS, GIVE SURVEY");
6159
SurveyWizard sw = new SurveyWizard();
6260
WizardDialog wizardDialog = new WizardDialog(parent.getShell(), sw);
63-
if (wizardDialog.open() == Window.OK) {
64-
System.out.println("Ok pressed");
65-
writeContentsToFile(workspaceSurveyPath,sw.surveyAnswers);
66-
writeContentsToFile(bundleSurveyPath,sw.surveyAnswers);
67-
writeContentsToFile(workspaceEmailPath,sw.email);
68-
writeContentsToFile(bundleEmailPath,sw.email);
69-
} else {
70-
System.out.println("Cancel pressed");
71-
}
72-
61+
wizardDialog.open();
62+
writeContentsToFile(workspaceSurveyPath,sw.getSurveyResults());
63+
writeContentsToFile(bundleSurveyPath, sw.getSurveyResults());
64+
System.out.println("Cancel pressed");
7365
}
66+
7467
//UNCOMMENT THIS TO FOR THE SURVEY TO RUN EVERY TIME FOR DEBUGGING
75-
// SurveyWizard sw = new SurveyWizard();
76-
// WizardDialog wizardDialog = new WizardDialog(parent.getShell(), sw);
77-
// if (wizardDialog.open() == Window.OK) {
78-
// System.out.println("Ok pressed");
79-
// writeContentsToFile(workspaceSurveyPath,sw.surveyAnswers);
80-
// writeContentsToFile(bundleSurveyPath,sw.surveyAnswers);
81-
// writeContentsToFile(workspaceEmailPath,sw.email);
82-
// writeContentsToFile(bundleEmailPath,sw.email);
83-
// } else {
84-
// System.out.println("Cancel pressed");
85-
// }
68+
// SurveyWizard sw = new SurveyWizard();
69+
// WizardDialog wizardDialog = new WizardDialog(parent.getShell(), sw);
70+
// wizardDialog.open();
71+
// System.out.println("Ok pressed");
72+
// writeContentsToFile(workspaceSurveyPath,sw.getSurveyResults());
73+
// writeContentsToFile(bundleSurveyPath,sw.getSurveyResults());
8674

8775
}
8876

edu.oregonstate.cope.eclipse.ui/src/edu/oregonstate/cope/eclipse/ui/handlers/SurveyPage.java

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import java.util.ArrayList;
44
import java.util.Arrays;
5+
import java.util.HashMap;
56
import java.util.List;
7+
import java.util.Map;
8+
import java.util.Set;
69

710
import org.eclipse.jface.wizard.WizardPage;
811
import org.eclipse.swt.SWT;
@@ -15,6 +18,7 @@
1518
import org.eclipse.swt.widgets.Composite;
1619
import org.eclipse.swt.widgets.Label;
1720
import org.eclipse.swt.widgets.Text;
21+
import org.json.simple.JSONObject;
1822

1923
public class SurveyPage extends WizardPage {
2024

@@ -25,7 +29,7 @@ public class SurveyPage extends WizardPage {
2529
* selected at one time. Again, the order of the buttons corresponds to the
2630
* order of the answers in the initial list.
2731
*/
28-
private List<List<Button>> allButtons;
32+
private Map<String, List<Button>> qAndA;
2933
private Text emailInput;
3034

3135
protected SurveyPage() {
@@ -45,16 +49,16 @@ public void createControl(Composite parent) {
4549
Composite questions = new Composite(scrolledComposite, SWT.NONE);
4650
addGridLayout(questions);
4751

48-
allButtons = new ArrayList<List<Button>>();
52+
qAndA = new HashMap<String, List<Button>>();
4953

50-
allButtons.add(createQuestion(questions, "What is the extent of your programming experience?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years", "15-20 years", "More than 20 years" })));
51-
allButtons.add(createQuestion(questions, "What is the extent of your programming experience with Java?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years", "15-20 years", "More than 20 years" })));
52-
allButtons.add(createQuestion(questions, "What is the extent of your experience with Eclipse or IntelliJ IDEA IDE?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years" })));
53-
allButtons.add(createQuestion(questions, "Select the project type you spend most of your time on", Arrays.asList(new String[] { "Proprietary Software Project", "Open Source Project", "Research Project", "Personal/Class project", "Other" })));
54-
allButtons.add(createQuestion(questions, "What is the extent of your experience using TDD?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years" })));
55-
allButtons.add(createQuestion(questions, "How often does your code development follow TDD practices?", Arrays.asList(new String[] { "Always", "Very often", "Sometimes", "Rarely", "Nevers" })));
56-
allButtons.add(createQuestion(questions, "What is your gender", Arrays.asList(new String[] { "Male", "Female", "Decline to State" })));
57-
allButtons.add(createQuestion(questions, "What is your current age", Arrays.asList(new String[] { "less than 18", "18-25", "26-29", "30-39", "40-49", "50 or older" })));
54+
qAndA.put("Q1", createQuestion(questions, "What is the extent of your programming experience?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years", "15-20 years", "More than 20 years" })));
55+
qAndA.put("Q2", createQuestion(questions, "What is the extent of your programming experience with Java?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years", "15-20 years", "More than 20 years" })));
56+
qAndA.put("Q3", createQuestion(questions, "What is the extent of your experience with Eclipse or IntelliJ IDEA IDE?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years" })));
57+
qAndA.put("Q4", createQuestion(questions, "Select the project type you spend most of your time on", Arrays.asList(new String[] { "Proprietary Software Project", "Open Source Project", "Research Project", "Personal/Class project", "Other" })));
58+
qAndA.put("Q5", createQuestion(questions, "What is the extent of your experience using TDD?", Arrays.asList(new String[] { "0-2 years", "2-5 years", "5-10 years", "10-15 years" })));
59+
qAndA.put("Q6", createQuestion(questions, "How often does your code development follow TDD practices?", Arrays.asList(new String[] { "Always", "Very often", "Sometimes", "Rarely", "Nevers" })));
60+
qAndA.put("Q7", createQuestion(questions, "What is your gender", Arrays.asList(new String[] { "Male", "Female", "Decline to State" })));
61+
qAndA.put("Q8", createQuestion(questions, "What is your current age", Arrays.asList(new String[] { "less than 18", "18-25", "26-29", "30-39", "40-49", "50 or older" })));
5862

5963
Composite emailComposite = new Composite(questions, SWT.NONE);
6064
emailComposite.setLayout(new GridLayout(1, false));
@@ -106,9 +110,10 @@ public void widgetDefaultSelected(SelectionEvent e) {
106110

107111
@Override
108112
public boolean isPageComplete() {
109-
for (List<Button> questionButtons : allButtons) {
113+
Set<String> questions = qAndA.keySet();
114+
for (String question : questions) {
110115
boolean enabled = false;
111-
for (Button button : questionButtons) {
116+
for (Button button : qAndA.get(question)) {
112117
if (button.getSelection())
113118
enabled = true;
114119
}
@@ -117,4 +122,20 @@ public boolean isPageComplete() {
117122
}
118123
return true;
119124
}
125+
126+
@SuppressWarnings("unchecked")
127+
public JSONObject getSurveyResults() {
128+
JSONObject resultObject = new JSONObject();
129+
for (String question : qAndA.keySet()) {
130+
List<Button> answers = qAndA.get(question);
131+
for (Button answer : answers) {
132+
if (answer.getSelection()) {
133+
resultObject.put(question, answer.getText());
134+
break;
135+
}
136+
}
137+
}
138+
resultObject.put("email", emailInput.getText());
139+
return resultObject;
140+
}
120141
}

edu.oregonstate.cope.eclipse.ui/src/edu/oregonstate/cope/eclipse/ui/handlers/SurveyWizard.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package edu.oregonstate.cope.eclipse.ui.handlers;
22

3+
import java.math.BigInteger;
4+
import java.util.Random;
5+
36
import org.eclipse.jface.wizard.Wizard;
7+
import org.json.simple.JSONObject;
48

59
public class SurveyWizard extends Wizard {
610

711
protected SurveyPage surveyPage;
812
protected Page2 two;
913

10-
public String email = "test";
11-
public String surveyAnswers = "q1:1";
14+
private JSONObject surveyAnswers;
1215

1316
public SurveyWizard() {
1417
super();
@@ -25,9 +28,27 @@ public void addPages() {
2528

2629
@Override
2730
public boolean performFinish() {
28-
// Print the result to the console
29-
// surveyAnswers = surveyPage.SurveyResults;
30-
// email = surveyPage.emailAddress;
31+
surveyAnswers = surveyPage.getSurveyResults();
32+
putRandomEmailIfAbsent();
33+
return true;
34+
}
35+
36+
@Override
37+
public boolean performCancel() {
38+
surveyAnswers = new JSONObject();
39+
putRandomEmailIfAbsent();
3140
return true;
3241
}
42+
43+
private void putRandomEmailIfAbsent() {
44+
String email = (String) surveyAnswers.get("email");
45+
if (email == null || email.isEmpty()) {
46+
email = new BigInteger(96, new Random()).toString(32);
47+
surveyAnswers.put("email", email);
48+
}
49+
}
50+
51+
public String getSurveyResults() {
52+
return surveyAnswers.toJSONString();
53+
}
3354
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<site>
3-
<feature url="features/edu.oregonstate.cope.eclipse.feature_0.3.1.201311221219.jar" id="edu.oregonstate.cope.eclipse.feature" version="0.3.1.201311221219"/>
3+
<feature url="features/edu.oregonstate.cope.eclipse.feature_0.4.0.qualifier.jar" id="edu.oregonstate.cope.eclipse.feature" version="0.4.0.qualifier"/>
44
</site>

0 commit comments

Comments
 (0)