-
Notifications
You must be signed in to change notification settings - Fork 66
Branch fix #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Branch fix #41
Changes from all commits
98e1d8b
f885745
c64d330
54a2cee
0506b41
1cfa99b
6520c6f
0f51250
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| target/ | ||
| /.idea/ | ||
| .env |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,66 @@ | ||
| package com.example; | ||
|
|
||
|
|
||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.control.ListView; | ||
| import javafx.scene.control.TextField; | ||
| import javafx.stage.FileChooser; | ||
| import javafx.stage.Stage; | ||
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Controller layer: mediates between the view (FXML) and the model. | ||
| */ | ||
| public class HelloController { | ||
|
|
||
| private final HelloModel model = new HelloModel(); | ||
| public final HelloModel model = new HelloModel(new NtfyConnectionImpl()); | ||
| @FXML private ListView<String> messageList; | ||
| @FXML private TextField inputField; | ||
| @FXML private Label fileLabel; | ||
|
|
||
| private File selectedFile; | ||
|
|
||
|
|
||
| @FXML | ||
| private Label messageLabel; | ||
| public void initialize() { | ||
| messageList.setItems(model.getMessages()); | ||
| } | ||
|
|
||
|
|
||
| public void sendMessage() { | ||
| String message = inputField.getText().trim(); | ||
| if (!message.isEmpty()) { | ||
| model.setMessageToSend(message); | ||
| model.sendMessage(); | ||
| inputField.clear(); | ||
| } | ||
| if (selectedFile != null) { | ||
| try { | ||
| sendFileToServer(selectedFile); | ||
| fileLabel.setText("File sent successfully"); | ||
| } catch (IOException e) { | ||
| fileLabel.setText("Error sending file"); | ||
| } | ||
| } else { | ||
| fileLabel.setText("No file selected"); | ||
| } | ||
| } | ||
|
|
||
| @FXML | ||
| private void initialize() { | ||
| if (messageLabel != null) { | ||
| messageLabel.setText(model.getGreeting()); | ||
| public void attachFile() { | ||
| FileChooser fileChooser = new FileChooser(); | ||
| fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Files", "*.*")); | ||
| selectedFile = fileChooser.showOpenDialog(new Stage()); | ||
| if (selectedFile != null) { | ||
| fileLabel.setText("Selected: " + selectedFile.getName()); | ||
| } else { | ||
| fileLabel.setText("No file selected"); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private void sendFileToServer(File file) throws IOException { | ||
| model.sendFileToServer(file); | ||
| } | ||
|
Comment on lines
+15
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainDecouple model wiring and tidy file‑sending UX
Length of output: 1793 🏁 Script executed: #!/bin/bash
# Find HelloModel class definition
fd -t f HelloModel.java --exec cat {} \;Length of output: 1161 🏁 Script executed: #!/bin/bash
# Find NtfyConnection interface/class
fd -t f NtfyConnection.java --exec cat {} \;Length of output: 321 🏁 Script executed: #!/bin/bash
# Search for DI configuration or framework usage (Spring, etc.)
rg -n "Configuration|@Bean|@Autowired|@Inject|@Component|Injector|Module" --type=java | head -20Length of output: 0 🏁 Script executed: #!/bin/bash
# Check if selectedFile is cleared or reset anywhere in the codebase
rg -n "selectedFile\s*=" --type=java -C2Length of output: 568 Length of output: 2641 Decouple model wiring and fix file-sending logic
🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||
| package com.example; | ||||||||||
|
|
||||||||||
|
|
||||||||||
| import javafx.application.Application; | ||||||||||
| import javafx.fxml.FXMLLoader; | ||||||||||
| import javafx.scene.Parent; | ||||||||||
|
|
@@ -10,15 +11,15 @@ public class HelloFX extends Application { | |||||||||
|
|
||||||||||
| @Override | ||||||||||
| public void start(Stage stage) throws Exception { | ||||||||||
| FXMLLoader fxmlLoader = new FXMLLoader(HelloFX.class.getResource("hello-view.fxml")); | ||||||||||
| FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("hello-view.fxml")); | ||||||||||
| Parent root = fxmlLoader.load(); | ||||||||||
| Scene scene = new Scene(root, 640, 480); | ||||||||||
| stage.setTitle("Hello MVC"); | ||||||||||
| Scene scene = new Scene(root); | ||||||||||
| stage.setTitle("Tittle goes here"); | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in window title. "Tittle" should be "Title". - stage.setTitle("Tittle goes here");
+ stage.setTitle("Title goes here");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| stage.setScene(scene); | ||||||||||
| stage.show(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public static void main(String[] args) { | ||||||||||
| static void main() { | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Incorrect main method signature. The main method must be Apply this diff: - static void main() {
+ public static void main(String[] args) {
launch();
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| launch(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,47 @@ | ||
| package com.example; | ||
|
|
||
| /** | ||
| * Model layer: encapsulates application data and business logic. | ||
| */ | ||
| import javafx.application.Platform; | ||
| import javafx.beans.property.SimpleStringProperty; | ||
| import javafx.beans.property.StringProperty; | ||
| import javafx.collections.FXCollections; | ||
| import javafx.collections.ObservableList; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
|
|
||
| public class HelloModel { | ||
| /** | ||
| * Returns a greeting based on the current Java and JavaFX versions. | ||
| */ | ||
| public String getGreeting() { | ||
| String javaVersion = System.getProperty("java.version"); | ||
| String javafxVersion = System.getProperty("javafx.version"); | ||
| return "Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."; | ||
| private final NtfyConnection connection; | ||
|
|
||
| private final ObservableList<String> messages = FXCollections.observableArrayList(); | ||
| private final StringProperty messageToSend = new SimpleStringProperty(); | ||
|
|
||
| public HelloModel(NtfyConnection connection) { | ||
| this.connection = connection; | ||
| receiveMessage(); | ||
| } | ||
|
|
||
|
|
||
| public ObservableList<String> getMessages() { | ||
| return messages; | ||
| } | ||
|
|
||
| public void setMessageToSend(String message) { | ||
| this.messageToSend.set(message); | ||
| } | ||
|
|
||
|
|
||
| public void sendMessage() { | ||
| connection.send(messageToSend.get()); | ||
| } | ||
|
|
||
| public void sendFileToServer(File file) throws IOException { | ||
| connection.sendFile(file.toPath()); | ||
| } | ||
|
|
||
| public void receiveMessage() { | ||
| connection.recieve(m-> Platform.runLater(()-> messages.add(m.message()))); | ||
| } | ||
|
|
||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.example; | ||
|
|
||
| import java.io.FileNotFoundException; | ||
| import java.nio.file.Path; | ||
| import java.util.function.Consumer; | ||
|
|
||
| public interface NtfyConnection { | ||
|
|
||
| boolean send(String message); | ||
|
|
||
| void recieve(Consumer<NtfyMessageDto> messageHandler); | ||
|
|
||
| boolean sendFile(Path filePath) throws FileNotFoundException; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package com.example; | ||
|
|
||
|
|
||
| import io.github.cdimascio.dotenv.Dotenv; | ||
| import tools.jackson.databind.ObjectMapper; | ||
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
| import java.net.URI; | ||
| import java.net.http.HttpClient; | ||
| import java.net.http.HttpRequest; | ||
| import java.net.http.HttpResponse; | ||
| import java.nio.file.Path; | ||
| import java.util.Objects; | ||
| import java.util.function.Consumer; | ||
|
|
||
| public class NtfyConnectionImpl implements NtfyConnection { | ||
|
|
||
| private final HttpClient http = HttpClient.newHttpClient(); | ||
| private final String hostName; | ||
| private final ObjectMapper mapper = new ObjectMapper(); | ||
|
|
||
|
|
||
| public NtfyConnectionImpl() { | ||
| Dotenv dotenv = Dotenv.load(); | ||
| hostName= Objects.requireNonNull(dotenv.get("HOST_NAME")); | ||
| } | ||
|
|
||
| public NtfyConnectionImpl(String hostName) { | ||
| this.hostName = hostName; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean send(String message) { | ||
| HttpRequest httpRequest = HttpRequest.newBuilder() | ||
| .POST(HttpRequest.BodyPublishers.ofString(message)) | ||
| .uri(URI.create(hostName + "/mytopic")) | ||
| .build(); | ||
| try { | ||
| http.send(httpRequest, HttpResponse.BodyHandlers.ofString()); | ||
| return true; | ||
| } catch (IOException e) { | ||
| System.out.println("IOException"); | ||
| } catch (InterruptedException e){ | ||
| System.out.println("Interrupted"); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
|
|
||
| public boolean sendFile(Path filePath) throws FileNotFoundException { | ||
| HttpRequest httpRequest = HttpRequest.newBuilder() | ||
| .POST(HttpRequest.BodyPublishers.ofFile(filePath)) | ||
| .uri(URI.create(hostName + "/mytopic")) | ||
| .build(); | ||
|
|
||
| try { | ||
| http.send(httpRequest, HttpResponse.BodyHandlers.ofFile(filePath)); | ||
| return true; | ||
| } catch (IOException e) { | ||
| System.out.println("IOException"); | ||
| } catch (InterruptedException e){ | ||
| System.out.println("Interrupted"); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public void recieve(Consumer<NtfyMessageDto> messageHandler) { | ||
| HttpRequest httpRequest = HttpRequest.newBuilder() | ||
| .GET() | ||
| .uri(URI.create(hostName + "/mytopic/json")) | ||
| .build(); | ||
|
|
||
| http.sendAsync(httpRequest, HttpResponse.BodyHandlers.ofLines()) | ||
| .thenAccept(response -> response.body() | ||
| .map(s-> mapper.readValue(s, NtfyMessageDto.class)) | ||
| .filter(message -> message.event().equals("message")) | ||
| .forEach(messageHandler)); | ||
|
|
||
|
|
||
| } | ||
|
Comment on lines
+4
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainFix Jackson import, file upload semantics, and async JSON parsing There are a few correctness issues here that will either prevent compilation or cause surprising behavior:
This keeps the async behavior, ensures the code compiles, and avoids crashing the async pipeline on a single malformed line. I'll now verify the key claims in this review comment by checking the codebase structure and confirming technical details about Jackson. Now let me verify the codebase context and confirm the other technical issues: Length of output: 273 🏁 Script executed: #!/bin/bash
# Examine the interface, implementation, and DTO to verify the review
echo "=== NtfyConnection.java interface ==="
cat ./src/main/java/com/example/NtfyConnection.java
echo ""
echo "=== NtfyMessageDto.java ==="
cat ./src/main/java/com/example/NtfyMessageDto.java
echo ""
echo "=== Current imports in NtfyConnectionImpl.java (first 15 lines) ==="
head -15 ./src/main/java/com/example/NtfyConnectionImpl.javaLength of output: 1072 Fix Jackson import, file upload semantics, and async JSON parsing There are three critical issues that will prevent compilation or cause incorrect behavior:
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.example; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
|
||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public record NtfyMessageDto(String id, long time, String event, String topic, String message){ | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| module hellofx { | ||
| requires javafx.controls; | ||
| requires javafx.fxml; | ||
| requires java.desktop; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify that The module requirement may be unnecessary if desktop integration APIs are not used in the codebase. 🏁 Script executed: #!/bin/bash
# Check for usage of java.desktop APIs (AWT, Swing, etc.)
rg -n --type=java '\b(java\.awt|javax\.swing|java\.beans)\b' src/main/java/Length of output: 0 🏁 Script executed: #!/bin/bash
# Comprehensive search for all java.desktop package imports
# java.desktop module includes: java.awt, java.applet, java.beans, javax.imageio, javax.print, javax.sound, javax.swing, etc.
echo "=== Searching for all imports from java.desktop packages ==="
rg -n --type=java '^\s*import\s+(java\.(awt|applet|beans|desktop)|javax\.(imageio|print|sound|swing))' src/main/java/
echo -e "\n=== Searching for any import statements ==="
rg -n --type=java '^\s*import\s+' src/main/java/ | head -20
echo -e "\n=== Checking module-info.java for all requires statements ==="
rg -n 'requires' src/main/java/module-info.java
echo -e "\n=== Checking for reflection-based class loading that might use desktop ==="
rg -n --type=java '(Class\.forName|getClass|ClassLoader)' src/main/java/Length of output: 480 🏁 Script executed: #!/bin/bash
# Discover repository structure and locate Java files
echo "=== Repository root structure ==="
ls -la
echo -e "\n=== Finding module-info.java ==="
find . -name "module-info.java" -type f
echo -e "\n=== Finding all Java files (first 30) ==="
find . -name "*.java" -type f | head -30
echo -e "\n=== Looking for src directory ==="
find . -type d -name "src" | head -10Length of output: 1288 🏁 Script executed: #!/bin/bash
# Check module-info.java and all imports in Java source
echo "=== Content of module-info.java ==="
cat ./src/main/java/module-info.java
echo -e "\n=== All import statements in main Java files ==="
rg -n 'import' ./src/main/java/com/example/ --type=java
echo -e "\n=== Checking for java.desktop or java.awt usage ==="
rg -n '(java\.awt|javax\.swing|java\.desktop)' ./src/main/java/com/example/ --type=java
echo -e "\n=== Checking for JavaFX usage (javafx imports) ==="
rg -n 'javafx' ./src/main/java/com/example/ --type=javaLength of output: 4747 Remove unused Verification confirms that the codebase contains zero imports or usage of 🤖 Prompt for AI Agents |
||
| requires io.github.cdimascio.dotenv.java; | ||
| requires java.net.http; | ||
| requires tools.jackson.databind; | ||
| requires javafx.graphics; | ||
|
|
||
| opens com.example to javafx.fxml; | ||
| exports com.example; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,20 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <?import javafx.scene.layout.StackPane?> | ||
| <?import javafx.scene.control.Label?> | ||
|
|
||
| <StackPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.example.HelloController"> | ||
| <children> | ||
| <Label fx:id="messageLabel" text="Hello, JavaFX!" /> | ||
| </children> | ||
| </StackPane> | ||
| <?import javafx.scene.control.*?> | ||
| <?import javafx.scene.layout.*?> | ||
|
|
||
| <AnchorPane prefHeight="576.0" prefWidth="435.0" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.HelloController"> | ||
| <VBox prefHeight="576.0" prefWidth="435.0" spacing="10" AnchorPane.bottomAnchor="0.0"> | ||
| <ListView fx:id="messageList" prefHeight="510.0" prefWidth="435.0" /> | ||
| <HBox spacing="10"> | ||
| <VBox prefWidth="300.0"> | ||
| <TextField fx:id="inputField" promptText="Type here" /> | ||
| <Label fx:id="fileLabel" prefHeight="18.0" prefWidth="301.0" text="No file selected" /> | ||
| </VBox> | ||
| <VBox prefHeight="51.0" prefWidth="78.0"> | ||
| <Button onAction="#sendMessage" text="Send" /> | ||
| <Button onAction="#attachFile" text="Attach File" /> | ||
| </VBox> | ||
| </HBox> | ||
| </VBox> | ||
| </AnchorPane> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /*.chatpan{*/ | ||
| /* -fx-background-color: #AD1A4D;*/ | ||
| /*}*/ | ||
|
|
||
| /*.chat-box{*/ | ||
| /* -fx-background-color: #BA2200;*/ | ||
| /* -fx-min-height: 400px;*/ | ||
| /* -fx-min-width: 200px;*/ | ||
| /*}*/ | ||
|
|
||
| /*.label{*/ | ||
| /* -fx-background-color: #FC7400;*/ | ||
| /* -fx-text-fill: white;*/ | ||
| /* -fx-pref-height: 20px;*/ | ||
| /* -fx-pref-width: 200px;*/ | ||
| /*}*/ | ||
|
|
||
| /*.button{*/ | ||
| /* -fx-background-color: #FC7400;*/ | ||
| /* -fx-text-fill: white;*/ | ||
| /* !*-fx-pref-height: 25px;*/ | ||
| /* -fx-pref-width: 50px;*/ | ||
| /* !*-fx-translate-x: 75;*/ | ||
| /* -fx-translate-y: 410;*!*/ | ||
| /*}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Critical: Incorrect Jackson dependency groupId.
The groupId
tools.jackson.coreis non-standard. The Jackson library usescom.fasterxml.jackson.coreas its groupId. SinceNtfyMessageDto.javaimportscom.fasterxml.jackson.annotation.JsonIgnoreProperties, this dependency mismatch will cause aClassNotFoundExceptionat runtime.Apply this diff to use the correct Jackson dependency:
Verify the latest stable version:
🌐 Web query:
💡 Result:
The latest stable version of com.fasterxml.jackson.core:jackson-databind is 2.20.1 (released Oct 31, 2025). [1][2]
Sources:
[1] mvnrepository.com — jackson-databind 2.20.1.
[2] FasterXML Jackson release notes (2.20) — patch 2.20.1.
Critical: Incorrect Jackson dependency groupId and outdated version.
The groupId
tools.jackson.coreis non-standard and does not exist in Maven repositories. The correct groupId iscom.fasterxml.jackson.core. SinceNtfyMessageDto.javaimportscom.fasterxml.jackson.annotation.JsonIgnorePropertiesfrom the standard Jackson library, this dependency mismatch will cause aClassNotFoundExceptionat runtime. Additionally, update to the latest stable version.Apply this diff:
The latest stable version of com.fasterxml.jackson.core:jackson-databind is 2.20.1 (released October 31, 2025).
📝 Committable suggestion
🤖 Prompt for AI Agents