Skip to content

Commit 9f68915

Browse files
committed
Improve exercise submitting dialog
1 parent 9d7ccd8 commit 9f68915

File tree

9 files changed

+278
-47
lines changed

9 files changed

+278
-47
lines changed

maven-wrapper/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>${project.groupId}</groupId>
4848
<artifactId>core</artifactId>
49-
<version>0.10.8-SNAPSHOT</version>
49+
<version>0.10.9-SNAPSHOT</version>
5050
</dependency>
5151
<dependency>
5252
<groupId>${project.groupId}</groupId>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package fi.helsinki.cs.tmc.coreimpl;
2+
3+
import com.google.common.base.Optional;
4+
import fi.helsinki.cs.tmc.core.domain.ProgressObserver;
5+
import fi.helsinki.cs.tmc.utilities.ProgressListener;
6+
import fi.helsinki.cs.tmc.utilities.ProgressMessage;
7+
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
import java.util.logging.Level;
11+
import java.util.logging.Logger;
12+
13+
public class ManualProgressObserver extends ProgressObserver {
14+
15+
private static final Logger LOG = Logger.getLogger(ManualProgressObserver.class.getName());
16+
private final List<ProgressListener> listeners;
17+
18+
public ManualProgressObserver() {
19+
this.listeners = new ArrayList<>();
20+
}
21+
22+
@Override
23+
public void progress(long id, String message) {
24+
progress(id, 0.0, message);
25+
}
26+
27+
@Override
28+
public void progress(long id, Double percentDone, String message) {
29+
ProgressMessage msg = new ProgressMessage(message, Optional.of(percentDone));
30+
listeners.stream().forEach(l -> l.accept(msg));
31+
}
32+
33+
@Override
34+
public void start(long l) {
35+
LOG.log(Level.INFO, "{0} started", l);
36+
}
37+
38+
@Override
39+
public void end(long l) {
40+
LOG.log(Level.INFO, "{0} ended", l);
41+
}
42+
43+
public void addListener(ProgressListener listener) {
44+
listeners.add(listener);
45+
}
46+
}

