server

Clone or download

Removed unused sout lines, updated selected action box UI

Modified Files

package com.stream_pi.server.window.dashboard.actiongridpane;
package com.stream_pi.server.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.action_api.action.Location;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.actionproperty.ClientProperties;
import com.stream_pi.action_api.actionproperty.ClientProperties;
import com.stream_pi.action_api.externalplugin.ExternalPlugin;
import com.stream_pi.action_api.externalplugin.ExternalPlugin;
import com.stream_pi.server.controller.ActionDataFormats;
import com.stream_pi.server.controller.ActionDataFormats;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.window.dashboard.actiondetailpane.ActionDetailsPaneListener;
import com.stream_pi.server.window.dashboard.actiondetailpane.ActionDetailsPaneListener;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.image.Image;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.Dragboard;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseButton;
import javafx.scene.input.TransferMode;
import javafx.scene.input.TransferMode;
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 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;
import java.util.HashMap;
import java.util.HashMap;
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 void setRow(int row) {
public void setRow(int row) {
this.row = row;
this.row = row;
}
}
public void setCol(int col) {
public void setCol(int col) {
this.col = col;
this.col = col;
}
}
public int getRow() {
public int getRow() {
return row;
return row;
}
}
public int getCol() {
public int getCol() {
return col;
return col;
}
}
private ActionDetailsPaneListener actionDetailsPaneListener;
private ActionDetailsPaneListener actionDetailsPaneListener;
public void clear()
public void clear()
{
{
setStyle(null);
setStyle(null);
setAction(null);
setAction(null);
getStyleClass().clear();
getStyleClass().clear();
setBackground(Background.EMPTY);
setBackground(Background.EMPTY);
removeFontIcon();
removeFontIcon();
getChildren().clear();
getChildren().clear();
baseInit();
baseInit();
}
}
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());
getChildren().addAll(displayTextLabel);
getChildren().addAll(displayTextLabel);
setMinSize(size, size);
setMinSize(size, size);
setMaxSize(size, size);
setMaxSize(size, size);
getStyleClass().add("action_box");
getStyleClass().add("action_box");
setIcon(null);
setIcon(null);
getStyleClass().add("action_box_valid");
getStyleClass().add("action_box_valid");
setOnDragOver(dragEvent ->
setOnDragOver(dragEvent ->
{
{
if(dragEvent.getDragboard().hasContent(ActionDataFormats.ACTION_TYPE))
if(dragEvent.getDragboard().hasContent(ActionDataFormats.ACTION_TYPE))
{
{
dragEvent.acceptTransferModes(TransferMode.ANY);
dragEvent.acceptTransferModes(TransferMode.ANY);
dragEvent.consume();
dragEvent.consume();
}
}
});
});
setOnDragDropped(dragEvent ->
setOnDragDropped(dragEvent ->
{
{
try
try
{
{
if(action == null)
if(action == null)
{
{
Dragboard db = dragEvent.getDragboard();
Dragboard db = dragEvent.getDragboard();
ActionType actionType = (ActionType) db.getContent(ActionDataFormats.ACTION_TYPE);
ActionType actionType = (ActionType) db.getContent(ActionDataFormats.ACTION_TYPE);
if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE)
if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE)
{
{
String moduleName = (String) dragEvent.getDragboard().getContent(ActionDataFormats.MODULE_NAME);
String moduleName = (String) dragEvent.getDragboard().getContent(ActionDataFormats.MODULE_NAME);
ExternalPlugin newAction = actionGridPaneListener.createNewActionFromExternalPlugin(moduleName);
ExternalPlugin newAction = actionGridPaneListener.createNewActionFromExternalPlugin(moduleName);
boolean isNew = (boolean) db.getContent(ActionDataFormats.IS_NEW);
boolean isNew = (boolean) db.getContent(ActionDataFormats.IS_NEW);
if(isNew)
if(isNew)
{
{
newAction.setDisplayText("Untitled Action");
newAction.setDisplayText("Untitled Action");
newAction.setShowDisplayText(true);
newAction.setShowDisplayText(true);
newAction.getClientProperties().resetToDefaults();
newAction.getClientProperties().resetToDefaults();
newAction.setDisplayTextAlignment(DisplayTextAlignment.CENTER);
newAction.setDisplayTextAlignment(DisplayTextAlignment.CENTER);
if(actionType == ActionType.TOGGLE)
if(actionType == ActionType.TOGGLE)
newAction.setCurrentIconState("false__false");
newAction.setCurrentIconState("false__false");
}
}
else
else
{
{
newAction.setClientProperties((ClientProperties) db.getContent(ActionDataFormats.CLIENT_PROPERTIES));
newAction.setClientProperties((ClientProperties) db.getContent(ActionDataFormats.CLIENT_PROPERTIES));
newAction.setIcons((HashMap<String, byte[]>) db.getContent(ActionDataFormats.ICONS));
newAction.setIcons((HashMap<String, byte[]>) db.getContent(ActionDataFormats.ICONS));
newAction.setCurrentIconState((String) db.getContent(ActionDataFormats.CURRENT_ICON_STATE));
newAction.setCurrentIconState((String) db.getContent(ActionDataFormats.CURRENT_ICON_STATE));
newAction.setBgColourHex((String) db.getContent(ActionDataFormats.BACKGROUND_COLOUR));
newAction.setBgColourHex((String) db.getContent(ActionDataFormats.BACKGROUND_COLOUR));
newAction.setDisplayTextFontColourHex((String) db.getContent(ActionDataFormats.DISPLAY_TEXT_FONT_COLOUR));
newAction.setDisplayTextFontColourHex((String) db.getContent(ActionDataFormats.DISPLAY_TEXT_FONT_COLOUR));
newAction.setDisplayText((String) db.getContent(ActionDataFormats.DISPLAY_TEXT));
newAction.setDisplayText((String) db.getContent(ActionDataFormats.DISPLAY_TEXT));
newAction.setDisplayTextAlignment((DisplayTextAlignment) db.getContent(ActionDataFormats.DISPLAY_TEXT_ALIGNMENT));
newAction.setDisplayTextAlignment((DisplayTextAlignment) db.getContent(ActionDataFormats.DISPLAY_TEXT_ALIGNMENT));
newAction.setShowDisplayText((boolean) db.getContent(ActionDataFormats.DISPLAY_TEXT_SHOW));
newAction.setShowDisplayText((boolean) db.getContent(ActionDataFormats.DISPLAY_TEXT_SHOW));
}
}
newAction.setLocation(new Location(getRow(),
newAction.setLocation(new Location(getRow(),
getCol()));
getCol()));
System.out.println("@@#$#$#$ :"+newAction.getProfileID());
newAction.setParent(actionGridPaneListener.getCurrentParent());
newAction.setParent(actionGridPaneListener.getCurrentParent());
newAction.setSocketAddressForClient(actionGridPaneListener.getClientConnection().getRemoteSocketAddress());
newAction.setSocketAddressForClient(actionGridPaneListener.getClientConnection().getRemoteSocketAddress());
try
try
{
{
newAction.onActionCreate();
newAction.onActionCreate();
}
}
catch (Exception e)
catch (Exception e)
{
{
exceptionAndAlertHandler.handleMinorException(new MinorException("Error","onCreate() failed for "+action.getModuleName()+"\n\n"+e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException("Error","onCreate() failed for "+action.getModuleName()+"\n\n"+e.getMessage()));
}
}
newAction.setProfileID(actionGridPaneListener.getCurrentProfile().getID());
newAction.setProfileID(actionGridPaneListener.getCurrentProfile().getID());
newAction.setSocketAddressForClient(actionGridPaneListener.getClientConnection().getRemoteSocketAddress());
newAction.setSocketAddressForClient(actionGridPaneListener.getClientConnection().getRemoteSocketAddress());
actionGridPaneListener.addActionToCurrentClientProfile(newAction);
actionGridPaneListener.addActionToCurrentClientProfile(newAction);
setAction(newAction);
setAction(newAction);
init();
init();
actionDetailsPaneListener.onActionClicked(newAction, this);
actionDetailsPaneListener.onActionClicked(newAction, this);
if(newAction.isHasIcon())
if(newAction.isHasIcon())
actionDetailsPaneListener.setSendIcon(true);
actionDetailsPaneListener.setSendIcon(true);
actionDetailsPaneListener.saveAction(true, false);
actionDetailsPaneListener.saveAction(true, false);
}
}
else
else
{
{
Action newAction = actionGridPaneListener.createNewOtherAction(actionType);
Action newAction = actionGridPaneListener.createNewOtherAction(actionType);
newAction.setLocation(new Location(getRow(),
newAction.setLocation(new Location(getRow(),
getCol()));
getCol()));
newAction.setParent(actionGridPaneListener.getCurrentParent());
newAction.setParent(actionGridPaneListener.getCurrentParent());
newAction.setProfileID(actionGridPaneListener.getCurrentProfile().getID());
newAction.setProfileID(actionGridPaneListener.getCurrentProfile().getID());
newAction.setSocketAddressForClient(actionGridPaneListener.getClientConnection().getRemoteSocketAddress());
newAction.setSocketAddressForClient(actionGridPaneListener.getClientConnection().getRemoteSocketAddress());
actionGridPaneListener.addActionToCurrentClientProfile(newAction);
actionGridPaneListener.addActionToCurrentClientProfile(newAction);
setAction(newAction);
setAction(newAction);
init();
init();
actionDetailsPaneListener.onActionClicked(newAction, this);
actionDetailsPaneListener.onActionClicked(newAction, this);
if(newAction.isHasIcon())
if(newAction.isHasIcon())
actionDetailsPaneListener.setSendIcon(true);
actionDetailsPaneListener.setSendIcon(true);
actionDetailsPaneListener.saveAction(true, false);
actionDetailsPaneListener.saveAction(true, false);
}
}
}
}
}
}
catch (MinorException e)
catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
e.printStackTrace();
e.printStackTrace();
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
});
});
setOnDragDetected(mouseEvent -> {
setOnDragDetected(mouseEvent -> {
if(getAction()!=null)
if(getAction()!=null)
{
{
if(getAction().getActionType() == ActionType.NORMAL)
if(getAction().getActionType() == ActionType.NORMAL)
{
{
Dragboard db = startDragAndDrop(TransferMode.ANY);
Dragboard db = startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
ClipboardContent content = new ClipboardContent();
content.put(ActionDataFormats.CLIENT_PROPERTIES, getAction().getClientProperties());
content.put(ActionDataFormats.CLIENT_PROPERTIES, getAction().getClientProperties());
content.put(ActionDataFormats.ICONS, getAction().getIcons());
content.put(ActionDataFormats.ICONS, getAction().getIcons());
content.put(ActionDataFormats.CURRENT_ICON_STATE, getAction().getCurrentIconState());
content.put(ActionDataFormats.CURRENT_ICON_STATE, getAction().getCurrentIconState());
content.put(ActionDataFormats.BACKGROUND_COLOUR, getAction().getBgColourHex());
content.put(ActionDataFormats.BACKGROUND_COLOUR, getAction().getBgColourHex());
content.put(ActionDataFormats.DISPLAY_TEXT_FONT_COLOUR, getAction().getDisplayTextFontColourHex());
content.put(ActionDataFormats.DISPLAY_TEXT_FONT_COLOUR, getAction().getDisplayTextFontColourHex());
content.put(ActionDataFormats.DISPLAY_TEXT, getAction().getDisplayText());
content.put(ActionDataFormats.DISPLAY_TEXT, getAction().getDisplayText());
content.put(ActionDataFormats.DISPLAY_TEXT_ALIGNMENT, getAction().getDisplayTextAlignment());
content.put(ActionDataFormats.DISPLAY_TEXT_ALIGNMENT, getAction().getDisplayTextAlignment());
content.put(ActionDataFormats.DISPLAY_TEXT_SHOW, getAction().isShowDisplayText());
content.put(ActionDataFormats.DISPLAY_TEXT_SHOW, getAction().isShowDisplayText());
content.put(ActionDataFormats.IS_NEW, false);
content.put(ActionDataFormats.IS_NEW, false);
content.put(ActionDataFormats.ACTION_TYPE, getAction().getActionType());
content.put(ActionDataFormats.ACTION_TYPE, getAction().getActionType());
content.put(ActionDataFormats.MODULE_NAME, getAction().getModuleName());
content.put(ActionDataFormats.MODULE_NAME, getAction().getModuleName());
db.setContent(content);
db.setContent(content);
mouseEvent.consume();
mouseEvent.consume();
}
}
}
}
});
});
setOnMouseClicked(mouseEvent -> {
setOnMouseClicked(mouseEvent -> {
if(action != null)
if(action != null)
{
{
if(mouseEvent.getClickCount() == 2 && getAction().getActionType() == ActionType.FOLDER)
if(mouseEvent.getClickCount() == 2 && getAction().getActionType() == ActionType.FOLDER)
{
{
getActionDetailsPaneListener().onOpenFolderButtonClicked();
getActionDetailsPaneListener().onOpenFolderButtonClicked();
}
}
else
else
{
{
try
try
{
{
actionDetailsPaneListener.onActionClicked(action, this);
actionDetailsPaneListener.onActionClicked(action, this);
if(mouseEvent.getButton().equals(MouseButton.SECONDARY))
if(mouseEvent.getButton().equals(MouseButton.SECONDARY))
{
{
actionContextMenu.show(this, mouseEvent.getScreenX(),
actionContextMenu.show(this, mouseEvent.getScreenX(),
mouseEvent.getScreenY());
mouseEvent.getScreenY());
}
}
}
}
catch (MinorException e)
catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
e.printStackTrace();
e.printStackTrace();
}
}
}
}
}
}
});
});
actionContextMenu = new ContextMenu();
actionContextMenu = new ContextMenu();
MenuItem deleteActionMenuItem = new MenuItem("Delete Action");
MenuItem deleteActionMenuItem = new MenuItem("Delete Action");
deleteActionMenuItem.setOnAction(event-> deleteAction());
deleteActionMenuItem.setOnAction(event-> deleteAction());
showToggleOffMenuItem = new MenuItem("Show Toggle OFF");
showToggleOffMenuItem = new MenuItem("Show Toggle OFF");
showToggleOffMenuItem.setOnAction(event-> fakeToggle(false));
showToggleOffMenuItem.setOnAction(event-> fakeToggle(false));
showToggleOnMenuItem = new MenuItem("Show Toggle ON");
showToggleOnMenuItem = new MenuItem("Show Toggle ON");
showToggleOnMenuItem.setOnAction(event-> fakeToggle(true));
showToggleOnMenuItem.setOnAction(event-> fakeToggle(true));
actionContextMenu.getItems().addAll(deleteActionMenuItem, showToggleOffMenuItem, showToggleOnMenuItem);
actionContextMenu.getItems().addAll(deleteActionMenuItem, showToggleOffMenuItem, showToggleOnMenuItem);
setCache(true);
setCache(true);
setCacheHint(CacheHint.QUALITY);
setCacheHint(CacheHint.QUALITY);
}
}
private MenuItem showToggleOffMenuItem;
private MenuItem showToggleOffMenuItem;
private MenuItem showToggleOnMenuItem;
private MenuItem showToggleOnMenuItem;
private void deleteAction()
private void deleteAction()
{
{
actionDetailsPaneListener.onDeleteButtonClicked();
actionDetailsPaneListener.onDeleteButtonClicked();
}
}
ContextMenu actionContextMenu;
ContextMenu actionContextMenu;
public void setInvalid(boolean invalid)
public void setInvalid(boolean invalid)
{
{
if(invalid)
if(invalid)
{
{
getStyleClass().remove("action_box_valid");
getStyleClass().remove("action_box_valid");
getStyleClass().add("action_box_invalid");
getStyleClass().add("action_box_invalid");
}
}
else
else
{
{
getStyleClass().remove("action_box_invalid");
getStyleClass().remove("action_box_invalid");
getStyleClass().add("action_box_valid");
getStyleClass().add("action_box_valid");
}
}
}
}
public ActionDetailsPaneListener getActionDetailsPaneListener() {
public ActionDetailsPaneListener getActionDetailsPaneListener() {
return actionDetailsPaneListener;
return actionDetailsPaneListener;
}
}
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, ActionDetailsPaneListener actionDetailsPaneListener, ActionGridPaneListener actionGridPaneListener,
public ActionBox(int size, ActionDetailsPaneListener actionDetailsPaneListener, ActionGridPaneListener actionGridPaneListener,
int col, int row)
int col, int row)
{
{
this.actionGridPaneListener = actionGridPaneListener;
this.actionGridPaneListener = actionGridPaneListener;
this.actionDetailsPaneListener = actionDetailsPaneListener;
this.actionDetailsPaneListener = actionDetailsPaneListener;
this.size = size;
this.size = size;
this.col = col;
this.col = col;
this.row = row;
this.row = row;
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);
Action obj = (Action) ois.readObject();
Action obj = (Action) ois.readObject();
return obj;
return obj;
} 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)
{
{
removeFontIcon();
removeFontIcon();
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(null);
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, true
), 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(100, 100, true, true, true, false))
)
)
);
);
}
}
}
}
public void setDefaultToggleIcon(boolean isToggleOn)
public void setDefaultToggleIcon(boolean isToggleOn)
{
{
String styleClass;
String styleClass;
if(isToggleOn)
if(isToggleOn)
{
{
styleClass = "action_box_toggle_on";
styleClass = "action_box_toggle_on";
}
}
else
else
{
{
styleClass = "action_box_toggle_off";
styleClass = "action_box_toggle_off";
}
}
setBackground(null);
setBackground(null);
if(fontIcon!=null)
if(fontIcon!=null)
{
{
fontIcon.getStyleClass().clear();
fontIcon.getStyleClass().clear();
}
}
else
else
{
{
fontIcon = new FontIcon();
fontIcon = new FontIcon();
fontIcon.setIconSize((int) (size * 0.8));
fontIcon.setIconSize((int) (size * 0.8));
getChildren().add(fontIcon);
getChildren().add(fontIcon);
}
}
fontIcon.getStyleClass().add(styleClass);
fontIcon.getStyleClass().add(styleClass);
fontIcon.toBack();
fontIcon.toBack();
}
}
public void removeFontIcon()
public void removeFontIcon()
{
{
if(fontIcon!=null)
if(fontIcon!=null)
{
{
getChildren().remove(fontIcon);
getChildren().remove(fontIcon);
fontIcon = null;
fontIcon = null;
}
}
}
}
FontIcon fontIcon = null;
FontIcon fontIcon = null;
private Action action = null;
private Action action = null;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
public ActionBox(int size, Action action, ActionDetailsPaneListener actionDetailsPaneListener, ExceptionAndAlertHandler exceptionAndAlertHandler, ActionGridPaneListener actionGridPaneListener,
public ActionBox(int size, Action action, ActionDetailsPaneListener actionDetailsPaneListener, ExceptionAndAlertHandler exceptionAndAlertHandler, ActionGridPaneListener actionGridPaneListener,
int col, int row)
int col, int row)
{
{
this.actionGridPaneListener = actionGridPaneListener;
this.actionGridPaneListener = actionGridPaneListener;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.action = action;
this.action = action;
this.actionDetailsPaneListener = actionDetailsPaneListener;
this.actionDetailsPaneListener = actionDetailsPaneListener;
this.size = size;
this.size = size;
this.col = col;
this.col = col;
this.row = row;
this.row = row;
baseInit();
baseInit();
init();
init();
}
}
public Action getAction() {
public Action getAction() {
return action;
return action;
}
}
public void setAction(Action action)
public void setAction(Action action)
{
{
this.action = action;
this.action = action;
}
}
public void init()
public void init()
{
{
init(false);
init(false);
}
}
public void init(boolean start)
public void init(boolean start)
{
{
setBackground(null);
setBackground(null);
setStyle(null);
setStyle(null);
showToggleOffMenuItem.setVisible(getAction().getActionType() == ActionType.TOGGLE);
showToggleOffMenuItem.setVisible(getAction().getActionType() == ActionType.TOGGLE);
showToggleOnMenuItem.setVisible(getAction().getActionType() == ActionType.TOGGLE);
showToggleOnMenuItem.setVisible(getAction().getActionType() == ActionType.TOGGLE);
if(getAction().isShowDisplayText())
if(getAction().isShowDisplayText())
setDisplayTextLabel(getAction().getDisplayText());
setDisplayTextLabel(getAction().getDisplayText());
else
else
setDisplayTextLabel("");
setDisplayTextLabel("");
setDisplayTextAlignment(action.getDisplayTextAlignment());
setDisplayTextAlignment(action.getDisplayTextAlignment());
setBackgroundColour(action.getBgColourHex());
setBackgroundColour(action.getBgColourHex());
setDisplayTextFontColour(action.getDisplayTextFontColourHex());
setDisplayTextFontColour(action.getDisplayTextFontColourHex());
setInvalid(action.isInvalid());
setInvalid(action.isInvalid());
Platform.runLater(()->{
Platform.runLater(()->{
try {
try {
if(action.getActionType() == ActionType.TOGGLE)
if(action.getActionType() == ActionType.TOGGLE)
{
{
fakeToggle(start);
fakeToggle(start);
}
}
else
else
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
if(!action.getCurrentIconState().isBlank())
if(!action.getCurrentIconState().isBlank())
{
{
setIcon(action.getCurrentIcon());
setIcon(action.getCurrentIcon());
}
}
}
}
else
else
{
{
setIcon(null);
setIcon(null);
}
}
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
});
});
}
}
public void fakeToggle(boolean isON)
public void fakeToggle(boolean isON)
{
{
System.out.println("CURRENT ICONS : "+action.getCurrentIconState());
String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__");
String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__");
boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true");
boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true");
boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true");
boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true");
if(isON) // ON
if(isON) // ON
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on");
boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on");
if(isToggleOnPresent)
if(isToggleOnPresent)
{
{
if(isToggleOnHidden)
if(isToggleOnHidden)
{
{
setDefaultToggleIcon(true);
setDefaultToggleIcon(true);
}
}
else
else
{
{
setIcon(action.getIcons().get("toggle_on"));
setIcon(action.getIcons().get("toggle_on"));
}
}
}
}
else
else
{
{
setDefaultToggleIcon(true);
setDefaultToggleIcon(true);
}
}
}
}
else
else
{
{
setDefaultToggleIcon(true);
setDefaultToggleIcon(true);
}
}
}
}
else // OFF
else // OFF
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off");
boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off");
if(isToggleOffPresent)
if(isToggleOffPresent)
{
{
if(isToggleOffHidden)
if(isToggleOffHidden)
{
{
setDefaultToggleIcon(false);
setDefaultToggleIcon(false);
}
}
else
else
{
{
setIcon(action.getIcons().get("toggle_off"));
setIcon(action.getIcons().get("toggle_off"));
}
}
}
}
else
else
{
{
setDefaultToggleIcon(false);
setDefaultToggleIcon(false);
}
}
}
}
else
else
{
{
setDefaultToggleIcon(false);
setDefaultToggleIcon(false);
}
}
}
}
}
}
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("COLOr : "+colour);
if(!colour.isEmpty())
if(!colour.isEmpty())
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);
if(!colour.isEmpty())
if(!colour.isEmpty())
setStyle("-fx-background-color : "+colour);
setStyle("-fx-background-color : "+colour);
}
}
public void setSelected(boolean status)
public void setSelected(boolean status)
{
{
if(status)
if(status)
{
{
getStyleClass().add("action_box_selected");
getStyleClass().add("action_box_selected");
}
}
else
else
{
{
getStyleClass().remove("action_box_selected");
getStyleClass().remove("action_box_selected");
}
}
}
}
}
}
.root {
.root {
-fx-font-family : 'Roboto';
-fx-font-family : 'Roboto';
}
}
.about_donate_hyperlink
.about_donate_hyperlink
{
{
-fx-font-size : 19;
-fx-font-size : 19;
-fx-font-weight : bold;
-fx-font-weight : bold;
}
}
.plugins_settings_each_plugin_button_bar
.plugins_settings_each_plugin_button_bar
{
{
-fx-alignment:center-right;
-fx-alignment:center-right;
}
}
.about_license_label
.about_license_label
{
{
-fx-font-size : 16;
-fx-font-size : 16;
}
}
.theme_settings_each_theme_box, .plugins_settings_each_plugin_box, .clients_settings_each_client_box
.theme_settings_each_theme_box, .plugins_settings_each_plugin_box, .clients_settings_each_client_box
{
{
-fx-border-width : 0 0 1 0;
-fx-border-width : 0 0 1 0;
-fx-border-color : grey;
-fx-border-color : grey;
}
}
.plugins_settings_each_plugin_heading_label, .themes_settings_each_theme_heading, .client_settings_each_client_nick_name_label
.plugins_settings_each_plugin_heading_label, .themes_settings_each_theme_heading, .client_settings_each_client_nick_name_label
{
{
-fx-font-size : 19;
-fx-font-size : 19;
}
}
.action_box
.action_box
{
{
-fx-border-width: 1px;
-fx-border-width: 1px;
-fx-border-color : grey;
-fx-border-color : grey;
}
}
.action_box_icon_present
.action_box_icon_present
{
{
}
}
.action_box_icon_not_present
.action_box_icon_not_present
{
{
}
}
.action_box_valid
.action_box_valid
{
{
-fx-border-color: grey;
-fx-border-color: grey;
}
}
.action_box_invalid
.action_box_invalid
{
{
-fx-border-color: red;
-fx-border-color: red;
}
}
.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;
}
}
.action_details_pane_heading_label
.action_details_pane_heading_label
{
{
-fx-font-size : 16;
-fx-font-size : 16;
}
}
.client_settings_each_client_socket_connection_label
.client_settings_each_client_socket_connection_label
{
{
-fx-font-size : 16;
-fx-font-size : 16;
}
}
.general_settings{
.general_settings{
-fx-alignment : TOP_CENTER;
-fx-alignment : TOP_CENTER;
-fx-padding : 10;
-fx-padding : 10;
}
}
.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
.alert_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;*/
}
}
.plugins_pane
.plugins_pane
{
{
-fx-spacing: 5;
-fx-spacing: 5;
}
}
.plugins_pane_each_plugin_button_imageview
.plugins_pane_each_plugin_button_imageview
{
{
-fx-width:20;
-fx-width:20;
-fx-height:20;
-fx-height:20;
}
}
.about_donate_hyperlink
.about_donate_hyperlink
{
{
-fx-padding : 10 0 0 0;
-fx-padding : 10 0 0 0;
-fx-font-size : 25;
-fx-font-size : 25;
}
}
.first_time_use_pane
.first_time_use_pane
{
{
-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_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
{
{
-fx-padding: 0 0 30 0;
-fx-padding: 0 0 30 0;
}
}
.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;
}
}
.plugins_settings_scroll_pane, .themes_settings_scroll_pane, .clients_settings_scroll_pane
.plugins_settings_scroll_pane, .themes_settings_scroll_pane, .clients_settings_scroll_pane
{
{
-fx-padding: 10 0 0 0;
-fx-padding: 10 0 0 0;
}
}
.plugins_settings_each_plugin_box, .theme_settings_each_theme_box, .clients_settings_each_client_box
.plugins_settings_each_plugin_box, .theme_settings_each_theme_box, .clients_settings_each_client_box
{
{
-fx-spacing : 5;
-fx-spacing : 5;
-fx-padding : 10 0 10 0;
-fx-padding : 10 0 10 0;
}
}
.plugins_pane_each_plugin_box_parent, .plugins_pane_each_plugin_box
.plugins_pane_each_plugin_box_parent, .plugins_pane_each_plugin_box
{
{
-fx-spacing : 5;
-fx-spacing : 5;
}
}
.about
.about
{
{
-fx-spacing : 5;
-fx-spacing : 5;
}
}
.about_links_box
.about_links_box
{
{
-fx-spacing : 15;
-fx-spacing : 15;
}
}
.action_details_pane_delete_button
.action_details_pane_delete_button
{
{
-fx-text-fill : red;
-fx-text-fill : red;
}
}
.action_details_pane_reset_button
.action_details_pane_reset_button
{
{
-fx-text-fill : orange;
-fx-text-fill : orange;
}
}
.client_and_profile_selector_pane_stack
.client_and_profile_selector_pane_stack
{
{
-fx-spacing: 5;
-fx-spacing: 5;
}
}
.plugins_settings, .themes_settings, .clients_settings
.plugins_settings, .themes_settings, .clients_settings
{
{
-fx-padding: 0 10 0 0;
-fx-padding: 0 10 0 0;
}
}
/*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;
}
}
.split-pane-divider {
.split-pane-divider {
-fx-padding: 2;
-fx-padding: 2;
}
}
.separator_ui_label
.separator_ui_label
{
{
-fx-text-fill: grey;
-fx-text-fill: grey;
}
}
.about_license_contributors_disclaimer_label
.about_license_contributors_disclaimer_label
{
{
-fx-min-height : 50;
-fx-min-height : 50;
}
}
.action_box_selected
.action_box_selected
{
{
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 10, 0.5, 0.0, 0.0);
-fx-border-width: 4;
-fx-border-color:orange;
}
}