-
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.
- Loading branch information
Showing
11 changed files
with
361 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/resources" type="java-resource" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
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,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: de.gs_sys.gui.jfx.FXstarter | ||
|
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,51 @@ | ||
/* | ||
Copyright (C) 2017, 2018 Georg Schmidt <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.gs_sys.gui.jfx; | ||
|
||
import javafx.application.Application; | ||
import javafx.event.EventHandler; | ||
import javafx.stage.Stage; | ||
import javafx.stage.WindowEvent; | ||
|
||
public class AppFX extends Application { | ||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
|
||
@Override | ||
public void start(Stage stage) throws Exception { | ||
// ignores the given stage ! | ||
|
||
/* create and setup main stage */ | ||
Stage mainStage = StageCreator.getStageFromFXML("Password Gen","gui.fxml"); | ||
|
||
/* Load hotkeys */ | ||
ControllerMain.loadHotkeys(mainStage); | ||
|
||
// Close App on X (Needs to be AFTER addStage() to overwrite default close) | ||
mainStage.setOnCloseRequest(new EventHandler<WindowEvent>() { | ||
@Override | ||
public void handle(WindowEvent event) { | ||
System.exit(0); | ||
} | ||
}); | ||
|
||
// No resize | ||
mainStage.setResizable(false); | ||
} | ||
} |
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,101 @@ | ||
/* | ||
Copyright (C) 2017, 2018 Georg Schmidt <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.gs_sys.gui.jfx; | ||
|
||
import de.gs_sys.lib.crypto.passwords.PasswordStrength; | ||
import javafx.application.Platform; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextField; | ||
import javafx.stage.Stage; | ||
; | ||
import java.net.URL; | ||
|
||
import java.util.ResourceBundle; | ||
|
||
|
||
public class ControllerMain implements Initializable { | ||
|
||
|
||
private final String versionString = "V 0.2 fx"; | ||
|
||
private static ControllerMain instance; | ||
|
||
@FXML | ||
private TextField password_field; | ||
|
||
@FXML | ||
private Button b_version; | ||
|
||
@FXML | ||
private Label passwordQuality; | ||
|
||
@FXML | ||
private Button button_check; | ||
|
||
@FXML | ||
void onButtonVersion() { | ||
password_field.setText("Copyright (c) 2018 Georg Schmidt"); | ||
} | ||
|
||
@FXML | ||
private void onCheck() { | ||
|
||
setQuality(password_field.getText()); | ||
} | ||
|
||
private void setQuality(String password) { | ||
passwordQuality.setText("Corresponds to " + PasswordStrength.complexity(password).getBit() + " bit."); | ||
} | ||
|
||
@Override | ||
public void initialize(URL location, ResourceBundle resources) { | ||
instance = this; | ||
|
||
// disables most console output | ||
PasswordStrength.setCli(false); | ||
|
||
b_version.setText(versionString); | ||
|
||
password_field.textProperty().addListener((obs, oldValue, newValue) -> onCheck()); | ||
|
||
// Default in button | ||
Platform.runLater(() -> button_check.requestFocus()); | ||
} | ||
|
||
/** | ||
* Registers the hotkeys | ||
*/ | ||
public static void loadHotkeys(Stage stage) | ||
{ | ||
stage.getScene().setOnKeyReleased(keyEvent1 -> { | ||
switch (keyEvent1.getCode()) | ||
{ | ||
case ESCAPE: | ||
System.exit(0); | ||
break; | ||
case ENTER: | ||
instance.onCheck(); | ||
break; | ||
default: | ||
} | ||
}); | ||
} | ||
} |
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,41 @@ | ||
/* | ||
Copyright (C) 2017, 2018 Georg Schmidt <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.gs_sys.gui.jfx; | ||
|
||
|
||
import de.gs_sys.lib.crypto.passwords.PasswordStrength; | ||
|
||
public class FXstarter { | ||
public static void main(String[] args) { | ||
|
||
// force old version | ||
if(args.length == 1 && args[0].equals("-old")) | ||
{ | ||
System.err.println("Needs to support JavaFX8!"); | ||
PasswordStrength.main(args); | ||
} | ||
|
||
try { | ||
FXstarter.class.getClassLoader().loadClass("javafx.application.Application"); | ||
AppFX.main(args); | ||
} catch (ClassNotFoundException e) { | ||
System.err.println("Needs to support JavaFX8!"); | ||
PasswordStrength.main(args); | ||
} | ||
} | ||
} |
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,66 @@ | ||
/* | ||
Copyright (C) 2017, 2018 Georg Schmidt <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.gs_sys.gui.jfx; | ||
|
||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Scene; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.stage.Stage; | ||
import javafx.stage.StageStyle; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Creates JavaFX sage from a fxml file | ||
*/ | ||
public class StageCreator { | ||
|
||
/** | ||
* Opens a .fxml file and returns a stage using this file and the given title | ||
* @param title Title of the window | ||
* @param file .fxml file with the window configuration | ||
* @return stage out of the fxml file | ||
*/ | ||
@SuppressWarnings("ConstantConditions") | ||
public static Stage getStageFromFXML(String title, String file) | ||
{ | ||
if(file == null || file.isEmpty()) | ||
return null; | ||
|
||
// create new stage | ||
Stage newStage = new Stage(StageStyle.DECORATED); // normal window | ||
|
||
// set title if exist | ||
if(title != null && !title.isEmpty()) | ||
newStage.setTitle(title); | ||
|
||
try { | ||
// create new scene | ||
BorderPane root = FXMLLoader.load(StageCreator.class.getClassLoader().getResource(file)); | ||
Scene scene = new Scene(root); | ||
|
||
/* final stage setup */ | ||
newStage.setScene(scene); | ||
newStage.show(); | ||
return newStage; | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
} |
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,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.layout.AnchorPane?> | ||
<?import javafx.scene.layout.BorderPane?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.text.Font?> | ||
|
||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="131.0" prefWidth="321.0" xmlns="http://javafx.com/javafx/8.0.161-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.gs_sys.gui.jfx.ControllerMain"> | ||
<center> | ||
<VBox prefHeight="108.0" prefWidth="321.0" BorderPane.alignment="CENTER"> | ||
<children> | ||
<TextField fx:id="password_field" alignment="CENTER"> | ||
<VBox.margin> | ||
<Insets bottom="5.0" left="10.0" right="10.0" top="10.0" /> | ||
</VBox.margin> | ||
<font> | ||
<Font size="18.0" /> | ||
</font> | ||
</TextField> | ||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0"> | ||
<children> | ||
<Button fx:id="button_check" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#onCheck" text="Check"> | ||
<HBox.margin> | ||
<Insets bottom="5.0" right="10.0" top="5.0" /> | ||
</HBox.margin> | ||
</Button> | ||
</children> | ||
</HBox> | ||
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0"> | ||
<children> | ||
<Button fx:id="b_version" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#onButtonVersion" prefWidth="80.0" text="V xx fx"> | ||
<HBox.margin> | ||
<Insets left="10.0" /> | ||
</HBox.margin> | ||
<font> | ||
<Font size="12.0" /> | ||
</font> | ||
</Button> | ||
<Label fx:id="passwordQuality" alignment="CENTER" contentDisplay="CENTER" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="200.0" text="QUALITY" textAlignment="CENTER"> | ||
<HBox.margin> | ||
<Insets left="10.0" /> | ||
</HBox.margin> | ||
</Label> | ||
<AnchorPane prefHeight="200.0" prefWidth="200.0" /> | ||
</children> | ||
</HBox> | ||
</children> | ||
</VBox> | ||
</center> | ||
</BorderPane> |