tmc-plugin/src/fi/helsinki/cs/tmc/exerciseSubmitter/ExerciseSubmitter.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import fi.helsinki.cs.tmc.actions.CheckForNewExercisesOrUpdates;
44
import fi.helsinki.cs.tmc.core.TmcCore;
55
import fi.helsinki.cs.tmc.core.domain.Exercise;
6-
import fi.helsinki.cs.tmc.core.domain.ProgressObserver;
76
import fi.helsinki.cs.tmc.core.domain.submission.SubmissionResult;
87
import fi.helsinki.cs.tmc.core.utilities.ServerErrorHelper;
98
import fi.helsinki.cs.tmc.data.ResultCollector;
109
import fi.helsinki.cs.tmc.core.events.TmcEvent;
1110
import fi.helsinki.cs.tmc.core.events.TmcEventBus;
11+
import fi.helsinki.cs.tmc.coreimpl.ManualProgressObserver;
1212
import fi.helsinki.cs.tmc.model.CourseDb;
1313
import fi.helsinki.cs.tmc.model.ProjectMediator;
1414
import fi.helsinki.cs.tmc.model.TmcProjectInfo;
@@ -68,11 +68,15 @@ private void submitProject(final TmcProjectInfo project) {
6868

6969
projectMediator.saveAllFiles();
7070

71-
Callable<SubmissionResult> callable = TmcCore.get().submit(ProgressObserver.NULL_OBSERVER, exercise);
71+
ManualProgressObserver observer = new ManualProgressObserver();
7272

73-
final SubmissionResultWaitingDialog dialog = SubmissionResultWaitingDialog.createAndShow();
73+
final SubmissionResultWaitingDialog dialog = SubmissionResultWaitingDialog.createAndShow(observer);
7474

75-
BgTask.start("Waiting for results from server.", callable, new BgTaskListener<SubmissionResult>() {
75+
Callable<SubmissionResult> callable = TmcCore.get().submit(observer, exercise, (submissionResponse) -> {
76+
dialog.showSubmissionButton(submissionResponse.showSubmissionUrl);
77+
});
78+
79+
BgTask.start("Waiting for results from server.", callable, observer, new BgTaskListener<SubmissionResult>() {
7680
@Override
7781
public void bgTaskReady(SubmissionResult result) {
7882

tmc-plugin/src/fi/helsinki/cs/tmc/ui/Bundle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ AboutDialog.closeButton.text=Close
9797
AboutDialog.infoTextPane.text=<html> <body> <div> Test My Code is a service designed for learning and teaching programming. It is open source, provides support for automatic assessment of programming assignments, and comes with a server that can be used to maintain course-specific point lists and grading. </div> <br> <div> Find out more at <a href="https://mooc.fi/tmc">https://mooc.fi/tmc</a>. </div> </body> </html>
9898
PreferencesPanel.fixUnoptimalSettings.toolTipText=Leave this on if you want to be able to open Maven projects effortlessly.
9999
PreferencesPanel.fixUnoptimalSettings.text=Ensure Netbeans is configured correctly
100+
SubmissionResultWaitingDialog.statusLabel.text=Submission's status:
101+
SubmissionResultWaitingDialog.showSubmissionButton.text=Show submission

tmc-plugin/src/fi/helsinki/cs/tmc/ui/SubmissionResultWaitingDialog.form

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
<?xml version="1.1" encoding="UTF-8" ?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22

33
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
44
<Properties>
55
<Property name="defaultCloseOperation" type="int" value="2"/>
66
</Properties>
77
<SyntheticProperties>
88
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
9+
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
910
</SyntheticProperties>
1011
<AuxValues>
1112
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
@@ -22,24 +23,33 @@
2223
<Layout>
2324
<DimensionLayout dim="0">
2425
<Group type="103" groupAlignment="0" attributes="0">
25-
<Group type="102" attributes="0">
26+
<Group type="102" alignment="0" attributes="0">
2627
<EmptySpace max="-2" attributes="0"/>
2728
<Group type="103" groupAlignment="0" attributes="0">
28-
<Group type="102" alignment="0" attributes="0">
29-
<Component id="jProgressBar1" pref="470" max="32767" attributes="0"/>
30-
<EmptySpace max="-2" attributes="0"/>
29+
<Group type="102" attributes="0">
30+
<Group type="103" groupAlignment="0" attributes="0">
31+
<Component id="queueLabel" alignment="0" min="-2" max="-2" attributes="0"/>
32+
<Component id="statusLabel" alignment="0" min="-2" max="-2" attributes="0"/>
33+
</Group>
34+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
3135
</Group>
32-
<Component id="queueLabel" alignment="0" min="-2" max="-2" attributes="0"/>
33-
<Group type="102" alignment="1" attributes="0">
34-
<Component id="backgroundLabel" min="-2" max="-2" attributes="0"/>
35-
<EmptySpace max="-2" attributes="0"/>
36-
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
36+
<Group type="102" attributes="0">
37+
<Group type="103" groupAlignment="0" attributes="0">
38+
<Component id="jProgressBar1" alignment="0" pref="470" max="32767" attributes="0"/>
39+
<Group type="102" alignment="1" attributes="0">
40+
<Component id="showSubmissionButton" min="-2" max="-2" attributes="0"/>
41+
<EmptySpace max="32767" attributes="0"/>
42+
<Component id="backgroundLabel" min="-2" max="-2" attributes="0"/>
43+
<EmptySpace max="-2" attributes="0"/>
44+
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
45+
</Group>
46+
<Group type="102" attributes="0">
47+
<Component id="waitingLabel" min="-2" max="-2" attributes="0"/>
48+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
49+
</Group>
50+
</Group>
3751
<EmptySpace max="-2" attributes="0"/>
3852
</Group>
39-
<Group type="102" alignment="0" attributes="0">
40-
<Component id="waitingLabel" min="-2" max="-2" attributes="0"/>
41-
<EmptySpace pref="231" max="32767" attributes="0"/>
42-
</Group>
4353
</Group>
4454
</Group>
4555
</Group>
@@ -53,10 +63,13 @@
5363
<Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
5464
<EmptySpace max="-2" attributes="0"/>
5565
<Component id="queueLabel" min="-2" max="-2" attributes="0"/>
66+
<EmptySpace max="-2" attributes="0"/>
67+
<Component id="statusLabel" min="-2" max="-2" attributes="0"/>
5668
<EmptySpace max="32767" attributes="0"/>
5769
<Group type="103" groupAlignment="3" attributes="0">
5870
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
5971
<Component id="backgroundLabel" alignment="3" min="-2" max="-2" attributes="0"/>
72+
<Component id="showSubmissionButton" alignment="3" min="-2" max="-2" attributes="0"/>
6073
</Group>
6174
<EmptySpace max="-2" attributes="0"/>
6275
</Group>
@@ -89,9 +102,6 @@
89102
</Events>
90103
</Component>
91104
<Component class="javax.swing.JProgressBar" name="jProgressBar1">
92-
<Properties>
93-
<Property name="indeterminate" type="boolean" value="true"/>
94-
</Properties>
95105
</Component>
96106
<Component class="javax.swing.JButton" name="cancelButton">
97107
<Properties>
@@ -104,5 +114,19 @@
104114
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
105115
</Events>
106116
</Component>
117+
<Component class="javax.swing.JLabel" name="statusLabel">
118+
<Properties>
119+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
120+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="SubmissionResultWaitingDialog.statusLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
121+
</Property>
122+
</Properties>
123+
</Component>
124+
<Component class="javax.swing.JButton" name="showSubmissionButton">
125+
<Properties>
126+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
127+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="SubmissionResultWaitingDialog.showSubmissionButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
128+
</Property>
129+
</Properties>
130+
</Component>
107131
</SubComponents>
108132
</Form>

0 commit comments

Comments
 (0)