Merge branch 'develop' into f/local_db
This commit is contained in:
commit
f8ce1ee6d9
@ -14,11 +14,32 @@ public class Chat implements Serializable {
|
||||
private User recipient;
|
||||
private DefaultListModel<Message> model = new DefaultListModel<>();
|
||||
|
||||
/**
|
||||
* Provides the list of messages that the recipient receives.<br>
|
||||
* Saves the Messages in the corresponding chat at that Point.
|
||||
*
|
||||
* @param recipient the user who receives the messages
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public Chat(User recipient) { this.recipient = recipient; }
|
||||
|
||||
/**
|
||||
* @return the recipient of a message
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public User getRecipient() { return recipient; }
|
||||
|
||||
/**
|
||||
* Adds the received message at the current Point in the current chat
|
||||
*
|
||||
* @param message the message to add in said chat
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void appendMessage(Message message) { model.addElement(message); }
|
||||
|
||||
/**
|
||||
* @return all messages in the current chat
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public DefaultListModel<Message> getModel() { return model; }
|
||||
}
|
@ -1,71 +1,97 @@
|
||||
package envoy.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>Config.java</strong><br>
|
||||
* Created: <strong>12 Oct 2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy 0.1
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
private String server;
|
||||
private int port;
|
||||
private File localDB;
|
||||
|
||||
/**
|
||||
* Defaults to the {@code client.properties} file for information.
|
||||
*
|
||||
* @param properties a {@link Properties} object containing information about
|
||||
* the server and port, as well as the path to the local
|
||||
* database
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void load(Properties properties) {
|
||||
if (properties.containsKey("server")) server = properties.getProperty("server");
|
||||
if (properties.containsKey("port")) port = Integer.parseInt(properties.getProperty("port"));
|
||||
localDB = new File(properties.getProperty("localDB", ".\\localDB"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server, port and localDB path via command line properties --server /
|
||||
* -s, --port / -p and --localDB / -db.
|
||||
*
|
||||
* @param args the command line arguments to parse
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void load(String[] args) {
|
||||
for (int i = 0; i < args.length; i++)
|
||||
switch (args[i]) {
|
||||
case "--server":
|
||||
case "-s":
|
||||
server = args[++i];
|
||||
break;
|
||||
case "--port":
|
||||
case "-p":
|
||||
port = Integer.parseInt(args[++i]);
|
||||
break;
|
||||
case "--localDB":
|
||||
case "-db":
|
||||
localDB = new File(args[++i]);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInitialized() { return server != null && !server.isEmpty() && port > 0 && port < 65566 && localDB != null; }
|
||||
|
||||
public String getServer() { return server; }
|
||||
|
||||
public void setServer(String server) { this.server = server; }
|
||||
|
||||
public int getPort() { return port; }
|
||||
|
||||
public void setPort(int port) { this.port = port; }
|
||||
|
||||
public File getLocalDB() { return localDB; }
|
||||
|
||||
public void setLocalDB(File localDB) { this.localDB = localDB; }
|
||||
}
|
||||
package envoy.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>Config.java</strong><br>
|
||||
* Created: <strong>12 Oct 2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
private String server;
|
||||
private int port;
|
||||
private File localDB;
|
||||
|
||||
/**
|
||||
* Defaults to the {@code client.properties} file for information.
|
||||
*
|
||||
* @param properties a {@link Properties} object containing information about
|
||||
* the server and port, as well as the path to the local
|
||||
* database
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void load(Properties properties) {
|
||||
if (properties.containsKey("server")) server = properties.getProperty("server");
|
||||
if (properties.containsKey("port")) port = Integer.parseInt(properties.getProperty("port"));
|
||||
localDB = new File(properties.getProperty("localDB", ".\\localDB"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server, port and localDB path via command line properties --server /
|
||||
* -s, --port / -p and --localDB / -db.
|
||||
*
|
||||
* @param args the command line arguments to parse
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void load(String[] args) {
|
||||
for (int i = 0; i < args.length; i++)
|
||||
switch (args[i]) {
|
||||
case "--server":
|
||||
case "-s":
|
||||
server = args[++i];
|
||||
break;
|
||||
case "--port":
|
||||
case "-p":
|
||||
port = Integer.parseInt(args[++i]);
|
||||
break;
|
||||
case "--localDB":
|
||||
case "-db":
|
||||
localDB = new File(args[++i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if server, port andd localDB directory are known.
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public boolean isInitialized() { return server != null && !server.isEmpty() && port > 0 && port < 65566 && localDB != null; }
|
||||
|
||||
/**
|
||||
* @return the URL of our website
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public String getServer() { return server; }
|
||||
|
||||
/**
|
||||
* Changes the default URL.
|
||||
* Exclusively meant for developing reasons. (localhost)
|
||||
*
|
||||
* @param server the URL where wish to host Envoy
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void setServer(String server) { this.server = server; }
|
||||
|
||||
/**
|
||||
* @return the port at which Envoy is located in the Server
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public int getPort() { return port; }
|
||||
|
||||
/**
|
||||
* Changes the default port.
|
||||
* Exclusively meant for developing reasons. (localhost)
|
||||
*
|
||||
* @param port the port where we wish to connect to {@code Envoy}.
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void setPort(int port) { this.port = port; }
|
||||
|
||||
public File getLocalDB() { return localDB; }
|
||||
|
||||
public void setLocalDB(File localDB) { this.localDB = localDB; }
|
||||
}
|
@ -10,11 +10,15 @@ import javax.swing.ListCellRenderer;
|
||||
import envoy.schema.Message;
|
||||
|
||||
/**
|
||||
* Defines how a message is displayed.<br>
|
||||
* <br>
|
||||
*
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>UserListRenderer.java</strong><br>
|
||||
* Created: <strong>19 Oct 2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public class MessageListRenderer extends JLabel implements ListCellRenderer<Message> {
|
||||
|
||||
@ -44,4 +48,4 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
|
||||
text));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ import envoy.exception.EnvoyException;
|
||||
*
|
||||
* @author Leon Hofmeister
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy 0.1
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public class Startup {
|
||||
|
||||
|
@ -9,11 +9,14 @@ import javax.swing.ListCellRenderer;
|
||||
import envoy.schema.User;
|
||||
|
||||
/**
|
||||
* Defines how the {@code UserList} is displayed.
|
||||
*
|
||||
* Project: <strong>envoy-client</strong><br>
|
||||
* File: <strong>UserListRenderer.java</strong><br>
|
||||
* Created: <strong>12 Oct 2019</strong><br>
|
||||
*
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public class UserListRenderer extends JLabel implements ListCellRenderer<User> {
|
||||
|
||||
@ -38,4 +41,4 @@ public class UserListRenderer extends JLabel implements ListCellRenderer<User> {
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user