Removed clicking into a tab to see that you cannot interact with it

Additionally re-ensured compliance with our CSS conventions.
This commit is contained in:
delvh
2020-09-01 20:57:18 +02:00
parent 9f517cfc6b
commit 661823219c
6 changed files with 235 additions and 158 deletions

View File

@ -21,16 +21,14 @@ import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
@ -98,6 +96,9 @@ public final class ChatScene implements Restorable {
@FXML
private Button newGroupButton;
@FXML
private Button newContactButton;
@FXML
private TextArea messageTextArea;
@ -140,12 +141,16 @@ public final class ChatScene implements Restorable {
@FXML
private Tab groupCreationTab;
@FXML
private HBox contactSpecificOnlineOperations;
private final LocalDB localDB = context.getLocalDB();
private final Client client = context.getClient();
private final WriteProxy writeProxy = context.getWriteProxy();
private final SceneContext sceneContext = context.getSceneContext();
private final AudioRecorder recorder = new AudioRecorder();
private final SystemCommandsMap messageTextAreaCommands = new SystemCommandsMap();
private final Tooltip onlyIfOnlineTooltip = new Tooltip("You need to be online to do this");
private Chat currentChat;
private FilteredList<Chat> chats;
@ -192,15 +197,21 @@ public final class ChatScene implements Restorable {
initializeSystemCommandsMap();
Platform.runLater(() -> {
if (client.isOnline()) try {
final var online = client.isOnline();
// no check will be performed in case it has already been disabled - a negative
// GroupCreationResult might have been returned
if (!newGroupButton.isDisabled()) newGroupButton.setDisable(!online);
newContactButton.setDisable(!online);
if (online) try {
Tooltip.uninstall(contactSpecificOnlineOperations, onlyIfOnlineTooltip);
contactSearchTab.setContent(FXMLLoader.load(new File("src/main/resources/fxml/ContactSearchTab.fxml").toURI().toURL()));
groupCreationTab.setContent(FXMLLoader.load(new File("src/main/resources/fxml/GroupCreationTab.fxml").toURI().toURL()));
} catch (final IOException e2) {
logger.log(Level.SEVERE, "An error occurred when attempting to load tabs: ", e2);
}
else {
contactSearchTab.setContent(createOfflineNote());
groupCreationTab.setContent(createOfflineNote());
Tooltip.install(contactSpecificOnlineOperations, onlyIfOnlineTooltip);
updateInfoLabel("You are offline", "info-label-warning");
}
});
@ -293,22 +304,6 @@ public final class ChatScene implements Restorable {
eventBus.register(GroupCreationResult.class, e -> Platform.runLater(() -> { newGroupButton.setDisable(!e.get()); }));
}
private AnchorPane createOfflineNote() {
final var anc = new AnchorPane();
final var vBox = new VBox();
vBox.setAlignment(Pos.TOP_CENTER);
vBox.setPrefWidth(316);
final var label = new Label("You have to be online!");
label.setPadding(new Insets(50, 0, 5, 0));
final var button = new Button("OK");
button.setOnAction(e -> eventBus.dispatch(new BackEvent()));
vBox.getChildren().add(label);
vBox.getChildren().add(button);
anc.getChildren().add(vBox);
anc.setId("note-background");
return anc;
}
/**
* Initializes all {@code SystemCommands} used in {@code ChatScene}.
*
@ -575,7 +570,7 @@ public final class ChatScene implements Restorable {
if (!infoLabel.getText().equals(noMoreMessaging))
// Informing the user that he is a f*cking moron and should use Envoy online
// because he ran out of messageIDs to use
updateInfoLabel(noMoreMessaging, "infoLabel-error");
updateInfoLabel(noMoreMessaging, "info-label-error");
}
}
@ -620,7 +615,7 @@ public final class ChatScene implements Restorable {
postButton.setDisable(true);
messageTextArea.setDisable(true);
messageTextArea.clear();
updateInfoLabel("You need to go online to send more messages", "infoLabel-error");
updateInfoLabel("You need to go online to send more messages", "info-label-error");
return;
}
final var text = messageTextArea.getText().strip();

View File

@ -56,17 +56,17 @@ public class GroupCreationTab {
private Label errorMessageLabel;
@FXML
private Button proceedDupButton;
private Button proceedDuplicateButton;
@FXML
private Button cancelDupButton;
private Button cancelDuplicateButton;
@FXML
private HBox errorProceedBox;
private String name;
private String name;
private final LocalDB localDB = Context.getInstance().getLocalDB();
private final LocalDB localDB = Context.getInstance().getLocalDB();
private static final EventBus eventBus = EventBus.getInstance();
@ -194,12 +194,12 @@ public class GroupCreationTab {
}
private void setProcessPaneSize(int value) {
proceedDupButton.setPrefHeight(value);
proceedDupButton.setMinHeight(value);
proceedDupButton.setMaxHeight(value);
cancelDupButton.setPrefHeight(value);
cancelDupButton.setMinHeight(value);
cancelDupButton.setMaxHeight(value);
proceedDuplicateButton.setPrefHeight(value);
proceedDuplicateButton.setMinHeight(value);
proceedDuplicateButton.setMaxHeight(value);
cancelDuplicateButton.setPrefHeight(value);
cancelDuplicateButton.setMinHeight(value);
cancelDuplicateButton.setMaxHeight(value);
errorProceedBox.setPrefHeight(value);
errorProceedBox.setMinHeight(value);
errorProceedBox.setMaxHeight(value);

View File

@ -36,7 +36,7 @@ public abstract class OnlyIfOnlineSettingsPane extends SettingsPane {
if (!online) {
final var infoLabel = new Label("You shall not pass!\n(... Unless you would happen to be online)");
infoLabel.setId("infoLabel-warning");
infoLabel.setId("info-label-warning");
infoLabel.setWrapText(true);
getChildren().add(infoLabel);
setBackground(new Background(new BackgroundFill(Color.grayRgb(100, 0.3), CornerRadii.EMPTY, Insets.EMPTY)));