-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checks for version of geometry_generator of opened file
- Loading branch information
1 parent
9513dfb
commit 0b4f165
Showing
15 changed files
with
347 additions
and
47 deletions.
There are no files selected for viewing
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
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,67 @@ | ||
package fabulator.object; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Version { // TODO: tests | ||
|
||
private int major; | ||
private int minor; | ||
private int patch; | ||
|
||
public Version(String versionString) throws NumberFormatException { | ||
this.parseString(versionString); | ||
} | ||
|
||
private void parseString(String versionString) throws NumberFormatException { | ||
if (versionString != null && !versionString.isEmpty()) { | ||
String[] parts = versionString.split("\\."); | ||
|
||
if (parts.length == 3) { | ||
this.major = Integer.parseInt(parts[0]); | ||
this.minor = Integer.parseInt(parts[1]); | ||
this.patch = Integer.parseInt(parts[2]); | ||
} else { | ||
throw new NumberFormatException(); | ||
} | ||
} else { | ||
throw new NumberFormatException(); | ||
} | ||
} | ||
|
||
public static boolean outdated(Version minVersion, Version version) { | ||
boolean outdated = true; | ||
|
||
if (version != null) { | ||
outdated = !minVersion.lessEqual(version); | ||
} | ||
return outdated; | ||
} | ||
|
||
public boolean lessEqual(Version version) { | ||
boolean lessEqual = false; | ||
|
||
if (version.getMajor() > this.major) { | ||
lessEqual = true; | ||
|
||
} else if (version.getMajor() == this.major) { | ||
if (version.getMinor() > this.minor) { | ||
lessEqual = true; | ||
|
||
} else if (version.getMinor() == this.minor) { | ||
lessEqual = version.getPatch() >= this.patch; | ||
} | ||
} | ||
return lessEqual; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format( | ||
"%d.%d.%d", | ||
this.major, | ||
this.minor, | ||
this.patch | ||
); | ||
} | ||
} |
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
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
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,88 @@ | ||
package fabulator.ui.window; | ||
|
||
import fabulator.language.Text; | ||
import fabulator.ui.builder.ButtonBuilder; | ||
import fabulator.ui.builder.LabelBuilder; | ||
import fabulator.util.LayoutUtils; | ||
import javafx.collections.ObservableList; | ||
import javafx.event.ActionEvent; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.VBox; | ||
import lombok.Setter; | ||
|
||
public class ChoiceDialog extends FABulatorWindow { | ||
|
||
private Text[] dialogText; | ||
private Button yesButton; | ||
private Button noButton; | ||
|
||
@Setter | ||
private Runnable yesRunnable = () -> {}; | ||
|
||
@Setter | ||
private Runnable noRunnable = () -> {}; | ||
|
||
public ChoiceDialog(int width, int height, Text title, Text... dialogText) { | ||
super(width, height, title); | ||
|
||
this.dialogText = dialogText; | ||
|
||
this.initialize(); | ||
this.setup(); | ||
} | ||
|
||
private void initialize() { | ||
this.yesButton = new ButtonBuilder() | ||
.setId("yesButton") | ||
.setText(Text.YES) | ||
.setTooltip(Text.YES) | ||
.setOnAction(this::yesClicked) | ||
.build(); | ||
|
||
this.noButton = new ButtonBuilder() | ||
.setId("noButton") | ||
.setText(Text.CANCEL) | ||
.setTooltip(Text.CANCEL) | ||
.setOnAction(this::noClicked) | ||
.build(); | ||
} | ||
|
||
private void setup() { | ||
VBox root = new VBox(); | ||
root.getStyleClass().add("choice-dialog"); | ||
|
||
ObservableList<Node> rootChildren = root.getChildren(); | ||
|
||
for (Text text : this.dialogText) { | ||
Label textLabel = new LabelBuilder() | ||
.setText(text) | ||
.setWrapText(true) | ||
.build(); | ||
rootChildren.add(textLabel); | ||
} | ||
|
||
rootChildren.addAll( | ||
LayoutUtils.vSpacer(), | ||
new HBox( | ||
LayoutUtils.hSpacer(), | ||
this.yesButton, | ||
this.noButton | ||
) | ||
); | ||
|
||
this.setRoot(root); | ||
} | ||
|
||
private void yesClicked(ActionEvent event) { | ||
this.close(); | ||
this.yesRunnable.run(); | ||
} | ||
|
||
private void noClicked(ActionEvent event) { | ||
this.close(); | ||
this.noRunnable.run(); | ||
} | ||
} |
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
Oops, something went wrong.