mirror of
https://github.com/igniterealtime/Spark.git
synced 2026-08-18 02:56:24 +00:00
cleanup BroadcastHistoryFrame
This commit is contained in:
@ -29,49 +29,46 @@ import static javax.swing.LayoutStyle.ComponentPlacement;
|
||||
* @author ps
|
||||
*/
|
||||
public class BroadcastHistoryFrame extends JFrame {
|
||||
private JFormattedTextField dateField;
|
||||
private JTextArea broadcastHistoryArea;
|
||||
private JLabel searchDate;
|
||||
private JToggleButton searchButton;
|
||||
private JFormattedTextField dateField = new JFormattedTextField();
|
||||
private JTextArea broadcastHistoryArea = new JTextArea();
|
||||
|
||||
private JLabel searchDate = new JLabel();
|
||||
private JToggleButton searchButton = new JToggleButton();
|
||||
|
||||
public BroadcastHistoryFrame() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void readFromFile(String date) throws IOException {
|
||||
public void readFromFile(String date) {
|
||||
File transcriptsFolder = SparkManager.getTranscriptDir();
|
||||
File myfile = new File(transcriptsFolder, "broadcast_history." + date + ".txt");
|
||||
if (!myfile.exists()) {
|
||||
return;
|
||||
}
|
||||
String content = Files.readString(myfile.toPath());
|
||||
broadcastHistoryArea.setText(content);
|
||||
try {
|
||||
String content = Files.readString(myfile.toPath());
|
||||
broadcastHistoryArea.setText(content);
|
||||
} catch (IOException ex) {
|
||||
Log.error("Couldn't read from file", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
broadcastHistoryArea = new JTextArea();
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
broadcastHistoryArea.setEditable(false);
|
||||
broadcastHistoryArea.setLineWrap(true);
|
||||
broadcastHistoryArea.setWrapStyleWord(true);
|
||||
|
||||
searchButton = new JToggleButton();
|
||||
dateField = new JFormattedTextField();
|
||||
searchDate = new JLabel();
|
||||
Date date = new Date();
|
||||
Format formatter = new SimpleDateFormat("yyy-MM");
|
||||
String myDate = formatter.format(date);
|
||||
dateField.setValue(myDate);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
|
||||
JScrollPane panelPane = new JScrollPane(broadcastHistoryArea);
|
||||
searchDate.setText(Res.getString("label.broadcast.history.search.date"));
|
||||
setTitle(Res.getString("title.broadcast.history"));
|
||||
|
||||
try {
|
||||
readFromFile(myDate);
|
||||
} catch (IOException ex) {
|
||||
Log.error("Couldn't read from file", ex);
|
||||
}
|
||||
readFromFile(myDate);
|
||||
|
||||
searchButton.setText((Res.getString("button.search")));
|
||||
searchButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
@ -139,18 +136,13 @@ public class BroadcastHistoryFrame extends JFrame {
|
||||
|
||||
private void searchButtonMouseClicked(java.awt.event.MouseEvent evt) {
|
||||
broadcastHistoryArea.setText("");
|
||||
try {
|
||||
readFromFile(dateField.getText());
|
||||
} catch (IOException ex) {
|
||||
Log.error("Couldn't read from file", ex);
|
||||
}
|
||||
readFromFile(dateField.getText());
|
||||
}
|
||||
|
||||
public void run() {
|
||||
public static void invokeDialog() {
|
||||
invokeLater(() -> {
|
||||
BroadcastHistoryFrame frame = new BroadcastHistoryFrame();
|
||||
frame.setVisible(true);
|
||||
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
|
||||
actionsMenu.add(broadcastMenu);
|
||||
|
||||
broadcastMenu.addActionListener(e -> broadcastToRoster());
|
||||
broadcastHistoryMenu.addActionListener(e -> new BroadcastHistoryFrame().run());
|
||||
broadcastHistoryMenu.addActionListener(e -> BroadcastHistoryFrame.invokeDialog());
|
||||
// Register with action menu
|
||||
JMenuItem startConversationMenu = new JMenuItem("", SparkRes.getImageIcon(SparkRes.Icon.SMALL_MESSAGE_IMAGE));
|
||||
ResourceUtils.resButton(startConversationMenu, Res.getString("menuitem.start.a.chat"));
|
||||
@ -121,7 +121,7 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
|
||||
|
||||
String jid = (String) JOptionPane.showInputDialog(SparkManager.getMainWindow(), Res.getString("label.enter.address"), Res.getString("title.start.chat"), JOptionPane.QUESTION_MESSAGE, null, null, selectedUser);
|
||||
if (ModelUtil.hasLength(jid) && ModelUtil.hasLength(XmppStringUtils.parseDomain(jid))) {
|
||||
if (ModelUtil.hasLength(jid) && jid.indexOf('@') == -1) {
|
||||
if (!isBlank(jid) && !jid.contains("@")) {
|
||||
// Append server address
|
||||
jid = jid + "@" + SparkManager.getConnection().getXMPPServiceDomain();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user