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.event.KeyEvent;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Insets;
|
||||||
import javax.swing.event.CaretListener;
|
import javax.swing.event.CaretListener;
|
||||||
import javax.swing.event.CaretEvent;
|
import javax.swing.event.CaretEvent;
|
||||||
|
|
||||||
@ -40,7 +42,10 @@ ComposeWindow extends JFrame {
|
|||||||
composition;
|
composition;
|
||||||
|
|
||||||
private ComposeComponent
|
private ComposeComponent
|
||||||
display;
|
contentsDisplay;
|
||||||
|
|
||||||
|
private AttachmentsComponent
|
||||||
|
attachmentsDisplay;
|
||||||
|
|
||||||
// ---%-@-%---
|
// ---%-@-%---
|
||||||
|
|
||||||
@ -73,7 +78,7 @@ ComposeWindow extends JFrame {
|
|||||||
if (composition.contentWarning != null)
|
if (composition.contentWarning != null)
|
||||||
assert !composition.contentWarning.trim().isEmpty();
|
assert !composition.contentWarning.trim().isEmpty();
|
||||||
|
|
||||||
display.setSubmitting(true);
|
contentsDisplay.setSubmitting(true);
|
||||||
api.submit(
|
api.submit(
|
||||||
composition.text, composition.visibility,
|
composition.text, composition.visibility,
|
||||||
composition.replyToPostId, composition.contentWarning,
|
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
|
private synchronized void
|
||||||
syncDisplayToComposition()
|
syncDisplayToComposition()
|
||||||
{
|
{
|
||||||
display.setText(composition.text);
|
ComposeComponent d = contentsDisplay;
|
||||||
display.setReplyToPostId(composition.replyToPostId);
|
d.setText(composition.text);
|
||||||
display.setVisibility(stringFor(composition.visibility));
|
d.setReplyToPostId(composition.replyToPostId);
|
||||||
display.setContentWarning(composition.contentWarning);
|
d.setVisibility(stringFor(composition.visibility));
|
||||||
|
d.setContentWarning(composition.contentWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void
|
private synchronized void
|
||||||
syncCompositionToDisplay()
|
syncCompositionToDisplay()
|
||||||
{
|
{
|
||||||
composition.text = display.getText();
|
ComposeComponent d = contentsDisplay;
|
||||||
composition.visibility =
|
Composition c = composition;
|
||||||
visibilityFrom(display.getVisibility());
|
c.text = d.getText();
|
||||||
composition.replyToPostId =
|
c.visibility = visibilityFrom(d.getVisibility());
|
||||||
nonEmpty(display.getReplyToPostId());
|
c.replyToPostId = nonEmpty(d.getReplyToPostId());
|
||||||
composition.contentWarning =
|
c.contentWarning = nonEmpty(d.getContentWarning());
|
||||||
nonEmpty(display.getContentWarning());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - -%- -
|
// - -%- -
|
||||||
@ -151,14 +170,17 @@ ComposeWindow extends JFrame {
|
|||||||
this.primaire = primaire;
|
this.primaire = primaire;
|
||||||
this.api = primaire.getMastodonApi();
|
this.api = primaire.getMastodonApi();
|
||||||
|
|
||||||
getContentPane().setPreferredSize(new Dimension(360, 270));
|
final Dimension SZ = new Dimension(360, 270);
|
||||||
|
|
||||||
|
getContentPane().setPreferredSize(SZ);
|
||||||
pack();
|
pack();
|
||||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
display = new ComposeComponent(this);
|
contentsDisplay = new ComposeComponent(this);
|
||||||
|
attachmentsDisplay = new AttachmentsComponent(this);
|
||||||
newComposition();
|
newComposition();
|
||||||
|
|
||||||
setContentPane(display);
|
showContentsPage();
|
||||||
setIconImage(primaire.getProgramIcon());
|
setIconImage(primaire.getProgramIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +243,9 @@ implements ActionListener, CaretListener, KeyListener {
|
|||||||
private JButton
|
private JButton
|
||||||
submit;
|
submit;
|
||||||
|
|
||||||
|
private JButton
|
||||||
|
showAttachmentsPage;
|
||||||
|
|
||||||
// ---%-@-%---
|
// ---%-@-%---
|
||||||
|
|
||||||
public void
|
public void
|
||||||
@ -300,7 +325,14 @@ implements ActionListener, CaretListener, KeyListener {
|
|||||||
// - -%- -
|
// - -%- -
|
||||||
|
|
||||||
public void
|
public void
|
||||||
actionPerformed(ActionEvent eA) { primaire.submit(); }
|
actionPerformed(ActionEvent eA)
|
||||||
|
{
|
||||||
|
if (eA.getSource() == showAttachmentsPage)
|
||||||
|
primaire.showAttachmentsPage();
|
||||||
|
|
||||||
|
if (eA.getSource() == submit)
|
||||||
|
primaire.submit();
|
||||||
|
}
|
||||||
|
|
||||||
public void
|
public void
|
||||||
caretUpdate(CaretEvent eCa) { updateTextLength(); }
|
caretUpdate(CaretEvent eCa) { updateTextLength(); }
|
||||||
@ -375,12 +407,16 @@ implements ActionListener, CaretListener, KeyListener {
|
|||||||
"Mentioned"
|
"Mentioned"
|
||||||
// Where should we be saving strings..
|
// Where should we be saving strings..
|
||||||
});
|
});
|
||||||
visibility.setPreferredSize(new Dimension(64, 24));
|
visibility.setPreferredSize(new Dimension(48, 24));
|
||||||
|
|
||||||
submit = new JButton("Submit");
|
submit = new JButton("Submit");
|
||||||
submit.addActionListener(this);
|
submit.addActionListener(this);
|
||||||
|
|
||||||
|
showAttachmentsPage = new JButton("Media");
|
||||||
|
showAttachmentsPage.addActionListener(this);
|
||||||
|
|
||||||
Box bottom = Box.createHorizontalBox();
|
Box bottom = Box.createHorizontalBox();
|
||||||
|
bottom.add(showAttachmentsPage);
|
||||||
bottom.add(Box.createGlue());
|
bottom.add(Box.createGlue());
|
||||||
bottom.add(textLength);
|
bottom.add(textLength);
|
||||||
bottom.add(Box.createHorizontalStrut(12));
|
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
|
public String
|
||||||
replyToPostId;
|
replyToPostId;
|
||||||
|
|
||||||
|
public Attachment[]
|
||||||
|
attachments;
|
||||||
|
|
||||||
// ---%-@-%---
|
// ---%-@-%---
|
||||||
|
|
||||||
public
|
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
8
RichTextPane3.java
Executable file → Normal file
8
RichTextPane3.java
Executable file → Normal file
@ -182,7 +182,7 @@ implements
|
|||||||
layout.put(temp, cursor.clone());
|
layout.put(temp, cursor.clone());
|
||||||
|
|
||||||
rem.delete(0, l);
|
rem.delete(0, l);
|
||||||
boolean more = rem.length() != 0;
|
boolean more = rem.length() != 0;
|
||||||
if (more) ++cursor.line;
|
if (more) ++cursor.line;
|
||||||
cursor.x = more ? 0 : w;
|
cursor.x = more ? 0 : w;
|
||||||
aw = mw;
|
aw = mw;
|
||||||
@ -247,7 +247,7 @@ implements
|
|||||||
aug.value = child.value;
|
aug.value = child.value;
|
||||||
for (Tree<String> gc: child) aug.add(gc);
|
for (Tree<String> gc: child) aug.add(gc);
|
||||||
|
|
||||||
// Append all of our attributes. We'd like
|
// Append all of our attributes. We'd like
|
||||||
// those like href to end up at the text
|
// those like href to end up at the text
|
||||||
// nodes. This might collide with our
|
// nodes. This might collide with our
|
||||||
// child node's attributes, for now I'll
|
// child node's attributes, for now I'll
|
||||||
@ -471,7 +471,7 @@ implements
|
|||||||
Position ssp = layout.get(selStart);
|
Position ssp = layout.get(selStart);
|
||||||
Position sep = layout.get(selEnd);
|
Position sep = layout.get(selEnd);
|
||||||
assert ssp != null && sep != null;
|
assert ssp != null && sep != null;
|
||||||
if (ssp.compareTo(sep) > 1)
|
if (ssp.compareTo(sep) > 0)
|
||||||
{
|
{
|
||||||
Position temp = ssp;
|
Position temp = ssp;
|
||||||
ssp = sep;
|
ssp = sep;
|
||||||
@ -613,7 +613,7 @@ implements
|
|||||||
compareTo(Position other)
|
compareTo(Position other)
|
||||||
{
|
{
|
||||||
if (line < other.line) return -1;
|
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;
|
||||||
if (x > other.x) return 1;
|
if (x > other.x) return 1;
|
||||||
return 0;
|
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