Merge pull request #43 from informatik-ag-ngl/f/context

Simplified dependency injection for the client
This commit is contained in:
Kai S. K. Engelbart 2020-09-02 10:39:53 +02:00 committed by GitHub
commit 63ed1c480d
20 changed files with 611 additions and 500 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,98 @@
package envoy.client.data;
import javafx.stage.Stage;
import envoy.client.net.Client;
import envoy.client.net.WriteProxy;
import envoy.client.ui.SceneContext;
/**
* Provides access to commonly used objects.
* <p>
* Project: <strong>client</strong><br>
* File: <strong>Context.java</strong><br>
* Created: <strong>01.09.2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Client v0.2-beta
*/
public class Context {
private WriteProxy writeProxy;
private LocalDB localDB;
private Stage stage;
private SceneContext sceneContext;
private final Client client = new Client();
private static final Context instance = new Context();
private Context() {}
/**
* @return the instance of {@code Context} used throughout Envoy
* @since Envoy Client v0.2-beta
*/
public static Context getInstance() { return instance; }
/**
* Initializes the write proxy given that {@code localDB} is initialized.
*
* @since Envoy Client v0.2-beta
*/
public void initWriteProxy() {
if (localDB == null) throw new IllegalStateException("The LocalDB has to be initialized!");
writeProxy = new WriteProxy(client, localDB);
}
/**
* @return the localDB
* @since Envoy Client v0.2-beta
*/
public LocalDB getLocalDB() { return localDB; }
/**
* @param localDB the localDB to set
* @since Envoy Client v0.2-beta
*/
public void setLocalDB(LocalDB localDB) { this.localDB = localDB; }
/**
* @return the sceneContext
* @since Envoy Client v0.2-beta
*/
public SceneContext getSceneContext() { return sceneContext; }
/**
* @param sceneContext the sceneContext to set. Additionally sets the stage.
* @since Envoy Client v0.2-beta
*/
public void setSceneContext(SceneContext sceneContext) {
this.sceneContext = sceneContext;
stage = sceneContext.getStage();
}
/**
* @return the client
* @since Envoy Client v0.2-beta
*/
public Client getClient() { return client; }
/**
* @return the writeProxy
* @since Envoy Client v0.2-beta
*/
public WriteProxy getWriteProxy() { return writeProxy; }
/**
* @return the stage
* @since Envoy Client v0.2-beta
*/
public Stage getStage() { return stage; }
/**
* @param stage the stage to set
* @since Envoy Client v0.2-beta
*/
public void setStage(Stage stage) { this.stage = stage; }
}

View File

@ -3,8 +3,9 @@ package envoy.client.event;
import envoy.event.Event.Valueless; import envoy.event.Event.Valueless;
/** /**
* This event serves the purpose to trigger the tab change to tab 0 in {@link ChatScene}.<p> * This event serves the purpose to trigger the tab change to tab 0 in
* * {@link envoy.client.ui.controller.ChatScene}.
* <p>
* Project: <strong>client</strong><br> * Project: <strong>client</strong><br>
* File: <strong>BackEvent.java</strong><br> * File: <strong>BackEvent.java</strong><br>
* Created: <strong>23.08.2020</strong><br> * Created: <strong>23.08.2020</strong><br>
@ -12,7 +13,7 @@ import envoy.event.Event.Valueless;
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy Client v0.2-beta * @since Envoy Client v0.2-beta
*/ */
public class BackEvent extends Valueless{ public class BackEvent extends Valueless {
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
} }

View File

@ -1,27 +0,0 @@
package envoy.client.event;
import envoy.client.data.LocalDB;
import envoy.client.ui.controller.ChatScene;
import envoy.event.Event;
/**
* This event carries an instance of {@link LocalDB} so the groupCreationTab has the most recent version of the contactList. <br>
* It is triggered as soon as the corresponding button in {@link ChatScene} is clicked. <p>
*
* Project: <strong>client</strong><br>
* File: <strong>LoadGroupCreationEvent.java</strong><br>
* Created: <strong>23.08.2020</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Client v0.2-beta
*/
public class LoadGroupCreationEvent extends Event<LocalDB>{
private static final long serialVersionUID = 0L;
/**
* @param value the localDB
* @since Envoy Client v0.2-beta
*/
public LoadGroupCreationEvent(LocalDB value) { super(value); }
}

View File

