Compare commits
	
		
			4 Commits
		
	
	
		
			645b1f2414
			...
			392d10c587
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 392d10c587 | |||
| 430b89bdda | |||
| 2a7f9813a1 | |||
| 553edc8b6c | 
| @@ -48,7 +48,7 @@ public class AboutController { | ||||
|         try { | ||||
|             properties.load(getClass().getClassLoader().getResourceAsStream("git.properties")); | ||||
|         } catch (IOException e) { | ||||
|             logger.log(Level.SEVERE, "Failed to load main view", e); | ||||
|             logger.log(Level.SEVERE, "Failed to load git information", e); | ||||
|         } | ||||
|         versionTextField.setText(String.valueOf(properties.get("git.commit.id.full"))); | ||||
|  | ||||
|   | ||||
| @@ -13,9 +13,7 @@ public class HelpController { | ||||
|  | ||||
|     @FXML | ||||
|     public void initialize() throws Exception { | ||||
|         logger.info("20250407T222451"); | ||||
|         String url = HelpController.class.getResource("/help-index.html").toExternalForm(); | ||||
|         webView.getEngine().load(url); | ||||
|         logger.info("20250407T222456"); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -36,6 +36,7 @@ import java.util.logging.FileHandler; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.logging.Level; | ||||
| import java.util.Optional; | ||||
| import java.util.Properties; | ||||
| import javafx.application.Application; | ||||
| import javafx.application.Platform; | ||||
| import javafx.fxml.FXMLLoader; | ||||
| @@ -50,8 +51,6 @@ public class Main extends Application { | ||||
|     public record StartParameters (Optional<NotificationController.NotificationParameters> notification) {} | ||||
|  | ||||
|     private static final Logger logger = Logger.getLogger(Main.class.getName()); | ||||
|     // TODO: get git info | ||||
|     private static final String VERSION = "0.0.1"; | ||||
|     private static Path configPath = null; | ||||
|     private static Path statePath = null; | ||||
|  | ||||
| @@ -130,6 +129,14 @@ public class Main extends Application { | ||||
|                 primaryStage.titleProperty().bindBidirectional(controller.windowTitle); | ||||
|                 primaryStage.show(); | ||||
|                 logger.info("Application started"); | ||||
|  | ||||
|                 Properties properties = new Properties(); | ||||
|                 try { | ||||
|                     properties.load(getClass().getClassLoader().getResourceAsStream("git.properties")); | ||||
|                     logger.info("Application version: " + String.valueOf(properties.get("git.commit.id.full"))); | ||||
|                 } catch (IOException e) { | ||||
|                     logger.log(Level.SEVERE, "Failed to load git information", e); | ||||
|                 } | ||||
|             } | ||||
|         } catch (IOException e) { | ||||
|             logger.log(Level.SEVERE, "Failed to load main view", e); | ||||
| @@ -167,7 +174,13 @@ public class Main extends Application { | ||||
|         } | ||||
|  | ||||
|         if (parsedArgs.getVersionFlag()) { | ||||
|             System.out.println("Numbers Station version " + VERSION); | ||||
|             Properties properties = new Properties(); | ||||
|             try { | ||||
|                 properties.load(Main.class.getClassLoader().getResourceAsStream("git.properties")); | ||||
|                 System.out.println(String.valueOf(properties.get("git.commit.id.full"))); | ||||
|             } catch (IOException e) { | ||||
|                 System.out.println("Failed to get git information"); | ||||
|             } | ||||
|             System.exit(0); | ||||
|         } | ||||
|  | ||||
| @@ -270,8 +283,8 @@ public class Main extends Application { | ||||
|             switch (loadedStation.getMessageMethod()) { | ||||
|                 case StationSettings.MessageMethod.EXTERNAL_PROGRAM: | ||||
|                     Process process = new ProcessBuilder(loadedStation.getExternalProgramCommand(), nextMessagePath.toString()).start(); | ||||
|                     // TODO: make timeout a setting | ||||
|                     if (!process.waitFor(5, TimeUnit.SECONDS)) { | ||||
|  | ||||
|                     if (!process.waitFor(loadedStation.getExternalProgramTimeout().getSeconds(), TimeUnit.SECONDS)) { | ||||
|                         throw new StationRunException("Timeout while running external program " + loadedStation.getExternalProgramCommand()); | ||||
|                     } | ||||
|  | ||||
|   | ||||
| @@ -100,6 +100,7 @@ public class MainSettings { | ||||
|         XmlMapper xmlMapper = new XmlMapper(); | ||||
|         xmlMapper.registerModule(new JavaTimeModule()); | ||||
|         xmlMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); | ||||
|         xmlMapper.configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false); | ||||
|         xmlMapper.enable(SerializationFeature.INDENT_OUTPUT); | ||||
|         try { | ||||
|             Path filePath = getSettingsFilePath(); | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import java.nio.file.Path; | ||||
| import java.nio.file.Paths; | ||||
| import java.nio.file.SimpleFileVisitor; | ||||
| import java.security.SecureRandom; | ||||
| import java.time.Duration; | ||||
| import java.time.LocalDate; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.ZonedDateTime; | ||||
| @@ -27,6 +28,7 @@ public class StationSettings { | ||||
|     private String address; | ||||
|     private int digitsPerGroup; | ||||
|     private String externalProgramCommand; | ||||
|     private Duration externalProgramTimeout; | ||||
|     private boolean manageScheduleExternally; | ||||
|     private int messageLength; | ||||
|     private MessageMethod messageMethod; | ||||
| @@ -53,6 +55,7 @@ public class StationSettings { | ||||
|         prefixes = new ArrayList<String>(); | ||||
|         digitsPerGroup = 4; | ||||
|         messageLength = 100; | ||||
|         externalProgramTimeout = Duration.ofSeconds(5); | ||||
|         messageMethod = MessageMethod.SFTP; | ||||
|         messagePeriod = MessagePeriod.DAILY; | ||||
|         scheduleStart = ZonedDateTime.now(); | ||||
| @@ -62,6 +65,7 @@ public class StationSettings { | ||||
|         name = newName; | ||||
|         prefixes = new ArrayList<String>(); | ||||
|         digitsPerGroup = 4; | ||||
|         externalProgramTimeout = Duration.ofSeconds(5); | ||||
|         messageLength = 100; | ||||
|         messageMethod = MessageMethod.SFTP; | ||||
|         messagePeriod = MessagePeriod.DAILY; | ||||
| @@ -250,6 +254,14 @@ public class StationSettings { | ||||
|         externalProgramCommand = newExternalProgramCommand; | ||||
|     } | ||||
|  | ||||
|     public Duration getExternalProgramTimeout() { | ||||
|         return externalProgramTimeout; | ||||
|     } | ||||
|  | ||||
|     public void setExternalProgramTimeout(Duration newExternalProgramTimeout) { | ||||
|         externalProgramTimeout = newExternalProgramTimeout; | ||||
|     } | ||||
|  | ||||
|     public boolean getManageScheduleExternally() { | ||||
|         return manageScheduleExternally; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user