Skip to content

Commit 0be5b14

Browse files
committed
Bundle index update disabling with dependency resolving
1 parent 5fbcb31 commit 0be5b14

File tree

8 files changed

+54
-40
lines changed

8 files changed

+54
-40
lines changed
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
package fi.helsinki.cs.tmc.actions;
22

3+
import java.util.Arrays;
4+
import java.util.prefs.BackingStoreException;
35
import org.openide.util.NbPreferences;
46

57
import java.util.prefs.Preferences;
8+
import org.openide.util.Exceptions;
69

710
public class FixUnoptimalSettings {
811

912
private final Preferences mavenPrefrences;
13+
private final Preferences indexingPreferences;
1014

1115
public FixUnoptimalSettings() {
1216
this.mavenPrefrences = NbPreferences.root()
1317
.node("org")
1418
.node("netbeans")
1519
.node("modules")
1620
.node("maven");
21+
this.indexingPreferences = NbPreferences.root()
22+
.node("org")
23+
.node("netbeans")
24+
.node("modules")
25+
.node("maven")
26+
.node("nexus")
27+
.node("indexing");
1728
}
1829

1930
public void run() {
2031
fixMavenDependencyDownloadPolicy();
32+
fixMavenIndexingPolicy();
2133
}
2234

2335
private void fixMavenDependencyDownloadPolicy() {
@@ -26,11 +38,15 @@ private void fixMavenDependencyDownloadPolicy() {
2638
mavenPrefrences.put("binaryDownload", "EVERY_OPEN");
2739
}
2840
}
29-
30-
void undo() {
31-
final String binaryDownloadValue = mavenPrefrences.get("binaryDownload", "");
32-
if (binaryDownloadValue.equals("EVERY_OPEN")) {
33-
mavenPrefrences.put("binaryDownload", "NEVER");
41+
42+
private void fixMavenIndexingPolicy() {
43+
final String disableIndexingValue = indexingPreferences.get("createIndex", "");
44+
if (!disableIndexingValue.equals("false")) {
45+
indexingPreferences.put("createIndex", "false");
46+
}
47+
final String updateFrequencyValue = indexingPreferences.get("indexUpdateFrequency", "");
48+
if (!updateFrequencyValue.equals("3")) {
49+
indexingPreferences.put("indexUpdateFrequency", "3");
3450
}
3551
}
3652
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ public void actionPerformed(ActionEvent e) {
5757
settings.setCheckingForUpdatesInTheBackground(prefUi.getCheckForUpdatesInTheBackground());
5858
settings.setCheckingForUnopenedAtStartup(prefUi.getCheckForUnopenedExercisesAtStartup());
5959
settings.setErrorMsgLocale(prefUi.getErrorMsgLocale());
60-
settings.setResolveDependencies(prefUi.getResolveProjectDependenciesEnabled());
60+
settings.setFixUnoptimalSettings(prefUi.getFixUnoptimalSettingsEnabled());
6161
settings.setSendDiagnostics(prefUi.getSendDiagnosticsEnabled());
6262

6363
eventBus.post(new InvokedEvent());
6464

65-
if (settings.getResolveDependencies()) {
65+
if (settings.getFixUnoptimalSettings()) {
6666
fixUnoptimalSettings.run();
67-
} else {
68-
fixUnoptimalSettings.undo();
6967
}
7068

7169
if (settings.getSendDiagnostics()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void run() {
6868
prefUI.setCheckForUpdatesInTheBackground(settings.isCheckingForUpdatesInTheBackground());
6969
prefUI.setCheckForUnopenedExercisesAtStartup(settings.isCheckingForUnopenedAtStartup());
7070
prefUI.setErrorMsgLocale(settings.getErrorMsgLocale());
71-
prefUI.setResolveProjectDependenciesEnabled(settings.getResolveDependencies());
71+
prefUI.setFixUnoptimalSettingsEnabled(settings.getFixUnoptimalSettings());
7272
prefUI.setSendDiagnosticsEnabled(settings.getSendDiagnostics());
7373

7474
ActionListener listener = new ActionListener() {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class TmcCoreSettingsImpl implements TmcSettings {
3737
private static final String PREF_CHECK_FOR_UPDATES_IN_BACKGROUND = "checkForUpdatesInBackground";
3838
private static final String PREF_CHECK_FOR_UNOPENED_AT_STARTUP = "checkForUnopenedAtStartup";
3939
private static final String PREF_ERROR_MSG_LOCALE = "errorMsgLocale";
40-
private static final String PREF_RESOLVE_DEPENDENCIES = "resolveDependencies";
40+
private static final String PREF_FIX_UNOPTIMAL_SETTINGS = "fixUnoptimalSettings";
4141
private static final String PREF_SEND_DIAGNOSTICS = "sendDiagnostics";
4242
private static final String PREF_OAUTH_TOKEN = "oauthToken";
4343
private static final String PREF_OAUTH_APPLICATION_ID = "oauthApplicationId";
@@ -277,12 +277,12 @@ public void setErrorMsgLocale(Locale locale) {
277277
settings.put(PREF_ERROR_MSG_LOCALE, locale.toString());
278278
}
279279

280-
public void setResolveDependencies(boolean value) {
281-
settings.put(PREF_RESOLVE_DEPENDENCIES, value ? "1" : "0");
280+
public void setFixUnoptimalSettings(boolean value) {
281+
settings.put(PREF_FIX_UNOPTIMAL_SETTINGS, value ? "1" : "0");
282282
}
283283

284-
public boolean getResolveDependencies() {
285-
return settings.get(PREF_RESOLVE_DEPENDENCIES, "1").equals("1");
284+
public boolean getFixUnoptimalSettings() {
285+
return settings.get(PREF_FIX_UNOPTIMAL_SETTINGS, "1").equals("1");
286286
}
287287

288288
public void setSendDiagnostics(boolean value) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ PastebinDialog.leaveMessageLabel.text=Comment for paste (optional)
6060
PastebinDialog.title=Confirm code review request
6161
PastebinDialog.cancelButton.text=&Cancel
6262
PreferencesPanel.restartMessage.text=Changing language requires restart
63-
PreferencesPanel.resolveDependencies.toolTipText=Leave this on if you want to be able to open Maven projects effortlessly.
64-
PreferencesPanel.resolveDependencies.text=Ensure Netbeans is configured to resolve project dependencies
6563
PreferencesPanel.sendDiagnostics.toolTipText=This information helps us to helps us to fix crashes and other problems with this plugin.
6664
PreferencesPanel.sendDiagnostics.text=Automatically send anonymous crash reports and diagnostics for plugin development
6765
OpenClosedExercisesDialog.closeButton.text=Close
@@ -97,3 +95,5 @@ PreferencesPanel.selectedOrganizationLabel.text=No organization selected
9795
AboutDialog.headerLabel.text=About Test My Code
9896
AboutDialog.closeButton.text=Close
9997
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>
98+
PreferencesPanel.fixUnoptimalSettings.toolTipText=Leave this on if you want to be able to open Maven projects effortlessly.
99+
PreferencesPanel.fixUnoptimalSettings.text=Ensure Netbeans is configured correctly

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<Group type="103" groupAlignment="0" attributes="0">
2727
<Group type="102" attributes="0">
2828
<Group type="103" groupAlignment="0" attributes="0">
29-
<Component id="resolveDependencies" min="-2" max="-2" attributes="0"/>
29+
<Component id="fixUnoptimalSettings" min="-2" max="-2" attributes="0"/>
3030
<Component id="sendDiagnostics" min="-2" max="-2" attributes="0"/>
3131
</Group>
3232
<EmptySpace min="0" pref="216" max="32767" attributes="0"/>
@@ -123,7 +123,7 @@
123123
<EmptySpace max="-2" attributes="0"/>
124124
<Component id="checkForUnopenedExercisesCheckbox" min="-2" max="-2" attributes="0"/>
125125
<EmptySpace max="-2" attributes="0"/>
126-
<Component id="resolveDependencies" min="-2" max="-2" attributes="0"/>
126+
<Component id="fixUnoptimalSettings" min="-2" max="-2" attributes="0"/>
127127
<EmptySpace max="-2" attributes="0"/>
128128
<Component id="sendDiagnostics" min="-2" max="-2" attributes="0"/>
129129
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
@@ -242,18 +242,18 @@
242242
</Property>
243243
</Properties>
244244
</Component>
245-
<Component class="javax.swing.JCheckBox" name="resolveDependencies">
245+
<Component class="javax.swing.JCheckBox" name="fixUnoptimalSettings">
246246
<Properties>
247247
<Property name="selected" type="boolean" value="true"/>
248248
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
249-
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="PreferencesPanel.resolveDependencies.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
249+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="PreferencesPanel.fixUnoptimalSettings.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
250250
</Property>
251251
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
252-
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="PreferencesPanel.resolveDependencies.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
252+
<ResourceString bundle="fi/helsinki/cs/tmc/ui/Bundle.properties" key="PreferencesPanel.fixUnoptimalSettings.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
253253
</Property>
254254
</Properties>
255255
<Events>
256-
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resolveDependenciesActionPerformed"/>
256+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fixUnoptimalSettingsActionPerformed"/>
257257
</Events>
258258
</Component>
259259
<Component class="javax.swing.JCheckBox" name="sendDiagnostics">

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ public void setCheckForUnopenedExercisesAtStartup(boolean shouldCheck) {
128128
}
129129

130130
@Override
131-
public boolean getResolveProjectDependenciesEnabled() {
132-
return resolveDependencies.isSelected();
131+
public boolean getFixUnoptimalSettingsEnabled() {
132+
return fixUnoptimalSettings.isSelected();
133133
}
134134

135135
@Override
136-
public void setResolveProjectDependenciesEnabled(boolean value) {
137-
resolveDependencies.setSelected(value);
136+
public void setFixUnoptimalSettingsEnabled(boolean value) {
137+
fixUnoptimalSettings.setSelected(value);
138138
}
139139

140140
@Override
@@ -268,7 +268,7 @@ private void initComponents() {
268268
errorMsgLocaleLabel = new javax.swing.JLabel();
269269
errorMsgLocaleComboBox = new javax.swing.JComboBox();
270270
restartMessage = new javax.swing.JLabel();
271-
resolveDependencies = new javax.swing.JCheckBox();
271+
fixUnoptimalSettings = new javax.swing.JCheckBox();
272272
sendDiagnostics = new javax.swing.JCheckBox();
273273
organizationLabel = new javax.swing.JLabel();
274274
changeOrganizationButton = new javax.swing.JButton();
@@ -317,12 +317,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
317317
restartMessage.setFont(new java.awt.Font("Ubuntu", 1, 14)); // NOI18N
318318
restartMessage.setText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.restartMessage.text")); // NOI18N
319319

320-
resolveDependencies.setSelected(true);
321-
resolveDependencies.setText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.resolveDependencies.text")); // NOI18N
322-
resolveDependencies.setToolTipText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.resolveDependencies.toolTipText")); // NOI18N
323-
resolveDependencies.addActionListener(new java.awt.event.ActionListener() {
320+
fixUnoptimalSettings.setSelected(true);
321+
fixUnoptimalSettings.setText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.fixUnoptimalSettings.text")); // NOI18N
322+
fixUnoptimalSettings.setToolTipText(org.openide.util.NbBundle.getMessage(PreferencesPanel.class, "PreferencesPanel.fixUnoptimalSettings.toolTipText")); // NOI18N
323+
fixUnoptimalSettings.addActionListener(new java.awt.event.ActionListener() {
324324
public void actionPerformed(java.awt.event.ActionEvent evt) {
325-
resolveDependenciesActionPerformed(evt);
325+
fixUnoptimalSettingsActionPerformed(evt);
326326
}
327327
});
328328

@@ -370,7 +370,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
370370
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
371371
.addGroup(layout.createSequentialGroup()
372372
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
373-
.addComponent(resolveDependencies)
373+
.addComponent(fixUnoptimalSettings)
374374
.addComponent(sendDiagnostics))
375375
.addGap(0, 216, Short.MAX_VALUE))
376376
.addGroup(layout.createSequentialGroup()
@@ -447,7 +447,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
447447
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
448448
.addComponent(checkForUnopenedExercisesCheckbox)
449449
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
450-
.addComponent(resolveDependencies)
450+
.addComponent(fixUnoptimalSettings)
451451
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
452452
.addComponent(sendDiagnostics)
453453
.addGap(18, 18, 18)
@@ -494,9 +494,9 @@ private void changeCourseButtonActionPerformed(java.awt.event.ActionEvent evt) {
494494
updateSettingsForRefresh();
495495
}//GEN-LAST:event_changeCourseButtonActionPerformed
496496

497-
private void resolveDependenciesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resolveDependenciesActionPerformed
497+
private void fixUnoptimalSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fixUnoptimalSettingsActionPerformed
498498

499-
}//GEN-LAST:event_resolveDependenciesActionPerformed
499+
}//GEN-LAST:event_fixUnoptimalSettingsActionPerformed
500500

501501
private void sendDiagnosticsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendDiagnosticsActionPerformed
502502
TmcCoreSettingsImpl tmcSettings = (TmcCoreSettingsImpl) this.settings;
@@ -536,6 +536,7 @@ private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
536536
private javax.swing.JLabel coursesLabel;
537537
private javax.swing.JComboBox errorMsgLocaleComboBox;
538538
private javax.swing.JLabel errorMsgLocaleLabel;
539+
private javax.swing.JCheckBox fixUnoptimalSettings;
539540
private javax.swing.JButton folderChooserBtn;
540541
private javax.swing.JSeparator jSeparator1;
541542
private javax.swing.JSeparator jSeparator2;
@@ -546,7 +547,6 @@ private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
546547
private javax.swing.JLabel organizationLabel;
547548
private javax.swing.JLabel projectFolderLabel;
548549
private javax.swing.JTextField projectFolderTextField;
549-
private javax.swing.JCheckBox resolveDependencies;
550550
private javax.swing.JLabel restartMessage;
551551
private javax.swing.JLabel selectedCourseLabel;
552552
private javax.swing.JLabel selectedOrganizationLabel;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public interface PreferencesUI {
1818

1919
String getSelectedCourseName();
2020

21-
boolean getResolveProjectDependenciesEnabled();
21+
boolean getFixUnoptimalSettingsEnabled();
2222

23-
void setResolveProjectDependenciesEnabled(boolean value);
23+
void setFixUnoptimalSettingsEnabled(boolean value);
2424

2525
boolean getSendDiagnosticsEnabled();
2626

0 commit comments

Comments
 (0)