client

Clone or download

Modified Files

package com.stream_pi.client.window.dashboard.actiongridpane;
package com.stream_pi.client.window.dashboard.actiongridpane;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import javafx.animation.Interpolator;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.animation.Timeline;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.Image;
import javafx.scene.layout.Background;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextAlignment;
import javafx.util.Duration;
import javafx.util.Duration;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectInputStream;
import java.nio.ByteBuffer;
import java.nio.ByteBuffer;
public class ActionBox extends StackPane{
public class ActionBox extends StackPane{
private Label displayTextLabel;
private Label displayTextLabel;
private int row;
private int row;
private int col;
private int col;
public int getRow() {
public int getRow() {
return row;
return row;
}
}
public int getCol() {
public int getCol() {
return col;
return col;
}
}
public void clear()
public void clear()
{
{
setAction(null);
setAction(null);
setBackground(Background.EMPTY);
setBackground(Background.EMPTY);
setStyle(null);
setStyle(null);
getChildren().clear();
getChildren().clear();
}
}
private FontIcon statusIcon;
private FontIcon statusIcon;
public void baseInit()
public void baseInit()
{
{
displayTextLabel = new Label();
displayTextLabel = new Label();
displayTextLabel.setWrapText(true);
displayTextLabel.setWrapText(true);
displayTextLabel.setTextAlignment(TextAlignment.CENTER);
displayTextLabel.setTextAlignment(TextAlignment.CENTER);
displayTextLabel.getStyleClass().add("action_box_display_text_label");
displayTextLabel.getStyleClass().add("action_box_display_text_label");
displayTextLabel.prefHeightProperty().bind(heightProperty());
displayTextLabel.prefHeightProperty().bind(heightProperty());
displayTextLabel.prefWidthProperty().bind(widthProperty());
displayTextLabel.prefWidthProperty().bind(widthProperty());
statusIcon = new FontIcon("fas-exclamation-triangle");
statusIcon = new FontIcon("fas-exclamation-triangle");
statusIcon.getStyleClass().add("action_box_error_icon");
statusIcon.getStyleClass().add("action_box_error_icon");
statusIcon.setOpacity(0);
statusIcon.setOpacity(0);
statusIcon.setCache(true);
statusIcon.setCache(true);
statusIcon.setCacheHint(CacheHint.SPEED);
statusIcon.setCacheHint(CacheHint.SPEED);
statusIcon.setIconSize(size - 30);
statusIcon.setIconSize(size - 30);
getChildren().addAll(statusIcon, displayTextLabel);
getChildren().addAll(statusIcon, displayTextLabel);
setMinSize(size, size);
setMinSize(size, size);
setMaxSize(size, size);
setMaxSize(size, size);
getStyleClass().clear();
getStyleClass().clear();
getStyleClass().add("action_box");
getStyleClass().add("action_box");
getStyleClass().add("action_box_icon_not_present");
getStyleClass().add("action_box_icon_not_present");
getStyleClass().add("action_box_"+row+"_"+col);
getStyleClass().add("action_box_"+row+"_"+col);
setOnMouseClicked(touchEvent -> actionClicked());
setOnMouseClicked(touchEvent -> actionClicked());
setOnMousePressed(TouchEvent -> {
setOnMousePressed(TouchEvent -> {
if(action != null)
if(action != null)
{
{
getStyleClass().add("action_box_onclick");
getStyleClass().add("action_box_onclick");
}
}
});
});
setOnMouseReleased(TouchEvent ->{
setOnMouseReleased(TouchEvent ->{
if(action != null)
if(action != null)
{
{
getStyleClass().remove("action_box_onclick");
getStyleClass().remove("action_box_onclick");
}
}
});
});
statusIconAnimation = new Timeline(
statusIconAnimation = new Timeline(
new KeyFrame(
new KeyFrame(
Duration.millis(0.0D),
Duration.millis(0.0D),
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)),
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)),
new KeyFrame(
new KeyFrame(
Duration.millis(100.0D),
Duration.millis(100.0D),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)),
new KeyFrame(
new KeyFrame(
Duration.millis(600.0D),
Duration.millis(600.0D),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)),
new KeyFrame(
new KeyFrame(
Duration.millis(700.0D),
Duration.millis(700.0D),
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT))
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT))
);
);
statusIconAnimation.setOnFinished(event -> {
statusIconAnimation.setOnFinished(event -> {
statusIcon.toBack();
statusIcon.toBack();
});
});
setCache(true);
setCache(true);
setCacheHint(CacheHint.SPEED);
setCacheHint(CacheHint.SPEED);
}
}
public void actionClicked()
public void actionClicked()
{
{
if(action!=null)
if(action!=null)
{
{
if(action.getActionType() == ActionType.FOLDER)
if(action.getActionType() == ActionType.FOLDER)
{
{
getActionGridPaneListener().renderFolder(action.getID());
getActionGridPaneListener().renderFolder(action.getID());
}
}
else
else
{
{
if(action.getActionType() == ActionType.COMBINE)
if(action.getActionType() == ActionType.COMBINE)
{
{
getActionGridPaneListener().combineActionClicked(action.getID());
getActionGridPaneListener().combineActionClicked(action.getID());
}
}
else if(action.getActionType() == ActionType.NORMAL)
else if(action.getActionType() == ActionType.NORMAL)
{
{
getActionGridPaneListener().normalActionClicked(action.getID());
getActionGridPaneListener().normalActionClicked(action.getID());
}
}
}
}
}
}
}
}
private Timeline statusIconAnimation;
private Timeline statusIconAnimation;
public Timeline getStatusIconAnimation() {
public Timeline getStatusIconAnimation() {
return statusIconAnimation;
return statusIconAnimation;
}
}
public ActionGridPaneListener getActionGridPaneListener() {
public ActionGridPaneListener getActionGridPaneListener() {
return actionGridPaneListener;
return actionGridPaneListener;
}
}
private int size;
private int size;
private ActionGridPaneListener actionGridPaneListener;
private ActionGridPaneListener actionGridPaneListener;
public ActionBox(int size, ActionGridPaneListener actionGridPaneListener, int row, int col)
public ActionBox(int size, ActionGridPaneListener actionGridPaneListener, int row, int col)
{
{
this.actionGridPaneListener = actionGridPaneListener;
this.actionGridPaneListener = actionGridPaneListener;
this.size = size;
this.size = size;
this.row = row;
this.row = row;
this.col = col;
this.col = col;
baseInit();
baseInit();
}
}
public static Action deserialize(ByteBuffer buffer) {
public static Action deserialize(ByteBuffer buffer) {
try {
try {
ByteArrayInputStream is = new ByteArrayInputStream(buffer.array());
ByteArrayInputStream is = new ByteArrayInputStream(buffer.array());
ObjectInputStream ois = new ObjectInputStream(is);
ObjectInputStream ois = new ObjectInputStream(is);
return (Action) ois.readObject();
return (Action) ois.readObject();
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
throw new RuntimeException(e);
throw new RuntimeException(e);
}
}
}
}
public void setIcon(byte[] iconByteArray)
public void setIcon(byte[] iconByteArray)
{
{
if(iconByteArray == null)
if(iconByteArray == null)
{
{
getStyleClass().remove("action_box_icon_present");
getStyleClass().remove("action_box_icon_present");
getStyleClass().add("action_box_icon_not_present");
getStyleClass().add("action_box_icon_not_present");
setBackground(Background.EMPTY);
setBackground(null);
}
}
else
else
{
{
getStyleClass().add("action_box_icon_present");
getStyleClass().add("action_box_icon_present");
getStyleClass().remove("action_box_icon_not_present");
getStyleClass().remove("action_box_icon_not_present");
setBackground(
setBackground(
new Background(
new Background(
new BackgroundImage(new Image(
new BackgroundImage(new Image(
new ByteArrayInputStream(iconByteArray), size, size, false, true
new ByteArrayInputStream(iconByteArray), size, size, false, false
), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
new BackgroundSize(100, 100, true, true, true, false))
new BackgroundSize(size, size, false, false, true, false))
)
)
);
);
}
}
}
}
private Action action;
private Action action;
public Action getAction() {
public Action getAction() {
return action;
return action;
}
}
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private String parent;
private String parent;
public String getStreamPiParent() {
public String getStreamPiParent() {
return parent;
return parent;
}
}
public void setStreamPiParent(String parent) {
public void setStreamPiParent(String parent) {
this.parent = parent;
this.parent = parent;
}
}
public ActionBox(int size, Action action, ExceptionAndAlertHandler exceptionAndAlertHandler,
public ActionBox(int size, Action action, ExceptionAndAlertHandler exceptionAndAlertHandler,
ActionGridPaneListener actionGridPaneListener, int row, int col)
ActionGridPaneListener actionGridPaneListener, int row, int col)
{
{
this.actionGridPaneListener = actionGridPaneListener;
this.actionGridPaneListener = actionGridPaneListener;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.action = action;
this.action = action;
this.size = size;
this.size = size;
this.row = row;
this.row = row;
this.col = col;
this.col = col;
baseInit();
baseInit();
init();
init();
}
}
public void setAction(Action action)
public void setAction(Action action)
{
{
this.action = action;
this.action = action;
}
}
public void init()
public void init()
{
{
setDisplayTextFontColour(action.getDisplayTextFontColourHex());
setDisplayTextFontColour(action.getDisplayTextFontColourHex());
if(action.isShowDisplayText())
if(action.isShowDisplayText())
setDisplayTextLabel(action.getDisplayText());
setDisplayTextLabel(action.getDisplayText());
else
else
setDisplayTextLabel("");
setDisplayTextLabel("");
setDisplayTextAlignment(action.getDisplayTextAlignment());
setDisplayTextAlignment(action.getDisplayTextAlignment());
setBackgroundColour(action.getBgColourHex());
setBackgroundColour(action.getBgColourHex());
if(action.isHasIcon() && action.isShowIcon())
if(action.isHasIcon() && action.isShowIcon())
{
{
setIcon(action.getIconAsByteArray());
setIcon(action.getIconAsByteArray());
}
}
else
else
{
{
setIcon(null);
setIcon(null);
}
}
}
}
public void animateStatus()
public void animateStatus()
{
{
statusIcon.toFront();
statusIcon.toFront();
statusIconAnimation.play();
statusIconAnimation.play();
}
}
public void setDisplayTextLabel(String text)
public void setDisplayTextLabel(String text)
{
{
displayTextLabel.setText(text);
displayTextLabel.setText(text);
}
}
public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment)
public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment)
{
{
if(displayTextAlignment == DisplayTextAlignment.CENTER)
if(displayTextAlignment == DisplayTextAlignment.CENTER)
displayTextLabel.setAlignment(Pos.CENTER);
displayTextLabel.setAlignment(Pos.CENTER);
else if (displayTextAlignment == DisplayTextAlignment.BOTTOM)
else if (displayTextAlignment == DisplayTextAlignment.BOTTOM)
displayTextLabel.setAlignment(Pos.BOTTOM_CENTER);
displayTextLabel.setAlignment(Pos.BOTTOM_CENTER);
else if (displayTextAlignment == DisplayTextAlignment.TOP)
else if (displayTextAlignment == DisplayTextAlignment.TOP)
displayTextLabel.setAlignment(Pos.TOP_CENTER);
displayTextLabel.setAlignment(Pos.TOP_CENTER);
}
}
public void setDisplayTextFontColour(String colour)
public void setDisplayTextFontColour(String colour)
{
{
System.out.println("'"+colour+"'COLOR");
System.out.println("'"+colour+"'COLOR");
if(!colour.isEmpty())
if(!colour.isEmpty())
{
{
System.out.println(
System.out.println(
"putting ..." + Thread.currentThread().getName()
"putting ..." + Thread.currentThread().getName()
);
);
displayTextLabel.setStyle("-fx-text-fill : "+colour+";");
displayTextLabel.setStyle("-fx-text-fill : "+colour+";");
}
}
}
}
public void setBackgroundColour(String colour)
public void setBackgroundColour(String colour)
{
{
System.out.println("COLOr : "+colour);
System.out.println("COLOr : "+colour);
if(!colour.isEmpty() && action.getIconAsByteArray() == null)
if(!colour.isEmpty() && action.getIconAsByteArray() == null)
setStyle("-fx-background-color : "+colour);
setStyle("-fx-background-color : "+colour);
}
}
}
}
.root {
.root {
-fx-font-family : 'Roboto';
-fx-font-family : 'Roboto';
}
}
.action_box
.action_box
{
{
-fx-border-width: 1px;
-fx-border-width: 1px;
-fx-shape: "M100,100 h200 a20,20 0 0 1 20,20 v200 a20,20 0 0 1 -20,20 h-200 a20,20 0 0 1 -20,-20 v-200 a20,20 0 0 1 20,-20 z";
-fx-border-color : grey;
-fx-border-color : grey;
-fx-shape : "M100,100 h200 a20,20 0 0 1 20,20 v200 a20,20 0 0 1 -20,20 h-200 a20,20 0 0 1 -20,-20 v-200 a20,20 0 0 1 20,-20 z";
}
}
.action_box_icon_present
.action_box_icon_present
{
{
}
}
.action_box_icon_not_present
.action_box_icon_not_present
{
{
}
}
.action_box_onclick
.action_box_onclick
{
{
}
}
.settings_heading_label
.settings_heading_label
{
{
-fx-font-size: 20;
-fx-font-size: 20;
}
}
.alert_header
.alert_header
{
{
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_pane
.alert_pane
{
{
-fx-border-width : 5;
-fx-border-width : 5;
-fx-border-radius : 5;
-fx-border-radius : 5;
-fx-background-radius : 5;
-fx-background-radius : 5;
-fx-max-width : 400;
-fx-max-width : 400;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
}
}
.alert_header_icon
.alert_header_icon
{
{
-fx-icon-size : 30;
-fx-icon-size : 30;
}
}
.alert_content_pane
.alert_content_pane
{
{
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_pane_parent, .combobox_pane_parent
.alert_pane_parent, .combobox_pane_parent
{
{
-fx-background-color : rgba(0,0,0,0.5);
-fx-background-color : rgba(0,0,0,0.5);
}
}
.alert_pane_header_text
.alert_pane_header_text
{
{
-fx-font-size: 18;
-fx-font-size: 18;
}
}
.alert_button_bar
.alert_button_bar
{
{
-fx-alignment: CENTER_RIGHT;
-fx-alignment: CENTER_RIGHT;
-fx-spacing: 5;
-fx-spacing: 5;
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_scroll_pane {
.alert_scroll_pane {
-fx-max-height : 300;
-fx-max-height : 300;
/*-fx-focus-color: #FFFFFF;
/*-fx-focus-color: #FFFFFF;
-fx-faint-focus-color:#FFFFFF;*/
-fx-faint-focus-color:#FFFFFF;*/
}
}
.combo_box
.combo_box
{
{
-fx-alignment:CENTER_LEFT;
-fx-alignment:CENTER_LEFT;
-fx-pref-width:200;
-fx-pref-width:200;
-fx-padding: 5;
-fx-padding: 5;
-fx-border-width : 1;
-fx-border-width : 1;
-fx-border-color : grey;
-fx-border-color : grey;
-fx-border-radius : 3;
-fx-border-radius : 3;
}
}
.combo_box_popup
.combo_box_popup
{
{
-fx-border-width : 5;
-fx-border-width : 5;
-fx-border-radius : 5;
-fx-border-radius : 5;
-fx-background-radius : 5;
-fx-background-radius : 5;
-fx-max-height : 300;
-fx-max-height : 300;
-fx-max-width : 410;
-fx-max-width : 410;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
}
}
.combo_box_popup_vbox
.combo_box_popup_vbox
{
{
-fx-padding: 5 5 0 5;
-fx-padding: 5 5 0 5;
-fx-spacing:5;
-fx-spacing:5;
}
}
.combo_box_drop_down_icon
.combo_box_drop_down_icon
{
{
-fx-icon-code: fas-caret-down;
-fx-icon-code: fas-caret-down;
-fx-icon-size: 14;
-fx-icon-size: 14;
}
}
.first_time_use_pane
.first_time_use_pane
{
{
-fx-background-color:white;
-fx-background-color:white;
-fx-padding : 5;
-fx-padding : 5;
}
}
.first_time_use_pane_heading_label
.first_time_use_pane_heading_label
{
{
-fx-font-size: 20;
-fx-font-size: 20;
}
}
.first_time_use_final_config_pane_scroll_pane
.first_time_use_final_config_pane_scroll_pane
{
{
-fx-background-color:transparent;
-fx-background-color:transparent;
}
}
.first_time_use_pane_stackpane
.first_time_use_pane_stackpane
{
{
}
}
.first_time_use_pane_welcome
.first_time_use_pane_welcome
{
{
}
}
.first_time_use_pane_license
.first_time_use_pane_license
{
{
-fx-spacing : 10;
-fx-spacing : 10;
}
}
.first_time_use_pane_final_config
.first_time_use_pane_final_config
{
{
}
}
.first_time_use_pane_final_config_label
.first_time_use_pane_final_config_label
{
{
}
}
.first_time_use_welcome_pane_welcome_label
.first_time_use_welcome_pane_welcome_label
{
{
-fx-font-size: 30;
-fx-font-size: 30;
}
}
.first_time_use_welcome_pane_next_to_continue_label
.first_time_use_welcome_pane_next_to_continue_label
{
{
-fx-font-size: 15;
-fx-font-size: 15;
}
}
.scroll-pane
.scroll-pane
{
{
-fx-focus-color:transparent;
-fx-focus-color:transparent;
-fx-faint-focus-color:transparent;
-fx-faint-focus-color:transparent;
}
}
/*Alert Classes added to default stylesheet to show init error, if occurs */
/*Alert Classes added to default stylesheet to show init error, if occurs */
.action_box_display_text_label
.action_box_display_text_label
{
{
-fx-font-size : 16;
-fx-font-size : 16;
-fx-background-color : transparent;
-fx-background-color : transparent;
}
}
.alert_pane
.alert_pane
{
{
-fx-background-color : white;
-fx-background-color : white;
-fx-border-color : white;
-fx-border-color : white;
}
}
.alert_content_pane
.alert_content_pane
{
{
-fx-background-color: white;
-fx-background-color: white;
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_scroll_pane
.alert_scroll_pane
{
{
-fx-background: white;
-fx-background: white;
-fx-border-color:white;
-fx-border-color:white;
}
}
.alert_button_bar
.alert_button_bar
{
{
-fx-background-color:white;
-fx-background-color:white;
}
}