mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2025-01-08 21:14:44 +01:00
Added UI prototype for attachments uploading.
Fixed text selection bug.
This commit is contained in:
parent
fc2880325e
commit
174df078a5
0
BasicHTMLParser.java
Executable file → Normal file
0
BasicHTMLParser.java
Executable file → Normal file
0
ClipboardApi.java
Executable file → Normal file
0
ClipboardApi.java
Executable file → Normal file
213
ComposeWindow.java
Executable file → Normal file
213
ComposeWindow.java
Executable file → Normal file
@ -19,6 +19,8 @@ import java.awt.event.KeyListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import javax.swing.event.CaretListener;
|
||||
import javax.swing.event.CaretEvent;
|
||||
|
||||
@ -40,7 +42,10 @@ ComposeWindow extends JFrame {
|
||||
composition;
|
||||
|
||||
private ComposeComponent
|
||||
display;
|
||||
contentsDisplay;
|
||||
|
||||
private AttachmentsComponent
|
||||
attachmentsDisplay;
|
||||
|
||||
// ---%-@-%---
|
||||
|
||||
@ -73,7 +78,7 @@ ComposeWindow extends JFrame {
|
||||
if (composition.contentWarning != null)
|
||||
assert !composition.contentWarning.trim().isEmpty();
|
||||
|
||||
display.setSubmitting(true);
|
||||
contentsDisplay.setSubmitting(true);
|
||||
api.submit(
|
||||
composition.text, composition.visibility,
|
||||
composition.replyToPostId, composition.contentWarning,
|
||||
@ -108,7 +113,21 @@ ComposeWindow extends JFrame {
|
||||
|
||||
}
|
||||
);
|
||||
display.setSubmitting(false);
|
||||
contentsDisplay.setSubmitting(false);
|
||||
}
|
||||
|
||||
public void
|
||||
showContentsPage()
|
||||
{
|
||||
setContentPane(contentsDisplay);
|
||||
revalidate();
|
||||
}
|
||||
|
||||
public void
|
||||
showAttachmentsPage()
|
||||
{
|
||||
setContentPane(attachmentsDisplay);
|
||||
revalidate();
|
||||
}
|
||||
|
||||
// - -%- -
|
||||
@ -116,22 +135,22 @@ ComposeWindow extends JFrame {
|
||||
private synchronized void
|
||||
syncDisplayToComposition()
|
||||
{
|
||||
display.setText(composition.text);
|
||||
display.setReplyToPostId(composition.replyToPostId);
|
||||
display.setVisibility(stringFor(composition.visibility));
|
||||
display.setContentWarning(composition.contentWarning);
|
||||
ComposeComponent d = contentsDisplay;
|
||||
d.setText(composition.text);
|
||||
d.setReplyToPostId(composition.replyToPostId);
|
||||
d.setVisibility(stringFor(composition.visibility));
|
||||
d.setContentWarning(composition.contentWarning);
|
||||
}
|
||||
|
||||
private synchronized void
|
||||
syncCompositionToDisplay()
|
||||
{
|
||||
composition.text = display.getText();
|
||||
composition.visibility =
|
||||
visibilityFrom(display.getVisibility());
|
||||
composition.replyToPostId =
|
||||
nonEmpty(display.getReplyToPostId());
|
||||
composition.contentWarning =
|
||||
nonEmpty(display.getContentWarning());
|
||||
ComposeComponent d = contentsDisplay;
|
||||
Composition c = composition;
|
||||
c.text = d.getText();
|
||||
c.visibility = visibilityFrom(d.getVisibility());
|
||||
c.replyToPostId = nonEmpty(d.getReplyToPostId());
|
||||
c.contentWarning = nonEmpty(d.getContentWarning());
|
||||
}
|
||||
|
||||
// - -%- -
|
||||
@ -151,14 +170,17 @@ ComposeWindow extends JFrame {
|
||||
this.primaire = primaire;
|
||||
this.api = primaire.getMastodonApi();
|
||||
|
||||
getContentPane().setPreferredSize(new Dimension(360, 270));
|
||||
final Dimension SZ = new Dimension(360, 270);
|
||||
|
||||
getContentPane().setPreferredSize(SZ);
|
||||
pack();
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
display = new ComposeComponent(this);
|
||||
contentsDisplay = new ComposeComponent(this);
|
||||
attachmentsDisplay = new AttachmentsComponent(this);
|
||||
newComposition();
|
||||
|
||||
setContentPane(display);
|
||||
showContentsPage();
|
||||
setIconImage(primaire.getProgramIcon());
|
||||
}
|
||||
|
||||
@ -221,6 +243,9 @@ implements ActionListener, CaretListener, KeyListener {
|
||||
private JButton
|
||||
submit;
|
||||
|
||||
private JButton
|
||||
showAttachmentsPage;
|
||||
|
||||
// ---%-@-%---
|
||||
|
||||
public void
|
||||
@ -300,7 +325,14 @@ implements ActionListener, CaretListener, KeyListener {
|
||||
// - -%- -
|
||||
|
||||
public void
|
||||
actionPerformed(ActionEvent eA) { primaire.submit(); }
|
||||
actionPerformed(ActionEvent eA)
|
||||
{
|
||||
if (eA.getSource() == showAttachmentsPage)
|
||||
primaire.showAttachmentsPage();
|
||||
|
||||
if (eA.getSource() == submit)
|
||||
primaire.submit();
|
||||
}
|
||||
|
||||
public void
|
||||
caretUpdate(CaretEvent eCa) { updateTextLength(); }
|
||||
@ -375,12 +407,16 @@ implements ActionListener, CaretListener, KeyListener {
|
||||
"Mentioned"
|
||||
// Where should we be saving strings..
|
||||
});
|
||||
visibility.setPreferredSize(new Dimension(64, 24));
|
||||
visibility.setPreferredSize(new Dimension(48, 24));
|
||||
|
||||
submit = new JButton("Submit");
|
||||
submit.addActionListener(this);
|
||||
|
||||
showAttachmentsPage = new JButton("Media");
|
||||
showAttachmentsPage.addActionListener(this);
|
||||
|
||||
Box bottom = Box.createHorizontalBox();
|
||||
bottom.add(showAttachmentsPage);
|
||||
bottom.add(Box.createGlue());
|
||||
bottom.add(textLength);
|
||||
bottom.add(Box.createHorizontalStrut(12));
|
||||
@ -405,3 +441,142 @@ implements ActionListener, CaretListener, KeyListener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class
|
||||
AttachmentsComponent extends JPanel
|
||||
implements ActionListener {
|
||||
|
||||
private ComposeWindow
|
||||
primaire;
|
||||
|
||||
// - -%- -
|
||||
|
||||
private Attachment[]
|
||||
working;
|
||||
|
||||
private JButton
|
||||
attachment1,
|
||||
attachment2,
|
||||
attachment3,
|
||||
attachment4;
|
||||
|
||||
private JButton
|
||||
delete,
|
||||
revert;
|
||||
|
||||
private JButton
|
||||
close;
|
||||
|
||||
private JLabel
|
||||
descriptionLabel;
|
||||
|
||||
private JTextArea
|
||||
description;
|
||||
|
||||
// ---%-@-%---
|
||||
|
||||
public void
|
||||
actionPerformed(ActionEvent eA)
|
||||
{
|
||||
Object src = eA.getSource();
|
||||
|
||||
if (src == close)
|
||||
{
|
||||
primaire.showContentsPage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (src == revert)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (src == delete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ---%-@-%---
|
||||
|
||||
AttachmentsComponent(ComposeWindow primaire)
|
||||
{
|
||||
this.primaire = primaire;
|
||||
|
||||
Border b1 = BorderFactory.createEmptyBorder(8, 8, 8, 8);
|
||||
Border b2 = BorderFactory.createEmptyBorder(4, 4, 4, 4);
|
||||
Border b3 = BorderFactory.createLineBorder(Color.GRAY);
|
||||
Border bc = BorderFactory.createCompoundBorder(b3, b2);
|
||||
|
||||
attachment1 = new JButton("+");
|
||||
attachment2 = new JButton("+");
|
||||
attachment3 = new JButton("+");
|
||||
attachment4 = new JButton("+");
|
||||
attachment1.setMargin(new Insets(0, 0, 0, 0));
|
||||
attachment2.setMargin(new Insets(0, 0, 0, 0));
|
||||
attachment3.setMargin(new Insets(0, 0, 0, 0));
|
||||
attachment4.setMargin(new Insets(0, 0, 0, 0));
|
||||
attachment1.addActionListener(this);
|
||||
attachment2.addActionListener(this);
|
||||
attachment3.addActionListener(this);
|
||||
attachment4.addActionListener(this);
|
||||
|
||||
JPanel left = new JPanel();
|
||||
left.setOpaque(false);
|
||||
left.setLayout(null);
|
||||
// BoxLayout wasn't listening to my
|
||||
// preferred nor minimum sizes.
|
||||
attachment1.setSize(40, 40);
|
||||
attachment2.setSize(40, 40);
|
||||
attachment3.setSize(40, 40);
|
||||
attachment4.setSize(40, 40);
|
||||
attachment1.setLocation(0, 0);
|
||||
attachment2.setLocation(0, 44);
|
||||
attachment3.setLocation(0, 88);
|
||||
attachment4.setLocation(0, 132);
|
||||
left.add(attachment1);
|
||||
left.add(attachment2);
|
||||
left.add(attachment3);
|
||||
left.add(attachment4);
|
||||
left.setPreferredSize(new Dimension(40, 172));
|
||||
|
||||
delete = new JButton("Delete");
|
||||
revert = new JButton("Revert");
|
||||
close = new JButton("Save & close");
|
||||
delete.addActionListener(this);
|
||||
revert.addActionListener(this);
|
||||
close.addActionListener(this);
|
||||
|
||||
Box bottom = Box.createHorizontalBox();
|
||||
bottom.add(delete);
|
||||
bottom.add(Box.createHorizontalStrut(16));
|
||||
bottom.add(revert);
|
||||
bottom.add(Box.createGlue());
|
||||
bottom.add(close);
|
||||
|
||||
description = new JTextArea();
|
||||
description.setLineWrap(true);
|
||||
description.setWrapStyleWord(true);
|
||||
java.awt.Font f = description.getFont();
|
||||
description.setFont(f.deriveFont(16f));
|
||||
description.setBorder(bc);
|
||||
descriptionLabel = new JLabel("Description");
|
||||
descriptionLabel.setLabelFor(description);
|
||||
|
||||
JPanel row1 = new JPanel();
|
||||
row1.setOpaque(false);
|
||||
row1.setLayout(new BorderLayout());
|
||||
row1.add(descriptionLabel, BorderLayout.NORTH);
|
||||
row1.add(description, BorderLayout.CENTER);
|
||||
Box right = Box.createVerticalBox();
|
||||
right.add(row1);
|
||||
|
||||
setLayout(new BorderLayout(12, 10));
|
||||
add(right, BorderLayout.CENTER);
|
||||
add(left, BorderLayout.WEST);
|
||||
add(bottom, BorderLayout.SOUTH);
|
||||
|
||||
setBorder(b1);
|
||||
}
|
||||
|
||||
}
|
||||
|
0
ImageApi.java
Executable file → Normal file
0
ImageApi.java
Executable file → Normal file
0
ImageWindow.java
Executable file → Normal file
0
ImageWindow.java
Executable file → Normal file
3
JKomasto.java
Executable file → Normal file
3
JKomasto.java
Executable file → Normal file
@ -614,6 +614,9 @@ Composition {
|
||||
public String
|
||||
replyToPostId;
|
||||
|
||||
public Attachment[]
|
||||
attachments;
|
||||
|
||||
// ---%-@-%---
|
||||
|
||||
public
|
||||
|
0
KDE_Dialog_Appear.wav
Executable file → Normal file
0
KDE_Dialog_Appear.wav
Executable file → Normal file
0
LoginWindow.java
Executable file → Normal file
0
LoginWindow.java
Executable file → Normal file
0
MastodonApi.java
Executable file → Normal file
0
MastodonApi.java
Executable file → Normal file
0
NotificationsWindow.java
Executable file → Normal file
0
NotificationsWindow.java
Executable file → Normal file
0
PostWindow.java
Executable file → Normal file
0
PostWindow.java
Executable file → Normal file
0
ProfileWindow.java
Executable file → Normal file
0
ProfileWindow.java
Executable file → Normal file
0
RepliesWindow.java
Executable file → Normal file
0
RepliesWindow.java
Executable file → Normal file
0
RequestListener.java
Executable file → Normal file
0
RequestListener.java
Executable file → Normal file
0
RichTextPane.java
Executable file → Normal file
0
RichTextPane.java
Executable file → Normal file
0
RichTextPane2.java
Executable file → Normal file
0
RichTextPane2.java
Executable file → Normal file
4
RichTextPane3.java
Executable file → Normal file
4
RichTextPane3.java
Executable file → Normal file
@ -471,7 +471,7 @@ implements
|
||||
Position ssp = layout.get(selStart);
|
||||
Position sep = layout.get(selEnd);
|
||||
assert ssp != null && sep != null;
|
||||
if (ssp.compareTo(sep) > 1)
|
||||
if (ssp.compareTo(sep) > 0)
|
||||
{
|
||||
Position temp = ssp;
|
||||
ssp = sep;
|
||||
@ -613,7 +613,7 @@ implements
|
||||
compareTo(Position other)
|
||||
{
|
||||
if (line < other.line) return -1;
|
||||
if (line > other.line) return -1;
|
||||
if (line > other.line) return 1;
|
||||
if (x < other.x) return -1;
|
||||
if (x > other.x) return 1;
|
||||
return 0;
|
||||
|
0
RudimentaryHTMLParser.java
Executable file → Normal file
0
RudimentaryHTMLParser.java
Executable file → Normal file
0
TimelineWindow.java
Executable file → Normal file
0
TimelineWindow.java
Executable file → Normal file
0
TwoToggleButton.java
Executable file → Normal file
0
TwoToggleButton.java
Executable file → Normal file
0
WindowUpdater.java
Executable file → Normal file
0
WindowUpdater.java
Executable file → Normal file
0
notifOptions.txt
Executable file → Normal file
0
notifOptions.txt
Executable file → Normal file
0
notifOptions.txt~
Executable file → Normal file
0
notifOptions.txt~
Executable file → Normal file
Loading…
Reference in New Issue
Block a user