Skip to content

Commit d24556f

Browse files
- refactored PreferencesManager tests in a single class
- implemented Hyperlink's actions to open their
1 parent cbcb0f8 commit d24556f

6 files changed

Lines changed: 556 additions & 635 deletions

File tree

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@
245245
-Dmonocle.platform.headless.height=768
246246
-Dprism.order=sw
247247
-Dtestfx.robot=glass
248-
-Dtestfx.headless=false <!-- false to show UI -->
249-
<!-- comment out to show UI
248+
-Dtestfx.headless=true <!-- false to show UI -->
249+
<!-- comment out to show UI -->
250250
-Dglass.platform=Monocle
251251
-Dmonocle.platform=Headless
252-
-->
252+
<!-- -->
253253
</argLine>
254254
<systemPropertyVariables>
255255
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>

src/main/java/io/github/jeddict/ai/settings/JeddictPreferences.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.awt.event.KeyEvent;
4646
import java.io.IOException;
4747
import java.io.StringReader;
48+
import java.net.URI;
4849
import java.nio.file.Path;
4950
import java.nio.file.Paths;
5051
import java.util.HashMap;
@@ -77,6 +78,8 @@
7778
import org.apache.commons.lang3.StringUtils;
7879
import org.controlsfx.control.MasterDetailPane;
7980
import org.controlsfx.control.HyperlinkLabel;
81+
import org.openide.awt.HtmlBrowser.URLDisplayer;
82+
import org.openide.util.Exceptions;
8083
import static ste.lloop.Loop.on;
8184
import ste.netbeans.javafx.JFXPanel;
8285

@@ -286,13 +289,16 @@ private void initComponents() {
286289
);
287290
modelsLink = new Hyperlink(); modelsLink.setId("modelsUrl");
288291
modelsLink.setOnAction(event -> {
292+
browse(modelsLink.getText());
289293
modelsLink.setVisited(false); // Forces the link back to its unclicked default color
290294
});
291295
modelsLink.textProperty().bind(settings.string("modelsUrl"));
292296

293297
apiKeyLink = new Hyperlink(); apiKeyLink.setId("apiKeyUrl");
294298
apiKeyLink.setOnAction(event -> {
299+
browse(apiKeyLink.getText());
295300
apiKeyLink.setVisited(false); // Forces the link back to its unclicked default color
301+
296302
});
297303
apiKeyLink.textProperty().bind(settings.string("apiKeyUrl"));
298304

@@ -985,4 +991,12 @@ public ClassContextLegend() {
985991
setId("class-context-legend");
986992
}
987993
}
994+
995+
private void browse(final String url) {
996+
try {
997+
URLDisplayer.getDefault().showURL(URI.create(url).toURL());
998+
} catch (Exception x) {
999+
Exceptions.printStackTrace(x);
1000+
}
1001+
}
9881002
}

src/test/java/io/github/jeddict/ai/settings/JeddictPreferencesTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ public void save_persists_ui_settings_to_preferences_manager() {
121121
then(pm.getMaxRetries()).isEqualTo(3);
122122
then(pm.getOrganizationId()).isEqualTo("org-1");
123123

124-
then(pm.isAllowCodeExecution()).isTrue();
125-
then(pm.isIncludeCodeExecutionOutput()).isTrue();
126-
127124
then(pm.getFileExtensionListToInclude()).containsExactly("java","kt");
128125
then(pm.getExcludeDirs()).containsExactly("a","b","c");
129126

0 commit comments

Comments
 (0)