Skip to content

Commit e82713c

Browse files
committed
Add checkbox and functionality for sending diagnostics to bandicoot
1 parent 82e04fe commit e82713c

File tree

9 files changed

+101
-2
lines changed

9 files changed

+101
-2
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.9.9-SNAPSHOT</version>
49+
<version>0.9.10-SNAPSHOT</version>
5050
</dependency>
5151
<dependency>
5252
<groupId>${project.groupId}</groupId>

tmc-plugin/src/fi/helsinki/cs/tmc/actions/SaveSettingsAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ public class SaveSettingsAction extends AbstractAction {
2222
private TmcEventBus eventBus;
2323
private TmcCore tmcCore;
2424
private final FixUnoptimalSettings fixUnoptimalSettings;
25+
private SendDiagnostics sendDiagnostics;
2526

2627
public SaveSettingsAction() {
2728
this.courseDb = CourseDb.getInstance();
2829
this.eventBus = TmcEventBus.getDefault();
2930
this.tmcCore = TmcCore.get();
3031
this.fixUnoptimalSettings = new FixUnoptimalSettings();
32+
this.sendDiagnostics = new SendDiagnostics();
3133
}
3234

3335
@Override
@@ -53,6 +55,7 @@ public void actionPerformed(ActionEvent e) {
5355
settings.setIsSpywareEnabled(prefUi.getSpywareEnabled());
5456
settings.setErrorMsgLocale(prefUi.getErrorMsgLocale());
5557
settings.setResolveDependencies(prefUi.getResolveProjectDependenciesEnabled());
58+
settings.setSendDiagnostics(prefUi.getSendDiagnosticsEnabled());
5659

5760
eventBus.post(new InvokedEvent());
5861

@@ -62,6 +65,10 @@ public void actionPerformed(ActionEvent e) {
6265
fixUnoptimalSettings.undo();
6366
}
6467

68+
if (settings.getSendDiagnostics()) {
69+
sendDiagnostics.run();
70+
}
71+
6572
if (prefUi.getSelectedCourseName() != null) {
6673
courseDb.setAvailableCourses(prefUi.getAvailableCourses());
6774
courseDb.setCurrentCourseName(prefUi.getSelectedCourseName());
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package fi.helsinki.cs.tmc.actions;
2+
3+
import fi.helsinki.cs.tmc.core.TmcCore;
4+
import fi.helsinki.cs.tmc.core.domain.ProgressObserver;
5+
import fi.helsinki.cs.tmc.coreimpl.BridgingProgressObserver;
6+
import fi.helsinki.cs.tmc.utilities.BgTask;
7+
import java.util.concurrent.Callable;
8+
9+
public class SendDiagnostics {
10+
11+
public void run() {
12+
ProgressObserver observer = new BridgingProgressObserver();
13+
Callable<Void> sendDiagnostics = TmcCore.get().sendDiagnostics(observer);
14+
BgTask.start("Sending diagnostics", sendDiagnostics);
15+
}
16+
}

tmc-plugin/src/fi/helsinki/cs/tmc/actions/ShowSettingsAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public void run() {
6666
prefUI.setSpywareEnabled(settings.isSpywareEnabled());
6767
prefUI.setErrorMsgLocale(settings.getErrorMsgLocale());
6868
prefUI.setResolveProjectDependenciesEnabled(settings.getResolveDependencies());
69+
prefUI.setSendDiagnosticsEnabled(settings.getSendDiagnostics());
6970

7071
ActionListener listener = new ActionListener() {
7172
@Override

tmc-plugin/src/fi/helsinki/cs/tmc/coreimpl/TmcCoreSettingsImpl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class TmcCoreSettingsImpl implements TmcSettings {
3535
private static final String PREF_DETAILED_SPYWARE_ENABLED = "detailedSpywareEnabled";
3636
private static final String PREF_ERROR_MSG_LOCALE = "errorMsgLocale";
3737
private static final String PREF_RESOLVE_DEPENDENCIES = "resolveDependencies";
38+
private static final String PREF_SEND_DIAGNOSTICS = "sendDiagnostics";
3839

3940
private static PersistableSettings settings = PersistableSettings.forModule(TmcSettings.class);
4041

@@ -120,6 +121,16 @@ public Path getConfigRoot() {
120121

121122
return FileUtil.toFile(tmcRoot).toPath();
122123
}
124+
125+
@Override
126+
public String hostProgramName() {
127+
return "netbeans";
128+
}
129+
130+
@Override
131+
public String hostProgramVersion() {
132+
return System.getProperty("netbeans.buildnumber");
133+
}
123134

124135
public static class SavedEvent implements TmcEvent {}
125136

@@ -249,6 +260,14 @@ public void setResolveDependencies(boolean value) {
249260
public boolean getResolveDependencies() {
250261
return settings.get(PREF_RESOLVE_DEPENDENCIES, "1").equals("1");
251262
}
263+
264+
public void setSendDiagnostics(boolean value) {
265+
settings.put(PREF_SEND_DIAGNOSTICS, value ? "1" : "0");
266+
}
267+
268+
public boolean getSendDiagnostics() {
269+
return settings.get(PREF_SEND_DIAGNOSTICS, "1").equals("1");
270+
}
252271

253272
private Locale parseLocale(String s, Locale dflt) {
254273
if (s.isEmpty()) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ PastebinDialog.cancelButton.text=&Cancel
7575
PreferencesPanel.restartMessage.text=Changing language requires restart
7676
PreferencesPanel.resolveDependencies.toolTipText=Leave this on if you want to be able to open Maven projects effortlessly.
7777
PreferencesPanel.resolveDependencies.text=Ensure Netbeans is configured to resolve project dependencies
78+
PreferencesPanel.sendDiagnostics.toolTipText=Leave this on if you want to be able to open Maven projects effortlessly.
79+
PreferencesPanel.sendDiagnostics.text=Automatically send crash reports and diagnostics for plugin development

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
<Component id="spywareEnabledCheckbox" min="-2" max="-2" attributes="0"/>
8888
<EmptySpace max="32767" attributes="0"/>
8989
</Group>
90+
<Group type="102" attributes="0">
91+
<Component id="sendDiagnostics" min="-2" max="-2" attributes="0"/>
92+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
93+
</Group>
9094
</Group>
9195
</Group>
9296
</Group>
@@ -136,6 +140,8 @@
136140
<EmptySpace max="-2" attributes="0"/>
137141
<Component id="resolveDependencies" min="-2" max="-2" attributes="0"/>
138142
<EmptySpace max="-2" attributes="0"/>
143+
<Component id="sendDiagnostics" min="-2" max="-2" attributes="0"/>
144+
<EmptySpace max="-2" attributes="0"/>
139145
<Component id="spywareEnabledCheckbox" min="-2" max="-2" attributes="0"/>
140146
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
141147
<Component id="jSeparator3" min="-2" max="-2" attributes="0"/>
@@ -380,5 +386,19 @@
380386
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resolveDependenciesActionPerformed"/>
381387
</Events>
382388
</Component>
389+
<Component class="javax.swing.JCheckBox" name="sendDiagnostics">
390+
<Properties>
391+
<Property name="selected" type="boolean" value="true"/>
392+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
393+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="PreferencesPanel.sendDiagnostics.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
394+
</Property>
395+
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
396+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="PreferencesPanel.sendDiagnostics.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
397+
</Property>
398+
</Properties>
399+
<Events>
400+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sendDiagnosticsActionPerformed"/>
401+
</Events>
402+
</Component>
383403
</SubComponents>
384404
</Form>

tmc-plugin/src/fi/helsinki/cs/tmc/ui/PreferencesPanel.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,16 @@ public void setErrorMsgLocale(Locale locale) {
254254
errorMsgLocaleComboBox.setSelectedItem(new LocaleWrapper(locale));
255255
}
256256

257+
@Override
258+
public boolean getSendDiagnosticsEnabled() {
259+
return sendDiagnostics.isSelected();
260+
}
261+
262+
@Override
263+
public void setSendDiagnosticsEnabled(boolean value) {
264+
sendDiagnostics.setSelected(value);
265+
}
266+
257267
private static class LocaleWrapper {
258268
private Locale locale;
259269
public LocaleWrapper(Locale locale) {
@@ -505,6 +515,7 @@ private void initComponents() {
505515
errorMsgLocaleComboBox = new javax.swing.JComboBox();
506516
restartMessage = new javax.swing.JLabel();
507517
resolveDependencies = new javax.swing.JCheckBox();
518+
sendDiagnostics = new javax.swing.JCheckBox();
508519

509520
usernameLabel.setText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.usernameLabel.text")); // NOI18N
510521

@@ -599,6 +610,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
599610
}
600611
});
601612

613+
sendDiagnostics.setSelected(true);
614+
sendDiagnostics.setText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.sendDiagnostics.text")); // NOI18N
615+
sendDiagnostics.setToolTipText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.sendDiagnostics.toolTipText")); // NOI18N
616+
sendDiagnostics.addActionListener(new java.awt.event.ActionListener() {
617+
public void actionPerformed(java.awt.event.ActionEvent evt) {
618+
sendDiagnosticsActionPerformed(evt);
619+
}
620+
});
621+
602622
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
603623
this.setLayout(layout);
604624
layout.setHorizontalGroup(
@@ -658,7 +678,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
658678
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
659679
.addGroup(layout.createSequentialGroup()
660680
.addComponent(spywareEnabledCheckbox)
661-
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
681+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
682+
.addGroup(layout.createSequentialGroup()
683+
.addComponent(sendDiagnostics)
684+
.addGap(0, 0, Short.MAX_VALUE))))
662685
);
663686
layout.setVerticalGroup(
664687
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -700,6 +723,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
700723
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
701724
.addComponent(resolveDependencies)
702725
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
726+
.addComponent(sendDiagnostics)
727+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
703728
.addComponent(spywareEnabledCheckbox)
704729
.addGap(18, 18, 18)
705730
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -750,6 +775,10 @@ private void resolveDependenciesActionPerformed(java.awt.event.ActionEvent evt)
750775

751776
}//GEN-LAST:event_resolveDependenciesActionPerformed
752777

778+
private void sendDiagnosticsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendDiagnosticsActionPerformed
779+
780+
}//GEN-LAST:event_sendDiagnosticsActionPerformed
781+
753782
// Variables declaration - do not modify//GEN-BEGIN:variables
754783
private javax.swing.JLabel adviceLabel;
755784
private javax.swing.JCheckBox checkForUnopenedExercisesCheckbox;
@@ -771,6 +800,7 @@ private void resolveDependenciesActionPerformed(java.awt.event.ActionEvent evt)
771800
private javax.swing.JCheckBox resolveDependencies;
772801
private javax.swing.JLabel restartMessage;
773802
private javax.swing.JCheckBox savePasswordCheckBox;
803+
private javax.swing.JCheckBox sendDiagnostics;
774804
private javax.swing.JLabel serverAddressLabel;
775805
private javax.swing.JTextField serverAddressTextField;
776806
private javax.swing.JCheckBox spywareEnabledCheckbox;

tmc-plugin/src/fi/helsinki/cs/tmc/ui/PreferencesUI.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public interface PreferencesUI {
3232

3333
void setResolveProjectDependenciesEnabled(boolean value);
3434

35+
boolean getSendDiagnosticsEnabled();
36+
37+
void setSendDiagnosticsEnabled(boolean value);
38+
3539
Locale getErrorMsgLocale();
3640

3741
void setAvailableCourses(List<Course> courses);

0 commit comments

Comments
 (0)