1616
1717package de .doubleslash .keeptime .view ;
1818
19+ import java .util .Comparator ;
20+
1921import org .slf4j .Logger ;
2022import org .slf4j .LoggerFactory ;
2123
2224import de .doubleslash .keeptime .Main ;
2325import de .doubleslash .keeptime .common .BrowserHelper ;
2426import de .doubleslash .keeptime .common .FileOpenHelper ;
2527import de .doubleslash .keeptime .common .Licenses ;
26- import de .doubleslash .keeptime .view .license .LicenceTableRow ;
28+ import de .doubleslash .keeptime .view .license .LicenseTableRow ;
2729import javafx .collections .FXCollections ;
2830import javafx .collections .ObservableList ;
2931import javafx .fxml .FXML ;
@@ -58,7 +60,7 @@ public class AboutController {
5860 private Hyperlink ourLicenseHyperLink ;
5961
6062 @ FXML
61- private TableView <LicenceTableRow > licenseTableView ;
63+ private TableView <LicenseTableRow > licenseTableView ;
6264
6365 private static final Logger LOG = LoggerFactory .getLogger (AboutController .class );
6466
@@ -68,20 +70,20 @@ public void initialize() {
6870 versionNumberLabel .setText (Main .VERSION );
6971
7072 ourLicenseHyperLink .setFocusTraversable (false );
71- ourLicenseHyperLink .setOnAction (ae -> FileOpenHelper . openFile (Licenses .GPLV3 . getPath () ));
73+ ourLicenseHyperLink .setOnAction (ae -> showLicense (Licenses .GPLV3 ));
7274
7375 LOG .debug ("set up table" );
7476 // name column
75- TableColumn <LicenceTableRow , String > nameColumn ;
77+ TableColumn <LicenseTableRow , String > nameColumn ;
7678 nameColumn = new TableColumn <>("Name" );
7779 nameColumn .setMinWidth (160 );
7880
7981 nameColumn .setCellValueFactory (new PropertyValueFactory <>("name" ));
8082
8183 // licenseColumn
82- final TableColumn <LicenceTableRow , String > licenseColumn = new TableColumn <>("License" );
84+ final TableColumn <LicenseTableRow , String > licenseColumn = new TableColumn <>("License" );
8385 licenseColumn .setMinWidth (260 );
84- licenseColumn .setCellFactory (param -> new TableCell <LicenceTableRow , String >() {
86+ licenseColumn .setCellFactory (param -> new TableCell <LicenseTableRow , String >() {
8587 @ Override
8688 protected void updateItem (final String item , final boolean empty ) {
8789 super .updateItem (item , empty );
@@ -95,27 +97,19 @@ protected void updateItem(final String item, final boolean empty) {
9597
9698 setOnMouseClicked (eventOnMouseClicked -> {
9799 if (!empty && eventOnMouseClicked .getButton () == MouseButton .PRIMARY ) {
98- final LicenceTableRow row = (LicenceTableRow ) getTableRow ().getItem ();
100+ final LicenseTableRow row = (LicenseTableRow ) getTableRow ().getItem ();
99101 final Licenses license = row .getLicense ();
100102 LOG .debug ("License file name: {}" , license );
101103
102- if (!FileOpenHelper .openFile (license .getPath ())) {
103- final Alert alert = new Alert (AlertType .ERROR );
104- alert .setTitle ("Ooops" );
105- alert .setHeaderText ("Could not find the license file" );
106- alert .setContentText (
107- String .format ("We could not find the license file at \" %s\" .%nPlease visit \" %s\" ." ,
108- license .getPath (), license .getUrl ()));
109-
110- alert .show ();
111- }
104+ showLicense (license );
112105 }
113106 });
114107 }
108+
115109 });
116110 licenseColumn .setCellValueFactory (new PropertyValueFactory <>("licenseName" ));
117111
118- final ObservableList <LicenceTableRow > licenses = loadRows ();
112+ final ObservableList <LicenseTableRow > licenses = loadLicenseRows ();
119113
120114 licenseTableView .setItems (licenses );
121115
@@ -135,17 +129,31 @@ protected void updateItem(final String item, final boolean empty) {
135129 });
136130 }
137131
138- public ObservableList <LicenceTableRow > loadRows () {
139- final ObservableList <LicenceTableRow > rows = FXCollections .observableArrayList ();
140- rows .add (new LicenceTableRow ("jnativehook" , Licenses .GPLV3 ));
141- rows .add (new LicenceTableRow ("jnativehook" , Licenses .LGPLV3 ));
142- rows .add (new LicenceTableRow ("commons-lang3" , Licenses .APACHEV2 ));
143- rows .add (new LicenceTableRow ("flyway-maven-plugin" , Licenses .APACHEV2 ));
144- rows .add (new LicenceTableRow ("spring-boot-starter-data-jpa" , Licenses .APACHEV2 ));
145- rows .add (new LicenceTableRow ("mockito-core" , Licenses .MIT ));
146- rows .add (new LicenceTableRow ("h2" , Licenses .EPLV1 ));
147-
148- return rows ;
132+ public ObservableList <LicenseTableRow > loadLicenseRows () {
133+ final ObservableList <LicenseTableRow > licenseRows = FXCollections .observableArrayList ();
134+ licenseRows .add (new LicenseTableRow ("Open Sans" , Licenses .APACHEV2 ));
135+ licenseRows .add (new LicenseTableRow ("jnativehook" , Licenses .GPLV3 ));
136+ licenseRows .add (new LicenseTableRow ("jnativehook" , Licenses .LGPLV3 ));
137+ licenseRows .add (new LicenseTableRow ("commons-lang3" , Licenses .APACHEV2 ));
138+ licenseRows .add (new LicenseTableRow ("flyway-maven-plugin" , Licenses .APACHEV2 ));
139+ licenseRows .add (new LicenseTableRow ("spring-boot-starter-data-jpa" , Licenses .APACHEV2 ));
140+ licenseRows .add (new LicenseTableRow ("mockito-core" , Licenses .MIT ));
141+ licenseRows .add (new LicenseTableRow ("h2" , Licenses .EPLV1 ));
142+
143+ licenseRows .sort (Comparator .comparing (LicenseTableRow ::getName ));
144+
145+ return licenseRows ;
149146 }
150147
148+ private void showLicense (final Licenses license ) {
149+ if (!FileOpenHelper .openFile (license .getPath ())) {
150+ final Alert alert = new Alert (AlertType .ERROR );
151+ alert .setTitle ("Ooops" );
152+ alert .setHeaderText ("Could not find the license file" );
153+ alert .setContentText (String .format ("We could not find the license file at \" %s\" .%nPlease visit \" %s\" ." ,
154+ license .getPath (), license .getUrl ()));
155+
156+ alert .show ();
157+ }
158+ }
151159}
0 commit comments