@ -33,10 +33,9 @@ public final class WriteProxy {
* Initializes a write proxy using a client and a local database. The * Initializes a write proxy using a client and a local database. The
* corresponding cache processors are injected into the caches. * corresponding cache processors are injected into the caches.
* *
* @param client the client used to send messages and message status change * @param client the client instance used to send messages and events if online
* events * @param localDB the local database used to cache messages and events if
* @param localDB the local database used to cache messages and message status * offline
* change events
* @since Envoy Client v0.3-alpha * @since Envoy Client v0.3-alpha
*/ */
public WriteProxy(Client client, LocalDB localDB) { public WriteProxy(Client client, LocalDB localDB) {

View File

@ -124,8 +124,12 @@ public final class SceneContext {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
public void pop() { public void pop() {
// Pop scene and controller
sceneStack.pop(); sceneStack.pop();
controllerStack.pop(); controllerStack.pop();
// Apply new scene if present
if (!sceneStack.isEmpty()) { if (!sceneStack.isEmpty()) {
final var newScene = sceneStack.peek(); final var newScene = sceneStack.peek();
stage.setScene(newScene); stage.setScene(newScene);
@ -160,4 +164,10 @@ public final class SceneContext {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
public Stage getStage() { return stage; } public Stage getStage() { return stage; }
/**
* @return whether the scene stack is empty
* @since Envoy Client v0.2-beta
*/
public boolean isEmpty() { return sceneStack.isEmpty(); }
} }

View File

@ -1,7 +1,10 @@
package envoy.client.ui; package envoy.client.ui;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.time.Instant;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -14,10 +17,11 @@ import envoy.client.data.*;
import envoy.client.net.Client; import envoy.client.net.Client;
import envoy.client.ui.SceneContext.SceneInfo; import envoy.client.ui.SceneContext.SceneInfo;
import envoy.client.ui.controller.LoginScene; import envoy.client.ui.controller.LoginScene;
import envoy.data.GroupMessage; import envoy.data.*;
import envoy.data.Message; import envoy.data.User.UserStatus;
import envoy.event.GroupMessageStatusChange; import envoy.event.GroupMessageStatusChange;
import envoy.event.MessageStatusChange; import envoy.event.MessageStatusChange;
import envoy.exception.EnvoyException;
import envoy.util.EnvoyLog; import envoy.util.EnvoyLog;
/** /**
@ -40,9 +44,10 @@ public final class Startup extends Application {
*/ */
public static final String VERSION = "0.1-beta"; public static final String VERSION = "0.1-beta";
private LocalDB localDB; private static LocalDB localDB;
private Client client;
private static final Context context = Context.getInstance();
private static final Client client = context.getClient();
private static final ClientConfig config = ClientConfig.getInstance(); private static final ClientConfig config = ClientConfig.getInstance();
private static final Logger logger = EnvoyLog.getLogger(Startup.class); private static final Logger logger = EnvoyLog.getLogger(Startup.class);
@ -77,21 +82,145 @@ public final class Startup extends Application {
return; return;
} }
// Initialize client and unread message cache // Prepare handshake
client = new Client(); localDB.loadIDGenerator();
context.setLocalDB(localDB);
final var cacheMap = new CacheMap();
cacheMap.put(Message.class, new Cache<Message>());
cacheMap.put(GroupMessage.class, new Cache<GroupMessage>());
cacheMap.put(MessageStatusChange.class, new Cache<MessageStatusChange>());
cacheMap.put(GroupMessageStatusChange.class, new Cache<GroupMessageStatusChange>());
stage.setTitle("Envoy"); stage.setTitle("Envoy");
stage.getIcons().add(IconUtil.loadIcon("envoy_logo")); stage.getIcons().add(IconUtil.loadIcon("envoy_logo"));
final var sceneContext = new SceneContext(stage); final var sceneContext = new SceneContext(stage);
sceneContext.load(SceneInfo.LOGIN_SCENE); context.setSceneContext(sceneContext);
sceneContext.<LoginScene>getController().initializeData(client, localDB, cacheMap, sceneContext);
// Perform automatic login if configured
if (config.hasLoginCredentials())
performHandshake(new LoginCredentials(config.getUser(), config.getPassword(), false, Startup.VERSION, loadLastSync(config.getUser())));
else sceneContext.load(SceneInfo.LOGIN_SCENE);
}
/**
* Tries to perform a Handshake with the server.
*
* @param credentials the credentials to use for the handshake
* @since Envoy Client v0.2-beta
*/
public static void performHandshake(LoginCredentials credentials) {
final var cacheMap = new CacheMap();
cacheMap.put(Message.class, new Cache<Message>());
cacheMap.put(GroupMessage.class, new Cache<GroupMessage>());
cacheMap.put(MessageStatusChange.class, new Cache<MessageStatusChange>());
cacheMap.put(GroupMessageStatusChange.class, new Cache<GroupMessageStatusChange>());
try {
final var client = context.getClient();
client.performHandshake(credentials, cacheMap);
if (client.isOnline()) {
loadChatScene();
client.initReceiver(localDB, cacheMap);
}
} catch (IOException | InterruptedException | TimeoutException e) {
logger.log(Level.INFO, "Could not connect to server. Entering offline mode...");
attemptOfflineMode(credentials.getIdentifier());
}
}
/**
* Attempts to load {@link envoy.client.ui.controller.ChatScene} in offline mode
* for a given user.
*
* @param identifier the identifier of the user - currently his username
* @since Envoy Client v0.2-beta
*/
public static void attemptOfflineMode(String identifier) {
try {
// Try entering offline mode
localDB.loadUsers();
final User clientUser = localDB.getUsers().get(identifier);
if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown");
client.setSender(clientUser);
loadChatScene();
} catch (final Exception e) {
new Alert(AlertType.ERROR, "Client error: " + e).showAndWait();
logger.log(Level.SEVERE, "Offline mode could not be loaded: ", e);
System.exit(1);
}
}
/**
* Loads the last known time a user has been online.
*
* @param identifier the identifier of this user - currently his name
* @return the last {@code Instant} at which he has been online
* @since Envoy Client v0.2-beta
*/
public static Instant loadLastSync(String identifier) {
try {
localDB.loadUsers();
localDB.setUser(localDB.getUsers().get(identifier));
localDB.initializeUserStorage();
localDB.loadUserData();
} catch (final Exception e) {
// User storage empty, wrong user name etc. -> default lastSync
}
return localDB.getLastSync();
}
private static void loadChatScene() {
// Set client user in local database
localDB.setUser(client.getSender());
// Initialize chats in local database
try {
localDB.initializeUserStorage();
localDB.loadUserData();
} catch (final FileNotFoundException e) {
// The local database file has not yet been created, probably first login
} catch (final Exception e) {
new Alert(AlertType.ERROR, "Error while loading local database: " + e + "\nChats will not be stored locally.").showAndWait();
logger.log(Level.WARNING, "Could not load local database: ", e);
}
context.initWriteProxy();
localDB.synchronize();
if (client.isOnline()) context.getWriteProxy().flushCache();
else
// Set all contacts to offline mode
localDB.getChats()
.stream()
.map(Chat::getRecipient)
.filter(User.class::isInstance)
.map(User.class::cast)
.forEach(u -> u.setStatus(UserStatus.OFFLINE));
final var stage = context.getStage();
// Pop LoginScene if present
if (!context.getSceneContext().isEmpty()) context.getSceneContext().pop();
// Load ChatScene
stage.setMinHeight(400);
stage.setMinWidth(843);
context.getSceneContext().load(SceneContext.SceneInfo.CHAT_SCENE);
stage.centerOnScreen();
if (StatusTrayIcon.isSupported()) {
// Configure hide on close
stage.setOnCloseRequest(e -> {
if (Settings.getInstance().isHideOnClose()) {
stage.setIconified(true);
e.consume();
}
});
// Initialize status tray icon
final var trayIcon = new StatusTrayIcon(stage);
Settings.getInstance().getItems().get("hideOnClose").setChangeHandler(c -> {
if ((Boolean) c) trayIcon.show();
else trayIcon.hide();
});
}
} }
/** /**
@ -106,7 +235,7 @@ public final class Startup extends Application {
localDB.save(client.isOnline()); localDB.save(client.isOnline());
Settings.getInstance().save(); Settings.getInstance().save();
logger.log(Level.INFO, "Closing connection..."); if (client.isOnline()) logger.log(Level.INFO, "Closing connection...");
client.close(); client.close();
logger.log(Level.INFO, "Envoy was terminated by its user"); logger.log(Level.INFO, "Envoy was terminated by its user");

View File

@ -21,15 +21,15 @@ import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.layout.*; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
@ -39,13 +39,16 @@ import envoy.client.data.*;
import envoy.client.data.audio.AudioRecorder; import envoy.client.data.audio.AudioRecorder;
import envoy.client.data.commands.SystemCommandBuilder; import envoy.client.data.commands.SystemCommandBuilder;
import envoy.client.data.commands.SystemCommandsMap; import envoy.client.data.commands.SystemCommandsMap;
import envoy.client.event.*; import envoy.client.event.BackEvent;
import envoy.client.event.MessageCreationEvent;
import envoy.client.event.SendEvent;
import envoy.client.net.Client; import envoy.client.net.Client;
import envoy.client.net.WriteProxy; import envoy.client.net.WriteProxy;
import envoy.client.ui.*; import envoy.client.ui.*;
import envoy.client.ui.listcell.*; import envoy.client.ui.listcell.ChatControl;
import envoy.client.ui.listcell.ListCellFactory;
import envoy.client.ui.listcell.MessageListCell;
import envoy.client.util.ReflectionUtil; import envoy.client.util.ReflectionUtil;
import envoy.constant.Tabs;
import envoy.data.*; import envoy.data.*;
import envoy.data.Attachment.AttachmentType; import envoy.data.Attachment.AttachmentType;
import envoy.event.*; import envoy.event.*;
@ -93,6 +96,9 @@ public final class ChatScene implements Restorable {
@FXML @FXML
private Button newGroupButton; private Button newGroupButton;
@FXML
private Button newContactButton;
@FXML @FXML
private TextArea messageTextArea; private TextArea messageTextArea;
@ -135,29 +141,32 @@ public final class ChatScene implements Restorable {
@FXML @FXML
private Tab groupCreationTab; private Tab groupCreationTab;
private LocalDB localDB; @FXML
private Client client; private HBox contactSpecificOnlineOperations;
private WriteProxy writeProxy;
private SceneContext sceneContext;
private Chat currentChat; private final LocalDB localDB = context.getLocalDB();
private AudioRecorder recorder; private final Client client = context.getClient();
private boolean recording; private final WriteProxy writeProxy = context.getWriteProxy();
private Attachment pendingAttachment; private final SceneContext sceneContext = context.getSceneContext();
private boolean postingPermanentlyDisabled; 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 final SystemCommandsMap messageTextAreaCommands = new SystemCommandsMap(); private Chat currentChat;
private FilteredList<Chat> chats;
private boolean recording;
private Attachment pendingAttachment;
private boolean postingPermanentlyDisabled;
private static final Settings settings = Settings.getInstance(); private static final Settings settings = Settings.getInstance();
private static final EventBus eventBus = EventBus.getInstance(); private static final EventBus eventBus = EventBus.getInstance();
private static final Logger logger = EnvoyLog.getLogger(ChatScene.class); private static final Logger logger = EnvoyLog.getLogger(ChatScene.class);
private static final Context context = Context.getInstance();
private static final Image DEFAULT_ATTACHMENT_VIEW_IMAGE = IconUtil.loadIconThemeSensitive("attachment_present", 20); private static final Image DEFAULT_ATTACHMENT_VIEW_IMAGE = IconUtil.loadIconThemeSensitive("attachment_present", 20);
private static final int MAX_MESSAGE_LENGTH = 255; private static final int MAX_MESSAGE_LENGTH = 255;
private static final int DEFAULT_ICON_SIZE = 16; private static final int DEFAULT_ICON_SIZE = 16;
private FilteredList<Chat> chats;
/** /**
* Initializes the appearance of certain visual components. * Initializes the appearance of certain visual components.
* *
@ -175,29 +184,40 @@ public final class ChatScene implements Restorable {
attachmentView.setImage(DEFAULT_ATTACHMENT_VIEW_IMAGE); attachmentView.setImage(DEFAULT_ATTACHMENT_VIEW_IMAGE);
messageSearchButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("search", DEFAULT_ICON_SIZE))); messageSearchButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("search", DEFAULT_ICON_SIZE)));
clientProfilePic.setImage(IconUtil.loadIconThemeSensitive("user_icon", 43)); clientProfilePic.setImage(IconUtil.loadIconThemeSensitive("user_icon", 43));
final Rectangle clip = new Rectangle(); onlyIfOnlineTooltip.setShowDelay(Duration.millis(250));
final var clip = new Rectangle();
clip.setWidth(43); clip.setWidth(43);
clip.setHeight(43); clip.setHeight(43);
clip.setArcHeight(43); clip.setArcHeight(43);
clip.setArcWidth(43); clip.setArcWidth(43);
clientProfilePic.setClip(clip); clientProfilePic.setClip(clip);
chatList.setItems(chats = new FilteredList<>(FXCollections.observableList(localDB.getChats())));
contactLabel.setText(localDB.getUser().getName());
initializeSystemCommandsMap();
Platform.runLater(() -> { Platform.runLater(() -> {
if(client.isOnline()) { final var online = client.isOnline();
try { // no check will be performed in case it has already been disabled - a negative
contactSearchTab.setContent(FXMLLoader.load(new File("src/main/resources/fxml/ContactSearchTab.fxml").toURI().toURL())); // GroupCreationResult might have been returned
groupCreationTab.setContent(FXMLLoader.load(new File("src/main/resources/fxml/GroupCreationTab.fxml").toURI().toURL())); if (!newGroupButton.isDisabled()) newGroupButton.setDisable(!online);
} catch (IOException e2) { newContactButton.setDisable(!online);
logger.log(Level.SEVERE, "An error occurred when attempting to load tabs: ", e2); if (online) try {
} Tooltip.uninstall(contactSpecificOnlineOperations, onlyIfOnlineTooltip);
} else { contactSearchTab.setContent(new FXMLLoader().load(getClass().getResourceAsStream("/fxml/ContactSearchTab.fxml")));
contactSearchTab.setContent(createOfflineNote()); groupCreationTab.setContent(new FXMLLoader().load(getClass().getResourceAsStream("/fxml/GroupCreationTab.fxml")));
groupCreationTab.setContent(createOfflineNote()); } catch (final IOException e2) {
logger.log(Level.SEVERE, "An error occurred when attempting to load tabs: ", e2);
}
else {
Tooltip.install(contactSpecificOnlineOperations, onlyIfOnlineTooltip);
updateInfoLabel("You are offline", "info-label-warning");
} }
}); });
//Listen to backEvents // Listen to backEvents
eventBus.register(BackEvent.class, e -> tabPane.getSelectionModel().select(Tabs.CONTACT_LIST)); eventBus.register(BackEvent.class, e -> tabPane.getSelectionModel().select(Tabs.CONTACT_LIST.ordinal()));
// Listen to received messages // Listen to received messages
eventBus.register(MessageCreationEvent.class, e -> { eventBus.register(MessageCreationEvent.class, e -> {
@ -285,22 +305,6 @@ public final class ChatScene implements Restorable {
eventBus.register(GroupCreationResult.class, e -> Platform.runLater(() -> { newGroupButton.setDisable(!e.get()); })); eventBus.register(GroupCreationResult.class, e -> Platform.runLater(() -> { newGroupButton.setDisable(!e.get()); }));
} }
private AnchorPane createOfflineNote() {
AnchorPane anc = new AnchorPane();
VBox vBox = new VBox();
vBox.setAlignment(Pos.TOP_CENTER);
vBox.setPrefWidth(316);
Label label = new Label("You have to be online!");
label.setPadding(new Insets(50, 0, 5, 0));
Button 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}. * Initializes all {@code SystemCommands} used in {@code ChatScene}.
* *
@ -317,34 +321,6 @@ public final class ChatScene implements Restorable {
messageTextAreaCommands.add("DABR", builder.build()); messageTextAreaCommands.add("DABR", builder.build());
} }
/**
* Initializes all necessary data via dependency injection-
*
* @param sceneContext the scene context used to load other scenes
* @param localDB the local database form which chats and users are loaded
* @param client the client used to request ID generators
* @param writeProxy the write proxy used to send messages and other data to
* the server
* @since Envoy Client v0.1-beta
*/
public void initializeData(SceneContext sceneContext, LocalDB localDB, Client client, WriteProxy writeProxy) {
this.sceneContext = sceneContext;
this.localDB = localDB;
this.client = client;
this.writeProxy = writeProxy;
chats = new FilteredList<>(FXCollections.observableList(localDB.getChats()));
chatList.setItems(chats);
contactLabel.setText(localDB.getUser().getName());
MessageControl.setLocalDB(localDB);
MessageControl.setSceneContext(sceneContext);
if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info");
recorder = new AudioRecorder();
initializeSystemCommandsMap();
}
@Override @Override
public void onRestore() { updateRemainingCharsLabel(); } public void onRestore() { updateRemainingCharsLabel(); }
@ -423,10 +399,7 @@ public final class ChatScene implements Restorable {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
@FXML @FXML
private void settingsButtonClicked() { private void settingsButtonClicked() { sceneContext.load(SceneContext.SceneInfo.SETTINGS_SCENE); }
sceneContext.load(SceneContext.SceneInfo.SETTINGS_SCENE);
sceneContext.<SettingsScene>getController().initializeData(sceneContext, client);
}
/** /**
* Actions to perform when the "Add Contact" - Button has been clicked. * Actions to perform when the "Add Contact" - Button has been clicked.
@ -434,15 +407,10 @@ public final class ChatScene implements Restorable {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
@FXML @FXML
private void addContactButtonClicked() { private void addContactButtonClicked() { tabPane.getSelectionModel().select(Tabs.CONTACT_SEARCH.ordinal()); }
tabPane.getSelectionModel().select(Tabs.CONTACT_SEARCH);
}
@FXML @FXML
private void groupCreationButtonClicked() { private void groupCreationButtonClicked() { tabPane.getSelectionModel().select(Tabs.GROUP_CREATION.ordinal()); }
eventBus.dispatch(new LoadGroupCreationEvent(localDB));
tabPane.getSelectionModel().select(Tabs.GROUP_CREATION);
}
@FXML @FXML
private void voiceButtonClicked() { private void voiceButtonClicked() {
@ -603,7 +571,7 @@ public final class ChatScene implements Restorable {
if (!infoLabel.getText().equals(noMoreMessaging)) if (!infoLabel.getText().equals(noMoreMessaging))
// Informing the user that he is a f*cking moron and should use Envoy online // Informing the user that he is a f*cking moron and should use Envoy online
// because he ran out of messageIDs to use // because he ran out of messageIDs to use
updateInfoLabel(noMoreMessaging, "infoLabel-error"); updateInfoLabel(noMoreMessaging, "info-label-error");
} }
} }
@ -648,7 +616,7 @@ public final class ChatScene implements Restorable {
postButton.setDisable(true); postButton.setDisable(true);
messageTextArea.setDisable(true); messageTextArea.setDisable(true);
messageTextArea.clear(); 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; return;
} }
final var text = messageTextArea.getText().strip(); final var text = messageTextArea.getText().strip();

View File

@ -4,15 +4,14 @@ import static java.util.function.Predicate.not;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javafx.application.Platform;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import envoy.client.data.Chat; import envoy.client.data.Chat;
import envoy.client.data.Context;
import envoy.client.data.LocalDB; import envoy.client.data.LocalDB;
import envoy.client.event.BackEvent; import envoy.client.event.BackEvent;
import envoy.client.event.LoadGroupCreationEvent;
import envoy.client.event.SendEvent; import envoy.client.event.SendEvent;
import envoy.client.ui.listcell.ContactControl; import envoy.client.ui.listcell.ContactControl;
import envoy.client.ui.listcell.ListCellFactory; import envoy.client.ui.listcell.ListCellFactory;
@ -57,37 +56,33 @@ public class GroupCreationTab {
private Label errorMessageLabel; private Label errorMessageLabel;
@FXML @FXML
private Button proceedDupButton; private Button proceedDuplicateButton;
@FXML @FXML
private Button cancelDupButton; private Button cancelDuplicateButton;
@FXML @FXML
private HBox errorProceedBox; private HBox errorProceedBox;
private LocalDB localDB;
private String name; private String name;
private final LocalDB localDB = Context.getInstance().getLocalDB();
private static final EventBus eventBus = EventBus.getInstance(); private static final EventBus eventBus = EventBus.getInstance();
@FXML @FXML
private void initialize() { private void initialize() {
userList.setCellFactory(new ListCellFactory<>(ContactControl::new)); userList.setCellFactory(new ListCellFactory<>(ContactControl::new));
userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
createButton.setDisable(true);
eventBus.register(LoadGroupCreationEvent.class, e -> { userList.getItems()
createButton.setDisable(true); .addAll(localDB.getChats()
this.localDB = e.get(); .stream()
userList.getItems().clear(); .map(Chat::getRecipient)
Platform.runLater(() -> userList.getItems() .filter(User.class::isInstance)
.addAll(localDB.getChats() .filter(not(localDB.getUser()::equals))
.stream() .map(User.class::cast)
.map(Chat::getRecipient) .collect(Collectors.toList()));
.filter(User.class::isInstance)
.filter(not(localDB.getUser()::equals))
.map(User.class::cast)
.collect(Collectors.toList())));
});
} }
/** /**
@ -96,9 +91,7 @@ public class GroupCreationTab {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
@FXML @FXML
private void userListClicked() { private void userListClicked() { createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank()); }
createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank());
}
/** /**
* Checks, whether the {@code createButton} can be enabled because text is * Checks, whether the {@code createButton} can be enabled because text is
@ -201,12 +194,12 @@ public class GroupCreationTab {
} }
private void setProcessPaneSize(int value) { private void setProcessPaneSize(int value) {
proceedDupButton.setPrefHeight(value); proceedDuplicateButton.setPrefHeight(value);
proceedDupButton.setMinHeight(value); proceedDuplicateButton.setMinHeight(value);
proceedDupButton.setMaxHeight(value); proceedDuplicateButton.setMaxHeight(value);
cancelDupButton.setPrefHeight(value); cancelDuplicateButton.setPrefHeight(value);
cancelDupButton.setMinHeight(value); cancelDuplicateButton.setMinHeight(value);
cancelDupButton.setMaxHeight(value); cancelDuplicateButton.setMaxHeight(value);
errorProceedBox.setPrefHeight(value); errorProceedBox.setPrefHeight(value);
errorProceedBox.setMinHeight(value); errorProceedBox.setMinHeight(value);
errorProceedBox.setMaxHeight(value); errorProceedBox.setMaxHeight(value);

View File

@ -1,9 +1,5 @@
package envoy.client.ui.controller; package envoy.client.ui.controller;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.time.Instant;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -14,16 +10,12 @@ import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import envoy.client.data.*; import envoy.client.data.ClientConfig;
import envoy.client.net.Client; import envoy.client.ui.IconUtil;
import envoy.client.net.WriteProxy; import envoy.client.ui.Startup;
import envoy.client.ui.*;
import envoy.data.LoginCredentials; import envoy.data.LoginCredentials;
import envoy.data.User;
import envoy.data.User.UserStatus;
import envoy.event.EventBus; import envoy.event.EventBus;
import envoy.event.HandshakeRejection; import envoy.event.HandshakeRejection;
import envoy.exception.EnvoyException;
import envoy.util.Bounds; import envoy.util.Bounds;
import envoy.util.EnvoyLog; import envoy.util.EnvoyLog;
@ -65,17 +57,11 @@ public final class LoginScene {
@FXML @FXML
private ImageView logo; private ImageView logo;
private Client client;
private LocalDB localDB;
private CacheMap cacheMap;
private SceneContext sceneContext;
private boolean registration = false; private boolean registration = false;
private static final Logger logger = EnvoyLog.getLogger(LoginScene.class); private static final Logger logger = EnvoyLog.getLogger(LoginScene.class);
private static final EventBus eventBus = EventBus.getInstance(); private static final EventBus eventBus = EventBus.getInstance();
private static final ClientConfig config = ClientConfig.getInstance(); private static final ClientConfig config = ClientConfig.getInstance();
private static final Settings settings = Settings.getInstance();
@FXML @FXML
private void initialize() { private void initialize() {
@ -85,32 +71,9 @@ public final class LoginScene {
eventBus.register(HandshakeRejection.class, e -> Platform.runLater(() -> { new Alert(AlertType.ERROR, e.get()).showAndWait(); })); eventBus.register(HandshakeRejection.class, e -> Platform.runLater(() -> { new Alert(AlertType.ERROR, e.get()).showAndWait(); }));
logo.setImage(IconUtil.loadIcon("envoy_logo")); logo.setImage(IconUtil.loadIcon("envoy_logo"));
}
/**
* Loads the login dialog using the FXML file {@code LoginDialog.fxml}.
*
* @param client the client used to perform the handshake
* @param localDB the local database used for offline login
* @param cacheMap the map of all caches needed
* @param sceneContext the scene context used to initialize the chat scene
* @since Envoy Client v0.1-beta
*/
public void initializeData(Client client, LocalDB localDB, CacheMap cacheMap, SceneContext sceneContext) {
this.client = client;
this.localDB = localDB;
this.cacheMap = cacheMap;
this.sceneContext = sceneContext;
// Prepare handshake
localDB.loadIDGenerator();
// Set initial cursor // Set initial cursor
userTextField.requestFocus(); userTextField.requestFocus();
// Perform automatic login if configured
if (config.hasLoginCredentials())
performHandshake(new LoginCredentials(config.getUser(), config.getPassword(), false, Startup.VERSION, loadLastSync(config.getUser())));
} }
@FXML @FXML
@ -123,15 +86,12 @@ public final class LoginScene {
} else if (!Bounds.isValidContactName(userTextField.getText())) { } else if (!Bounds.isValidContactName(userTextField.getText())) {
new Alert(AlertType.ERROR, "The entered user name is not valid (" + Bounds.CONTACT_NAME_PATTERN + ")").showAndWait(); new Alert(AlertType.ERROR, "The entered user name is not valid (" + Bounds.CONTACT_NAME_PATTERN + ")").showAndWait();
userTextField.clear(); userTextField.clear();
} else performHandshake(new LoginCredentials(userTextField.getText(), passwordField.getText(), registration, } else Startup.performHandshake(new LoginCredentials(userTextField.getText(), passwordField.getText(), registration, Startup.VERSION,
Startup.VERSION, loadLastSync(userTextField.getText()))); Startup.loadLastSync(userTextField.getText())));
} }
@FXML @FXML
private void offlineModeButtonPressed() { private void offlineModeButtonPressed() { Startup.attemptOfflineMode(userTextField.getText()); }
attemptOfflineMode(new LoginCredentials(userTextField.getText(), passwordField.getText(), false, Startup.VERSION,
loadLastSync(userTextField.getText())));
}
@FXML @FXML
private void registerSwitchPressed() { private void registerSwitchPressed() {
@ -159,102 +119,4 @@ public final class LoginScene {
logger.log(Level.INFO, "The login process has been cancelled. Exiting..."); logger.log(Level.INFO, "The login process has been cancelled. Exiting...");
System.exit(0); System.exit(0);
} }
private Instant loadLastSync(String identifier) {
try {
localDB.loadUsers();
localDB.setUser(localDB.getUsers().get(identifier));
localDB.initializeUserStorage();
localDB.loadUserData();
} catch (final Exception e) {
// User storage empty, wrong user name etc. -> default lastSync
}
return localDB.getLastSync();
}
private void performHandshake(LoginCredentials credentials) {
try {
client.performHandshake(credentials, cacheMap);
if (client.isOnline()) {
loadChatScene();
client.initReceiver(localDB, cacheMap);
}
} catch (IOException | InterruptedException | TimeoutException e) {
logger.log(Level.INFO, "Could not connect to server. Entering offline mode...");
attemptOfflineMode(credentials);
}
}
private void attemptOfflineMode(LoginCredentials credentials) {
try {
// Try entering offline mode
localDB.loadUsers();
final User clientUser = localDB.getUsers().get(credentials.getIdentifier());
if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown");
client.setSender(clientUser);
loadChatScene();
} catch (final Exception e) {
new Alert(AlertType.ERROR, "Client error: " + e).showAndWait();
logger.log(Level.SEVERE, "Offline mode could not be loaded: ", e);
System.exit(1);
}
}
private void loadChatScene() {
// Set client user in local database
localDB.setUser(client.getSender());
// Initialize chats in local database
try {
localDB.initializeUserStorage();
localDB.loadUserData();
} catch (final FileNotFoundException e) {
// The local database file has not yet been created, probably first login
} catch (final Exception e) {
new Alert(AlertType.ERROR, "Error while loading local database: " + e + "\nChats will not be stored locally.").showAndWait();
logger.log(Level.WARNING, "Could not load local database: ", e);
}
// Initialize write proxy
final var writeProxy = new WriteProxy(client, localDB);
localDB.synchronize();
if (client.isOnline()) writeProxy.flushCache();
else
// Set all contacts to offline mode
localDB.getChats()
.stream()
.map(Chat::getRecipient)
.filter(User.class::isInstance)
.map(User.class::cast)
.forEach(u -> u.setStatus(UserStatus.OFFLINE));
// Load ChatScene
sceneContext.pop();
sceneContext.getStage().setMinHeight(400);
sceneContext.getStage().setMinWidth(843);
sceneContext.load(SceneContext.SceneInfo.CHAT_SCENE);
sceneContext.<ChatScene>getController().initializeData(sceneContext, localDB, client, writeProxy);
sceneContext.getStage().centerOnScreen();
if (StatusTrayIcon.isSupported()) {
// Configure hide on close
sceneContext.getStage().setOnCloseRequest(e -> {
if (settings.isHideOnClose()) {
sceneContext.getStage().setIconified(true);
e.consume();
}
});
// Initialize status tray icon
final var trayIcon = new StatusTrayIcon(sceneContext.getStage());
settings.getItems().get("hideOnClose").setChangeHandler(c -> {
if ((Boolean) c) trayIcon.show();
else trayIcon.hide();
});
}
}
} }

