* the first start alert is now material styled * the info dialog is now a alertpull/24/head
parent
34371bb2b5
commit
22df604093
@ -1,194 +0,0 @@
|
||||
package com.cemu_UI.uiElements;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXDialog;
|
||||
import com.jfoenix.controls.JFXDialogLayout;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class JFXDirStrmCancelDialog {
|
||||
private String headingText;
|
||||
private String bodyText;
|
||||
private String dialogBtnStyle;
|
||||
private String btn1Text;
|
||||
private String btn2Text;
|
||||
private String cancelText;
|
||||
private int dialogWidth;
|
||||
private int dialogHeight;
|
||||
private EventHandler<ActionEvent> btn1Action;
|
||||
private EventHandler<ActionEvent> btn2Action;
|
||||
private Pane pane;
|
||||
|
||||
/**
|
||||
* Creates a new JFoenix Dialog to show some information with okay and cancel
|
||||
* option
|
||||
*
|
||||
* @param headingText Heading Text, just the heading
|
||||
* @param bodyText body Text, all other text belongs here
|
||||
* @param dialogBtnStyle Style of the okay button
|
||||
* @param dialogWidth dialog width
|
||||
* @param dialogHeight dialog height
|
||||
* @param btn1Action action which is performed if btn1 is clicked
|
||||
* @param btn2Action action which is performed if btn2 is clicked
|
||||
* @param cancelAction action which is performed if the cancel button is clicked
|
||||
* @param pane pane to which the dialog belongs
|
||||
*/
|
||||
public JFXDirStrmCancelDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth,
|
||||
int dialogHeight, EventHandler<ActionEvent> btn1Action, EventHandler<ActionEvent> btn2Action,
|
||||
Pane pane, ResourceBundle bundle) {
|
||||
setHeadingText(headingText);
|
||||
setBodyText(bodyText);
|
||||
setDialogBtnStyle(dialogBtnStyle);
|
||||
setDialogWidth(dialogWidth);
|
||||
setDialogHeight(dialogHeight);
|
||||
setBtn1Action(btn1Action);
|
||||
setBtn2Action(btn2Action);
|
||||
setPane(pane);
|
||||
|
||||
btn1Text = bundle.getString("addDirectory");
|
||||
btn2Text = bundle.getString("addStreamSource");
|
||||
cancelText = bundle.getString("cancelBtnText");
|
||||
}
|
||||
|
||||
public JFXDirStrmCancelDialog() {
|
||||
// Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void show() {
|
||||
JFXDialogLayout content = new JFXDialogLayout();
|
||||
content.setHeading(new Text(headingText));
|
||||
content.setBody(new Text(bodyText));
|
||||
StackPane stackPane = new StackPane();
|
||||
stackPane.autosize();
|
||||
JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true);
|
||||
|
||||
JFXButton btn1 = new JFXButton(btn1Text);
|
||||
btn1.addEventHandler(ActionEvent.ACTION, (e) -> {
|
||||
dialog.close();
|
||||
});
|
||||
btn1.addEventHandler(ActionEvent.ACTION, btn1Action);
|
||||
btn1.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
btn1.setPrefHeight(32);
|
||||
btn1.setStyle(dialogBtnStyle);
|
||||
|
||||
JFXButton btn2 = new JFXButton(btn2Text);
|
||||
btn2.addEventHandler(ActionEvent.ACTION, (e) -> {
|
||||
dialog.close();
|
||||
});
|
||||
btn2.addEventHandler(ActionEvent.ACTION, btn2Action);
|
||||
btn2.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
btn2.setPrefHeight(32);
|
||||
btn2.setStyle(dialogBtnStyle);
|
||||
|
||||
JFXButton cancelBtn = new JFXButton(cancelText);
|
||||
cancelBtn.addEventHandler(ActionEvent.ACTION, (e) -> {
|
||||
dialog.close();
|
||||
});
|
||||
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
cancelBtn.setPrefHeight(32);
|
||||
cancelBtn.setStyle(dialogBtnStyle);
|
||||
|
||||
content.setActions(cancelBtn, btn1, btn2);
|
||||
content.setPrefSize(dialogWidth, dialogHeight);
|
||||
pane.getChildren().add(stackPane);
|
||||
AnchorPane.setTopAnchor(stackPane, (pane.getHeight() - content.getPrefHeight()) / 2);
|
||||
AnchorPane.setLeftAnchor(stackPane, (pane.getWidth() - content.getPrefWidth()) / 2);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public String getHeadingText() {
|
||||
return headingText;
|
||||
}
|
||||
|
||||
public void setHeadingText(String headingText) {
|
||||
this.headingText = headingText;
|
||||
}
|
||||
|
||||
public String getBodyText() {
|
||||
return bodyText;
|
||||
}
|
||||
|
||||
public void setBodyText(String bodyText) {
|
||||
this.bodyText = bodyText;
|
||||
}
|
||||
|
||||
public String getDialogBtnStyle() {
|
||||
return dialogBtnStyle;
|
||||
}
|
||||
|
||||
public void setDialogBtnStyle(String dialogBtnStyle) {
|
||||
this.dialogBtnStyle = dialogBtnStyle;
|
||||
}
|
||||
|
||||
public String getBtn1Text() {
|
||||
return btn1Text;
|
||||
}
|
||||
|
||||
public void setBtn1Text(String btn1Text) {
|
||||
this.btn1Text = btn1Text;
|
||||
}
|
||||
|
||||
public String getBtn2Text() {
|
||||
return btn2Text;
|
||||
}
|
||||
|
||||
public void setBtn2Text(String btn2Text) {
|
||||
this.btn2Text = btn2Text;
|
||||
}
|
||||
|
||||
public String getCancelText() {
|
||||
return cancelText;
|
||||
}
|
||||
|
||||
public void setCancelText(String cancelText) {
|
||||
this.cancelText = cancelText;
|
||||
}
|
||||
|
||||
public int getDialogWidth() {
|
||||
return dialogWidth;
|
||||
}
|
||||
|
||||
public void setDialogWidth(int dialogWidth) {
|
||||
this.dialogWidth = dialogWidth;
|
||||
}
|
||||
|
||||
public int getDialogHeight() {
|
||||
return dialogHeight;
|
||||
}
|
||||
|
||||
public void setDialogHeight(int dialogHeight) {
|
||||
this.dialogHeight = dialogHeight;
|
||||
}
|
||||
|
||||
public EventHandler<ActionEvent> getBtn1Action() {
|
||||
return btn1Action;
|
||||
}
|
||||
|
||||
public void setBtn1Action(EventHandler<ActionEvent> btn1Action) {
|
||||
this.btn1Action = btn1Action;
|
||||
}
|
||||
|
||||
public EventHandler<ActionEvent> getBtn2Action() {
|
||||
return btn2Action;
|
||||
}
|
||||
|
||||
public void setBtn2Action(EventHandler<ActionEvent> btn2Action) {
|
||||
this.btn2Action = btn2Action;
|
||||
}
|
||||
|
||||
public Pane getPane() {
|
||||
return pane;
|
||||
}
|
||||
|
||||
public void setPane(Pane pane) {
|
||||
this.pane = pane;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
/**
|
||||
* Kellerkinder Framework Alerts
|
||||
*
|
||||
* Copyright 2018 <@Seil0>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.kellerkinder.Alerts;
|
||||
|
||||
import com.jfoenix.controls.JFXAlert;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXDialogLayout;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class JFX2BtnCancelAlert {
|
||||
|
||||
private String headingText;
|
||||
private String bodyText;
|
||||
private String btnStyle;
|
||||
private String btn1Text;
|
||||
private String btn2Text;
|
||||
private String cancelText;
|
||||
private EventHandler<ActionEvent> btn1Action;
|
||||
private EventHandler<ActionEvent> btn2Action;
|
||||
private Stage stage;
|
||||
private JFXAlert<Void> alert;
|
||||
|
||||
/**
|
||||
* Creates a new JFoenix Alert with 2 buttons and one cancel button
|
||||
* @param titleText Title text of the alert
|
||||
* @param headerText Heading text of the alert
|
||||
* @param contentText Content text of the alert
|
||||
* @param btnStyle Style of the okay button
|
||||
* @param btn1Text btn1 text
|
||||
* @param btn2Text btn2 text
|
||||
* @param cancelText cancel button text
|
||||
* @param stage stage to which the dialog belongs
|
||||
*/
|
||||
public JFX2BtnCancelAlert(String headingText, String bodyText, String btnStyle, String btn1Text, String btn2Text,
|
||||
String cancelText, Stage stage) {
|
||||
setHeadingText(headingText);
|
||||
setBodyText(bodyText);
|
||||
setBtnStyle(btnStyle);
|
||||
setBtn1Text(btn1Text);
|
||||
setBtn2Text(btn2Text);
|
||||
setCancelText(cancelText);
|
||||
setStage(stage);
|
||||
}
|
||||
|
||||
public JFX2BtnCancelAlert() {
|
||||
// Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void showAndWait() {
|
||||
alert = new JFXAlert<>(stage);
|
||||
|
||||
JFXButton btnOne = new JFXButton();
|
||||
|
||||
btnOne.setText(btn1Text);
|
||||
btnOne.setOnAction(btn1Action);
|
||||
btnOne.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
btnOne.setPrefHeight(32);
|
||||
btnOne.setStyle(btnStyle);
|
||||
|
||||
JFXButton btnTwo = new JFXButton();
|
||||
btnTwo.setText(btn2Text);
|
||||
btnTwo.setOnAction(btn2Action);
|
||||
btnTwo.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
btnTwo.setPrefHeight(32);
|
||||
btnTwo.setStyle(btnStyle);
|
||||
|
||||
JFXButton cancelBtn = new JFXButton();
|
||||
cancelBtn.setText(cancelText);
|
||||
cancelBtn.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
alert.close();
|
||||
System.exit(1);
|
||||
}
|
||||
});
|
||||
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
|
||||
cancelBtn.setPrefHeight(32);
|
||||
cancelBtn.setStyle(btnStyle);
|
||||
|
||||
JFXDialogLayout content = new JFXDialogLayout();
|
||||
content.setActions(btnOne, btnTwo, cancelBtn);
|
||||
content.setHeading(new Text(headingText));
|
||||
content.setBody(new Text(bodyText));
|
||||
alert.setContent(content);
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
public String getHeadingText() {
|
||||
return headingText;
|
||||
}
|
||||
|
||||
public void setHeadingText(String headingText) {
|
||||
this.headingText = headingText;
|
||||
}
|
||||
|
||||
public String getBodyText() {
|
||||
return bodyText;
|
||||
}
|
||||
|
||||
public void setBodyText(String bodyText) {
|
||||
this.bodyText = bodyText;
|
||||
}
|
||||
|
||||
public String getBtnStyle() {
|
||||
return btnStyle;
|
||||
}
|
||||
|
||||
public void setBtnStyle(String btnStyle) {
|
||||
this.btnStyle = btnStyle;
|
||||
}
|
||||
|
||||
public String getBtn1Text() {
|
||||
return btn1Text;
|
||||
}
|
||||
|
||||
public void setBtn1Text(String btn1Text) {
|
||||
this.btn1Text = btn1Text;
|
||||
}
|
||||
|
||||
public String getBtn2Text() {
|
||||
return btn2Text;
|
||||
}
|
||||
|
||||
public void setBtn2Text(String btn2Text) {
|
||||
this.btn2Text = btn2Text;
|
||||
}
|
||||
|
||||
public String getCancelText() {
|
||||
return cancelText;
|
||||
}
|
||||
|
||||
public void setCancelText(String cancelText) {
|
||||
this.cancelText = cancelText;
|
||||
}
|
||||
|
||||
public EventHandler<ActionEvent> getBtn1Action() {
|
||||
return btn1Action;
|
||||
}
|
||||
|
||||
public void setBtn1Action(EventHandler<ActionEvent> btn1Action) {
|
||||
this.btn1Action = btn1Action;
|
||||
}
|
||||
|
||||
public EventHandler<ActionEvent> getBtn2Action() {
|
||||
return btn2Action;
|
||||
}
|
||||
|
||||
public void setBtn2Action(EventHandler<ActionEvent> btn2Action) {
|
||||
this.btn2Action = btn2Action;
|
||||
}
|
||||
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
public void setStage(Stage stage) {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
public JFXAlert<Void> getAlert() {
|
||||
return alert;
|
||||
}
|
||||
|
||||
public void setAlert(JFXAlert<Void> alert) {
|
||||
this.alert = alert;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue