diff --git a/src/main/java/envoy/client/ui/ClearableTextField.java b/src/main/java/envoy/client/ui/ClearableTextField.java
index adc5f94..2a4dcfb 100644
--- a/src/main/java/envoy/client/ui/ClearableTextField.java
+++ b/src/main/java/envoy/client/ui/ClearableTextField.java
@@ -1,16 +1,14 @@
package envoy.client.ui;
-import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.StringProperty;
-import javafx.geometry.Insets;
-import javafx.geometry.Pos;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Background;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
-import javafx.scene.text.Font;
import envoy.client.data.Settings;
@@ -25,7 +23,6 @@ import envoy.client.data.Settings;
* @author Leon Hofmeister
* @since Envoy Client v0.1-beta
*/
-@SuppressWarnings("javadoc")
public class ClearableTextField extends GridPane {
private final TextField textField;
@@ -56,6 +53,7 @@ public class ClearableTextField extends GridPane {
Settings.getInstance().getCurrentTheme().equals("dark") ? "/icons/clear_button_white.png" : "/icons/clear_button_black.png",
size)));
clearButton.setOnAction(e -> textField.clear());
+ clearButton.setFocusTraversable(false);
clearButton.getStyleClass().clear();
clearButton.setBackground(Background.EMPTY);
// Adding the two elements to the GridPane
@@ -64,17 +62,11 @@ public class ClearableTextField extends GridPane {
// Setting the percent - widths of the two columns.
// Used to locate the button on the right.
final var columnConstraints = new ColumnConstraints();
- columnConstraints.setPercentWidth(85);
+ columnConstraints.setPercentWidth(90);
getColumnConstraints().add(columnConstraints);
final var columnConstraints2 = new ColumnConstraints();
- columnConstraints2.setPercentWidth(15);
- columnConstraints2.setPrefWidth(size);
+ columnConstraints2.setPercentWidth(10);
getColumnConstraints().add(columnConstraints2);
- setAlignment(Pos.CENTER);
- setHgap(10);
- setVgap(10);
- setPadding(new Insets(5, 5, 5, 5));
- setMargin(clearButton, new Insets(5));
}
/**
@@ -84,169 +76,84 @@ public class ClearableTextField extends GridPane {
public TextField getTextField() { return textField; }
/**
- * @return
- * @see javafx.scene.control.TextInputControl#fontProperty()
+ * This method offers the freedom to perform custom actions when the
+ * {@code clearButton} has been pressed.
+ *
+ * The default is
+ * e -> {clearableTextField.getTextField().clear();}
+ *
+ * @param onClearButtonAction the action that should be performed
* @since Envoy Client v0.1-beta
*/
- public final ObjectProperty fontProperty() { return textField.fontProperty(); }
+ public void setClearButtonListener(EventHandler onClearButtonAction) { clearButton.setOnAction(onClearButtonAction); }
/**
- * @return
- * @see javafx.scene.control.TextField#prefColumnCountProperty()
- * @since Envoy Client v0.1-beta
- */
- public final IntegerProperty prefColumnCountProperty() { return textField.prefColumnCountProperty(); }
-
- /**
- * @return
- * @see javafx.scene.control.TextField#getPrefColumnCount()
- * @since Envoy Client v0.1-beta
- */
- public final int getPrefColumnCount() { return textField.getPrefColumnCount(); }
-
- /**
- * @param value
- * @see javafx.scene.control.TextField#setPrefColumnCount(int)
- * @since Envoy Client v0.1-beta
- */
- public final void setPrefColumnCount(int value) { textField.setPrefColumnCount(value); }
-
- /**
- * @return
- * @see javafx.scene.control.Control#skinProperty()
- * @since Envoy Client v0.1-beta
- */
- public final ObjectProperty> skinProperty() { return textField.skinProperty(); }
-
- /**
- * @param value
- * @see javafx.scene.control.TextInputControl#setFont(javafx.scene.text.Font)
- * @since Envoy Client v0.1-beta
- */
- public final void setFont(Font value) { textField.setFont(value); }
-
- /**
- * @return
- * @see javafx.scene.control.TextInputControl#getFont()
- * @since Envoy Client v0.1-beta
- */
- public final Font getFont() { return textField.getFont(); }
-
- /**
- * @return
+ * @return the current property of the prompt text
* @see javafx.scene.control.TextInputControl#promptTextProperty()
* @since Envoy Client v0.1-beta
*/
public final StringProperty promptTextProperty() { return textField.promptTextProperty(); }
/**
- * @return
+ * @return the current prompt text
* @see javafx.scene.control.TextInputControl#getPromptText()
* @since Envoy Client v0.1-beta
*/
public final String getPromptText() { return textField.getPromptText(); }
/**
- * @param value
+ * @param value the prompt text to display
* @see javafx.scene.control.TextInputControl#setPromptText(java.lang.String)
* @since Envoy Client v0.1-beta
*/
public final void setPromptText(String value) { textField.setPromptText(value); }
/**
- * @return
- * @see javafx.scene.control.TextInputControl#getText()
- * @since Envoy Client v0.1-beta
- */
- public final String getText() { return textField.getText(); }
-
- /**
- * @param value
- * @see javafx.scene.control.TextInputControl#setText(java.lang.String)
- * @since Envoy Client v0.1-beta
- */
- public final void setText(String value) { textField.setText(value); }
-
- /**
- * @return
- * @see javafx.scene.control.TextInputControl#textProperty()
- * @since Envoy Client v0.1-beta
- */
- public final StringProperty textProperty() { return textField.textProperty(); }
-
- /**
- * @param value
- * @see javafx.scene.control.TextInputControl#setEditable(boolean)
- * @since Envoy Client v0.1-beta
- */
- public final void setEditable(boolean value) { textField.setEditable(value); }
-
- /**
- * @return
+ * @return the current property of the tooltip
* @see javafx.scene.control.Control#tooltipProperty()
* @since Envoy Client v0.1-beta
*/
public final ObjectProperty tooltipProperty() { return textField.tooltipProperty(); }
/**
- * @param value
+ * @param value the new tooltip
* @see javafx.scene.control.Control#setTooltip(javafx.scene.control.Tooltip)
* @since Envoy Client v0.1-beta
*/
public final void setTooltip(Tooltip value) { textField.setTooltip(value); }
/**
- * @return
+ * @return the current tooltip
* @see javafx.scene.control.Control#getTooltip()
* @since Envoy Client v0.1-beta
*/
public final Tooltip getTooltip() { return textField.getTooltip(); }
/**
- * @return
+ * @return the current property of the context menu
* @see javafx.scene.control.Control#contextMenuProperty()
* @since Envoy Client v0.1-beta
*/
public final ObjectProperty contextMenuProperty() { return textField.contextMenuProperty(); }
/**
- * @param value
+ * @param value the new context menu
* @see javafx.scene.control.Control#setContextMenu(javafx.scene.control.ContextMenu)
* @since Envoy Client v0.1-beta
*/
public final void setContextMenu(ContextMenu value) { textField.setContextMenu(value); }
/**
- * @return
+ * @return the current context menu
* @see javafx.scene.control.Control#getContextMenu()
* @since Envoy Client v0.1-beta
*/
public final ContextMenu getContextMenu() { return textField.getContextMenu(); }
/**
- * @param minWidth
- * @param minHeight
- * @see javafx.scene.layout.Region#setMinSize(double, double)
+ * @param value whether this ClearableTextField should be editable
+ * @see javafx.scene.control.TextInputControl#setEditable(boolean)
* @since Envoy Client v0.1-beta
*/
- @Override
- public void setMinSize(double minWidth, double minHeight) { textField.setMinSize(minWidth, minHeight); }
-
- /**
- * @param prefWidth
- * @param prefHeight
- * @see javafx.scene.layout.Region#setPrefSize(double, double)
- * @since Envoy Client v0.1-beta
- */
- @Override
- public void setPrefSize(double prefWidth, double prefHeight) { textField.setPrefSize(prefWidth, prefHeight); }
-
- /**
- * @param maxWidth
- * @param maxHeight
- * @see javafx.scene.layout.Region#setMaxSize(double, double)
- * @since Envoy Client v0.1-beta
- */
- @Override
- public void setMaxSize(double maxWidth, double maxHeight) { textField.setMaxSize(maxWidth, maxHeight); }
+ public final void setEditable(boolean value) { textField.setEditable(value); }
}
diff --git a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java
index 743759c..1260f1d 100644
--- a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java
+++ b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java
@@ -59,6 +59,7 @@ public class ContactSearchScene {
@FXML
private void initialize() {
contactList.setCellFactory(e -> new ContactListCell());
+ searchBar.setClearButtonListener(e -> { searchBar.getTextField().clear(); contactList.getItems().clear(); });
eventBus.register(ContactSearchResult.class,
response -> Platform.runLater(() -> { contactList.getItems().clear(); contactList.getItems().addAll(response.get()); }));
}
diff --git a/src/main/java/envoy/client/ui/controller/GroupCreationScene.java b/src/main/java/envoy/client/ui/controller/GroupCreationScene.java
index 484d207..52c46ae 100644
--- a/src/main/java/envoy/client/ui/controller/GroupCreationScene.java
+++ b/src/main/java/envoy/client/ui/controller/GroupCreationScene.java
@@ -44,6 +44,7 @@ public class GroupCreationScene {
private void initialize() {
contactList.setCellFactory(e -> new ContactListCell());
contactList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
+ groupNameField.setClearButtonListener(e -> { groupNameField.getTextField().clear(); createButton.setDisable(true); });
}
/**
diff --git a/src/main/other/CustomComponents.jar b/src/main/other/CustomComponents.jar
new file mode 100644
index 0000000..083f070
Binary files /dev/null and b/src/main/other/CustomComponents.jar differ