D .idea/java-chat.iml => .idea/java-chat.iml +0 -9
@@ 1,9 0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module external.linked.project.id="chat:main" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="sh.swisschili.chat" external.system.module.version="1.1-SNAPSHOT" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$" />
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- </component>
-</module>>
\ No newline at end of file
M client/build.gradle => client/build.gradle +1 -1
@@ 27,7 27,7 @@ dependencies {
changing = true
}
implementation("com.github.weisj:darklaf-property-loader:latest.integration")
- runtime group: 'com.github.weisj', name: 'darklaf-theme', version: '2.4.10'
+ compile group: 'com.github.weisj', name: 'darklaf-theme', version: '2.4.10'
compile group: 'com.intellij', name: 'forms_rt', version: '7.0.3'
compile group: 'com.github.jiconfont', name: 'jiconfont-swing', version: '1.0.1'
compile group: 'com.github.jiconfont', name: 'jiconfont-font_awesome', version: '4.7.0.1'
M client/src/main/java/sh/swisschili/chat/client/MainWindow.java => client/src/main/java/sh/swisschili/chat/client/MainWindow.java +7 -1
@@ 74,7 74,13 @@ public class MainWindow {
private void createUIComponents() {
userPanel = userComponent.getRootPanel();
- messages = new JList<>();
+ messages = new JList<Message>() {
+ @Override
+ public boolean getScrollableTracksViewportWidth() {
+ return true;
+ }
+ };
+ messages.addComponentListener(new MessageListAdapter(messages));
messagesScrollPane = new InfiniteScrollPane<>(messages);
}
M client/src/main/java/sh/swisschili/chat/client/MessageCell.form => client/src/main/java/sh/swisschili/chat/client/MessageCell.form +2 -4
@@ 43,11 43,9 @@
</component>
</children>
</grid>
- <component id="d0ad1" class="javax.swing.JLabel" binding="body">
+ <component id="131b0" class="javax.swing.JTextArea" binding="body">
<constraints border-constraint="Center"/>
- <properties>
- <text value="Label"/>
- </properties>
+ <properties/>
</component>
</children>
</grid>
M client/src/main/java/sh/swisschili/chat/client/MessageCell.java => client/src/main/java/sh/swisschili/chat/client/MessageCell.java +7 -6
@@ 33,7 33,7 @@ import java.util.Locale;
public class MessageCell implements ListCellRenderer<Message> {
private JPanel rootPanel;
- private JLabel body;
+ private JTextArea body;
private JLabel sender;
private JLabel time;
@@ 43,10 43,12 @@ public class MessageCell implements ListCellRenderer<Message> {
public MessageCell(@NotNull Message value, int parentWidth) {
$$$setupUI$$$();
-// int width = parentWidth / 6;
-// int lines = value.getBody().length() / width + 1;
+ body.setText(value.getBody());
+ body.setLineWrap(true);
+ body.setWrapStyleWord(true);
- body.setText("<html><body style='width:100%'>" + value.getBody());
+ if (parentWidth > 0)
+ body.setSize(parentWidth, Short.MAX_VALUE);
sender.setText(value.getSender().getName());
time.setText(new Date(value.getUnixTime()).toString());
@@ 85,8 87,7 @@ public class MessageCell implements ListCellRenderer<Message> {
if (timeFont != null) time.setFont(timeFont);
time.setText("Time");
panel1.add(time, cc.xy(3, 1));
- body = new JLabel();
- body.setText("Label");
+ body = new JTextArea();
rootPanel.add(body, BorderLayout.CENTER);
}
A client/src/main/java/sh/swisschili/chat/client/MessageListAdapter.java => client/src/main/java/sh/swisschili/chat/client/MessageListAdapter.java +20 -0
@@ 0,0 1,20 @@
+package sh.swisschili.chat.client;
+
+import javax.swing.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+public class MessageListAdapter extends ComponentAdapter {
+ private final JList<?> list;
+
+ public MessageListAdapter(JList<?> list) {
+ this.list = list;
+ }
+
+ @Override
+ public void componentResized(ComponentEvent e) {
+ // Invalidate cache
+ list.setFixedCellHeight(10);
+ list.setFixedCellHeight(-1);
+ }
+}
M util/src/main/java/sh/swisschili/chat/util/ServerPool.java => util/src/main/java/sh/swisschili/chat/util/ServerPool.java +2 -0
@@ 20,6 20,8 @@ package sh.swisschili.chat.util;
import io.grpc.Channel;
import io.grpc.ManagedChannelBuilder;
+import sh.swisschili.chat.util.AuthGrpc;
+import sh.swisschili.chat.util.ChatGrpc;
import sh.swisschili.chat.util.AuthGrpc.AuthStub;
import sh.swisschili.chat.util.ChatGrpc.ChatStub;