Merge pull request #51 from informatik-ag-ngl/f/primaryComponents
Added customized primary components
This commit is contained in:
commit
6ae43fc810
@ -15,13 +15,11 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
@ -55,15 +53,15 @@ public class ChatWindow extends JFrame {
|
|||||||
private LocalDB localDB;
|
private LocalDB localDB;
|
||||||
// GUI components
|
// GUI components
|
||||||
private JPanel contentPane = new JPanel();
|
private JPanel contentPane = new JPanel();
|
||||||
private JTextArea messageEnterTextArea = new JTextArea();
|
private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
|
||||||
private JList<User> userList = new JList<>();
|
private JList<User> userList = new JList<>();
|
||||||
private Chat currentChat;
|
private Chat currentChat;
|
||||||
private JList<Message> messageList = new JList<>();
|
private JList<Message> messageList = new JList<>();
|
||||||
private JScrollPane scrollPane = new JScrollPane();
|
private JScrollPane scrollPane = new JScrollPane();
|
||||||
private JTextPane textPane = new JTextPane();
|
private JTextPane textPane = new JTextPane();
|
||||||
// private JCheckBox jCbChangeMode;
|
// private JCheckBox jCbChangeMode;
|
||||||
private JButton postButton = new JButton("Post");
|
private PrimaryButton postButton = new PrimaryButton("Post");
|
||||||
private JButton settingsButton = new JButton("Settings");
|
private PrimaryButton settingsButton = new PrimaryButton("Settings");
|
||||||
|
|
||||||
private static int space = 4;
|
private static int space = 4;
|
||||||
|
|
||||||
@ -136,12 +134,6 @@ public class ChatWindow extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Checks for changed Message
|
|
||||||
messageEnterTextArea.setWrapStyleWord(true);
|
|
||||||
messageEnterTextArea.setLineWrap(true);
|
|
||||||
messageEnterTextArea.setBorder(null);
|
|
||||||
messageEnterTextArea.setFont(new Font("Arial", Font.PLAIN, 17));
|
|
||||||
messageEnterTextArea.setBorder(new EmptyBorder(space, space, space, space));
|
|
||||||
|
|
||||||
GridBagConstraints gbc_messageEnterTextfield = new GridBagConstraints();
|
GridBagConstraints gbc_messageEnterTextfield = new GridBagConstraints();
|
||||||
gbc_messageEnterTextfield.fill = GridBagConstraints.BOTH;
|
gbc_messageEnterTextfield.fill = GridBagConstraints.BOTH;
|
||||||
@ -153,7 +145,6 @@ public class ChatWindow extends JFrame {
|
|||||||
contentPane.add(messageEnterTextArea, gbc_messageEnterTextfield);
|
contentPane.add(messageEnterTextArea, gbc_messageEnterTextfield);
|
||||||
|
|
||||||
// Post Button
|
// Post Button
|
||||||
postButton.setBorderPainted(false);
|
|
||||||
GridBagConstraints gbc_moveSelectionPostButton = new GridBagConstraints();
|
GridBagConstraints gbc_moveSelectionPostButton = new GridBagConstraints();
|
||||||
|
|
||||||
gbc_moveSelectionPostButton.fill = GridBagConstraints.BOTH;
|
gbc_moveSelectionPostButton.fill = GridBagConstraints.BOTH;
|
||||||
@ -166,8 +157,6 @@ public class ChatWindow extends JFrame {
|
|||||||
contentPane.add(postButton, gbc_moveSelectionPostButton);
|
contentPane.add(postButton, gbc_moveSelectionPostButton);
|
||||||
|
|
||||||
// Settings Button
|
// Settings Button
|
||||||
settingsButton.setBorderPainted(false);
|
|
||||||
|
|
||||||
GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints();
|
GridBagConstraints gbc_moveSelectionSettingsButton = new GridBagConstraints();
|
||||||
|
|
||||||
gbc_moveSelectionSettingsButton.fill = GridBagConstraints.BOTH;
|
gbc_moveSelectionSettingsButton.fill = GridBagConstraints.BOTH;
|
||||||
|
@ -42,22 +42,18 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
|
|||||||
final String text = value.getContent().get(0).getText();
|
final String text = value.getContent().get(0).getText();
|
||||||
final String state = value.getMetadata().getState().toString();
|
final String state = value.getMetadata().getState().toString();
|
||||||
final String date = value.getMetadata().getDate() == null ? ""
|
final String date = value.getMetadata().getDate() == null ? ""
|
||||||
: new SimpleDateFormat("dd.MM.yyyy HH:mm ")
|
: new SimpleDateFormat("dd.MM.yyyy HH:mm ").format(value.getMetadata().getDate().toGregorianCalendar().getTime());
|
||||||
.format(value.getMetadata().getDate().toGregorianCalendar().getTime());
|
|
||||||
|
|
||||||
// Getting the MessageColor in the Chat of the current theme
|
// Getting the MessageColor in the Chat of the current theme
|
||||||
String textColor = null;
|
String textColor = null;
|
||||||
|
|
||||||
textColor = toHex(
|
textColor = toHex(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getMessageColorChat());
|
||||||
Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getMessageColorChat());
|
|
||||||
|
|
||||||
// Getting the DateColor in the Chat of the current theme
|
// Getting the DateColor in the Chat of the current theme
|
||||||
String dateColor = null;
|
String dateColor = null;
|
||||||
dateColor = toHex(
|
dateColor = toHex(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getDateColorChat());
|
||||||
Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getDateColorChat());
|
|
||||||
|
|
||||||
setText(String.format(
|
setText(String.format("<html><p style=\"color:%s\"><b><small>%s</b></small><br><p style=\"color:%s\">%s :%s</html>",
|
||||||
"<html><p style=\"color:%s\"><b><small>%s</b></small><br><p style=\"color:%s\">%s :%s</html>",
|
|
||||||
dateColor,
|
dateColor,
|
||||||
date,
|
date,
|
||||||
textColor,
|
textColor,
|
||||||
|
63
src/main/java/envoy/client/ui/PrimaryButton.java
Normal file
63
src/main/java/envoy/client/ui/PrimaryButton.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package envoy.client.ui;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-client</strong><br>
|
||||||
|
* File: <strong>PrimaryButton.javaEvent.java</strong><br>
|
||||||
|
* Created: <strong>07.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy v0.2-alpha
|
||||||
|
*/
|
||||||
|
public class PrimaryButton extends JButton {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 3662266120667728364L;
|
||||||
|
|
||||||
|
private int arcSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a primary button
|
||||||
|
*
|
||||||
|
* @param title the title of the button
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public PrimaryButton(String title) { this(title, 6); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a primary button
|
||||||
|
*
|
||||||
|
* @param title the title of the button
|
||||||
|
* @param the size of the arc used to draw the round button edges
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public PrimaryButton(String title, int arcSize) {
|
||||||
|
super(title);
|
||||||
|
setBorderPainted(false);
|
||||||
|
setFocusPainted(false);
|
||||||
|
setContentAreaFilled(false);
|
||||||
|
this.arcSize = arcSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
g.setColor(getBackground());
|
||||||
|
g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize);
|
||||||
|
super.paintComponent(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the arcSize
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public int getArcSize() { return arcSize; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param arcSize the arcSize to set
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public void setArcSize(int arcSize) { this.arcSize = arcSize; }
|
||||||
|
}
|
67
src/main/java/envoy/client/ui/PrimaryTextArea.java
Normal file
67
src/main/java/envoy/client/ui/PrimaryTextArea.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package envoy.client.ui;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-client</strong><br>
|
||||||
|
* File: <strong>PrimaryTextArea.javaEvent.java</strong><br>
|
||||||
|
* Created: <strong>07.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy v0.2-alpha
|
||||||
|
*/
|
||||||
|
public class PrimaryTextArea extends JTextArea {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -5829028696155434913L;
|
||||||
|
private int arcSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the text area
|
||||||
|
*
|
||||||
|
* @param borderSpace
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public PrimaryTextArea(int borderSpace) { this(6, borderSpace); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the text area
|
||||||
|
*
|
||||||
|
* @param arcSize is the diameter of the arc at the four corners.
|
||||||
|
* @param borderSpace is the insets of the border on all four sides.
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public PrimaryTextArea(int arcSize, int borderSpace) {
|
||||||
|
super();
|
||||||
|
setWrapStyleWord(true);
|
||||||
|
setLineWrap(true);
|
||||||
|
setBorder(null);
|
||||||
|
setFont(new Font("Arial", Font.PLAIN, 17));
|
||||||
|
setBorder(new EmptyBorder(borderSpace, borderSpace, borderSpace, borderSpace));
|
||||||
|
setOpaque(false);
|
||||||
|
|
||||||
|
this.arcSize = arcSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
g.setColor(getBackground());
|
||||||
|
g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize);
|
||||||
|
super.paintComponent(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the arcSize - the diameter of the arc at the four corners.
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public int getArcSize() { return arcSize; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param arcSize the arcSize to set
|
||||||
|
* @since Envoy 0.2-alpha
|
||||||
|
*/
|
||||||
|
public void setArcSize(int arcSize) { this.arcSize = arcSize; }
|
||||||
|
}
|
@ -26,9 +26,8 @@ public class Theme implements Serializable {
|
|||||||
private Color selectionColor;
|
private Color selectionColor;
|
||||||
private Color typingMessageColor;
|
private Color typingMessageColor;
|
||||||
|
|
||||||
public Theme(String themeName, Color backgroundColor, Color cellColor, Color interactableForegroundColor,
|
public Theme(String themeName, Color backgroundColor, Color cellColor, Color interactableForegroundColor, Color interactableBackgroundColor,
|
||||||
Color interactableBackgroundColor, Color messageColorChat, Color dateColorChat, Color selectionColor,
|
Color messageColorChat, Color dateColorChat, Color selectionColor, Color typingMessageColor, Color userNameColor) {
|
||||||
Color typingMessageColor, Color userNameColor) {
|
|
||||||
|
|
||||||
this.themeName = themeName;
|
this.themeName = themeName;
|
||||||
|
|
||||||
@ -44,9 +43,8 @@ public class Theme implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Theme(String name, Theme other) {
|
public Theme(String name, Theme other) {
|
||||||
this(name, other.backgroundColor, other.cellColor, other.interactableBackgroundColor,
|
this(name, other.backgroundColor, other.cellColor, other.interactableBackgroundColor, other.interactableForegroundColor,
|
||||||
other.interactableForegroundColor, other.messageColorChat, other.dateColorChat, other.selectionColor,
|
other.messageColorChat, other.dateColorChat, other.selectionColor, other.typingMessageColor, other.userNameColor);
|
||||||
other.typingMessageColor, other.userNameColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,22 +45,15 @@ public class UserListRenderer extends JLabel implements ListCellRenderer<User> {
|
|||||||
|
|
||||||
// Getting the UserNameColor of the current theme
|
// Getting the UserNameColor of the current theme
|
||||||
String textColor = null;
|
String textColor = null;
|
||||||
textColor = toHex(
|
textColor = toHex(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getUserNameColor());
|
||||||
Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getUserNameColor());
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case ONLINE:
|
case ONLINE:
|
||||||
setText(String.format(
|
setText(String
|
||||||
"<html><p style=\"color:#03fc20\"><b><small>%s</b></small><br><p style=\"color:%s\">%s</html>",
|
.format("<html><p style=\"color:#03fc20\"><b><small>%s</b></small><br><p style=\"color:%s\">%s</html>", status, textColor, name));
|
||||||
status,
|
|
||||||
textColor,
|
|
||||||
name));
|
|
||||||
break;
|
break;
|
||||||
case OFFLINE:
|
case OFFLINE:
|
||||||
setText(String.format(
|
setText(String
|
||||||
"<html><p style=\"color:#fc0303\"><b><small>%s</b></small><br><p style=\"color:%s\">%s</html>",
|
.format("<html><p style=\"color:#fc0303\"><b><small>%s</b></small><br><p style=\"color:%s\">%s</html>", status, textColor, name));
|
||||||
status,
|
|
||||||
textColor,
|
|
||||||
name));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
Reference in New Issue
Block a user