View File

@ -5,6 +5,7 @@ import javafx.scene.control.Label;
import javafx.scene.control.ListView; import javafx.scene.control.ListView;
import javafx.scene.control.TitledPane; import javafx.scene.control.TitledPane;
import envoy.client.data.Context;
import envoy.client.net.Client; import envoy.client.net.Client;
import envoy.client.ui.SceneContext; import envoy.client.ui.SceneContext;
import envoy.client.ui.listcell.AbstractListCell; import envoy.client.ui.listcell.AbstractListCell;
@ -26,21 +27,8 @@ public final class SettingsScene {
@FXML @FXML
private TitledPane titledPane; private TitledPane titledPane;
private SceneContext sceneContext; private final Client client = Context.getInstance().getClient();
private final SceneContext sceneContext = Context.getInstance().getSceneContext();
/**
* @param sceneContext enables the user to return to the chat scene
* @param client the {@code Client} used to get the current user and to
* check if this user is online
* @since Envoy Client v0.1-beta
*/
public void initializeData(SceneContext sceneContext, Client client) {
this.sceneContext = sceneContext;
settingsList.getItems().add(new GeneralSettingsPane());
settingsList.getItems().add(new UserSettingsPane(sceneContext, client.getSender(), client.isOnline()));
settingsList.getItems().add(new DownloadSettingsPane(sceneContext));
settingsList.getItems().add(new BugReportPane(client.getSender(), client.isOnline()));
}
@FXML @FXML
private void initialize() { private void initialize() {
@ -49,6 +37,10 @@ public final class SettingsScene {
@Override @Override
protected Label renderItem(SettingsPane item) { return new Label(item.getTitle()); } protected Label renderItem(SettingsPane item) { return new Label(item.getTitle()); }
}); });
settingsList.getItems().add(new GeneralSettingsPane());
settingsList.getItems().add(new UserSettingsPane(sceneContext, client.getSender(), client.isOnline()));
settingsList.getItems().add(new DownloadSettingsPane(sceneContext));
settingsList.getItems().add(new BugReportPane(client.getSender(), client.isOnline()));
} }
@FXML @FXML

