-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Team846/apBranch
Merging 2024 offseason work New features: - Automatically saves log files - Dialog to open files - Error messages popup
- Loading branch information
Showing
14 changed files
with
310 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
target | ||
target/classes/com/funkylogclient/Message.class | ||
pom.xml | ||
|
||
logs846 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.funkylogclient; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.util.LinkedList; | ||
import java.util.Scanner; | ||
|
||
import javafx.stage.Stage; | ||
import javafx.stage.FileChooser; | ||
|
||
public class LogFileProcesser { | ||
|
||
private static Scanner input; | ||
private static File file; | ||
|
||
public static void selectFile(Stage stage) { | ||
try { | ||
FileChooser fileChooser = new FileChooser(); | ||
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("FunkyLogs File", "*.log846"); | ||
fileChooser.getExtensionFilters().add(extFilter); | ||
fileChooser.setTitle("Open Log File"); | ||
|
||
fileChooser.setInitialDirectory(new File(FunkyLogSorter.getLogFileDirectory())); | ||
|
||
file = fileChooser.showOpenDialog(stage); | ||
readFile(file, stage); | ||
} catch (Exception e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
|
||
} | ||
|
||
public void setFile(String pathname) { | ||
file = new File(pathname); | ||
} | ||
|
||
public File getFile() { | ||
if (file != null) | ||
System.out.println(file.getAbsolutePath()); | ||
return file; | ||
} | ||
|
||
public static void readFile(File file, Stage primaryStage) { | ||
try { | ||
input = new Scanner(file); | ||
} catch (FileNotFoundException ex) { | ||
System.out.println("File not found"); | ||
System.exit(1); | ||
} | ||
LinkedList<Message> messages = new LinkedList<Message>(); | ||
while (input.hasNextLine()) { | ||
Message log = new Message(input.nextLine()); | ||
if (log.getValid()) { | ||
messages.add(log); | ||
} | ||
} | ||
SavedFunkyLogs.displaySavedLogs(messages, primaryStage, file.getName()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.