Shortened code

This commit is contained in:
Maximilian P. Käfer 2020-08-24 21:08:48 +02:00
parent 46a883dda9
commit 1983cebde1

View File

@ -122,33 +122,19 @@ public class GroupCreationTab {
private void createButtonClicked() { private void createButtonClicked() {
name = groupNameField.getText(); name = groupNameField.getText();
if (!Bounds.isValidContactName(name)) { if (!Bounds.isValidContactName(name)) {
errorMessageLabel.setPrefHeight(30); setErrorMessageLabelSize(30);
errorMessageLabel.setMinHeight(30);
errorMessageLabel.setMaxHeight(30);
errorMessageLabel.setText("The group name is not valid!"); errorMessageLabel.setText("The group name is not valid!");
groupNameField.clear(); groupNameField.clear();
} else if (groupNameAlreadyPresent(name)) { } else if (groupNameAlreadyPresent(name)) {
errorMessageLabel.setPrefHeight(30); setErrorMessageLabelSize(30);
errorMessageLabel.setMinHeight(30);
errorMessageLabel.setMaxHeight(30);
errorMessageLabel.setText("Name does already exist! Proceed anyways?"); errorMessageLabel.setText("Name does already exist! Proceed anyways?");
proceedDupButton.setPrefHeight(30); setProcessPaneSize(30);
proceedDupButton.setMinHeight(30);
proceedDupButton.setMaxHeight(30);
cancelDupButton.setPrefHeight(30);
cancelDupButton.setMinHeight(30);
cancelDupButton.setMaxHeight(30);
errorProceedBox.setPrefHeight(30);
errorProceedBox.setMinHeight(30);
errorProceedBox.setMaxHeight(30);
createButton.setDisable(true); createButton.setDisable(true);
cancelButton.setDisable(true); cancelButton.setDisable(true);
} else { } else {
createGroup(name); createGroup(name);
eventBus.dispatch(new BackEvent()); eventBus.dispatch(new BackEvent());
errorMessageLabel.setPrefHeight(0); setErrorMessageLabelSize(0);
errorMessageLabel.setMinHeight(0);
errorMessageLabel.setMaxHeight(0);
groupNameField.clear(); groupNameField.clear();
} }
} }
@ -183,7 +169,11 @@ public class GroupCreationTab {
} }
@FXML @FXML
private void backButtonClicked() { eventBus.dispatch(new BackEvent()); } private void backButtonClicked() {
eventBus.dispatch(new BackEvent());
setErrorMessageLabelSize(0);
setProcessPaneSize(0);
}
@FXML @FXML
private void proceedOnNameDuplication() { private void proceedOnNameDuplication() {
@ -191,18 +181,8 @@ public class GroupCreationTab {
cancelButton.setDisable(false); cancelButton.setDisable(false);
createGroup(name); createGroup(name);
eventBus.dispatch(new BackEvent()); eventBus.dispatch(new BackEvent());
errorMessageLabel.setPrefHeight(0); setErrorMessageLabelSize(0);
errorMessageLabel.setMinHeight(0); setProcessPaneSize(0);
errorMessageLabel.setMaxHeight(0);
proceedDupButton.setPrefHeight(0);
proceedDupButton.setMinHeight(0);
proceedDupButton.setMaxHeight(0);
cancelDupButton.setPrefHeight(0);
cancelDupButton.setMinHeight(0);
cancelDupButton.setMaxHeight(0);
errorProceedBox.setPrefHeight(0);
errorProceedBox.setMinHeight(0);
errorProceedBox.setMaxHeight(0);
groupNameField.clear(); groupNameField.clear();
} }
@ -210,18 +190,26 @@ public class GroupCreationTab {
private void cancelOnNameDuplication() { private void cancelOnNameDuplication() {
createButton.setDisable(false); createButton.setDisable(false);
cancelButton.setDisable(false); cancelButton.setDisable(false);
errorMessageLabel.setPrefHeight(0); setErrorMessageLabelSize(0);
errorMessageLabel.setMinHeight(0); setProcessPaneSize(0);
errorMessageLabel.setMaxHeight(0);
proceedDupButton.setPrefHeight(0);
proceedDupButton.setMinHeight(0);
proceedDupButton.setMaxHeight(0);
cancelDupButton.setPrefHeight(0);
cancelDupButton.setMinHeight(0);
cancelDupButton.setMaxHeight(0);
errorProceedBox.setPrefHeight(0);
errorProceedBox.setMinHeight(0);
errorProceedBox.setMaxHeight(0);
groupNameField.clear(); groupNameField.clear();
} }
private void setErrorMessageLabelSize(int value) {
errorMessageLabel.setPrefHeight(value);
errorMessageLabel.setMinHeight(value);
errorMessageLabel.setMaxHeight(value);
}
private void setProcessPaneSize(int value) {
proceedDupButton.setPrefHeight(value);
proceedDupButton.setMinHeight(value);
proceedDupButton.setMaxHeight(value);
cancelDupButton.setPrefHeight(value);
cancelDupButton.setMinHeight(value);
cancelDupButton.setMaxHeight(value);
errorProceedBox.setPrefHeight(value);
errorProceedBox.setMinHeight(value);
errorProceedBox.setMaxHeight(value);
}
} }