Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/openconsignment/common/Constants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package openconsignment.common;

public class Constants {
public static final String ORGANIZATION_NAME = "SATYAM AGENCIES";
public static final String REPORT_FILE_NAME = "report.pdf";
public static final String DATE_TIME_FORMAT = "dd-MM-yyyy";
public static final String DATABASE_FILE_NAME = "database.db";
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/openconsignment/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
Expand Down Expand Up @@ -67,6 +69,20 @@ public static void launchPdf(String filename) throws IOException {
});
}

public static void launchBrowser(String url) throws IOException {
if (!Desktop.isDesktopSupported()) {
throw new IOException("Desktop is not supported on this platform.");
}

CompletableFuture.runAsync(() -> {
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException | URISyntaxException e) {
logger.log(Level.WARNING, "Error opening browser link " + url, e);
}
});
}

public static String formatDate(String dateString) {
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern(Constants.DATE_TIME_FORMAT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package openconsignment.controller;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Hyperlink;
import javafx.scene.text.Text;
import openconsignment.common.Constants;
import openconsignment.common.Utils;

/**
* FXML Controller class
*
* @author ADMIN
*/
public class WelcomeScreenController implements Initializable {

/** Initializes the controller class. */
@FXML
private Text organization_name;

@FXML
private void handleOpenGithub(ActionEvent event) {
Hyperlink link = (Hyperlink) event.getSource();
String url = link.getText();

try {
Utils.launchBrowser(url);
} catch (IOException ex) {
Utils.showAlert(ex.toString());
Logger.getLogger(WelcomeScreenController.class.getName()).log(Level.SEVERE, ex.toString(), ex);
}
}

@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
organization_name.setText(Constants.ORGANIZATION_NAME);
}
}
13 changes: 6 additions & 7 deletions src/main/resources/fxml/WelcomeScreen.fxml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.*?>
<?import javafx.scene.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>

<?import javafx.scene.control.Hyperlink?>
<Group xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="openconsignment.controller.WelcomeScreenController">
<children>
<AnchorPane id="AnchorPane" prefHeight="490.0" prefWidth="757.0">
<stylesheets>
<URL value="@welcomescreen.css" />
</stylesheets>
<children>
<Rectangle arcHeight="50.0" arcWidth="50.0" height="469.0" layoutX="19.0" layoutY="19.0" stroke="#36016b" strokeLineCap="ROUND" strokeLineJoin="ROUND" strokeType="OUTSIDE" strokeWidth="20.0" width="739.0">
<fill>
Expand All @@ -26,7 +23,7 @@
</LinearGradient>
</fill>
</Rectangle>
<Text layoutX="60.0" layoutY="88.0" strokeType="OUTSIDE" strokeWidth="0.0" text="OpenConsignment" textAlignment="CENTER" wrappingWidth="658.658203125">
<Text fx:id="organization_name" layoutX="60.0" layoutY="88.0" strokeType="OUTSIDE" strokeWidth="0.0" text="ORGANIZATION NAME" textAlignment="CENTER" wrappingWidth="658.658203125">
<font>
<Font name="System Bold Italic" size="40.0" />
</font>
Expand All @@ -44,11 +41,13 @@
<Image url="@../icons/transparent_logo.png" />
</image>
</ImageView>
<Text layoutX="182.0" layoutY="423.0" strokeType="OUTSIDE" strokeWidth="0.0" text="https://github.com/Razdeep/OpenConsignment" textAlignment="CENTER" wrappingWidth="414.658203125">
<Hyperlink layoutX="182.0" layoutY="405.0" prefWidth="400.0"
text="https://github.com/Razdeep/OpenConsignment"
textAlignment="CENTER" onAction="#handleOpenGithub">
<font>
<Font size="17.0" />
</font>
</Text>
</Hyperlink>
</children>
</AnchorPane>
</children>
Expand Down
12 changes: 0 additions & 12 deletions src/main/resources/fxml/welcomescreen.css

This file was deleted.

Loading