View File

@ -0,0 +1,29 @@
package envoy.client.ui.controller;
/**
* Provides options to select different tabs.
* <p>
* Project: <strong>client</strong><br>
* File: <strong>Tabs.java</strong><br>
* Created: <strong>30.8.2020</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Client v0.2-beta
*/
public enum Tabs {
/**
* Selects the {@code contact list} tab.
*/
CONTACT_LIST,
/**
* Selects the {@code contact search} tab.
*/
CONTACT_SEARCH,
/**
* Selects the {@code group creation} tab.
*/
GROUP_CREATION
}

View File

@ -19,6 +19,7 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import envoy.client.data.Context;
import envoy.client.data.LocalDB; import envoy.client.data.LocalDB;
import envoy.client.data.Settings; import envoy.client.data.Settings;
import envoy.client.ui.AudioControl; import envoy.client.ui.AudioControl;
@ -43,11 +44,10 @@ import envoy.util.EnvoyLog;
*/ */
public final class MessageControl extends Label { public final class MessageControl extends Label {
private boolean ownMessage; private final boolean ownMessage;
private static LocalDB localDB; private final LocalDB localDB = Context.getInstance().getLocalDB();
private final SceneContext sceneContext = Context.getInstance().getSceneContext();
private static SceneContext sceneContext;
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss") private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss")
.withZone(ZoneId.systemDefault()); .withZone(ZoneId.systemDefault());
@ -177,22 +177,10 @@ public final class MessageControl extends Label {
} }
} }
/**
* @param localDB the localDB used by the current user
* @since Envoy Client v0.2-beta
*/
public static void setLocalDB(LocalDB localDB) { MessageControl.localDB = localDB; }
/** /**
* @return whether the message stored by this {@code MessageControl} has been * @return whether the message stored by this {@code MessageControl} has been
* sent by this user of Envoy * sent by this user of Envoy
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
public boolean isOwnMessage() { return ownMessage; } public boolean isOwnMessage() { return ownMessage; }
/**
* @param sceneContext the scene context storing the stage used in Envoy
* @since Envoy Client v0.1-beta
*/
public static void setSceneContext(SceneContext sceneContext) { MessageControl.sceneContext = sceneContext; }
} }

View File

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

View File

@ -1,17 +0,0 @@
package envoy.constant;
/**
* Project: <strong>client</strong><br>
* File: <strong>Tabs.java</strong><br>
* Created: <strong>Aug 30, 2020</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Client v0.2-beta
*/
public class Tabs {
private Tabs() {}
public static int CONTACT_LIST = 0;
public static int CONTACT_SEARCH = 1;
public static int GROUP_CREATION = 2;
}

View File

@ -107,19 +107,19 @@
-fx-background-color: transparent; -fx-background-color: transparent;
} }
#infoLabel-success { #info-label-success {
-fx-text-fill: #00FF00; -fx-text-fill: #00FF00;
} }
#infoLabel-info { #info-label-info {
-fx-text-fill: yellow; -fx-text-fill: yellow;
} }
#infoLabel-warning { #info-label-warning {
-fx-text-fill: orange; -fx-text-fill: orange;
} }
#infoLabel-error { #info-label-error {
-fx-text-fill: red; -fx-text-fill: red;
} }
@ -136,9 +136,9 @@
} }
.tab-pane { .tab-pane {
-fx-tab-max-height: 0 ; -fx-tab-max-height: 0.0 ;
} }
.tab-pane .tab-header-area { .tab-pane .tab-header-area {
visibility: hidden ; visibility: hidden ;
-fx-padding: -20 0 0 0; -fx-padding: -20.0 0.0 0.0 0.0;
} }

View File

@ -21,107 +21,146 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<GridPane fx:id="scene" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="500.0" prefHeight="1152.0" prefWidth="2042.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.ChatScene"> <GridPane fx:id="scene" maxHeight="-Infinity"
maxWidth="-Infinity" minHeight="400.0" minWidth="500.0"
prefHeight="1152.0" prefWidth="2042.0"
xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="envoy.client.ui.controller.ChatScene">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="NEVER" maxWidth="327.99997965494794" minWidth="-Infinity" prefWidth="317.0" /> <ColumnConstraints hgrow="NEVER"
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" /> maxWidth="327.99997965494794" minWidth="-Infinity" prefWidth="317.0" />
<ColumnConstraints hgrow="ALWAYS"
maxWidth="1.7976931348623157E308" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="122.00000508626302" minHeight="-Infinity" prefHeight="96.66666158040364" vgrow="NEVER" /> <RowConstraints maxHeight="122.00000508626302"
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="50.0" prefHeight="949.3333384195963" vgrow="ALWAYS" /> minHeight="-Infinity" prefHeight="96.66666158040364" vgrow="NEVER" />
<RowConstraints maxHeight="59.3333740234375" minHeight="-Infinity" prefHeight="22.666748046875" vgrow="NEVER" /> <RowConstraints maxHeight="1.7976931348623157E308"
<RowConstraints maxHeight="120.0" minHeight="-Infinity" prefHeight="83.333251953125" vgrow="NEVER" /> minHeight="50.0" prefHeight="949.3333384195963" vgrow="ALWAYS" />
<RowConstraints maxHeight="59.3333740234375"
minHeight="-Infinity" prefHeight="22.666748046875" vgrow="NEVER" />
<RowConstraints maxHeight="120.0" minHeight="-Infinity"
prefHeight="83.333251953125" vgrow="NEVER" />
</rowConstraints> </rowConstraints>
<children> <children>
<TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="1" GridPane.rowSpan="2147483647"> <TabPane fx:id="tabPane" prefHeight="200.0" prefWidth="200.0"
<tabs> tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="1"
<Tab text=""> GridPane.rowSpan="2147483647">
<content> <tabs>
<AnchorPane minHeight="0.0" minWidth="0.0"> <Tab text="">
<children> <content>
<VBox fx:id="contactOperations" prefHeight="3000.0" prefWidth="316.0"> <AnchorPane minHeight="0.0" minWidth="0.0">
<children> <children>
<VBox id="search-panel" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="80.0" prefWidth="316.0"> <VBox fx:id="contactOperations" prefHeight="3000.0"
<children> prefWidth="316.0">
<Label id="contact-search-enter-container" maxHeight="30.0" minHeight="30.0" prefHeight="30.0" prefWidth="325.0"> <children>
<graphic> <VBox id="search-panel" maxHeight="-Infinity"
<TextArea id="contact-search-input" fx:id="contactSearch" focusTraversable="false" maxHeight="30.0" minHeight="30.0" onInputMethodTextChanged="#searchContacts" onKeyTyped="#searchContacts" prefHeight="30.0" prefWidth="200.0" promptText="Search Contacts"> minHeight="-Infinity" prefHeight="80.0" prefWidth="316.0">
<font> <children>
<Font size="14.0" /> <Label id="contact-search-enter-container"
</font> maxHeight="30.0" minHeight="30.0" prefHeight="30.0"
<padding> prefWidth="325.0">
<Insets left="12.0" right="12.0" /> <graphic>
</padding> <TextArea id="contact-search-input"
</TextArea> fx:id="contactSearch" focusTraversable="false"
</graphic> maxHeight="30.0" minHeight="30.0"
<VBox.margin> onInputMethodTextChanged="#searchContacts"
<Insets left="10.0" right="10.0" top="3.0" /> onKeyTyped="#searchContacts" prefHeight="30.0"
</VBox.margin> prefWidth="200.0" promptText="Search Contacts">
</Label> <font>
<HBox id="underline" alignment="TOP_CENTER" prefHeight="41.0" prefWidth="296.0" spacing="5.0"> <Font size="14.0" />
<children> </font>
<Button mnemonicParsing="true" onAction="#addContactButtonClicked" prefWidth="100.0" text=" Add Contact"> <padding>
<padding> <Insets left="12.0" right="12.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </padding>
</padding> </TextArea>
<HBox.margin> </graphic>
<Insets /> <VBox.margin>
</HBox.margin> <Insets left="10.0" right="10.0" top="3.0" />
</Button> </VBox.margin>
<Button mnemonicParsing="false" onAction="#groupCreationButtonClicked" prefWidth="100.0" text="New Group"> </Label>
<HBox.margin> <HBox fx:id="contactSpecificOnlineOperations"
<Insets /> id="underline" alignment="TOP_CENTER" prefHeight="41.0"
</HBox.margin> prefWidth="296.0" spacing="5.0">
<padding> <children>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Button fx:id="newContactButton"
</padding> mnemonicParsing="true"
</Button> onAction="#addContactButtonClicked" prefWidth="100.0"
</children> text=" Add Contact">
<VBox.margin> <padding>
<Insets left="10.0" right="10.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0"
</VBox.margin> top="5.0" />
<padding> </padding>
<Insets top="3.0" /> <HBox.margin>
</padding> <Insets />
</HBox> </HBox.margin>
</children> </Button>
</VBox> <Button fx:id="newGroupButton"
<ListView id="chat-list" fx:id="chatList" focusTraversable="false" onMouseClicked="#chatListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS"> mnemonicParsing="false"
<contextMenu> onAction="#groupCreationButtonClicked" prefWidth="100.0"
<ContextMenu anchorLocation="CONTENT_TOP_LEFT"> text="New Group">
<items> <HBox.margin>
<MenuItem fx:id="deleteContactMenuItem" mnemonicParsing="false" onAction="#deleteContact" text="Delete" /> <Insets />
</items> </HBox.margin>
</ContextMenu> <padding>
</contextMenu> <Insets bottom="5.0" left="5.0" right="5.0"
<padding> top="5.0" />
<Insets bottom="5.0" left="5.0" right="2.0" top="5.0" /> </padding>
</padding> </Button>
</ListView> </children>
</children> <VBox.margin>
</VBox> <Insets left="10.0" right="10.0" top="5.0" />
</children> </VBox.margin>
</AnchorPane> <padding>
</content> <Insets top="3.0" />
</Tab> </padding>
<Tab fx:id="contactSearchTab" text=""> </HBox>
<content> </children>
</content> </VBox>
</Tab> <ListView id="chat-list" fx:id="chatList"
<Tab fx:id="groupCreationTab" text="" /> focusTraversable="false" onMouseClicked="#chatListClicked"
</tabs> prefWidth="316.0" VBox.vgrow="ALWAYS">
<GridPane.margin> <contextMenu>
<Insets right="1.0" /> <ContextMenu anchorLocation="CONTENT_TOP_LEFT">
</GridPane.margin> <items>
</TabPane> <MenuItem fx:id="deleteContactMenuItem"
mnemonicParsing="false" onAction="#deleteContact"
text="Delete" />
</items>
</ContextMenu>
</contextMenu>
<padding>
<Insets bottom="5.0" left="5.0" right="2.0" top="5.0" />
</padding>
</ListView>
</children>
</VBox>
</children>
</AnchorPane>
</content>
</Tab>
<Tab fx:id="contactSearchTab" text="">
<content>
</content>
</Tab>
<Tab fx:id="groupCreationTab" text="" />
</tabs>
<GridPane.margin>
<Insets right="1.0" />
</GridPane.margin>
</TabPane>
<HBox id="top-bar" alignment="CENTER_LEFT" prefHeight="100.0"> <HBox id="top-bar" alignment="CENTER_LEFT" prefHeight="100.0">
<children> <children>
<ImageView id="profile-pic" fx:id="clientProfilePic" fitHeight="43.0" fitWidth="43.0" pickOnBounds="true" preserveRatio="true"> <ImageView id="profile-pic" fx:id="clientProfilePic"
fitHeight="43.0" fitWidth="43.0" pickOnBounds="true"
preserveRatio="true">
<HBox.margin> <HBox.margin>
<Insets left="15.0" top="5.0" /> <Insets left="15.0" top="5.0" />
</HBox.margin> </HBox.margin>
</ImageView> </ImageView>
<Label id="transparent-background" fx:id="contactLabel" prefHeight="27.0" prefWidth="134.0"> <Label id="transparent-background" fx:id="contactLabel"
prefHeight="27.0" prefWidth="134.0">
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
@ -132,10 +171,14 @@
<Insets left="10.0" top="5.0" /> <Insets left="10.0" top="5.0" />
</HBox.margin> </HBox.margin>
</Label> </Label>
<Region id="transparent-background" prefHeight="77.0" prefWidth="115.0" /> <Region id="transparent-background" prefHeight="77.0"
<VBox id="transparent-background" alignment="CENTER_RIGHT" prefHeight="200.0" prefWidth="100.0" spacing="5.0"> prefWidth="115.0" />
<VBox id="transparent-background" alignment="CENTER_RIGHT"
prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<children> <children>
<Button fx:id="settingsButton" mnemonicParsing="true" onAction="#settingsButtonClicked" prefHeight="30.0" prefWidth="30.0" text=""> <Button fx:id="settingsButton" mnemonicParsing="true"
onAction="#settingsButtonClicked" prefHeight="30.0"
prefWidth="30.0" text="">
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
@ -156,7 +199,10 @@
<Insets bottom="1.0" right="1.0" /> <Insets bottom="1.0" right="1.0" />
</GridPane.margin> </GridPane.margin>
</HBox> </HBox>
<ListView id="message-list" fx:id="messageList" focusTraversable="false" GridPane.columnIndex="1" GridPane.columnSpan="2147483647" GridPane.rowIndex="1" GridPane.rowSpan="2"> <ListView id="message-list" fx:id="messageList"
focusTraversable="false" GridPane.columnIndex="1"
GridPane.columnSpan="2147483647" GridPane.rowIndex="1"
GridPane.rowSpan="2">
<GridPane.margin> <GridPane.margin>
<Insets /> <Insets />
</GridPane.margin> </GridPane.margin>
@ -164,11 +210,17 @@
<Insets bottom="5.0" top="5.0" /> <Insets bottom="5.0" top="5.0" />
</padding> </padding>
</ListView> </ListView>
<HBox alignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="3"> <HBox alignment="CENTER" GridPane.columnIndex="1"
GridPane.rowIndex="3">
<children> <children>
<Label id="text-enter-container" alignment="CENTER" minWidth="300.0" prefHeight="100.0" prefWidth="800.0"> <Label id="text-enter-container" alignment="CENTER"
minWidth="300.0" prefHeight="100.0" prefWidth="800.0">
<graphic> <graphic>
<TextArea id="message-enter" fx:id="messageTextArea" disable="true" onInputMethodTextChanged="#messageTextUpdated" onKeyPressed="#checkPostConditions" onKeyTyped="#checkKeyCombination" prefHeight="100.0" prefWidth="1250.0" promptText="Enter Message" wrapText="true"> <TextArea id="message-enter" fx:id="messageTextArea"
disable="true" onInputMethodTextChanged="#messageTextUpdated"
onKeyPressed="#checkPostConditions"
onKeyTyped="#checkKeyCombination" prefHeight="100.0"
prefWidth="1250.0" promptText="Enter Message" wrapText="true">
<opaqueInsets> <opaqueInsets>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</opaqueInsets> </opaqueInsets>
@ -180,30 +232,42 @@
</Label> </Label>
<HBox prefHeight="38.0" prefWidth="100.0" spacing="5.0"> <HBox prefHeight="38.0" prefWidth="100.0" spacing="5.0">
<children> <children>
<Button id="round-button" fx:id="postButton" defaultButton="true" disable="true" minWidth="40.0" mnemonicParsing="true" onAction="#postMessage" prefHeight="40.0" prefWidth="40.0" text="Post"> <Button id="round-button" fx:id="postButton"
defaultButton="true" disable="true" minWidth="40.0"
mnemonicParsing="true" onAction="#postMessage" prefHeight="40.0"
prefWidth="40.0" text="Post">
<tooltip> <tooltip>
<Tooltip anchorLocation="WINDOW_TOP_LEFT" autoHide="true" maxWidth="350.0" text="Click this button to send the message. If it is disabled, you first have to select a contact to send it to. A message may automatically be sent when you press (Ctrl + ) Enter, according to your preferences. Additionally sends a message when pressing &quot;Alt&quot; + &quot;P&quot;." wrapText="true" /> <Tooltip anchorLocation="WINDOW_TOP_LEFT"
autoHide="true" maxWidth="350.0"
text="Click this button to send the message. If it is disabled, you first have to select a contact to send it to. A message may automatically be sent when you press (Ctrl + ) Enter, according to your preferences. Additionally sends a message when pressing &quot;Alt&quot; + &quot;P&quot;."
wrapText="true" />
</tooltip> </tooltip>
<contextMenu> <contextMenu>
<ContextMenu anchorLocation="CONTENT_TOP_LEFT"> <ContextMenu anchorLocation="CONTENT_TOP_LEFT">
<items> <items>
<MenuItem mnemonicParsing="false" onAction="#copyAndPostMessage" text="Copy and Send" /> <MenuItem mnemonicParsing="false"
onAction="#copyAndPostMessage" text="Copy and Send" />
</items> </items>
</ContextMenu> </ContextMenu>
</contextMenu> </contextMenu>
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
<HBox.margin> <HBox.margin>
<Insets left="10.0" /> <Insets left="10.0" />
</HBox.margin> </HBox.margin>
</Button> </Button>
<Button id="round-button" fx:id="voiceButton" disable="true" minWidth="40.0" onAction="#voiceButtonClicked" prefHeight="40.0" prefWidth="40.0"> <Button id="round-button" fx:id="voiceButton"
disable="true" minWidth="40.0" onAction="#voiceButtonClicked"
prefHeight="40.0" prefWidth="40.0">
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
</Button> </Button>
<Button id="round-button" fx:id="attachmentButton" disable="true" minWidth="40.0" mnemonicParsing="false" onAction="#attachmentButtonClicked" prefHeight="40.0" prefWidth="40.0"> <Button id="round-button" fx:id="attachmentButton"
disable="true" minWidth="40.0" mnemonicParsing="false"
onAction="#attachmentButtonClicked" prefHeight="40.0"
prefWidth="40.0">
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
@ -218,9 +282,13 @@
<Insets bottom="40.0" left="10.0" right="10.0" top="15.0" /> <Insets bottom="40.0" left="10.0" right="10.0" top="15.0" />
</GridPane.margin> </GridPane.margin>
</HBox> </HBox>
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="2"> <HBox prefHeight="100.0" prefWidth="200.0"
GridPane.columnIndex="1" GridPane.rowIndex="2">
<children> <children>
<Label id="remaining-chars-label" fx:id="remainingChars" ellipsisString="" maxHeight="30.0" maxWidth="180.0" prefHeight="30.0" prefWidth="180.0" text="remaining chars: 0/x" textFill="LIME" textOverrun="LEADING_WORD_ELLIPSIS" visible="false"> <Label id="remaining-chars-label" fx:id="remainingChars"
ellipsisString="" maxHeight="30.0" maxWidth="180.0"
prefHeight="30.0" prefWidth="180.0" text="remaining chars: 0/x"
textFill="LIME" textOverrun="LEADING_WORD_ELLIPSIS" visible="false">
<padding> <padding>
<Insets bottom="5.0" top="5.0" /> <Insets bottom="5.0" top="5.0" />
</padding> </padding>
@ -228,17 +296,23 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</opaqueInsets> </opaqueInsets>
<tooltip> <tooltip>
<Tooltip text="Shows how many chars you can still enter in this message" wrapText="true" /> <Tooltip
text="Shows how many chars you can still enter in this message"
wrapText="true" />
</tooltip> </tooltip>
</Label> </Label>
<Label fx:id="infoLabel" text="Something happened" textFill="#faa007" visible="false" wrapText="true"> <Label fx:id="infoLabel" text="Something happened"
textFill="#faa007" visible="false" wrapText="true">
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
</Label> </Label>
</children> </children>
</HBox> </HBox>
<ImageView fx:id="attachmentView" pickOnBounds="true" preserveRatio="true" visible="false" GridPane.columnIndex="1" GridPane.columnSpan="2147483647" GridPane.halignment="RIGHT" GridPane.rowIndex="2"> <ImageView fx:id="attachmentView" pickOnBounds="true"
preserveRatio="true" visible="false" GridPane.columnIndex="1"
GridPane.columnSpan="2147483647" GridPane.halignment="RIGHT"
GridPane.rowIndex="2">
<viewport> <viewport>
<Rectangle2D height="20.0" width="20.0" /> <Rectangle2D height="20.0" width="20.0" />
</viewport> </viewport>
@ -246,14 +320,18 @@
<Insets bottom="5.0" right="10.0" top="5.0" /> <Insets bottom="5.0" right="10.0" top="5.0" />
</GridPane.margin> </GridPane.margin>
</ImageView> </ImageView>
<HBox id="top-bar" alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1"> <HBox id="top-bar" alignment="CENTER_LEFT" prefHeight="100.0"
prefWidth="200.0" GridPane.columnIndex="1">
<children> <children>
<ImageView id="profile-pic" fx:id="recipientProfilePic" fitHeight="43.0" fitWidth="43.0" pickOnBounds="true" preserveRatio="true"> <ImageView id="profile-pic" fx:id="recipientProfilePic"
fitHeight="43.0" fitWidth="43.0" pickOnBounds="true"
preserveRatio="true">
<HBox.margin> <HBox.margin>
<Insets left="20.0" top="5.0" /> <Insets left="20.0" top="5.0" />
</HBox.margin> </HBox.margin>
</ImageView> </ImageView>
<VBox alignment="CENTER_LEFT" prefHeight="97.0" prefWidth="316.0"> <VBox alignment="CENTER_LEFT" prefHeight="97.0"
prefWidth="316.0">
<children> <children>
<Label fx:id="topBarContactLabel" text=""> <Label fx:id="topBarContactLabel" text="">
<font> <font>
@ -266,8 +344,12 @@
<Insets left="15.0" /> <Insets left="15.0" />
</HBox.margin> </HBox.margin>
</VBox> </VBox>
<Region prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" /> <Region prefHeight="200.0" prefWidth="200.0"
<Button id="round-button" fx:id="messageSearchButton" contentDisplay="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="40.0" prefWidth="40.0" visible="false"> HBox.hgrow="ALWAYS" />
<Button id="round-button" fx:id="messageSearchButton"
contentDisplay="CENTER" maxHeight="-Infinity" maxWidth="-Infinity"
minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false"
prefHeight="40.0" prefWidth="40.0" visible="false">
<HBox.margin> <HBox.margin>
<Insets right="20.0" /> <Insets right="20.0" />
</HBox.margin> </HBox.margin>

