server
Clone or download
Modified Files
package com.stream_pi.server.window.dashboard.actiondetailpane;
package com.stream_pi.server.window.dashboard.actiondetailpane;
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.actionproperty.property.ControlType;
import com.stream_pi.action_api.actionproperty.property.ControlType;
import com.stream_pi.action_api.actionproperty.property.FileExtensionFilter;
import com.stream_pi.action_api.actionproperty.property.FileExtensionFilter;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.externalplugin.ExternalPlugin;
import com.stream_pi.action_api.externalplugin.ExternalPlugin;
import com.stream_pi.action_api.otheractions.CombineAction;
import com.stream_pi.action_api.otheractions.CombineAction;
import com.stream_pi.action_api.otheractions.FolderAction;
import com.stream_pi.action_api.otheractions.FolderAction;
import com.stream_pi.server.uipropertybox.UIPropertyBox;
import com.stream_pi.server.uipropertybox.UIPropertyBox;
import com.stream_pi.server.client.Client;
import com.stream_pi.server.client.Client;
import com.stream_pi.server.client.ClientProfile;
import com.stream_pi.server.client.ClientProfile;
import com.stream_pi.server.connection.ClientConnection;
import com.stream_pi.server.connection.ClientConnection;
import com.stream_pi.server.connection.ClientConnections;
import com.stream_pi.server.connection.ClientConnections;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.controller.ActionDataFormats;
import com.stream_pi.server.controller.ActionDataFormats;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionGridPaneListener;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionGridPaneListener;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBoxWithFileChooser;
import com.stream_pi.util.uihelper.HBoxInputBoxWithFileChooser;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.collections.FXCollections;
import javafx.collections.FXCollections;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.*;
import javafx.scene.input.Dragboard;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser;
import javafx.stage.Window;
import javafx.stage.Window;
import javafx.util.Callback;
import javafx.util.Callback;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.io.File;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.logging.Logger;
public class ActionDetailsPane extends VBox implements ActionDetailsPaneListener
public class ActionDetailsPane extends VBox implements ActionDetailsPaneListener
{
{
private ScrollPane scrollPane;
private ScrollPane scrollPane;
private VBox vbox;
private VBox vbox;
private VBox clientPropertiesVBox;
private VBox clientPropertiesVBox;
private Button saveButton;
private Button saveButton;
private Button deleteButton;
private Button deleteButton;
private Button openFolderButton;
private Button openFolderButton;
private Button resetToDefaultsFolderButton;
private Button resetToDefaultsFolderButton;
private HBox buttonBar;
private HBox buttonBar;
private VBox pluginExtraButtonBar;
private VBox pluginExtraButtonBar;
private Label actionHeadingLabel;
private Label actionHeadingLabel;
private Logger logger;
private Logger logger;
private Button returnButtonForCombineActionChild;
private Button returnButtonForCombineActionChild;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private HostServices hostServices;
private HostServices hostServices;
private ActionGridPaneListener actionGridPaneListener;
private ActionGridPaneListener actionGridPaneListener;
public ActionDetailsPane(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices,
public ActionDetailsPane(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices,
ActionGridPaneListener actionGridPaneListener)
ActionGridPaneListener actionGridPaneListener)
{
{
this.hostServices = hostServices;
this.hostServices = hostServices;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.actionGridPaneListener = actionGridPaneListener;
this.actionGridPaneListener = actionGridPaneListener;
logger = Logger.getLogger(ActionDetailsPane.class.getName());
logger = Logger.getLogger(ActionDetailsPane.class.getName());
setSpacing(10.0);
setSpacing(10.0);
clientPropertiesVBox = new VBox();
clientPropertiesVBox = new VBox();
clientPropertiesVBox.setSpacing(10.0);
clientPropertiesVBox.setSpacing(10.0);
vbox = new VBox();
vbox = new VBox();
vbox.setPadding(new Insets(0, 25, 0, 5));
vbox.setPadding(new Insets(0, 25, 0, 5));
vbox.getStyleClass().add("action_details_pane_vbox");
vbox.getStyleClass().add("action_details_pane_vbox");
vbox.setSpacing(10.0);
vbox.setSpacing(10.0);
pluginExtraButtonBar = new VBox();
pluginExtraButtonBar = new VBox();
pluginExtraButtonBar.setSpacing(10.0);
pluginExtraButtonBar.setSpacing(10.0);
getStyleClass().add("action_details_pane");
getStyleClass().add("action_details_pane");
scrollPane = new ScrollPane();
scrollPane = new ScrollPane();
VBox.setMargin(scrollPane, new Insets(0, 0, 0, 10));
VBox.setMargin(scrollPane, new Insets(0, 0, 0, 10));
scrollPane.getStyleClass().add("action_details_pane_scroll_pane");
scrollPane.getStyleClass().add("action_details_pane_scroll_pane");
setMinHeight(210);
setMinHeight(210);
scrollPane.setContent(vbox);
scrollPane.setContent(vbox);
vbox.prefWidthProperty().bind(scrollPane.widthProperty());
vbox.prefWidthProperty().bind(scrollPane.widthProperty());
scrollPane.prefWidthProperty().bind(widthProperty());
scrollPane.prefWidthProperty().bind(widthProperty());
VBox.setVgrow(scrollPane, Priority.ALWAYS);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
openFolderButton = new Button("Open Folder");
openFolderButton = new Button("Open Folder");
openFolderButton.managedProperty().bind(openFolderButton.visibleProperty());
openFolderButton.managedProperty().bind(openFolderButton.visibleProperty());
FontIcon folderOpenIcon = new FontIcon("far-folder-open");
FontIcon folderOpenIcon = new FontIcon("far-folder-open");
openFolderButton.setGraphic(folderOpenIcon);
openFolderButton.setGraphic(folderOpenIcon);
openFolderButton.setOnAction(event -> onOpenFolderButtonClicked());
openFolderButton.setOnAction(event -> onOpenFolderButtonClicked());
saveButton = new Button("Apply Changes");
saveButton = new Button("Apply Changes");
saveButton.getStyleClass().add("action_details_pane_save_button");
saveButton.getStyleClass().add("action_details_pane_save_button");
FontIcon syncIcon = new FontIcon("far-save");
FontIcon syncIcon = new FontIcon("far-save");
syncIcon.getStyleClass().add("action_details_save_delete_button_icon");
syncIcon.getStyleClass().add("action_details_save_delete_button_icon");
saveButton.setGraphic(syncIcon);
saveButton.setGraphic(syncIcon);
saveButton.setOnAction(event -> onSaveButtonClicked());
saveButton.setOnAction(event -> onSaveButtonClicked());
deleteButton = new Button("Delete action");
deleteButton = new Button("Delete action");
deleteButton.getStyleClass().add("action_details_pane_delete_button");
deleteButton.getStyleClass().add("action_details_pane_delete_button");
FontIcon deleteIcon = new FontIcon("fas-trash");
FontIcon deleteIcon = new FontIcon("fas-trash");
deleteIcon.getStyleClass().add("action_details_pane_delete_button_icon");
deleteIcon.getStyleClass().add("action_details_pane_delete_button_icon");
deleteButton.setGraphic(deleteIcon);
deleteButton.setGraphic(deleteIcon);
deleteButton.setOnAction(event -> onDeleteButtonClicked());
deleteButton.setOnAction(event -> onDeleteButtonClicked());
resetToDefaultsFolderButton = new Button("Reset");
resetToDefaultsFolderButton = new Button("Reset");
resetToDefaultsFolderButton.managedProperty().bind(resetToDefaultsFolderButton.visibleProperty());
resetToDefaultsFolderButton.managedProperty().bind(resetToDefaultsFolderButton.visibleProperty());
resetToDefaultsFolderButton.getStyleClass().add("action_details_pane_reset_button");
resetToDefaultsFolderButton.getStyleClass().add("action_details_pane_reset_button");
FontIcon resetToDefaultsIcon = new FontIcon("fas-sync-alt");
FontIcon resetToDefaultsIcon = new FontIcon("fas-sync-alt");
resetToDefaultsIcon.getStyleClass().add("action_details_pane_reset_button_icon");
resetToDefaultsIcon.getStyleClass().add("action_details_pane_reset_button_icon");
resetToDefaultsFolderButton.setGraphic(resetToDefaultsIcon);
resetToDefaultsFolderButton.setGraphic(resetToDefaultsIcon);
resetToDefaultsFolderButton.setOnAction(event -> onResetToDefaultsButtonClicked());
resetToDefaultsFolderButton.setOnAction(event -> onResetToDefaultsButtonClicked());
returnButtonForCombineActionChild = new Button("Return");
returnButtonForCombineActionChild = new Button("Return");
returnButtonForCombineActionChild.setGraphic(new FontIcon("fas-caret-left"));
returnButtonForCombineActionChild.setGraphic(new FontIcon("fas-caret-left"));
returnButtonForCombineActionChild.managedProperty().bind(returnButtonForCombineActionChild.visibleProperty());
returnButtonForCombineActionChild.managedProperty().bind(returnButtonForCombineActionChild.visibleProperty());
returnButtonForCombineActionChild.setOnAction(event -> {
returnButtonForCombineActionChild.setOnAction(event -> {
try {
try {
logger.info("@@## : " + getAction().getParent());
logger.info("@@## : " + getAction().getParent());
onActionClicked(getClientProfile().getActionByID(getAction().getParent()), getActionBox());
onActionClicked(getClientProfile().getActionByID(getAction().getParent()), getActionBox());
} catch (MinorException e) {
} catch (MinorException e) {
e.printStackTrace();
e.printStackTrace();
}
}
});
});
buttonBar = new HBox(openFolderButton, resetToDefaultsFolderButton, returnButtonForCombineActionChild, saveButton, deleteButton);
buttonBar = new HBox(openFolderButton, resetToDefaultsFolderButton, returnButtonForCombineActionChild, saveButton, deleteButton);
buttonBar.getStyleClass().add("action_details_pane_button_bar");
buttonBar.getStyleClass().add("action_details_pane_button_bar");
buttonBar.setPadding(new Insets(10, 10, 10, 0));
buttonBar.setPadding(new Insets(10, 10, 10, 0));
buttonBar.setAlignment(Pos.CENTER_RIGHT);
buttonBar.setAlignment(Pos.CENTER_RIGHT);
buttonBar.setVisible(false);
buttonBar.setVisible(false);
buttonBar.setSpacing(10.0);
buttonBar.setSpacing(10.0);
actionHeadingLabel = new Label();
actionHeadingLabel = new Label();
actionHeadingLabel.getStyleClass().add("action_details_pane_heading_label");
actionHeadingLabel.getStyleClass().add("action_details_pane_heading_label");
HBox headingHBox = new HBox(actionHeadingLabel);
HBox headingHBox = new HBox(actionHeadingLabel);
headingHBox.getStyleClass().add("action_details_pane_heading_box");
headingHBox.getStyleClass().add("action_details_pane_heading_box");
headingHBox.setPadding(new Insets(5, 10, 0, 10));
headingHBox.setPadding(new Insets(5, 10, 0, 10));
getChildren().addAll(headingHBox, scrollPane, buttonBar);
getChildren().addAll(headingHBox, scrollPane, buttonBar);
displayTextAlignmentComboBox = new ComboBox<>(FXCollections.observableArrayList(DisplayTextAlignment.TOP,
displayTextAlignmentComboBox = new ComboBox<>(FXCollections.observableArrayList(DisplayTextAlignment.TOP,
DisplayTextAlignment.CENTER, DisplayTextAlignment.BOTTOM));
DisplayTextAlignment.CENTER, DisplayTextAlignment.BOTTOM));
displayTextAlignmentComboBox.managedProperty().bind(displayTextAlignmentComboBox.visibleProperty());
displayTextAlignmentComboBox.managedProperty().bind(displayTextAlignmentComboBox.visibleProperty());
Callback<ListView<DisplayTextAlignment>, ListCell<DisplayTextAlignment>> displayTextAlignmentComboBoxFactory = new Callback<>() {
Callback<ListView<DisplayTextAlignment>, ListCell<DisplayTextAlignment>> displayTextAlignmentComboBoxFactory = new Callback<>() {
@Override
@Override
public ListCell<DisplayTextAlignment> call(ListView<DisplayTextAlignment> displayTextAlignment) {
public ListCell<DisplayTextAlignment> call(ListView<DisplayTextAlignment> displayTextAlignment) {
return new ListCell<>() {
return new ListCell<>() {
@Override
@Override
protected void updateItem(DisplayTextAlignment displayTextAlignment, boolean b) {
protected void updateItem(DisplayTextAlignment displayTextAlignment, boolean b) {
super.updateItem(displayTextAlignment, b);
super.updateItem(displayTextAlignment, b);
if (displayTextAlignment != null) {
if (displayTextAlignment != null) {
setText(displayTextAlignment.getUIName());
setText(displayTextAlignment.getUIName());
}
}
}
}
};
};
}
}
};
};
displayTextAlignmentComboBox.setCellFactory(displayTextAlignmentComboBoxFactory);
displayTextAlignmentComboBox.setCellFactory(displayTextAlignmentComboBoxFactory);
displayTextAlignmentComboBox.setButtonCell(displayTextAlignmentComboBoxFactory.call(null));
displayTextAlignmentComboBox.setButtonCell(displayTextAlignmentComboBoxFactory.call(null));
actionClientProperties = new ArrayList<>();
actionClientProperties = new ArrayList<>();
displayNameTextField = new TextField();
displayNameTextField = new TextField();
displayNameTextField.managedProperty().bind(displayNameTextField.visibleProperty());
displayNameTextField.managedProperty().bind(displayNameTextField.visibleProperty());
defaultIconFileTextField = new TextField();
defaultIconFileTextField = new TextField();
defaultIconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
defaultIconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
try {
try {
if (!s.equals(t1) && t1.length() > 0) {
if (!s.equals(t1) && t1.length() > 0) {
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
hideDefaultIconCheckBox.setDisable(false);
hideDefaultIconCheckBox.setDisable(false);
hideDefaultIconCheckBox.setSelected(false);
hideDefaultIconCheckBox.setSelected(false);
clearIconButton.setDisable(false);
clearIconButton.setDisable(false);
getAction().addIcon("default", iconFileByteArray);
getAction().addIcon("default", iconFileByteArray);
getAction().setCurrentIconState("default");
getAction().setCurrentIconState("default");
setSendIcon(true);
setSendIcon(true);
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
}
}
});
});
toggleOffIconFileTextField = new TextField();
toggleOffIconFileTextField = new TextField();
toggleOffIconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
toggleOffIconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
try {
try {
if (!s.equals(t1) && t1.length() > 0) {
if (!s.equals(t1) && t1.length() > 0) {
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
hideToggleOffIconCheckBox.setDisable(false);
hideToggleOffIconCheckBox.setDisable(false);
hideToggleOffIconCheckBox.setSelected(false);
hideToggleOffIconCheckBox.setSelected(false);
clearIconButton.setDisable(false);
clearIconButton.setDisable(false);
getAction().addIcon("toggle_off", iconFileByteArray);
getAction().addIcon("toggle_off", iconFileByteArray);
setSendIcon(true);
setSendIcon(true);
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
}
}
});
});
toggleOnIconFileTextField = new TextField();
toggleOnIconFileTextField = new TextField();
toggleOnIconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
toggleOnIconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
try {
try {
if (!s.equals(t1) && t1.length() > 0) {
if (!s.equals(t1) && t1.length() > 0) {
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
hideToggleOnIconCheckBox.setDisable(false);
hideToggleOnIconCheckBox.setDisable(false);
hideToggleOnIconCheckBox.setSelected(false);
hideToggleOnIconCheckBox.setSelected(false);
clearIconButton.setDisable(false);
clearIconButton.setDisable(false);
getAction().addIcon("toggle_on", iconFileByteArray);
getAction().addIcon("toggle_on", iconFileByteArray);
setSendIcon(true);
setSendIcon(true);
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
}
}
});
});
clearIconButton = new Button("Clear Icon");
clearIconButton = new Button("Clear Icon");
clearIconButton.managedProperty().bind(clearIconButton.visibleProperty());
clearIconButton.managedProperty().bind(clearIconButton.visibleProperty());
clearIconButton.setOnAction(event -> {
clearIconButton.setOnAction(event -> {
hideDefaultIconCheckBox.setDisable(true);
hideDefaultIconCheckBox.setDisable(true);
hideDefaultIconCheckBox.setSelected(false);
hideDefaultIconCheckBox.setSelected(false);
hideToggleOffIconCheckBox.setDisable(true);
hideToggleOffIconCheckBox.setDisable(true);
hideToggleOffIconCheckBox.setSelected(false);
hideToggleOffIconCheckBox.setSelected(false);
hideToggleOnIconCheckBox.setDisable(true);
hideToggleOnIconCheckBox.setDisable(true);
hideToggleOnIconCheckBox.setSelected(false);
hideToggleOnIconCheckBox.setSelected(false);
clearIconButton.setDisable(true);
clearIconButton.setDisable(true);
setSendIcon(false);
setSendIcon(false);
defaultIconFileTextField.clear();
defaultIconFileTextField.clear();
toggleOffIconFileTextField.clear();
toggleOffIconFileTextField.clear();
toggleOnIconFileTextField.clear();
toggleOnIconFileTextField.clear();
});
});
hideDisplayTextCheckBox = new CheckBox("Hide");
hideDisplayTextCheckBox = new CheckBox("Hide");
hideDisplayTextCheckBox.managedProperty().bind(hideDisplayTextCheckBox.visibleProperty());
hideDisplayTextCheckBox.managedProperty().bind(hideDisplayTextCheckBox.visibleProperty());
hideDefaultIconCheckBox = new CheckBox("Hide");
hideDefaultIconCheckBox = new CheckBox("Hide");
hideToggleOnIconCheckBox = new CheckBox("Hide");
hideToggleOnIconCheckBox = new CheckBox("Hide");
hideToggleOffIconCheckBox = new CheckBox("Hide");
hideToggleOffIconCheckBox = new CheckBox("Hide");
actionBackgroundColourPicker = new ColorPicker();
actionBackgroundColourPicker = new ColorPicker();
actionBackgroundColourPicker.managedProperty().bind(actionBackgroundColourPicker.visibleProperty());
actionBackgroundColourPicker.managedProperty().bind(actionBackgroundColourPicker.visibleProperty());
displayTextColourPicker = new ColorPicker();
displayTextColourPicker = new ColorPicker();
displayTextColourPicker.managedProperty().bind(displayTextColourPicker.visibleProperty());
displayTextColourPicker.managedProperty().bind(displayTextColourPicker.visibleProperty());
actionBackgroundColourTransparentCheckBox = new CheckBox("Default");
actionBackgroundColourTransparentCheckBox = new CheckBox("Default");
actionBackgroundColourPicker.disableProperty()
actionBackgroundColourPicker.disableProperty()
.bind(actionBackgroundColourTransparentCheckBox.selectedProperty());
.bind(actionBackgroundColourTransparentCheckBox.selectedProperty());
HBox.setMargin(actionBackgroundColourTransparentCheckBox, new Insets(0, 0, 0, 10));
HBox.setMargin(actionBackgroundColourTransparentCheckBox, new Insets(0, 0, 0, 10));
displayTextColourDefaultCheckBox = new CheckBox("Default");
displayTextColourDefaultCheckBox = new CheckBox("Default");
displayTextColourPicker.disableProperty()
displayTextColourPicker.disableProperty()
.bind(displayTextColourDefaultCheckBox.selectedProperty());
.bind(displayTextColourDefaultCheckBox.selectedProperty());
HBox.setMargin(displayTextColourDefaultCheckBox, new Insets(0, 0, 0, 10));
HBox.setMargin(displayTextColourDefaultCheckBox, new Insets(0, 0, 0, 10));
HBox displayTextColourHBox = new HBox(new Label("Display Text Colour"), SpaceFiller.horizontal(), displayTextColourPicker,
HBox displayTextColourHBox = new HBox(new Label("Display Text Colour"), SpaceFiller.horizontal(), displayTextColourPicker,
displayTextColourDefaultCheckBox);
displayTextColourDefaultCheckBox);
displayTextColourHBox.setAlignment(Pos.CENTER);
displayTextColourHBox.setAlignment(Pos.CENTER);
displayTextColourHBox.setSpacing(5.0);
displayTextColourHBox.setSpacing(5.0);
HBox bgColourHBox = new HBox(new Label("Background Colour"), SpaceFiller.horizontal(), actionBackgroundColourPicker,
HBox bgColourHBox = new HBox(new Label("Background Colour"), SpaceFiller.horizontal(), actionBackgroundColourPicker,
actionBackgroundColourTransparentCheckBox);
actionBackgroundColourTransparentCheckBox);
bgColourHBox.setAlignment(Pos.CENTER);
bgColourHBox.setAlignment(Pos.CENTER);
bgColourHBox.setSpacing(5.0);
bgColourHBox.setSpacing(5.0);
HBox clearIconHBox = new HBox(clearIconButton);
HBox clearIconHBox = new HBox(clearIconButton);
clearIconHBox.setAlignment(Pos.CENTER_RIGHT);
clearIconHBox.setAlignment(Pos.CENTER_RIGHT);
displayTextFieldHBox = new HBoxInputBox("Display Name", displayNameTextField, hideDisplayTextCheckBox);
displayTextFieldHBox = new HBoxInputBox("Display Name", displayNameTextField, hideDisplayTextCheckBox);
HBox alignmentHBox = new HBox(new Label("Alignment"), SpaceFiller.horizontal(),
HBox alignmentHBox = new HBox(new Label("Alignment"), SpaceFiller.horizontal(),
displayTextAlignmentComboBox);
displayTextAlignmentComboBox);
normalToggleActionCommonPropsVBox = new VBox(
normalToggleActionCommonPropsVBox = new VBox(
displayTextColourHBox,
displayTextColourHBox,
alignmentHBox,
alignmentHBox,
bgColourHBox,
bgColourHBox,
clearIconHBox
clearIconHBox
);
);
normalToggleActionCommonPropsVBox.managedProperty().bind(normalToggleActionCommonPropsVBox.visibleProperty());
normalToggleActionCommonPropsVBox.managedProperty().bind(normalToggleActionCommonPropsVBox.visibleProperty());
normalToggleActionCommonPropsVBox.setSpacing(10.0);
normalToggleActionCommonPropsVBox.setSpacing(10.0);
normalActionsPropsVBox = new VBox(
normalActionsPropsVBox = new VBox(
new HBoxInputBoxWithFileChooser("Icon", defaultIconFileTextField, hideDefaultIconCheckBox,
new HBoxInputBoxWithFileChooser("Icon", defaultIconFileTextField, hideDefaultIconCheckBox,
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif"))
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif"))
);
);
normalActionsPropsVBox.managedProperty().bind(normalActionsPropsVBox.visibleProperty());
normalActionsPropsVBox.managedProperty().bind(normalActionsPropsVBox.visibleProperty());
normalActionsPropsVBox.setSpacing(10.0);
normalActionsPropsVBox.setSpacing(10.0);
toggleActionsPropsVBox = new VBox(
toggleActionsPropsVBox = new VBox(
new HBoxInputBoxWithFileChooser("Toggle Off Icon", toggleOffIconFileTextField, hideToggleOffIconCheckBox,
new HBoxInputBoxWithFileChooser("Toggle Off Icon", toggleOffIconFileTextField, hideToggleOffIconCheckBox,
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif")),
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif")),
new HBoxInputBoxWithFileChooser("Toggle On Icon", toggleOnIconFileTextField, hideToggleOnIconCheckBox,
new HBoxInputBoxWithFileChooser("Toggle On Icon", toggleOnIconFileTextField, hideToggleOnIconCheckBox,
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif"))
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif"))
);
);
toggleActionsPropsVBox.managedProperty().bind(toggleActionsPropsVBox.visibleProperty());
toggleActionsPropsVBox.managedProperty().bind(toggleActionsPropsVBox.visibleProperty());
toggleActionsPropsVBox.setSpacing(10.0);
toggleActionsPropsVBox.setSpacing(10.0);
vbox.getChildren().addAll(displayTextFieldHBox,normalToggleActionCommonPropsVBox,
vbox.getChildren().addAll(displayTextFieldHBox,normalToggleActionCommonPropsVBox,
normalActionsPropsVBox, toggleActionsPropsVBox, clientPropertiesVBox,
normalActionsPropsVBox, toggleActionsPropsVBox, clientPropertiesVBox,
pluginExtraButtonBar);
pluginExtraButtonBar);
vbox.setVisible(false);
vbox.setVisible(false);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
setOnDragOver(dragEvent -> {
setOnDragOver(dragEvent -> {
if (dragEvent.getDragboard().hasContent(ActionDataFormats.ACTION_TYPE) && action != null) {
if (dragEvent.getDragboard().hasContent(ActionDataFormats.ACTION_TYPE) && action != null) {
if (getAction().getActionType() == ActionType.COMBINE) {
if (getAction().getActionType() == ActionType.COMBINE) {
dragEvent.acceptTransferModes(TransferMode.ANY);
dragEvent.acceptTransferModes(TransferMode.ANY);
dragEvent.consume();
dragEvent.consume();
}
}
}
}
});
});
setOnDragDropped(dragEvent -> {
setOnDragDropped(dragEvent -> {
try {
try {
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)
{
{
ExternalPlugin newAction = actionGridPaneListener.createNewActionFromExternalPlugin(
ExternalPlugin newAction = actionGridPaneListener.createNewActionFromExternalPlugin(
(String) db.getContent(ActionDataFormats.MODULE_NAME)
(String) db.getContent(ActionDataFormats.MODULE_NAME)
);
);
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.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(-1, -1));
newAction.setLocation(new Location(-1, -1));
newAction.setParent(getAction().getID());
newAction.setParent(getAction().getID());
newAction.setProfileID(actionGridPaneListener.getCurrentProfile().getID());
newAction.setProfileID(actionGridPaneListener.getCurrentProfile().getID());
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 "+getAction().getModuleName()+"\n\n"+e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException("Error","onCreate() failed for "+getAction().getModuleName()+"\n\n"+e.getMessage()));
}
}
combineActionPropertiesPane.getCombineAction().addChild(newAction.getID());
combineActionPropertiesPane.getCombineAction().addChild(newAction.getID());
addActionToCurrentClientProfile(newAction);
addActionToCurrentClientProfile(newAction);
ClientConnection connection = ClientConnections.getInstance()
ClientConnection connection = ClientConnections.getInstance()
.getClientConnectionBySocketAddress(getClient().getRemoteSocketAddress());
.getClientConnectionBySocketAddress(getClient().getRemoteSocketAddress());
connection.saveActionDetails(getClientProfile().getID(), newAction);
connection.saveActionDetails(getClientProfile().getID(), newAction);
combineActionPropertiesPane.renderProps();
combineActionPropertiesPane.renderProps();
saveAction(true, false);
saveAction(true, false);
}
}
} catch (MinorException e) {
} catch (MinorException e) {
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
e.printStackTrace();
e.printStackTrace();
} catch (SevereException e) {
} catch (SevereException e) {
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
e.printStackTrace();
e.printStackTrace();
} catch (CloneNotSupportedException e) {
} catch (CloneNotSupportedException e) {
e.printStackTrace();
e.printStackTrace();
} catch (Exception e)
} catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
});
});
}
}
private void onResetToDefaultsButtonClicked()
private void onResetToDefaultsButtonClicked()
{
{
getAction().getClientProperties().resetToDefaults();
getAction().getClientProperties().resetToDefaults();
try
try
{
{
onActionClicked(getAction(), getActionBox());
onActionClicked(getAction(), getActionBox());
saveAction(true, true);
saveAction(true, true);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
private VBox normalActionsPropsVBox;
private VBox normalActionsPropsVBox;
private VBox normalToggleActionCommonPropsVBox;
private VBox normalToggleActionCommonPropsVBox;
private VBox toggleActionsPropsVBox;
private VBox toggleActionsPropsVBox;
private HBox displayTextFieldHBox;
private HBox displayTextFieldHBox;
private ClientConnection clientConnection;
private ClientConnection clientConnection;
private ClientProfile clientProfile;
private ClientProfile clientProfile;
public void setClientConnection(ClientConnection clientConnection) {
public void setClientConnection(ClientConnection clientConnection) {
this.clientConnection = clientConnection;
this.clientConnection = clientConnection;
}
}
public ClientConnection getClientConnection() {
public ClientConnection getClientConnection() {
return clientConnection;
return clientConnection;
}
}
public Client getClient()
public Client getClient()
{
{
return getClientConnection().getClient();
return getClientConnection().getClient();
}
}
public void setClientProfile(ClientProfile clientProfile) {
public void setClientProfile(ClientProfile clientProfile) {
this.clientProfile = clientProfile;
this.clientProfile = clientProfile;
}
}
public ClientProfile getClientProfile() {
public ClientProfile getClientProfile() {
return clientProfile;
return clientProfile;
}
}
public void setActionHeadingLabelText(String text) {
public void setActionHeadingLabelText(String text) {
actionHeadingLabel.setText(text);
actionHeadingLabel.setText(text);
}
}
private Action action;
private Action action;
public synchronized Action getAction() {
public synchronized Action getAction() {
return action;
return action;
}
}
private ActionBox actionBox;
private ActionBox actionBox;
public ActionBox getActionBox() {
public ActionBox getActionBox() {
return actionBox;
return actionBox;
}
}
@Override
@Override
public void onActionClicked(Action action, ActionBox actionBox) throws MinorException
public void onActionClicked(Action action, ActionBox actionBox) throws MinorException
{
{
clear();
clear();
setAction(action);
setAction(action);
this.actionBox = actionBox;
this.actionBox = actionBox;
renderActionProperties();
renderActionProperties();
}
}
public void refresh()
public void refresh()
{
{
clear(false);
clear(false);
try
try
{
{
renderActionProperties();
renderActionProperties();
}
}
catch (MinorException e)
catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
private TextField displayNameTextField;
private TextField displayNameTextField;
private CheckBox hideDisplayTextCheckBox;
private CheckBox hideDisplayTextCheckBox;
private CheckBox hideDefaultIconCheckBox;
private CheckBox hideDefaultIconCheckBox;
private TextField defaultIconFileTextField;
private TextField defaultIconFileTextField;
private CheckBox hideToggleOnIconCheckBox;
private CheckBox hideToggleOnIconCheckBox;
private TextField toggleOnIconFileTextField;
private TextField toggleOnIconFileTextField;
private CheckBox hideToggleOffIconCheckBox;
private CheckBox hideToggleOffIconCheckBox;
private TextField toggleOffIconFileTextField;
private TextField toggleOffIconFileTextField;
private Button clearIconButton;
private Button clearIconButton;
private ColorPicker actionBackgroundColourPicker;
private ColorPicker actionBackgroundColourPicker;
private ColorPicker displayTextColourPicker;
private ColorPicker displayTextColourPicker;
private CheckBox actionBackgroundColourTransparentCheckBox;
private CheckBox actionBackgroundColourTransparentCheckBox;
private CheckBox displayTextColourDefaultCheckBox;
private CheckBox displayTextColourDefaultCheckBox;
private ComboBox<DisplayTextAlignment> displayTextAlignmentComboBox;
private ComboBox<DisplayTextAlignment> displayTextAlignmentComboBox;
public void clear(boolean actionNull)
public void clear(boolean actionNull)
{
{
sendIcon = false;
sendIcon = false;
actionClientProperties.clear();
actionClientProperties.clear();
displayNameTextField.clear();
displayNameTextField.clear();
defaultIconFileTextField.clear();
defaultIconFileTextField.clear();
toggleOffIconFileTextField.clear();
toggleOffIconFileTextField.clear();
toggleOnIconFileTextField.clear();
toggleOnIconFileTextField.clear();
clientPropertiesVBox.getChildren().clear();
clientPropertiesVBox.getChildren().clear();
pluginExtraButtonBar.getChildren().clear();
pluginExtraButtonBar.getChildren().clear();
vbox.setVisible(false);
vbox.setVisible(false);
normalActionsPropsVBox.setVisible(false);
normalActionsPropsVBox.setVisible(false);
toggleActionsPropsVBox.setVisible(false);
toggleActionsPropsVBox.setVisible(false);
saveButton.setVisible(false);
saveButton.setVisible(false);
openFolderButton.setVisible(false);
openFolderButton.setVisible(false);
resetToDefaultsFolderButton.setVisible(false);
resetToDefaultsFolderButton.setVisible(false);
returnButtonForCombineActionChild.setVisible(false);
returnButtonForCombineActionChild.setVisible(false);
clearIconButton.setVisible(false);
clearIconButton.setVisible(false);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
buttonBar.setVisible(false);
buttonBar.setVisible(false);
setActionHeadingLabelText("");
setActionHeadingLabelText("");
actionBackgroundColourPicker.setValue(Color.WHITE);
actionBackgroundColourPicker.setValue(Color.WHITE);
displayTextColourPicker.setValue(Color.WHITE);
displayTextColourPicker.setValue(Color.WHITE);
if(actionNull)
if(actionNull)
{
{
action = null;
action = null;
actionBox = null;
actionBox = null;
}
}
}
}
@Override
@Override
public void clear()
public void clear()
{
{
clear(true);
clear(true);
}
}
boolean isCombineChild = false;
boolean isCombineChild = false;
public boolean isCombineChild() {
public boolean isCombineChild() {
return isCombineChild;
return isCombineChild;
}
}
public void renderActionProperties() throws MinorException
public void renderActionProperties() throws MinorException
{
{
//Combine Child action
//Combine Child action
isCombineChild = getAction().getLocation().getCol() == -1;
isCombineChild = getAction().getLocation().getCol() == -1;
displayNameTextField.setText(getAction().getDisplayText());
displayNameTextField.setText(getAction().getDisplayText());
vbox.setVisible(true);
vbox.setVisible(true);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
buttonBar.setVisible(true);
buttonBar.setVisible(true);
displayTextAlignmentComboBox.getSelectionModel().select(getAction().getDisplayTextAlignment());
displayTextAlignmentComboBox.getSelectionModel().select(getAction().getDisplayTextAlignment());
if(!getAction().getBgColourHex().isEmpty())
if(!getAction().getBgColourHex().isEmpty())
actionBackgroundColourPicker.setValue(Color.valueOf(getAction().getBgColourHex()));
actionBackgroundColourPicker.setValue(Color.valueOf(getAction().getBgColourHex()));
else
else
actionBackgroundColourTransparentCheckBox.setSelected(true);
actionBackgroundColourTransparentCheckBox.setSelected(true);
if(!getAction().getDisplayTextFontColourHex().isEmpty())
if(!getAction().getDisplayTextFontColourHex().isEmpty())
displayTextColourPicker.setValue(Color.valueOf(getAction().getDisplayTextFontColourHex()));
displayTextColourPicker.setValue(Color.valueOf(getAction().getDisplayTextFontColourHex()));
else
else
displayTextColourDefaultCheckBox.setSelected(true);
displayTextColourDefaultCheckBox.setSelected(true);
hideDisplayTextCheckBox.setSelected(!getAction().isShowDisplayText());
hideDisplayTextCheckBox.setSelected(!getAction().isShowDisplayText());
if(getAction().isInvalid())
if(getAction().isInvalid())
{
{
setActionHeadingLabelText("Invalid action ("+getAction().getModuleName()+")");
setActionHeadingLabelText("Invalid action ("+getAction().getModuleName()+")");
return;
return;
}
}
saveButton.setVisible(getAction().isInvalid());
saveButton.setVisible(!getAction().isInvalid());
if(isCombineChild)
if(isCombineChild)
{
{
setReturnButtonForCombineActionChildVisible(true);
setReturnButtonForCombineActionChildVisible(true);
normalActionsPropsVBox.setVisible(false);
normalActionsPropsVBox.setVisible(false);
normalToggleActionCommonPropsVBox.setVisible(false);
normalToggleActionCommonPropsVBox.setVisible(false);
hideDisplayTextCheckBox.setSelected(false);
hideDisplayTextCheckBox.setSelected(false);
hideDisplayTextCheckBox.setVisible(false);
hideDisplayTextCheckBox.setVisible(false);
}
}
else
else
{
{
normalToggleActionCommonPropsVBox.setVisible(true);
normalToggleActionCommonPropsVBox.setVisible(true);
if(getAction().getActionType() == ActionType.TOGGLE)
if(getAction().getActionType() == ActionType.TOGGLE)
{
{
normalActionsPropsVBox.setVisible(false);
normalActionsPropsVBox.setVisible(false);
toggleActionsPropsVBox.setVisible(true);
toggleActionsPropsVBox.setVisible(true);
boolean doesToggleOnExist = getAction().getIcons().containsKey("toggle_on");
boolean doesToggleOnExist = getAction().getIcons().containsKey("toggle_on");
boolean isToggleOnHidden = getAction().getCurrentIconState().contains("toggle_on");
boolean isToggleOnHidden = getAction().getCurrentIconState().contains("toggle_on");
if(!doesToggleOnExist)
if(!doesToggleOnExist)
isToggleOnHidden = false;
isToggleOnHidden = false;
hideToggleOnIconCheckBox.setDisable(!doesToggleOnExist);
hideToggleOnIconCheckBox.setDisable(!doesToggleOnExist);
hideToggleOnIconCheckBox.setSelected(isToggleOnHidden);
hideToggleOnIconCheckBox.setSelected(isToggleOnHidden);
boolean doesToggleOffExist = getAction().getIcons().containsKey("toggle_off");
boolean doesToggleOffExist = getAction().getIcons().containsKey("toggle_off");
boolean isToggleOffHidden = getAction().getCurrentIconState().contains("toggle_off");
boolean isToggleOffHidden = getAction().getCurrentIconState().contains("toggle_off");
if(!doesToggleOffExist)
if(!doesToggleOffExist)
isToggleOffHidden = false;
isToggleOffHidden = false;
hideToggleOffIconCheckBox.setDisable(!doesToggleOffExist);
hideToggleOffIconCheckBox.setDisable(!doesToggleOffExist);
hideToggleOffIconCheckBox.setSelected(isToggleOffHidden);
hideToggleOffIconCheckBox.setSelected(isToggleOffHidden);
}
}
else
else
{
{
normalActionsPropsVBox.setVisible(true);
normalActionsPropsVBox.setVisible(true);
toggleActionsPropsVBox.setVisible(false);
toggleActionsPropsVBox.setVisible(false);
boolean doesDefaultExist = getAction().getIcons().containsKey("default");
boolean doesDefaultExist = getAction().getIcons().containsKey("default");
boolean isDefaultHidden = !getAction().getCurrentIconState().equals("default");
boolean isDefaultHidden = !getAction().getCurrentIconState().equals("default");
if(!doesDefaultExist)
if(!doesDefaultExist)
isDefaultHidden = false;
isDefaultHidden = false;
hideDefaultIconCheckBox.setDisable(!doesDefaultExist);
hideDefaultIconCheckBox.setDisable(!doesDefaultExist);
hideDefaultIconCheckBox.setSelected(isDefaultHidden);
hideDefaultIconCheckBox.setSelected(isDefaultHidden);
}
}
setReturnButtonForCombineActionChildVisible(false);
setReturnButtonForCombineActionChildVisible(false);
hideDisplayTextCheckBox.setVisible(true);
hideDisplayTextCheckBox.setVisible(true);
setFolderButtonVisible(getAction().getActionType().equals(ActionType.FOLDER));
setFolderButtonVisible(getAction().getActionType().equals(ActionType.FOLDER));
setResetToDefaultsFolderButtonVisible(!(getAction().getActionType().equals(ActionType.FOLDER) || getAction().getActionType().equals(ActionType.COMBINE)));
setResetToDefaultsFolderButtonVisible(!(getAction().getActionType().equals(ActionType.FOLDER) || getAction().getActionType().equals(ActionType.COMBINE)));
clearIconButton.setDisable(!getAction().isHasIcon());
clearIconButton.setDisable(!getAction().isHasIcon());
}
}
if(getAction().getActionType() == ActionType.NORMAL || getAction().getActionType() == ActionType.TOGGLE)
if(getAction().getActionType() == ActionType.NORMAL || getAction().getActionType() == ActionType.TOGGLE)
{
{
setActionHeadingLabelText(getAction().getName());
setActionHeadingLabelText(getAction().getName());
}
}
else if(getAction().getActionType() == ActionType.COMBINE)
else if(getAction().getActionType() == ActionType.COMBINE)
{
{
setActionHeadingLabelText("Combine action");
setActionHeadingLabelText("Combine action");
}
}
else if(getAction().getActionType() == ActionType.FOLDER)
else if(getAction().getActionType() == ActionType.FOLDER)
{
{
setActionHeadingLabelText("Folder action");
setActionHeadingLabelText("Folder action");
}
}
if(getAction().getActionType() == ActionType.NORMAL || getAction().getActionType() == ActionType.TOGGLE)
if(getAction().getActionType() == ActionType.NORMAL || getAction().getActionType() == ActionType.TOGGLE)
{
{
renderClientProperties();
renderClientProperties();
renderPluginExtraButtonBar();
renderPluginExtraButtonBar();
}
}
else if(getAction().getActionType() == ActionType.COMBINE)
else if(getAction().getActionType() == ActionType.COMBINE)
renderCombineActionProperties();
renderCombineActionProperties();
}
}
private void renderPluginExtraButtonBar()
private void renderPluginExtraButtonBar()
{
{
ExternalPlugin externalPlugin = (ExternalPlugin) getAction();
ExternalPlugin externalPlugin = (ExternalPlugin) getAction();
externalPlugin.initClientActionSettingsButtonBar();
externalPlugin.initClientActionSettingsButtonBar();
if(externalPlugin.getClientActionSettingsButtonBar() != null)
if(externalPlugin.getClientActionSettingsButtonBar() != null)
{
{
HBox tba = new HBox(SpaceFiller.horizontal(), externalPlugin.getClientActionSettingsButtonBar());
HBox tba = new HBox(SpaceFiller.horizontal(), externalPlugin.getClientActionSettingsButtonBar());
pluginExtraButtonBar.getChildren().add(tba);
pluginExtraButtonBar.getChildren().add(tba);
}
}
}
}
private CombineActionPropertiesPane combineActionPropertiesPane;
private CombineActionPropertiesPane combineActionPropertiesPane;
public CombineActionPropertiesPane getCombineActionPropertiesPane() {
public CombineActionPropertiesPane getCombineActionPropertiesPane() {
return combineActionPropertiesPane;
return combineActionPropertiesPane;
}
}
public void setReturnButtonForCombineActionChildVisible(boolean visible)
public void setReturnButtonForCombineActionChildVisible(boolean visible)
{
{
returnButtonForCombineActionChild.setVisible(visible);
returnButtonForCombineActionChild.setVisible(visible);
}
}
public void renderCombineActionProperties()
public void renderCombineActionProperties()
{
{
try
try
{
{
combineActionPropertiesPane = new CombineActionPropertiesPane((CombineAction) getAction(),
combineActionPropertiesPane = new CombineActionPropertiesPane((CombineAction) getAction(),
getClientProfile(),
getClientProfile(),
this
this
);
);
clientPropertiesVBox.getChildren().add(combineActionPropertiesPane);
clientPropertiesVBox.getChildren().add(combineActionPropertiesPane);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
@Override
@Override
public synchronized void setAction(Action action) {
public synchronized void setAction(Action action) {
this.action = action;
this.action = action;
}
}
@Override
@Override
public void onOpenFolderButtonClicked()
public void onOpenFolderButtonClicked()
{
{
actionBox.getActionGridPaneListener().renderFolder((FolderAction) getAction());
actionBox.getActionGridPaneListener().renderFolder((FolderAction) getAction());
clear();
clear();
}
}
@Override
@Override
public Window getCurrentWindow() {
public Window getCurrentWindow() {
return getScene().getWindow();
return getScene().getWindow();
}
}
private ArrayList<UIPropertyBox> actionClientProperties;
private ArrayList<UIPropertyBox> actionClientProperties;
private TextField delayBeforeRunningTextField;
private TextField delayBeforeRunningTextField;
public void renderClientProperties() throws MinorException
public void renderClientProperties() throws MinorException
{
{
delayBeforeRunningTextField = new TextField();
delayBeforeRunningTextField = new TextField();
delayBeforeRunningTextField.setText(getAction().getDelayBeforeExecuting()+"");
delayBeforeRunningTextField.setText(getAction().getDelayBeforeExecuting()+"");
clientPropertiesVBox.getChildren().add(
clientPropertiesVBox.getChildren().add(
new HBoxInputBox("Delay before running (milli-seconds)", delayBeforeRunningTextField, 100)
new HBoxInputBox("Delay before running (milli-seconds)", delayBeforeRunningTextField, 100)
);
);
for(int i =0;i< getAction().getClientProperties().getSize(); i++)
for(int i =0;i< getAction().getClientProperties().getSize(); i++)
{
{
Property eachProperty = getAction().getClientProperties().get().get(i);
Property eachProperty = getAction().getClientProperties().get().get(i);
if(!eachProperty.isVisible())
if(!eachProperty.isVisible())
continue;
continue;
Label label = new Label(eachProperty.getDisplayName());
Label label = new Label(eachProperty.getDisplayName());
HBox hBox = new HBox(label);
HBox hBox = new HBox(label);
hBox.setSpacing(5.0);
hBox.setSpacing(5.0);
hBox.setAlignment(Pos.CENTER_LEFT);
hBox.setAlignment(Pos.CENTER_LEFT);
Node controlNode = null;
Node controlNode = null;
if(eachProperty.getHelpLink() != null)
if(eachProperty.getHelpLink() != null)
{
{
Button helpButton = new Button();
Button helpButton = new Button();
FontIcon questionIcon = new FontIcon("fas-question");
FontIcon questionIcon = new FontIcon("fas-question");
helpButton.setGraphic(questionIcon);
helpButton.setGraphic(questionIcon);
helpButton.setOnAction(event -> {
helpButton.setOnAction(event -> {
hostServices.showDocument(eachProperty.getHelpLink());
hostServices.showDocument(eachProperty.getHelpLink());
});
});
hBox.getChildren().add(helpButton);
hBox.getChildren().add(helpButton);
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
}
}
hBox.getChildren().add(SpaceFiller.horizontal());
hBox.getChildren().add(SpaceFiller.horizontal());
if(eachProperty.getControlType() == ControlType.COMBO_BOX)
if(eachProperty.getControlType() == ControlType.COMBO_BOX)
{
{
ComboBox<String> comboBox = new ComboBox<>();
ComboBox<String> comboBox = new ComboBox<>();
comboBox.getItems().addAll(eachProperty.getListValue());
comboBox.getItems().addAll(eachProperty.getListValue());
comboBox.getSelectionModel().select(eachProperty.getSelectedIndex());
comboBox.getSelectionModel().select(eachProperty.getSelectedIndex());
controlNode = comboBox;
controlNode = comboBox;
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
}
}
else if(eachProperty.getControlType() == ControlType.FILE_PATH)
else if(eachProperty.getControlType() == ControlType.FILE_PATH)
{
{
TextField textField = new TextField(eachProperty.getRawValue());
TextField textField = new TextField(eachProperty.getRawValue());
FileExtensionFilter[] fileExtensionFilters = eachProperty.getExtensionFilters();
FileExtensionFilter[] fileExtensionFilters = eachProperty.getExtensionFilters();
FileChooser.ExtensionFilter[] extensionFilters = new FileChooser.ExtensionFilter[fileExtensionFilters.length];
FileChooser.ExtensionFilter[] extensionFilters = new FileChooser.ExtensionFilter[fileExtensionFilters.length];
for(int x = 0;x<fileExtensionFilters.length;x++)
for(int x = 0;x<fileExtensionFilters.length;x++)
{
{
extensionFilters[x] = new FileChooser.ExtensionFilter(
extensionFilters[x] = new FileChooser.ExtensionFilter(
fileExtensionFilters[x].getDescription(),
fileExtensionFilters[x].getDescription(),
fileExtensionFilters[x].getExtensions()
fileExtensionFilters[x].getExtensions()
);
);
}
}
hBox = new HBoxInputBoxWithFileChooser(eachProperty.getDisplayName(), textField, null,
hBox = new HBoxInputBoxWithFileChooser(eachProperty.getDisplayName(), textField, null,
extensionFilters);
extensionFilters);
controlNode = textField;
controlNode = textField;
}
}
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD)
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD)
{
{
controlNode= new TextField(eachProperty.getRawValue());
controlNode= new TextField(eachProperty.getRawValue());
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
}
}
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD_MASKED)
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD_MASKED)
{
{
PasswordField textField = new PasswordField();
PasswordField textField = new PasswordField();
textField.setText(eachProperty.getRawValue());
textField.setText(eachProperty.getRawValue());
controlNode= textField;
controlNode= textField;
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
}
}
else if(eachProperty.getControlType() == ControlType.TOGGLE)
else if(eachProperty.getControlType() == ControlType.TOGGLE)
{
{
ToggleButton toggleButton = new ToggleButton();
ToggleButton toggleButton = new ToggleButton();
toggleButton.setSelected(eachProperty.getBoolValue());
toggleButton.setSelected(eachProperty.getBoolValue());
if(eachProperty.getBoolValue())
if(eachProperty.getBoolValue())
toggleButton.setText("ON");
toggleButton.setText("ON");
else
else
toggleButton.setText("OFF");
toggleButton.setText("OFF");
toggleButton.selectedProperty().addListener((observableValue, aBoolean, t1) -> {
toggleButton.selectedProperty().addListener((observableValue, aBoolean, t1) -> {
if(t1)
if(t1)
toggleButton.setText("ON");
toggleButton.setText("ON");
else
else
toggleButton.setText("OFF");
toggleButton.setText("OFF");
});
});
controlNode = toggleButton;
controlNode = toggleButton;
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
}
}
else if(eachProperty.getControlType() == ControlType.SLIDER_DOUBLE)
else if(eachProperty.getControlType() == ControlType.SLIDER_DOUBLE)
{
{
Slider slider = new Slider();
Slider slider = new Slider();
slider.setValue(eachProperty.getDoubleValue());
slider.setValue(eachProperty.getDoubleValue());
slider.setMax(eachProperty.getMaxDoubleValue());
slider.setMax(eachProperty.getMaxDoubleValue());
slider.setMin(eachProperty.getMinDoubleValue());
slider.setMin(eachProperty.getMinDoubleValue());
controlNode = slider;
controlNode = slider;
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
}
}
else if(eachProperty.getControlType() == ControlType.SLIDER_INTEGER)
else if(eachProperty.getControlType() == ControlType.SLIDER_INTEGER)
{
{
Slider slider = new Slider();
Slider slider = new Slider();
slider.setValue(eachProperty.getIntValue());
slider.setValue(eachProperty.getIntValue());
slider.setMax(eachProperty.getMaxIntValue());
slider.setMax(eachProperty.getMaxIntValue());
slider.setMin(eachProperty.getMinIntValue());
slider.setMin(eachProperty.getMinIntValue());
slider.setBlockIncrement(1.0);
slider.setBlockIncrement(1.0);
slider.setSnapToTicks(true);
slider.setSnapToTicks(true);
controlNode = slider;
controlNode = slider;
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
}
}
UIPropertyBox clientProperty = new UIPropertyBox(i, eachProperty.getDisplayName(), controlNode,
UIPropertyBox clientProperty = new UIPropertyBox(i, eachProperty.getDisplayName(), controlNode,
eachProperty.getControlType(), eachProperty.getType(), eachProperty.isCanBeBlank());
eachProperty.getControlType(), eachProperty.getType(), eachProperty.isCanBeBlank());
actionClientProperties.add(clientProperty);
actionClientProperties.add(clientProperty);
clientPropertiesVBox.getChildren().add(hBox);
clientPropertiesVBox.getChildren().add(hBox);
}
}
}
}
public void onSaveButtonClicked()
public void onSaveButtonClicked()
{
{
try {
try {
// saveButton.setDisable(true);
// saveButton.setDisable(true);
// deleteButton.setDisable(true);
// deleteButton.setDisable(true);
validateForm();
validateForm();
saveAction(true, true);
saveAction(true, true);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
private boolean sendIcon = false;
private boolean sendIcon = false;
@Override
@Override
public void setSendIcon(boolean sendIcon)
public void setSendIcon(boolean sendIcon)
{
{
this.sendIcon = sendIcon;
this.sendIcon = sendIcon;
}
}
public void addActionToCurrentClientProfile(Action newAction) throws CloneNotSupportedException {
public void addActionToCurrentClientProfile(Action newAction) throws CloneNotSupportedException {
getClientProfile().addAction(newAction);
getClientProfile().addAction(newAction);
}
}
@Override
@Override
public synchronized void saveAction(Action action, boolean runAsync, boolean runOnActionSavedFromServer)
public synchronized void saveAction(Action action, boolean runAsync, boolean runOnActionSavedFromServer)
{
{
String delayBeforeRunning = "0";
String delayBeforeRunning = "0";
if(action.getActionType() != ActionType.FOLDER && action.getActionType() !=ActionType.COMBINE)
if(action.getActionType() != ActionType.FOLDER && action.getActionType() !=ActionType.COMBINE)
delayBeforeRunning =delayBeforeRunningTextField.getText();
delayBeforeRunning =delayBeforeRunningTextField.getText();
new OnSaveActionTask(
new OnSaveActionTask(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
getClient().getRemoteSocketAddress()
getClient().getRemoteSocketAddress()
),
),
action, delayBeforeRunning,
action, delayBeforeRunning,
displayNameTextField.getText(),
displayNameTextField.getText(),
isCombineChild(),
isCombineChild(),
!hideDisplayTextCheckBox.isSelected(),
!hideDisplayTextCheckBox.isSelected(),
displayTextColourDefaultCheckBox.isSelected(),
displayTextColourDefaultCheckBox.isSelected(),
"#" + displayTextColourPicker.getValue().toString().substring(2),
"#" + displayTextColourPicker.getValue().toString().substring(2),
clearIconButton.isDisable(),
clearIconButton.isDisable(),
hideDefaultIconCheckBox.isSelected(),
hideDefaultIconCheckBox.isSelected(),
hideToggleOffIconCheckBox.isSelected(),
hideToggleOffIconCheckBox.isSelected(),
hideToggleOnIconCheckBox.isSelected(),
hideToggleOnIconCheckBox.isSelected(),
displayTextAlignmentComboBox.getSelectionModel().getSelectedItem(),
displayTextAlignmentComboBox.getSelectionModel().getSelectedItem(),
actionBackgroundColourTransparentCheckBox.isSelected(),
actionBackgroundColourTransparentCheckBox.isSelected(),
"#" + actionBackgroundColourPicker.getValue().toString().substring(2),
"#" + actionBackgroundColourPicker.getValue().toString().substring(2),
getCombineActionPropertiesPane(),
getCombineActionPropertiesPane(),
clientProfile, sendIcon, actionBox, actionClientProperties, exceptionAndAlertHandler,
clientProfile, sendIcon, actionBox, actionClientProperties, exceptionAndAlertHandler,
saveButton, deleteButton, runOnActionSavedFromServer, runAsync, this
saveButton, deleteButton, runOnActionSavedFromServer, runAsync, this
);
);
}
}
@Override
@Override
public void saveAction(boolean runAsync, boolean runOnActionSavedFromServer)
public void saveAction(boolean runAsync, boolean runOnActionSavedFromServer)
{
{
saveAction(getAction(), runAsync, runOnActionSavedFromServer);
saveAction(getAction(), runAsync, runOnActionSavedFromServer);
}
}
public void setFolderButtonVisible(boolean visible)
public void setFolderButtonVisible(boolean visible)
{
{
openFolderButton.setVisible(visible);
openFolderButton.setVisible(visible);
}
}
public void setResetToDefaultsFolderButtonVisible(boolean visible)
public void setResetToDefaultsFolderButtonVisible(boolean visible)
{
{
resetToDefaultsFolderButton.setVisible(visible);
resetToDefaultsFolderButton.setVisible(visible);
}
}
public void validateForm() throws MinorException
public void validateForm() throws MinorException
{
{
String displayNameStr = displayNameTextField.getText();
String displayNameStr = displayNameTextField.getText();
StringBuilder finalErrors = new StringBuilder();
StringBuilder finalErrors = new StringBuilder();
if(displayNameStr.isBlank())
if(displayNameStr.isBlank())
{
{
finalErrors.append(" * Display Name cannot be blank\n");
finalErrors.append(" * Display Name cannot be blank\n");
}
}
if(!isCombineChild())
if(!isCombineChild())
{
{
if(getAction().getActionType() == ActionType.NORMAL)
if(getAction().getActionType() == ActionType.NORMAL)
{
{
if(getAction().isHasIcon())
if(getAction().isHasIcon())
{
{
if(hideDisplayTextCheckBox.isSelected() && hideDefaultIconCheckBox.isSelected())
if(hideDisplayTextCheckBox.isSelected() && hideDefaultIconCheckBox.isSelected())
{
{
finalErrors.append(" * Both Icon and display text check box cannot be hidden.\n");
finalErrors.append(" * Both Icon and display text check box cannot be hidden.\n");
}
}
}
}
else
else
{
{
if(hideDisplayTextCheckBox.isSelected())
if(hideDisplayTextCheckBox.isSelected())
finalErrors.append(" * Display Text cannot be hidden, since there is also no icon.\n");
finalErrors.append(" * Display Text cannot be hidden, since there is also no icon.\n");
}
}
}
}
}
}
if(getAction().getActionType() == ActionType.NORMAL)
if(getAction().getActionType() == ActionType.NORMAL)
{
{
try
try
{
{
int n = Integer.parseInt(delayBeforeRunningTextField.getText());
int n = Integer.parseInt(delayBeforeRunningTextField.getText());
if (n<0)
if (n<0)
{
{
finalErrors.append(" * Sleep should be greater than 0.\n");
finalErrors.append(" * Sleep should be greater than 0.\n");
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
finalErrors.append(" * Sleep should be a number.\n");
finalErrors.append(" * Sleep should be a number.\n");
}
}
}
}
for (UIPropertyBox clientProperty : actionClientProperties) {
for (UIPropertyBox clientProperty : actionClientProperties) {
Node controlNode = clientProperty.getControlNode();
Node controlNode = clientProperty.getControlNode();
if (clientProperty.getControlType() == ControlType.TEXT_FIELD ||
if (clientProperty.getControlType() == ControlType.TEXT_FIELD ||
clientProperty.getControlType() == ControlType.FILE_PATH)
clientProperty.getControlType() == ControlType.FILE_PATH)
{
{
String value = ((TextField) controlNode).getText();
String value = ((TextField) controlNode).getText();
if(clientProperty.getType() == Type.INTEGER)
if(clientProperty.getType() == Type.INTEGER)
{
{
try
try
{
{
Integer.parseInt(value);
Integer.parseInt(value);
}
}
catch (NumberFormatException e)
catch (NumberFormatException e)
{
{
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" must be integer.\n");
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" must be integer.\n");
}
}
}
}
else
else
{
{
if(value.isBlank() && !clientProperty.isCanBeBlank())
if(value.isBlank() && !clientProperty.isCanBeBlank())
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" cannot be blank.\n");
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" cannot be blank.\n");
}
}
}
}
}
}
if(!finalErrors.toString().isEmpty())
if(!finalErrors.toString().isEmpty())
{
{
throw new MinorException("You made mistakes",
throw new MinorException("You made mistakes",
finalErrors.toString());
finalErrors.toString());
}
}
}
}
public void onDeleteButtonClicked()
public void onDeleteButtonClicked()
{
{
new OnDeleteActionTask(
new OnDeleteActionTask(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
getClient().getRemoteSocketAddress()
getClient().getRemoteSocketAddress()
),
),
action,
action,
isCombineChild(),
isCombineChild(),
getCombineActionPropertiesPane(),
getCombineActionPropertiesPane(),
clientProfile, actionBox, this, exceptionAndAlertHandler,
clientProfile, actionBox, this, exceptionAndAlertHandler,
!isCombineChild
!isCombineChild
);
);
}
}
}
}