util

Clone or download

Merge pull request #1 from abhinayagarwal/changes

Miscellaneous changes

Modified Files

--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,27 @@
+name: Build
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - name: Setup Java 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+
+ - name: Verify project
+ run: mvn clean verify
+
+# TODO: Deploy Snapshots
M .gitignore
+5 −2
--- 'a/.gitignore'
+++ b/.gitignore
@@ -1,8 +1,11 @@
-.idea/
+# Maven
target/
-Util.iml
+# IntelliJ IDEA
+.idea/
+*.iml
+# Eclipse
.settings/
.project
.factorypath
M pom.xml
+29 −44
--- 'a/pom.xml'
+++ b/pom.xml
@@ -4,12 +4,39 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>com.stream_pi</groupId>
+ <groupId>com.stream-pi</groupId>
<artifactId>util</artifactId>
- <version>1.0.0</version>
+ <version>1.0.0-SNAPSHOT</version>
<url>https://stream-pi.com/</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.release>11</maven.compiler.release>
+
+ <javafx.version>16-ea+6</javafx.version>
+ <ikonli.version>11.5.0</ikonli.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openjfx</groupId>
+ <artifactId>javafx-controls</artifactId>
+ <version>${javafx.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.kordamp.ikonli</groupId>
+ <artifactId>ikonli-javafx</artifactId>
+ <version>${ikonli.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.kordamp.ikonli</groupId>
+ <artifactId>ikonli-fontawesome5-pack</artifactId>
+ <version>${ikonli.version}</version>
+ </dependency>
+ </dependencies>
+
<build>
<plugins>
<plugin>
@@ -31,49 +58,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
- <configuration>
- <release>11</release>
- </configuration>
</plugin>
</plugins>
</build>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>11</maven.compiler.source>
- <maven.compiler.target>11</maven.compiler.target>
-
- <IkonliVersion>11.5.0</IkonliVersion>
- <IkonliFA5PackVersion>11.5.0</IkonliFA5PackVersion>
-
- <JavaFXVersion>16-ea+6</JavaFXVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.kordamp.ikonli</groupId>
- <artifactId>ikonli-fontawesome5-pack</artifactId>
- <version>${IkonliFA5PackVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.openjfx</groupId>
- <artifactId>javafx-controls</artifactId>
- <version>${JavaFXVersion}</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.openjfx</groupId>
- <artifactId>javafx-base</artifactId>
- <version>${JavaFXVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.kordamp.ikonli</groupId>
- <artifactId>ikonli-javafx</artifactId>
- <version>${IkonliVersion}</version>
- </dependency>
- </dependencies>
-
</project>
\ No newline at end of file
--- 'a/src/main/java/com/stream_pi/util/alert/StreamPiAlert.java'
+++ b/src/main/java/com/stream_pi/util/alert/StreamPiAlert.java
@@ -52,9 +52,7 @@ public class StreamPiAlert
public static void setParent(StackPane parent)
{
stackPaneParent = parent;
-
stackPaneParent.getStyleClass().add("alert_pane_parent");
-
stackPaneParent.getChildren().addListener((ListChangeListener<Node>) c ->
{
if(stackPaneParent.getChildren().size() > 0)
@@ -157,9 +155,7 @@ public class StreamPiAlert
{
Label label = new Label(contentText);
label.setWrapText(true);
-
VBox vBox = new VBox(label);
-
set(title, streamPiAlertType, vBox, "OK");
}
@@ -238,7 +234,7 @@ public class StreamPiAlert
FontIcon fontIcon = new FontIcon(streamPiAlertType.getIconCode());
fontIcon.getStyleClass().addAll("alert_header_icon", streamPiAlertType.getIconStyleClassName());
- HBox header = new HBox(label, new SpaceFiller(SpaceFiller.FillerType.HBox), fontIcon);
+ HBox header = new HBox(label, SpaceFiller.horizontal(), fontIcon);
header.getStyleClass().add("alert_header");
@@ -252,32 +248,28 @@ public class StreamPiAlert
Button button = new Button(eachButtonString);
button.setOnAction(event -> {
if(this.streamPiAlertListener != null)
+ {
this.streamPiAlertListener.onClick(eachButtonString);
-
+ }
destroy();
});
button.getStyleClass().add("alert_button");
-
buttonBar.getChildren().add(button);
}
- contentPane.getStyleClass().add("alert_content_pane");
-
ScrollPane scrollPane = new ScrollPane(contentPane);
scrollPane.prefHeightProperty().bind(contentPane.heightProperty().add(20));
scrollPane.getStyleClass().add("alert_scroll_pane");
-
- contentPane.prefWidthProperty().bind(scrollPane.widthProperty().subtract(10));
-
scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
-
VBox.setVgrow(scrollPane, Priority.ALWAYS);
+ contentPane.getStyleClass().add("alert_content_pane");
+ contentPane.prefWidthProperty().bind(scrollPane.widthProperty().subtract(10));
+
VBox alertVBox = new VBox( header, scrollPane, buttonBar);
alertVBox.getStyleClass().add("alert_pane");
-
alertVBox.setMaxHeight(Double.NEGATIVE_INFINITY);
return alertVBox;
--- 'a/src/main/java/com/stream_pi/util/combobox/StreamPiComboBox.java'
+++ b/src/main/java/com/stream_pi/util/combobox/StreamPiComboBox.java
@@ -41,7 +41,6 @@ import javafx.scene.layout.VBox;
public class StreamPiComboBox<T> extends HBox
{
private List<T> options;
-
private static StackPane stackPaneParent;
/**
@@ -50,9 +49,7 @@ public class StreamPiComboBox<T> extends
*/
public static void setParent(StackPane parent) {
stackPaneParent = parent;
-
stackPaneParent.getStyleClass().add("combo_box_pane_parent");
-
stackPaneParent.getChildren().addListener((ListChangeListener<Node>) c ->
{
if(stackPaneParent.getChildren().size() > 0)
@@ -75,7 +72,6 @@ public class StreamPiComboBox<T> extends
public StreamPiComboBox(List<T> options)
{
setup();
-
setOptions(options);
}
@@ -105,7 +101,7 @@ public class StreamPiComboBox<T> extends
buttons = new ArrayList<>();
getStyleClass().add("combo_box");
- setOnMouseClicked(event->show());
+ setOnMouseClicked(event -> show());
currentSelectedLabel = new Label();
currentSelectedLabel.getStyleClass().add("combo_box_current_selected_label");
@@ -115,7 +111,7 @@ public class StreamPiComboBox<T> extends
getChildren().addAll(
currentSelectedLabel,
- new SpaceFiller(SpaceFiller.FillerType.HBox),
+ SpaceFiller.horizontal(),
fontIcon
);
}
@@ -202,7 +198,6 @@ public class StreamPiComboBox<T> extends
public void setCurrentSelectedItemIndex(int index)
{
this.currentIndex = index;
-
setCurrentSelectedLabelText(streamPiComboBoxFactory.getOptionDisplayText(options.get(index)));
}
--- 'a/src/main/java/com/stream_pi/util/exception/SevereException.java'
+++ b/src/main/java/com/stream_pi/util/exception/SevereException.java
@@ -16,7 +16,8 @@ Originally Written by : Debayan Sutradha
package com.stream_pi.util.exception;
-public class SevereException extends StreamPiException{
+public class SevereException extends StreamPiException {
+
public SevereException(String message)
{
super(message);
--- 'a/src/main/java/com/stream_pi/util/exception/StreamPiException.java'
+++ b/src/main/java/com/stream_pi/util/exception/StreamPiException.java
@@ -17,10 +17,10 @@ Originally Written by : Debayan Sutradha
package com.stream_pi.util.exception;
public class StreamPiException extends Exception {
+
private String title;
private String message;
-
public StreamPiException(String message)
{
super(message);
--- 'a/src/main/java/com/stream_pi/util/iohelper/IOHelper.java'
+++ b/src/main/java/com/stream_pi/util/iohelper/IOHelper.java
@@ -23,7 +23,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class IOHelper {
- public static void unzip(InputStream inputStream, String destDir) throws Exception{
+
+ public static void unzip(InputStream inputStream, String destDir) throws Exception {
File dir = new File(destDir);
// create output directory if it doesn't exist
if(!dir.exists()) dir.mkdirs();
@@ -31,7 +32,6 @@ public class IOHelper {
//buffer for read and write data to file
byte[] buffer = new byte[1024];
-
fis = inputStream;
ZipInputStream zis = new ZipInputStream(fis);
ZipEntry ze = zis.getNextEntry();
@@ -48,11 +48,11 @@ public class IOHelper {
{
FileOutputStream fos = new FileOutputStream(newFile);
int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
+ while ((len = zis.read(buffer)) > 0)
+ {
+ fos.write(buffer, 0, len);
}
fos.close();
-
}
//close this ZipEntry
zis.closeEntry();
--- 'a/src/main/java/com/stream_pi/util/loggerhelper/StreamPiLogFallbackHandler.java'
+++ b/src/main/java/com/stream_pi/util/loggerhelper/StreamPiLogFallbackHandler.java
@@ -19,6 +19,7 @@ package com.stream_pi.util.loggerhelper;
import java.util.logging.ConsoleHandler;
public class StreamPiLogFallbackHandler extends ConsoleHandler{
+
public StreamPiLogFallbackHandler() throws Exception
{
super();
--- 'a/src/main/java/com/stream_pi/util/platform/ReleaseStatus.java'
+++ b/src/main/java/com/stream_pi/util/platform/ReleaseStatus.java
@@ -18,7 +18,9 @@ Originally Written by : Debayan Sutradha
package com.stream_pi.util.platform;
public enum ReleaseStatus {
- EA("Early Access"), GA("General Availability");
+
+ EA("Early Access"),
+ GA("General Availability");
private final String UIName;
--- 'a/src/main/java/com/stream_pi/util/uihelper/HBoxInputBox.java'
+++ b/src/main/java/com/stream_pi/util/uihelper/HBoxInputBox.java
@@ -23,15 +23,14 @@ import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
public class HBoxInputBox extends HBox {
+
private TextField textField;
+
public HBoxInputBox(String labelText, TextField textField, int prefWidth, CheckBox enablerCheckBox)
{
textField.setPrefWidth(prefWidth);
-
Label label = new Label(labelText);
-
-
- getChildren().addAll(label, new SpaceFiller(SpaceFiller.FillerType.HBox), textField);
+ getChildren().addAll(label, SpaceFiller.horizontal(), textField);
if(enablerCheckBox != null)
{
@@ -39,7 +38,6 @@ public class HBoxInputBox extends HBox {
HBox.setMargin(enablerCheckBox, new Insets(0, 0, 0, 45));
getChildren().add(enablerCheckBox);
}
-
this.textField = textField;
}
@@ -58,7 +56,6 @@ public class HBoxInputBox extends HBox {
this(labelText, textField, prefWidth, null);
}
-
public TextField getTextField()
{
return textField;
--- 'a/src/main/java/com/stream_pi/util/uihelper/HBoxInputBoxWithFileChooser.java'
+++ b/src/main/java/com/stream_pi/util/uihelper/HBoxInputBoxWithFileChooser.java
@@ -28,6 +28,7 @@ import org.kordamp.ikonli.javafx.FontIco
import java.io.File;
public class HBoxInputBoxWithFileChooser extends HBox {
+
public HBoxInputBoxWithFileChooser(String labelText, TextField textField, CheckBox enablerCheckBox, FileChooser.ExtensionFilter extensionFilter)
{
textField.setDisable(true);
@@ -45,12 +46,10 @@ public class HBoxInputBoxWithFileChooser
button.setOnAction(event -> {
FileChooser fileChooser = new FileChooser();
-
fileChooser.getExtensionFilters().addAll(
extensionFilter
);
-
try {
File selectedDirectory = fileChooser.showOpenDialog(button.getScene().getWindow());
textField.setText(selectedDirectory.getAbsolutePath());
--- 'a/src/main/java/com/stream_pi/util/uihelper/SpaceFiller.java'
+++ b/src/main/java/com/stream_pi/util/uihelper/SpaceFiller.java
@@ -21,22 +21,19 @@ import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
-public class SpaceFiller extends Region {
+public class SpaceFiller {
- public SpaceFiller(FillerType fillerType)
+ public static Region horizontal()
{
- if(fillerType == FillerType.HBox)
- {
- HBox.setHgrow(this, Priority.ALWAYS);
- }
- else if(fillerType == FillerType.VBox)
- {
- VBox.setVgrow(this, Priority.ALWAYS);
- }
+ final Region region = new Region();
+ HBox.setHgrow(region, Priority.ALWAYS);
+ return region;
}
- public enum FillerType
+ public static Region vertical()
{
- HBox, VBox
+ final Region region = new Region();
+ VBox.setVgrow(region, Priority.ALWAYS);
+ return region;
}
}
--- 'a/src/main/java/com/stream_pi/util/version/Version.java'
+++ b/src/main/java/com/stream_pi/util/version/Version.java
@@ -97,24 +97,21 @@ public class Version implements Serializ
public boolean isBiggerThan(Version version)
{
- if(major>version.major)
- return true;
- else if(major < version.major)
- return false;
- else
+ if (major == version.major)
{
- if (minor > version.minor)
- return true;
- else if(minor < version.minor)
- return false;
+ if (minor == version.minor)
+ {
+ return revision > version.revision;
+ }
else
{
- if(revision > version.revision)
- return true;
- else
- return false;
+ return minor > version.minor;
}
}
+ else
+ {
+ return major > version.major;
+ }
}
public boolean isEqual(Version version)
--- 'a/src/main/java/com/stream_pi/util/xmlconfighelper/XMLConfigHelper.java'
+++ b/src/main/java/com/stream_pi/util/xmlconfighelper/XMLConfigHelper.java
@@ -33,7 +33,7 @@ import org.w3c.dom.Node;
public class XMLConfigHelper {
- private static Logger logger = Logger.getLogger(XMLConfigHelper.class.getName());
+ private static final Logger logger = Logger.getLogger(XMLConfigHelper.class.getName());
public static String getStringProperty(Element parentElement, String propertyName) throws Exception
{
@@ -66,16 +66,13 @@ public class XMLConfigHelper {
{
logger.warning("CANNOT get property "+parentElement.getNodeName()+"."+propertyName+"!");
- if(createNewIfDoesntExist)
+ if (createNewIfDoesntExist)
{
logger.warning("Creating new property by that name ...");
-
Element newProp = document.createElement(propertyName);
parentElement.appendChild(newProp);
-
save(document, file);
}
-
throw e;
}
}
@@ -85,7 +82,6 @@ public class XMLConfigHelper {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(file);
Source input = new DOMSource(document);
-
transformer.transform(input, output);
}
@@ -99,7 +95,6 @@ public class XMLConfigHelper {
Document document, File file)
{
String tbr = ifNotPresent;
-
try
{
tbr = getProperty(parentElement, propertyName, createNewIfDoesntExist, document, file);
@@ -109,8 +104,6 @@ public class XMLConfigHelper {
if(printStackTrace)
e.printStackTrace();
}
-
-
return tbr;
}
@@ -140,8 +133,6 @@ public class XMLConfigHelper {
if(printStackTrace)
e.printStackTrace();
}
-
-
return tbr;
}
@@ -169,8 +160,6 @@ public class XMLConfigHelper {
if(printStackTrace)
e.printStackTrace();
}
-
-
return tbr;
}
@@ -184,8 +173,7 @@ public class XMLConfigHelper {
return getBooleanProperty(parentElement, propertyName, ifNotPresent, printStackTrace, false, null, null);
}
-
- public static boolean getBooleanProperty(Element parentElement, String propertyName, boolean ifNotPresent, boolean printStackTrace, boolean createNewIfDoesntExist,
+ public static boolean getBooleanProperty(Element parentElement, String propertyName, boolean ifNotPresent, boolean printStackTrace, boolean createNewIfDoesntExist,
Document document, File file)
{
boolean tbr = ifNotPresent;
@@ -199,7 +187,6 @@ public class XMLConfigHelper {
if(printStackTrace)
e.printStackTrace();
}
-
return tbr;
}
@@ -217,5 +204,4 @@ public class XMLConfigHelper {
{
return document.getElementsByTagName(nameOfElement).getLength() > 0;
}
-
}