Skip to content

Commit 5d0a89d

Browse files
committed
Fixes
1 parent 5b6d2a2 commit 5d0a89d

File tree

14 files changed

+218
-120
lines changed

14 files changed

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

nbproject/platform.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ extcluster.mavenmodules.sources=
3838
# org.openide.execution,\
3939
# org.openide.options,\
4040
# org.openide.util.enumerations
41-
nbplatform.active=nb81
41+
nbplatform.active=nb82

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
import java.util.concurrent.Callable;
1919
import java.util.logging.Level;
2020
import java.util.logging.Logger;
21+
import java.util.prefs.BackingStoreException;
22+
import java.util.prefs.Preferences;
2123
import org.netbeans.api.project.Project;
2224
import org.openide.filesystems.FileObject;
2325
import org.openide.nodes.Node;
26+
import org.openide.util.Exceptions;
2427
import org.openide.util.NbBundle.Messages;
28+
import org.openide.util.NbPreferences;
2529
import org.openide.windows.WindowManager;
2630

2731
@Messages("CTL_RunTestsLocallyExerciseAction=Run &tests locally")
@@ -46,12 +50,12 @@ public RunTestsLocallyAction() {
4650

4751
@Override
4852
protected void performAction(final Node[] nodes) {
53+
if (nodes.length == 1) {
54+
this.project = projectsFromNodes(nodes).get(0);
55+
56+
WindowManager.getDefault().invokeWhenUIReady(this);
57+
}
4958

50-
if (nodes.length == 1) {
51-
this.project = projectsFromNodes(nodes).get(0);
52-
53-
WindowManager.getDefault().invokeWhenUIReady(this);
54-
}
5559
}
5660

5761
@Override

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ public class SaveSettingsAction extends AbstractAction {
2121
private CourseDb courseDb;
2222
private TmcEventBus eventBus;
2323
private TmcCore tmcCore;
24+
private final FixUnoptimalSettings fixUnoptimalSettings;
25+
2426
public SaveSettingsAction() {
2527
this.courseDb = CourseDb.getInstance();
2628
this.eventBus = TmcEventBus.getDefault();
2729
this.tmcCore = TmcCore.get();
30+
this.fixUnoptimalSettings = new FixUnoptimalSettings();
2831
}
2932

3033
@Override
@@ -49,8 +52,15 @@ public void actionPerformed(ActionEvent e) {
4952
settings.setCheckingForUnopenedAtStartup(prefUi.getCheckForUnopenedExercisesAtStartup());
5053
settings.setIsSpywareEnabled(prefUi.getSpywareEnabled());
5154
settings.setErrorMsgLocale(prefUi.getErrorMsgLocale());
55+
settings.setResolveDependencies(prefUi.getResolveProjectDependenciesEnabled());
5256

5357
eventBus.post(new InvokedEvent());
58+
59+
if (settings.getResolveDependencies()) {
60+
fixUnoptimalSettings.run();
61+
} else {
62+
fixUnoptimalSettings.undo();
63+
}
5464

5565
if (prefUi.getSelectedCourseName() != null) {
5666
courseDb.setAvailableCourses(prefUi.getAvailableCourses());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void run() {
6565
prefUI.setUsernameFieldName(tailoring.getUsernameFieldName());
6666
prefUI.setSpywareEnabled(settings.isSpywareEnabled());
6767
prefUI.setErrorMsgLocale(settings.getErrorMsgLocale());
68+
prefUI.setResolveProjectDependenciesEnabled(settings.getResolveDependencies());
6869

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public void run() {
6565
}
6666
prefs.put(PREF_MODULE_VERSION, currentVersion.toString());
6767
}
68+
69+
new EnsureMavenBinaryIsExecutable().run();
6870

6971
boolean isFirstRun = prefs.getBoolean(PREF_FIRST_RUN, true);
7072
if (isFirstRun) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class TmcCoreSettingsImpl implements TmcSettings {
3434
private static final String PREF_SPYWARE_ENABLED = "spywareEnabled";
3535
private static final String PREF_DETAILED_SPYWARE_ENABLED = "detailedSpywareEnabled";
3636
private static final String PREF_ERROR_MSG_LOCALE = "errorMsgLocale";
37+
private static final String PREF_RESOLVE_DEPENDENCIES = "resolveDependencies";
3738

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

@@ -241,6 +242,14 @@ public void setErrorMsgLocale(Locale locale) {
241242
settings.put(PREF_ERROR_MSG_LOCALE, locale.toString());
242243
}
243244

245+
public void setResolveDependencies(boolean value) {
246+
settings.put(PREF_RESOLVE_DEPENDENCIES, value ? "1" : "0");
247+
}
248+
249+
public boolean getResolveDependencies() {
250+
return settings.get(PREF_RESOLVE_DEPENDENCIES, "1").equals("1");
251+
}
252+
244253
private Locale parseLocale(String s, Locale dflt) {
245254
if (s.isEmpty()) {
246255
return dflt;

tmc-plugin/src/fi/helsinki/cs/tmc/spyware/eventsources/ProjectActionCaptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* of the actual action provider.
2424
*/
2525
public class ProjectActionCaptor implements ActionProvider {
26-
public static interface Listener {
27-
public void actionInvoked(Project project, String command);
26+
public interface Listener {
27+
void actionInvoked(Project project, String command);
2828
}
2929
private static List<Listener> listeners = new ArrayList<Listener>();
3030

tmc-plugin/src/fi/helsinki/cs/tmc/spyware/eventsources/WindowStatechangesEventSource.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,22 @@ private String toStringWithObjects(Object object) {
173173
} else if (object instanceof Mode) {
174174
return ((Mode) object).getName();
175175
} else if (object instanceof Accessible) {
176+
// Workaround a weird bug
177+
if (object instanceof JTextComponent) {
178+
try {
179+
((JTextComponent) object).getCaret();
180+
} catch (NullPointerException e) {
181+
log.log(Level.WARNING, "JTextcomponent's caret mysteriously missing: {}", e);
182+
return "null";
183+
}
184+
}
176185
try {
177-
if (object != null) {
178-
Accessible acc = (Accessible) object;
179-
if (acc != null) {
180-
AccessibleContext context = acc.getAccessibleContext();
181-
if (context != null) {
182-
String str = context.getAccessibleName();
183-
if (str != null) {
184-
return str;
185-
}
186-
}
186+
Accessible acc = (Accessible) object;
187+
AccessibleContext context = acc.getAccessibleContext();
188+
if (context != null) {
189+
String str = context.getAccessibleName();
190+
if (str != null) {
191+
return str;
187192
}
188193
}
189194
} catch (Exception e) {

tmc-plugin/src/fi/helsinki/cs/tmc/tailoring/Tailoring.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
* @see <code>SelectedTailoring.properties.sample</code>
1010
*/
1111
public interface Tailoring {
12-
public String getDefaultServerUrl();
13-
public String getDefaultUsername();
14-
public String getUsernameFieldName();
15-
public boolean isSpywareEnabledByDefault();
16-
public boolean isDetailedSpywareEnabledByDefault();
12+
String getDefaultServerUrl();
13+
String getDefaultUsername();
14+
String getUsernameFieldName();
15+
boolean isSpywareEnabledByDefault();
16+
boolean isDetailedSpywareEnabledByDefault();
1717

18-
public Locale[] getAvailableErrorMsgLocales();
19-
public Locale getDefaultErrorMsgLocale();
18+
Locale[] getAvailableErrorMsgLocales();
19+
Locale getDefaultErrorMsgLocale();
2020

21-
public String getUpdateCenterTitle();
22-
public String getUpdateCenterUrl();
21+
String getUpdateCenterTitle();
22+
String getUpdateCenterUrl();
2323
}

0 commit comments

Comments
 (0)