diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index c35db20..c8f14e8 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -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 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(); diff --git a/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java b/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java index 40ac115..6c095d6 100644 --- a/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java +++ b/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java @@ -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); diff --git a/client/src/main/java/envoy/client/ui/settings/OnlyIfOnlineSettingsPane.java b/client/src/main/java/envoy/client/ui/settings/OnlyIfOnlineSettingsPane.java index 886a2b9..95e375c 100644 --- a/client/src/main/java/envoy/client/ui/settings/OnlyIfOnlineSettingsPane.java +++ b/client/src/main/java/envoy/client/ui/settings/OnlyIfOnlineSettingsPane.java @@ -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))); diff --git a/client/src/main/resources/css/base.css b/client/src/main/resources/css/base.css index bc6d471..d3c0954 100644 --- a/client/src/main/resources/css/base.css +++ b/client/src/main/resources/css/base.css @@ -107,19 +107,19 @@ -fx-background-color: transparent; } -#infoLabel-success { +#info-label-success { -fx-text-fill: #00FF00; } -#infoLabel-info { +#info-label-info { -fx-text-fill: yellow; } -#infoLabel-warning { +#info-label-warning { -fx-text-fill: orange; } -#infoLabel-error { +#info-label-error { -fx-text-fill: red; } @@ -136,9 +136,9 @@ } .tab-pane { - -fx-tab-max-height: 0 ; + -fx-tab-max-height: 0.0 ; } .tab-pane .tab-header-area { visibility: hidden ; - -fx-padding: -20 0 0 0; + -fx-padding: -20.0 0.0 0.0 0.0; } diff --git a/client/src/main/resources/fxml/ChatScene.fxml b/client/src/main/resources/fxml/ChatScene.fxml index 8ddee10..e3de7aa 100644 --- a/client/src/main/resources/fxml/ChatScene.fxml +++ b/client/src/main/resources/fxml/ChatScene.fxml @@ -21,107 +21,146 @@ - + - - + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + -