Merge branch 'develop' into f/compatibility_verification
Conflicts: src/main/java/envoy/client/net/Client.java src/main/java/envoy/client/net/MessageStatusChangeEventProcessor.java src/main/java/envoy/client/ui/Startup.java src/main/java/envoy/client/ui/controller/ChatScene.java src/main/java/envoy/client/ui/controller/ContactSearchScene.java src/main/java/envoy/client/ui/controller/GroupCreationScene.java src/main/java/envoy/client/ui/controller/LoginScene.java
This commit is contained in:
commit
0bbade44a7
@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import envoy.util.EnvoyLog;
|
||||
@ -25,7 +26,7 @@ public class Cache<T> implements Consumer<T>, Serializable {
|
||||
private transient Consumer<T> processor;
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(Cache.class);
|
||||
private static final long serialVersionUID = 0L;
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Adds an element to the cache.
|
||||
@ -35,7 +36,7 @@ public class Cache<T> implements Consumer<T>, Serializable {
|
||||
*/
|
||||
@Override
|
||||
public void accept(T element) {
|
||||
logger.fine(String.format("Adding element %s to cache", element));
|
||||
logger.log(Level.FINE, String.format("Adding element %s to cache", element));
|
||||
elements.offer(element);
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package envoy.client.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import envoy.data.ConfigItem;
|
||||
import envoy.data.IDGenerator;
|
||||
import envoy.data.Message;
|
||||
import envoy.event.MessageStatusChange;
|
||||
import envoy.util.SerializationUtils;
|
||||
|
||||
/**
|
||||
@ -21,92 +21,67 @@ import envoy.util.SerializationUtils;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-alpha
|
||||
*/
|
||||
public class PersistentLocalDB extends LocalDB {
|
||||
public final class PersistentLocalDB extends LocalDB {
|
||||
|
||||
private File localDBDir, localDBFile, usersFile, idGeneratorFile, messageCacheFile, statusCacheFile;
|
||||
private File dbDir, userFile, idGeneratorFile, usersFile;
|
||||
|
||||
/**
|
||||
* Initializes an empty local database without a directory. All changes made to
|
||||
* this instance cannot be saved to the file system.<br>
|
||||
* <br>
|
||||
* This constructor shall be used in conjunction with the {@code ignoreLocalDB}
|
||||
* {@link ConfigItem}.
|
||||
* Constructs an empty local database. To serialize any user-specific data to
|
||||
* the file system, call {@link PersistentLocalDB#initializeUserStorage()} first
|
||||
* and then {@link PersistentLocalDB#save()}.
|
||||
*
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public PersistentLocalDB() {}
|
||||
|
||||
/**
|
||||
* Constructs an empty local database. To serialize any chats to the file
|
||||
* system, call {@link PersistentLocalDB#initializeUserStorage()}.
|
||||
*
|
||||
* @param localDBDir the directory in which to store users and chats
|
||||
* @throws IOException if the PersistentLocalDB could not be initialized
|
||||
* @param dbDir the directory in which to persist data
|
||||
* @throws IOException if {@code dbDir} is a file (and not a directory)
|
||||
* @since Envoy Client v0.1-alpha
|
||||
*/
|
||||
public PersistentLocalDB(File localDBDir) throws IOException {
|
||||
this.localDBDir = localDBDir;
|
||||
public PersistentLocalDB(File dbDir) throws IOException {
|
||||
this.dbDir = dbDir;
|
||||
|
||||
// Initialize local database directory
|
||||
if (localDBDir.exists() && !localDBDir.isDirectory())
|
||||
throw new IOException(String.format("LocalDBDir '%s' is not a directory!", localDBDir.getAbsolutePath()));
|
||||
usersFile = new File(localDBDir, "users.db");
|
||||
idGeneratorFile = new File(localDBDir, "id_generator.db");
|
||||
// Test if the database directory is actually a directory
|
||||
if (dbDir.exists() && !dbDir.isDirectory())
|
||||
throw new IOException(String.format("LocalDBDir '%s' is not a directory!", dbDir.getAbsolutePath()));
|
||||
|
||||
// Initialize global files
|
||||
idGeneratorFile = new File(dbDir, "id_gen.db");
|
||||
usersFile = new File(dbDir, "users.db");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a database file for a user-specific list of chats.<br>
|
||||
* {@inheritDoc}
|
||||
* Creates a database file for a user-specific list of chats.
|
||||
*
|
||||
* @throws NullPointerException if the client user is not yet specified
|
||||
* @throws IllegalStateException if the client user is not specified
|
||||
* @since Envoy Client v0.1-alpha
|
||||
*/
|
||||
@Override
|
||||
public void initializeUserStorage() {
|
||||
if (user == null) throw new NullPointerException("Client user is null");
|
||||
localDBFile = new File(localDBDir, user.getID() + ".db");
|
||||
messageCacheFile = new File(localDBDir, user.getID() + "_message_cache.db");
|
||||
statusCacheFile = new File(localDBDir, user.getID() + "_status_cache.db");
|
||||
if (user == null) throw new IllegalStateException("Client user is null, cannot initialize user storage");
|
||||
userFile = new File(dbDir, user.getID() + ".db");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void save() throws IOException {
|
||||
// Save users
|
||||
SerializationUtils.write(usersFile, users);
|
||||
|
||||
// Save user data
|
||||
if (user != null) {
|
||||
SerializationUtils.write(localDBFile, chats);
|
||||
SerializationUtils.write(messageCacheFile, messageCache);
|
||||
SerializationUtils.write(statusCacheFile, statusCache);
|
||||
}
|
||||
if (user != null) SerializationUtils.write(userFile, chats, messageCache, statusCache);
|
||||
|
||||
// Save id generator
|
||||
if (hasIDGenerator()) SerializationUtils.write(idGeneratorFile, idGenerator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void loadUsers() throws ClassNotFoundException, IOException { users = SerializationUtils.read(usersFile, HashMap.class); }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void loadUserData() throws ClassNotFoundException, IOException {
|
||||
chats = SerializationUtils.read(localDBFile, ArrayList.class);
|
||||
messageCache = SerializationUtils.read(messageCacheFile, Cache.class);
|
||||
statusCache = SerializationUtils.read(statusCacheFile, Cache.class);
|
||||
try (var in = new ObjectInputStream(new FileInputStream(userFile))) {
|
||||
chats = (ArrayList<Chat>) in.readObject();
|
||||
messageCache = (Cache<Message>) in.readObject();
|
||||
statusCache = (Cache<MessageStatusChange>) in.readObject();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void loadIDGenerator() {
|
||||
try {
|
||||
|
@ -11,5 +11,5 @@ package envoy.client.data;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class TransientLocalDB extends LocalDB {
|
||||
public final class TransientLocalDB extends LocalDB {
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import envoy.client.data.Cache;
|
||||
@ -67,8 +68,7 @@ public class Client implements Closeable {
|
||||
* from the server that can be relayed
|
||||
* after initialization
|
||||
* @throws TimeoutException if the server could not be reached
|
||||
* @throws IOException if the login credentials could not be
|
||||
* written
|
||||
* @throws IOException if the login credentials could not be written
|
||||
* @throws InterruptedException if the current thread is interrupted while
|
||||
* waiting for the handshake response
|
||||
*/
|
||||
@ -77,9 +77,9 @@ public class Client implements Closeable {
|
||||
throws TimeoutException, IOException, InterruptedException {
|
||||
if (online) throw new IllegalStateException("Handshake has already been performed successfully");
|
||||
// Establish TCP connection
|
||||
logger.finer(String.format("Attempting connection to server %s:%d...", config.getServer(), config.getPort()));
|
||||
logger.log(Level.FINER, String.format("Attempting connection to server %s:%d...", config.getServer(), config.getPort()));
|
||||
socket = new Socket(config.getServer(), config.getPort());
|
||||
logger.fine("Successfully established TCP connection to server");
|
||||
logger.log(Level.FINE, "Successfully established TCP connection to server");
|
||||
|
||||
// Create object receiver
|
||||
receiver = new Receiver(socket.getInputStream());
|
||||
@ -119,7 +119,7 @@ public class Client implements Closeable {
|
||||
// Remove all processors as they are only used during the handshake
|
||||
receiver.removeAllProcessors();
|
||||
|
||||
logger.info("Handshake completed.");
|
||||
logger.log(Level.INFO, "Handshake completed.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,7 +147,7 @@ public class Client implements Closeable {
|
||||
checkOnline();
|
||||
|
||||
// Process incoming messages
|
||||
final ReceivedMessageProcessor receivedMessageProcessor = new ReceivedMessageProcessor();
|
||||
final ReceivedMessageProcessor receivedMessageProcessor = new ReceivedMessageProcessor();
|
||||
final MessageStatusChangeProcessor messageStatusChangeEventProcessor = new MessageStatusChangeProcessor();
|
||||
|
||||
receiver.registerProcessor(Message.class, receivedMessageProcessor);
|
||||
@ -183,6 +183,7 @@ public class Client implements Closeable {
|
||||
sendEvent(evt.get());
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.log(Level.WARNING, "An error occurred when trying to send Event " + evt, e);
|
||||
}
|
||||
});
|
||||
|
||||
@ -229,7 +230,7 @@ public class Client implements Closeable {
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public void requestIdGenerator() throws IOException {
|
||||
logger.info("Requesting new id generator...");
|
||||
logger.log(Level.INFO, "Requesting new id generator...");
|
||||
writeObject(new IDGeneratorRequest());
|
||||
}
|
||||
|
||||
@ -251,7 +252,7 @@ public class Client implements Closeable {
|
||||
|
||||
private void writeObject(Object obj) throws IOException {
|
||||
checkOnline();
|
||||
logger.fine("Sending " + obj);
|
||||
logger.log(Level.FINE, "Sending " + obj);
|
||||
SerializationUtils.writeBytesWithLength(obj, socket.getOutputStream());
|
||||
}
|
||||
|
||||
@ -269,7 +270,7 @@ public class Client implements Closeable {
|
||||
* @param clientUser the client user to set
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public void setSender(User clientUser) { this.sender = clientUser; }
|
||||
public void setSender(User clientUser) { sender = clientUser; }
|
||||
|
||||
/**
|
||||
* @return the {@link Receiver} used by this {@link Client}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package envoy.client.net;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import envoy.client.event.MessageCreationEvent;
|
||||
@ -23,7 +24,7 @@ public class ReceivedMessageProcessor implements Consumer<Message> {
|
||||
|
||||
@Override
|
||||
public void accept(Message message) {
|
||||
if (message.getStatus() != MessageStatus.SENT) logger.warning("The message has the unexpected status " + message.getStatus());
|
||||
if (message.getStatus() != MessageStatus.SENT) logger.log(Level.WARNING, "The message has the unexpected status " + message.getStatus());
|
||||
else {
|
||||
// Update status to RECEIVED
|
||||
message.nextStatus();
|
||||
|
@ -45,7 +45,7 @@ public class Receiver extends Thread {
|
||||
/**
|
||||
* Starts the receiver loop. When an object is read, it is passed to the
|
||||
* appropriate processor.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
@Override
|
||||
@ -54,29 +54,30 @@ public class Receiver extends Thread {
|
||||
try {
|
||||
while (true) {
|
||||
// Read object length
|
||||
byte[] lenBytes = new byte[4];
|
||||
final byte[] lenBytes = new byte[4];
|
||||
in.read(lenBytes);
|
||||
int len = SerializationUtils.bytesToInt(lenBytes, 0);
|
||||
final int len = SerializationUtils.bytesToInt(lenBytes, 0);
|
||||
|
||||
// Read object into byte array
|
||||
byte[] objBytes = new byte[len];
|
||||
final byte[] objBytes = new byte[len];
|
||||
in.read(objBytes);
|
||||
|
||||
try (ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(objBytes))) {
|
||||
Object obj = oin.readObject();
|
||||
logger.fine("Received " + obj);
|
||||
final Object obj = oin.readObject();
|
||||
logger.log(Level.FINE, "Received " + obj);
|
||||
|
||||
// Get appropriate processor
|
||||
@SuppressWarnings("rawtypes")
|
||||
Consumer processor = processors.get(obj.getClass());
|
||||
final Consumer processor = processors.get(obj.getClass());
|
||||
if (processor == null)
|
||||
logger.warning(String.format("The received object has the class %s for which no processor is defined.", obj.getClass()));
|
||||
logger.log(Level.WARNING, String.format(
|
||||
"The received object has the class %s for which no processor is defined.", obj.getClass()));
|
||||
else processor.accept(obj);
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
} catch (final SocketException e) {
|
||||
// Connection probably closed by client.
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
logger.log(Level.SEVERE, "Error on receiver thread", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -94,7 +95,7 @@ public class Receiver extends Thread {
|
||||
|
||||
/**
|
||||
* Removes all object processors registered at this {@link Receiver}.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public void removeAllProcessors() { processors.clear(); }
|
||||
|
@ -45,21 +45,21 @@ public class WriteProxy {
|
||||
// Initialize cache processors for messages and message status change events
|
||||
localDB.getMessageCache().setProcessor(msg -> {
|
||||
try {
|
||||
logger.finer("Sending cached " + msg);
|
||||
logger.log(Level.FINER, "Sending cached " + msg);
|
||||
client.sendMessage(msg);
|
||||
|
||||
// Update message state to SENT in localDB
|
||||
localDB.getMessage(msg.getID()).ifPresent(Message::nextStatus);
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Could not send cached message", e);
|
||||
} catch (final IOException e) {
|
||||
logger.log(Level.SEVERE, "Could not send cached message: ", e);
|
||||
}
|
||||
});
|
||||
localDB.getStatusCache().setProcessor(evt -> {
|
||||
logger.finer("Sending cached " + evt);
|
||||
logger.log(Level.FINER, "Sending cached " + evt);
|
||||
try {
|
||||
client.sendEvent(evt);
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Could not send cached message status change event", e);
|
||||
} catch (final IOException e) {
|
||||
logger.log(Level.SEVERE, "Could not send cached message status change event: ", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package envoy.client.ui;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import envoy.data.Contact;
|
||||
import envoy.data.Group;
|
||||
@ -32,32 +31,19 @@ public class ContactListCell extends ListCell<Contact> {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
// the infoLabel displays specific contact info, i.e. status of a user or amount
|
||||
// of members in a group
|
||||
Label infoLabel = null;
|
||||
// Container with contact name
|
||||
final var vbox = new VBox(new Label(contact.getName()));
|
||||
if (contact instanceof User) {
|
||||
// user specific info
|
||||
infoLabel = new Label(((User) contact).getStatus().toString());
|
||||
Color textColor = null;
|
||||
switch (((User) contact).getStatus()) {
|
||||
case ONLINE:
|
||||
textColor = Color.LIMEGREEN;
|
||||
break;
|
||||
case AWAY:
|
||||
textColor = Color.ORANGERED;
|
||||
break;
|
||||
case BUSY:
|
||||
textColor = Color.RED;
|
||||
break;
|
||||
case OFFLINE:
|
||||
textColor = Color.GRAY;
|
||||
break;
|
||||
}
|
||||
infoLabel.setTextFill(textColor);
|
||||
} else
|
||||
// group specific infos
|
||||
infoLabel = new Label(String.valueOf(((Group) contact).getContacts().size()) + " members");
|
||||
setGraphic(new VBox(new Label(contact.getName()), infoLabel));
|
||||
// Online status
|
||||
final var user = (User) contact;
|
||||
final var statusLabel = new Label(user.getStatus().toString());
|
||||
statusLabel.getStyleClass().add(user.getStatus().toString().toLowerCase());
|
||||
vbox.getChildren().add(statusLabel);
|
||||
} else {
|
||||
// Member count
|
||||
vbox.getChildren().add(new Label(((Group) contact).getContacts().size() + " members"));
|
||||
}
|
||||
setGraphic(vbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package envoy.client.ui;
|
||||
import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
@ -13,6 +14,7 @@ import javafx.scene.layout.VBox;
|
||||
|
||||
import envoy.data.Message;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
import envoy.util.EnvoyLog;
|
||||
|
||||
/**
|
||||
* Displays a single message inside the message list.
|
||||
@ -20,7 +22,7 @@ import envoy.data.Message.MessageStatus;
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>MessageListCell.java</strong><br>
|
||||
* Created: <strong>28.03.2020</strong><br>
|
||||
*
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@ -32,20 +34,21 @@ public class MessageListCell extends ListCell<Message> {
|
||||
static {
|
||||
try {
|
||||
statusImages = IconUtil.loadByEnum(MessageStatus.class, 32);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
EnvoyLog.getLogger(MessageListCell.class).log(Level.WARNING, "could not load status icons: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the text, the data of creation and the status of a message.
|
||||
*
|
||||
*
|
||||
* @since Envoy v0.1-beta
|
||||
*/
|
||||
@Override
|
||||
protected void updateItem(Message message, boolean empty) {
|
||||
super.updateItem(message, empty);
|
||||
if(empty || message == null) {
|
||||
if (empty || message == null) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
|
@ -2,6 +2,7 @@ package envoy.client.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
@ -11,6 +12,7 @@ import javafx.stage.Stage;
|
||||
import envoy.client.data.Settings;
|
||||
import envoy.client.event.ThemeChangeEvent;
|
||||
import envoy.event.EventBus;
|
||||
import envoy.util.EnvoyLog;
|
||||
|
||||
/**
|
||||
* Manages a stack of scenes. The most recently added scene is displayed inside
|
||||
@ -23,7 +25,7 @@ import envoy.event.EventBus;
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>SceneContext.java</strong><br>
|
||||
* Created: <strong>06.06.2020</strong><br>
|
||||
*
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@ -31,43 +33,43 @@ public final class SceneContext {
|
||||
|
||||
/**
|
||||
* Contains information about different scenes and their FXML resource files.
|
||||
*
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public static enum SceneInfo {
|
||||
public enum SceneInfo {
|
||||
|
||||
/**
|
||||
* The main scene in which chats are displayed.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
CHAT_SCENE("/fxml/ChatScene.fxml"),
|
||||
|
||||
/**
|
||||
* The scene in which settings are displayed.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
SETTINGS_SCENE("/fxml/SettingsScene.fxml"),
|
||||
|
||||
/**
|
||||
* The scene in which the contact search is displayed.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
CONTACT_SEARCH_SCENE("/fxml/ContactSearchScene.fxml"),
|
||||
|
||||
/**
|
||||
* The scene in which the group creation screen is displayed.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
GROUP_CREATION_SCENE("/fxml/GroupCreationScene.fxml"),
|
||||
|
||||
/**
|
||||
* The scene in which the login screen is displayed.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
LOGIN_SCENE("/fxml/LoginScene.fxml");
|
||||
@ -88,7 +90,7 @@ public final class SceneContext {
|
||||
|
||||
/**
|
||||
* Initializes the scene context.
|
||||
*
|
||||
*
|
||||
* @param stage the stage in which scenes will be displayed
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@ -99,7 +101,7 @@ public final class SceneContext {
|
||||
|
||||
/**
|
||||
* Loads a new scene specified by a scene info.
|
||||
*
|
||||
*
|
||||
* @param sceneInfo specifies the scene to load
|
||||
* @throws RuntimeException if the loading process fails
|
||||
* @since Envoy Client v0.1-beta
|
||||
@ -117,14 +119,15 @@ public final class SceneContext {
|
||||
applyCSS();
|
||||
stage.sizeToScene();
|
||||
stage.show();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
EnvoyLog.getLogger(SceneContext.class).log(Level.SEVERE, String.format("Could not load scene for %s: ", sceneInfo), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the current scene and displays the previous one.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public void pop() {
|
||||
|
@ -51,7 +51,7 @@ public final class Startup extends Application {
|
||||
/**
|
||||
* Loads the configuration, initializes the client and the local database and
|
||||
* delegates the rest of the startup process to {@link LoginScene}.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@Override
|
||||
@ -70,6 +70,7 @@ public final class Startup extends Application {
|
||||
if (!config.isInitialized()) throw new EnvoyException("Configuration is not fully initialized");
|
||||
} catch (final Exception e) {
|
||||
new Alert(AlertType.ERROR, "Error loading configuration values:\n" + e);
|
||||
logger.log(Level.SEVERE, "Error loading configuration values: ", e);
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
@ -80,19 +81,19 @@ public final class Startup extends Application {
|
||||
EnvoyLog.setFileLevelBarrier(config.getFileLevelBarrier());
|
||||
EnvoyLog.setConsoleLevelBarrier(config.getConsoleLevelBarrier());
|
||||
|
||||
logger.log(Level.INFO, "Envoy starting...");
|
||||
|
||||
// Initialize the local database
|
||||
if (config.isIgnoreLocalDB()) {
|
||||
localDB = new TransientLocalDB();
|
||||
new Alert(AlertType.WARNING, "Ignoring local database.\nMessages will not be saved!").showAndWait();
|
||||
} else {
|
||||
try {
|
||||
localDB = new PersistentLocalDB(new File(config.getHomeDirectory(), config.getLocalDB().getPath()));
|
||||
} catch (final IOException e3) {
|
||||
logger.log(Level.SEVERE, "Could not initialize local database", e3);
|
||||
new Alert(AlertType.ERROR, "Could not initialize local database!\n" + e3).showAndWait();
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
} else try {
|
||||
localDB = new PersistentLocalDB(new File(config.getHomeDirectory(), config.getLocalDB().getPath()));
|
||||
} catch (final IOException e3) {
|
||||
logger.log(Level.SEVERE, "Could not initialize local database: ", e3);
|
||||
new Alert(AlertType.ERROR, "Could not initialize local database!\n" + e3).showAndWait();
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize client and unread message cache
|
||||
@ -110,20 +111,21 @@ public final class Startup extends Application {
|
||||
|
||||
/**
|
||||
* Closes the client connection and saves the local database and settings.
|
||||
*
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@Override
|
||||
public void stop() {
|
||||
try {
|
||||
logger.info("Closing connection...");
|
||||
logger.log(Level.INFO, "Closing connection...");
|
||||
client.close();
|
||||
|
||||
logger.info("Saving local database and settings...");
|
||||
logger.log(Level.INFO, "Saving local database and settings...");
|
||||
localDB.save();
|
||||
Settings.getInstance().save();
|
||||
logger.log(Level.INFO, "Envoy was terminated by its user");
|
||||
} catch (final Exception e) {
|
||||
logger.log(Level.SEVERE, "Unable to save local files", e);
|
||||
logger.log(Level.SEVERE, "Unable to save local files: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,13 @@ import java.awt.*;
|
||||
import java.awt.TrayIcon.MessageType;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import envoy.client.event.MessageCreationEvent;
|
||||
import envoy.data.Message;
|
||||
import envoy.event.EventBus;
|
||||
import envoy.exception.EnvoyException;
|
||||
import envoy.util.EnvoyLog;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
@ -25,7 +27,7 @@ public class StatusTrayIcon {
|
||||
* system tray. This includes displaying the icon, but also creating
|
||||
* notifications when new messages are received.
|
||||
*/
|
||||
private TrayIcon trayIcon;
|
||||
private final TrayIcon trayIcon;
|
||||
|
||||
/**
|
||||
* A received {@link Message} is only displayed as a system tray notification if
|
||||
@ -46,16 +48,16 @@ public class StatusTrayIcon {
|
||||
public StatusTrayIcon(Window focusTarget) throws EnvoyException {
|
||||
if (!SystemTray.isSupported()) throw new EnvoyException("The Envoy tray icon is not supported.");
|
||||
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
Image img = Toolkit.getDefaultToolkit().createImage(loader.getResource("envoy_logo.png"));
|
||||
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
final Image img = Toolkit.getDefaultToolkit().createImage(loader.getResource("envoy_logo.png"));
|
||||
trayIcon = new TrayIcon(img, "Envoy Client");
|
||||
trayIcon.setImageAutoSize(true);
|
||||
trayIcon.setToolTip("You are notified if you have unread messages.");
|
||||
|
||||
PopupMenu popup = new PopupMenu();
|
||||
final PopupMenu popup = new PopupMenu();
|
||||
|
||||
MenuItem exitMenuItem = new MenuItem("Exit");
|
||||
exitMenuItem.addActionListener((evt) -> System.exit(0));
|
||||
final MenuItem exitMenuItem = new MenuItem("Exit");
|
||||
exitMenuItem.addActionListener(evt -> System.exit(0));
|
||||
popup.add(exitMenuItem);
|
||||
|
||||
trayIcon.setPopupMenu(popup);
|
||||
@ -71,7 +73,7 @@ public class StatusTrayIcon {
|
||||
});
|
||||
|
||||
// Show the window if the user clicks on the icon
|
||||
trayIcon.addActionListener((evt) -> { focusTarget.setVisible(true); focusTarget.requestFocus(); });
|
||||
trayIcon.addActionListener(evt -> { focusTarget.setVisible(true); focusTarget.requestFocus(); });
|
||||
|
||||
// Start processing message events
|
||||
// TODO: Handle other message types
|
||||
@ -90,7 +92,8 @@ public class StatusTrayIcon {
|
||||
public void show() throws EnvoyException {
|
||||
try {
|
||||
SystemTray.getSystemTray().add(trayIcon);
|
||||
} catch (AWTException e) {
|
||||
} catch (final AWTException e) {
|
||||
EnvoyLog.getLogger(StatusTrayIcon.class).log(Level.INFO, "Could not display StatusTrayIcon: ", e);
|
||||
throw new EnvoyException("Could not attach Envoy tray icon to system tray.", e);
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public final class ChatScene {
|
||||
if (chat.equals(currentChat)) {
|
||||
try {
|
||||
currentChat.read(writeProxy);
|
||||
} catch (IOException e1) {
|
||||
} catch (final IOException e1) {
|
||||
logger.log(Level.WARNING, "Could not read current chat: ", e1);
|
||||
}
|
||||
Platform.runLater(messageList::refresh);
|
||||
@ -177,7 +177,7 @@ public final class ChatScene {
|
||||
// Read the current chat
|
||||
try {
|
||||
currentChat.read(writeProxy);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.log(Level.WARNING, "Could not read current chat.", e);
|
||||
}
|
||||
|
||||
@ -210,6 +210,34 @@ public final class ChatScene {
|
||||
sceneContext.<ContactSearchScene>getController().initializeData(sceneContext, localDB);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the text length of the {@code messageTextArea}, adjusts the
|
||||
* {@code remainingChars} label and checks whether to send the message
|
||||
* automatically.
|
||||
*
|
||||
* @param e the key event that will be analyzed for a post request
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@FXML
|
||||
private void checkKeyCombination(KeyEvent e) {
|
||||
// Checks whether the text is too long
|
||||
messageTextUpdated();
|
||||
// Automatic sending of messages via (ctrl +) enter
|
||||
checkPostConditions(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e the keys that have been pressed
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@FXML
|
||||
private void checkPostConditions(KeyEvent e) {
|
||||
if (!postButton.isDisabled() && (settings.isEnterToSend() && e.getCode() == KeyCode.ENTER
|
||||
|| !settings.isEnterToSend() && e.getCode() == KeyCode.ENTER && e.isControlDown()))
|
||||
postMessage();
|
||||
postButton.setDisable(messageTextArea.getText().isBlank() || currentChat == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions to perform when the text was updated in the messageTextArea.
|
||||
*
|
||||
@ -223,29 +251,21 @@ public final class ChatScene {
|
||||
messageTextArea.positionCaret(MAX_MESSAGE_LENGTH);
|
||||
messageTextArea.setScrollTop(Double.MAX_VALUE);
|
||||
}
|
||||
updateRemainingCharsLabel();
|
||||
}
|
||||
|
||||
// Redesigning the remainingChars - Label
|
||||
/**
|
||||
* Sets the text and text color of the {@code remainingChars} label.
|
||||
*
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
private void updateRemainingCharsLabel() {
|
||||
final int currentLength = messageTextArea.getText().length();
|
||||
final int remainingLength = MAX_MESSAGE_LENGTH - currentLength;
|
||||
remainingChars.setText(String.format("remaining chars: %d/%d", remainingLength, MAX_MESSAGE_LENGTH));
|
||||
remainingChars.setTextFill(Color.rgb(currentLength, remainingLength, 0, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions to perform when a key has been entered.
|
||||
*
|
||||
* @param e the Keys that have been entered
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
@FXML
|
||||
private void checkKeyCombination(KeyEvent e) {
|
||||
// Automatic sending of messages via (ctrl +) enter
|
||||
if (!postButton.isDisabled() && settings.isEnterToSend() && e.getCode() == KeyCode.ENTER
|
||||
|| !settings.isEnterToSend() && e.getCode() == KeyCode.ENTER && e.isControlDown())
|
||||
postMessage();
|
||||
postButton.setDisable(messageTextArea.getText().isBlank() || currentChat == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a new message to the server based on the text entered in the
|
||||
* messageTextArea.
|
||||
@ -254,10 +274,12 @@ public final class ChatScene {
|
||||
*/
|
||||
@FXML
|
||||
private void postMessage() {
|
||||
final var text = messageTextArea.getText().strip();
|
||||
if (text.isBlank()) throw new IllegalArgumentException("A message without visible text can not be sent.");
|
||||
try {
|
||||
// Create and send message
|
||||
final var message = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator())
|
||||
.setText(messageTextArea.getText().strip())
|
||||
.setText(text)
|
||||
.build();
|
||||
|
||||
// Send message
|
||||
@ -270,12 +292,13 @@ public final class ChatScene {
|
||||
if (!localDB.getIDGenerator().hasNext() && client.isOnline()) client.requestIdGenerator();
|
||||
|
||||
} catch (final IOException e) {
|
||||
logger.log(Level.SEVERE, "Error sending message", e);
|
||||
logger.log(Level.SEVERE, "Error while sending message: ", e);
|
||||
new Alert(AlertType.ERROR, "An error occured while sending the message!").showAndWait();
|
||||
}
|
||||
|
||||
// Clear text field and disable post button
|
||||
messageTextArea.setText("");
|
||||
postButton.setDisable(true);
|
||||
updateRemainingCharsLabel();
|
||||
}
|
||||
}
|
||||
|
@ -68,10 +68,8 @@ public class ContactSearchScene {
|
||||
@FXML
|
||||
private void initialize() {
|
||||
contactList.setCellFactory(e -> new ContactListCell());
|
||||
eventBus.register(ContactSearchResult.class, response -> Platform.runLater(() -> {
|
||||
contactList.getItems().clear();
|
||||
contactList.getItems().addAll(response.get());
|
||||
}));
|
||||
eventBus.register(ContactSearchResult.class,
|
||||
response -> Platform.runLater(() -> { contactList.getItems().clear(); contactList.getItems().addAll(response.get()); }));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +114,7 @@ public class ContactSearchScene {
|
||||
*/
|
||||
@FXML
|
||||
private void contactListClicked() {
|
||||
final var contact = contactList.getSelectionModel().getSelectedItem();
|
||||
final var contact = contactList.getSelectionModel().getSelectedItem();
|
||||
if (contact != null) {
|
||||
final var alert = new Alert(AlertType.CONFIRMATION);
|
||||
alert.setTitle("Add Contact to Contact List");
|
||||
|
@ -3,6 +3,7 @@ package envoy.client.ui.controller;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javafx.application.Platform;
|
||||
@ -138,7 +139,7 @@ public final class LoginScene {
|
||||
|
||||
@FXML
|
||||
private void abortLogin() {
|
||||
logger.info("The login process has been cancelled. Exiting...");
|
||||
logger.log(Level.INFO, "The login process has been cancelled. Exiting...");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@ -150,8 +151,8 @@ public final class LoginScene {
|
||||
loadChatScene();
|
||||
}
|
||||
} catch (IOException | InterruptedException | TimeoutException e) {
|
||||
logger.warning("Could not connect to server: " + e);
|
||||
logger.finer("Attempting offline mode...");
|
||||
logger.log(Level.WARNING, "Could not connect to server: ", e);
|
||||
logger.log(Level.FINER, "Attempting offline mode...");
|
||||
attemptOfflineMode(credentials);
|
||||
}
|
||||
}
|
||||
@ -167,6 +168,7 @@ public final class LoginScene {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -185,6 +187,7 @@ public final class LoginScene {
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
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
|
||||
|
@ -1,3 +1,34 @@
|
||||
.button {
|
||||
-fx-background-radius: 5em;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
-fx-scale-x: 1.05;
|
||||
-fx-scale-y: 1.05;
|
||||
}
|
||||
|
||||
.label {
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
#remainingCharsLabel {
|
||||
-fx-text-fill: #00FF00;
|
||||
-fx-opacity: 1;
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
.online {
|
||||
-fx-text-fill: limegreen;
|
||||
}
|
||||
|
||||
.away {
|
||||
-fx-text-fill: orangered;
|
||||
}
|
||||
|
||||
.busy {
|
||||
-fx-text-fill: red;
|
||||
}
|
||||
|
||||
.offline {
|
||||
-fx-text-fill: gray;
|
||||
}
|
||||
|
@ -1,4 +1,31 @@
|
||||
.button{
|
||||
-fx-background-color: rgb(105,0,153);
|
||||
* {
|
||||
-fx-text-fill: white;
|
||||
}
|
||||
|
||||
.root {
|
||||
-fx-background-color: black;
|
||||
}
|
||||
|
||||
.button {
|
||||
-fx-background-color: rgb(105.0,0.0,153.0);
|
||||
}
|
||||
|
||||
.button:pressed {
|
||||
-fx-background-color: darkgray;
|
||||
}
|
||||
|
||||
.button:disabled {
|
||||
-fx-background-color: lightgray;
|
||||
}
|
||||
|
||||
.list-view, .list-cell, .text-area .content, .text-field, .password-field, .tooltip, .pane, .pane .content, .vbox, .titled-pane > .title, .titled-pane > *.content {
|
||||
-fx-background-color: dimgray;
|
||||
}
|
||||
|
||||
.list-cell:selected {
|
||||
-fx-background-color:rgb(105.0,0.0,153.0) ;
|
||||
}
|
||||
|
||||
.alert.information.dialog-pane, .alert.warning.dialog-pane, .alert.error.dialog-pane {
|
||||
-fx-background-color: black;
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
.button{
|
||||
-fx-background-color: snow;
|
||||
.button, .list-cell:selected{
|
||||
-fx-background-color: orangered;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.control.Tooltip?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
@ -22,12 +23,51 @@
|
||||
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" percentHeight="15.0" prefHeight="100.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<ListView fx:id="userList" onMouseClicked="#userListClicked" prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="1" GridPane.rowSpan="2147483647" />
|
||||
<Label fx:id="contactLabel" prefHeight="16.0" prefWidth="250.0" text="Select a contact to chat with" GridPane.columnSpan="2" />
|
||||
<Button fx:id="settingsButton" mnemonicParsing="true" onAction="#settingsButtonClicked" text="_Settings" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
|
||||
<ListView fx:id="messageList" prefHeight="257.0" prefWidth="155.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1" GridPane.rowSpan="2" />
|
||||
<Button fx:id="postButton" defaultButton="true" disable="true" mnemonicParsing="true" onAction="#postMessage" prefHeight="10.0" prefWidth="65.0" text="_Post" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER" />
|
||||
<TextArea fx:id="messageTextArea" disable="true" onInputMethodTextChanged="#messageTextUpdated" onKeyPressed="#checkKeyCombination" onKeyTyped="#messageTextUpdated" prefHeight="200.0" prefWidth="200.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
<ListView fx:id="userList" onMouseClicked="#userListClicked" prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="1" GridPane.rowSpan="2147483647">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="10.0" left="10.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></ListView>
|
||||
<Label fx:id="contactLabel" prefHeight="16.0" prefWidth="250.0" text="Select a contact to chat with" GridPane.columnSpan="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="10.0" right="5.0" top="10.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></Label>
|
||||
<Button fx:id="settingsButton" mnemonicParsing="true" onAction="#settingsButtonClicked" text="_Settings" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></Button>
|
||||
<ListView fx:id="messageList" prefHeight="257.0" prefWidth="155.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1" GridPane.rowSpan="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="10.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></ListView>
|
||||
<Button fx:id="postButton" defaultButton="true" disable="true" mnemonicParsing="true" onAction="#postMessage" prefHeight="10.0" prefWidth="65.0" text="_Post" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<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 "Alt" + "P"." wrapText="true" />
|
||||
</tooltip></Button>
|
||||
<TextArea fx:id="messageTextArea" disable="true" onInputMethodTextChanged="#messageTextUpdated" onKeyPressed="#checkPostConditions" onKeyTyped="#checkKeyCombination" prefHeight="200.0" prefWidth="200.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="10.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<opaqueInsets>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</opaqueInsets></TextArea>
|
||||
<Button mnemonicParsing="true" onAction="#addContactButtonClicked" text="_Add Contacts" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
@ -36,13 +76,19 @@
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
</Button>
|
||||
<Label fx:id="remainingChars" disable="true" 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" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<Label id="remainingCharsLabel" 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" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<opaqueInsets>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</opaqueInsets>
|
||||
<tooltip>
|
||||
<Tooltip text="Shows how many chars you can still enter in this message" wrapText="true" />
|
||||
</tooltip>
|
||||
</Label>
|
||||
</children>
|
||||
</GridPane>
|
||||
|
@ -23,30 +23,45 @@
|
||||
<Tooltip text="Enter a name. If an account by that name exists, it will be displayed below." wrapText="true" />
|
||||
</tooltip>
|
||||
</TextField>
|
||||
<Button fx:id="clearButton" disable="true" mnemonicParsing="true" onAction="#clear" text="Clea_r">
|
||||
<Button fx:id="clearButton" disable="true" mnemonicParsing="true" onAction="#clear" prefHeight="26.0" prefWidth="110.0" text="Clea_r">
|
||||
<tooltip>
|
||||
<Tooltip autoHide="true" text="Clears the text to the left and the elements below" wrapText="true" />
|
||||
</tooltip>
|
||||
<HBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="10.0" top="5.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</Button>
|
||||
<Button fx:id="searchButton" defaultButton="true" disable="true" mnemonicParsing="true" onAction="#suggestContacts" prefHeight="26.0" prefWidth="71.0" text="_Search" textOverrun="LEADING_WORD_ELLIPSIS">
|
||||
<Button fx:id="searchButton" defaultButton="true" disable="true" mnemonicParsing="true" onAction="#suggestContacts" prefHeight="26.0" prefWidth="124.0" text="_Search" textOverrun="LEADING_WORD_ELLIPSIS">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<HBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
<Insets bottom="5.0" right="20.0" top="5.0" />
|
||||
</HBox.margin>
|
||||
<tooltip>
|
||||
<Tooltip autoHide="true" text="Search for accounts with the name entered to the left" wrapText="true" />
|
||||
</tooltip>
|
||||
</Button>
|
||||
<Button mnemonicParsing="false" onAction="#newGroupButtonClicked" text="New Group">
|
||||
<Button mnemonicParsing="false" onAction="#newGroupButtonClicked" prefHeight="26.0" prefWidth="139.0" text="New Group">
|
||||
<HBox.margin>
|
||||
<Insets left="100.0" />
|
||||
<Insets bottom="5.0" left="20.0" right="5.0" top="5.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</Button>
|
||||
</children>
|
||||
</HBox>
|
||||
<ListView fx:id="contactList" onMouseClicked="#contactListClicked" prefHeight="314.0" prefWidth="600.0" />
|
||||
<ListView fx:id="contactList" onMouseClicked="#contactListClicked" prefHeight="314.0" prefWidth="600.0">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<VBox.margin>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</VBox.margin></ListView>
|
||||
<Button fx:id="backButton" cancelButton="true" mnemonicParsing="true" onAction="#backButtonClicked" text="_Back">
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
|
@ -31,9 +31,27 @@
|
||||
<font>
|
||||
<Font size="16.0" />
|
||||
</font>
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</VBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<ListView fx:id="contactList" prefHeight="314.0" prefWidth="600.0" />
|
||||
<Button mnemonicParsing="false" onAction="#sendGroupObject" text="Create" />
|
||||
<ListView fx:id="contactList" prefHeight="314.0" prefWidth="600.0">
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
|
||||
</VBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></ListView>
|
||||
<Button mnemonicParsing="false" onAction="#sendGroupObject" text="Create">
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</VBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></Button>
|
||||
<Button fx:id="backButton" cancelButton="true" mnemonicParsing="true" onAction="#backButtonClicked" text="_Back">
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ButtonBar?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
@ -12,13 +13,18 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
|
||||
<VBox prefHeight="206.0" prefWidth="440.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.LoginScene">
|
||||
<children>
|
||||
<Label text="User Login">
|
||||
<font>
|
||||
<Font size="26.0" />
|
||||
</font>
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</VBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</Label>
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
@ -31,19 +37,65 @@
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="User Name:" />
|
||||
<Label text="Password" GridPane.rowIndex="1" />
|
||||
<Label fx:id="repeatPasswordLabel" text="Repeat Password:" visible="false" GridPane.rowIndex="2" />
|
||||
<TextField fx:id="userTextField" GridPane.columnIndex="1" />
|
||||
<PasswordField fx:id="passwordField" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<PasswordField fx:id="repeatPasswordField" promptText="Repeat the chosen password" visible="false" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Label text="User Name:">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" />
|
||||
</padding></Label>
|
||||
<Label text="Password" GridPane.rowIndex="1">
|
||||
<padding>
|
||||
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" />
|
||||
</padding>
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin></Label>
|
||||
<Label fx:id="repeatPasswordLabel" text="Repeat Password:" visible="false" GridPane.rowIndex="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" />
|
||||
</padding></Label>
|
||||
<TextField fx:id="userTextField" GridPane.columnIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="10.0" left="5.0" right="5.0" top="5.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></TextField>
|
||||
<PasswordField fx:id="passwordField" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="10.0" left="5.0" right="5.0" top="10.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></PasswordField>
|
||||
<PasswordField fx:id="repeatPasswordField" promptText="Repeat the chosen password" visible="false" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="10.0" />
|
||||
</GridPane.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></PasswordField>
|
||||
</children>
|
||||
</GridPane>
|
||||
<CheckBox fx:id="registerCheckBox" mnemonicParsing="true" onAction="#registerCheckboxChanged" prefHeight="17.0" prefWidth="181.0" text="_Register" />
|
||||
<CheckBox fx:id="registerCheckBox" mnemonicParsing="true" onAction="#registerCheckboxChanged" prefHeight="17.0" prefWidth="181.0" text="_Register">
|
||||
<padding>
|
||||
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" />
|
||||
</padding>
|
||||
<VBox.margin>
|
||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
|
||||
</VBox.margin></CheckBox>
|
||||
<Label fx:id="connectionLabel" />
|
||||
<ButtonBar prefHeight="40.0" prefWidth="200.0">
|
||||
<buttons>
|
||||
<Button mnemonicParsing="false" onAction="#abortLogin" text="Close" />
|
||||
<Button mnemonicParsing="false" onAction="#abortLogin" text="Close">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
</Button>
|
||||
<Button mnemonicParsing="false" onAction="#offlineModeButtonPressed" text="Offline mode" />
|
||||
<Button defaultButton="true" mnemonicParsing="false" onAction="#loginButtonPressed" text="Login" />
|
||||
</buttons>
|
||||
|
@ -9,16 +9,37 @@
|
||||
|
||||
<VBox alignment="TOP_RIGHT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.SettingsScene">
|
||||
<children>
|
||||
<HBox prefHeight="100.0" prefWidth="200.0">
|
||||
<HBox prefHeight="389.0" prefWidth="600.0">
|
||||
<children>
|
||||
<ListView fx:id="settingsList" onMouseClicked="#settingsListClicked" prefHeight="200.0" prefWidth="200.0" />
|
||||
<TitledPane fx:id="titledPane" collapsible="false" prefHeight="200.0" prefWidth="200.0" />
|
||||
<ListView fx:id="settingsList" onMouseClicked="#settingsListClicked" prefHeight="200.0" prefWidth="200.0">
|
||||
<opaqueInsets>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</opaqueInsets>
|
||||
<HBox.margin>
|
||||
<Insets bottom="10.0" left="10.0" right="5.0" top="10.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></ListView>
|
||||
<TitledPane fx:id="titledPane" collapsible="false" prefHeight="325.0" prefWidth="300.0">
|
||||
<HBox.margin>
|
||||
<Insets bottom="10.0" left="5.0" right="10.0" top="10.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding></TitledPane>
|
||||
</children>
|
||||
</HBox>
|
||||
<Button defaultButton="true" mnemonicParsing="true" onMouseClicked="#backButtonClicked" text="_Back">
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</VBox.margin>
|
||||
</Button>
|
||||
</children>
|
||||
</VBox>
|
||||
|
Reference in New Issue
Block a user