View File

@ -40,8 +40,8 @@
<Label id="infoLabel-error" fx:id="errorMessageLabel" maxHeight="0.0" minHeight="0.0" prefHeight="0.0" textAlignment="CENTER" textFill="RED" VBox.vgrow="ALWAYS" /> <Label id="infoLabel-error" fx:id="errorMessageLabel" maxHeight="0.0" minHeight="0.0" prefHeight="0.0" textAlignment="CENTER" textFill="RED" VBox.vgrow="ALWAYS" />
<HBox fx:id="errorProceedBox" alignment="TOP_CENTER" maxHeight="0.0" minHeight="0.0" prefHeight="0.0" prefWidth="316.0" spacing="5.0"> <HBox fx:id="errorProceedBox" alignment="TOP_CENTER" maxHeight="0.0" minHeight="0.0" prefHeight="0.0" prefWidth="316.0" spacing="5.0">
<children> <children>
<Button id="proceed-button" fx:id="proceedDupButton" maxHeight="0.0" minHeight="0.0" mnemonicParsing="false" onAction="#proceedOnNameDuplication" prefHeight="0.0" text="Proceed" /> <Button id="proceed-button" fx:id="proceedDuplicateButton" maxHeight="0.0" minHeight="0.0" mnemonicParsing="false" onAction="#proceedOnNameDuplication" prefHeight="0.0" text="Proceed" />
<Button id="proceed-button" fx:id="cancelDupButton" maxHeight="0.0" minHeight="0.0" mnemonicParsing="false" onAction="#cancelOnNameDuplication" prefHeight="0.0" text="Cancel" /> <Button id="proceed-button" fx:id="cancelDuplicateButton" maxHeight="0.0" minHeight="0.0" mnemonicParsing="false" onAction="#cancelOnNameDuplication" prefHeight="0.0" text="Cancel" />
</children> </children>
</HBox> </HBox>
<HBox id="underline" alignment="TOP_CENTER" prefWidth="200.0" spacing="5.0"> <HBox id="underline" alignment="TOP_CENTER" prefWidth="200.0" spacing="5.0">

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long