Update
parent
c71bece39b
commit
715b55276c
|
@ -81,6 +81,21 @@ public class EasyMail {
|
|||
Email email = this.currentUser.getUsermail().getInbox().getEmailBySubject(subject);
|
||||
return email.showEmails();
|
||||
}
|
||||
public String searchEmailInSentFolder(String subject) throws EmailNotFoundException {
|
||||
if (subject.trim().isEmpty())
|
||||
throw new IllegalArgumentException("subject field is required!");
|
||||
|
||||
Email email = this.currentUser.getUsermail().getSentFolder().getEmailBySubject(subject);
|
||||
return email.showEmails();
|
||||
}
|
||||
public String searchEmailInTrashFolder(String subject) throws EmailNotFoundException {
|
||||
if (subject.trim().isEmpty())
|
||||
throw new IllegalArgumentException("subject field is required!");
|
||||
|
||||
Email email = this.currentUser.getUsermail().getTrashFolder().getEmailBySubject(subject);
|
||||
return email.showEmails();
|
||||
}
|
||||
|
||||
|
||||
public String[] sendUserDetails() {
|
||||
String[] details = new String[2];
|
||||
|
|
|
@ -97,6 +97,7 @@ public class EasyMailWindow extends TemplateWindow {
|
|||
getAllInboxEmails(email);
|
||||
} catch (EmailNotFoundException e) {
|
||||
this.showError(e.getMessage());
|
||||
getAllInboxEmails("");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +116,7 @@ public class EasyMailWindow extends TemplateWindow {
|
|||
SentWindow sentWindow = new SentWindow();
|
||||
closeWindow();
|
||||
sentWindow.showWindow();
|
||||
sentWindow.getAllSentEmails();
|
||||
sentWindow.getAllSentEmails("");
|
||||
showUserDetails();
|
||||
}
|
||||
|
||||
|
@ -156,8 +157,6 @@ public class EasyMailWindow extends TemplateWindow {
|
|||
inboxTableModel.addRow(newEmail);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@ package gui;
|
|||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import domain.email.EmailNotFoundException;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
@ -41,8 +44,14 @@ public class SentWindow extends TemplateWindow {
|
|||
}
|
||||
|
||||
public void handleSearching() {
|
||||
try {
|
||||
String getSubjct = searchField.getText();
|
||||
|
||||
String email = fassade.searchEmailInSentFolder(getSubjct);
|
||||
inboxTableModel.setRowCount(0);
|
||||
getAllSentEmails(email);
|
||||
} catch (EmailNotFoundException e) {
|
||||
this.showError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void initNavigationPanel() {
|
||||
|
@ -90,7 +99,8 @@ public class SentWindow extends TemplateWindow {
|
|||
tablePanel.add(scrollPane);
|
||||
}
|
||||
|
||||
public void getAllSentEmails() {
|
||||
public void getAllSentEmails(String email) {
|
||||
if (email.trim().isEmpty()) {
|
||||
ArrayList<String> getEmails = fassade.sendAllEmailsToSentWindow();
|
||||
String[] splitEmail;
|
||||
if (getEmails.size() > 0)
|
||||
|
@ -102,5 +112,12 @@ public class SentWindow extends TemplateWindow {
|
|||
Object[] newEmail = { to, subject, date };
|
||||
inboxTableModel.addRow(newEmail);
|
||||
}
|
||||
|
||||
} else {
|
||||
String[] splitEmail = email.split(",");
|
||||
Object[] newEmail = { splitEmail[0], splitEmail[1], splitEmail[2] };
|
||||
inboxTableModel.addRow(newEmail);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.ArrayList;
|
|||
public class TrashWindow extends TemplateWindow {
|
||||
|
||||
private DefaultTableModel inboxTableModel;
|
||||
private JTextField searchField;
|
||||
|
||||
public TrashWindow() {
|
||||
super("Trash - EasyMail");
|
||||
|
@ -28,8 +29,24 @@ public class TrashWindow extends TemplateWindow {
|
|||
contentPane.add(composePanel);
|
||||
composePanel.setLayout(null);
|
||||
|
||||
searchField = new PlaceholderTextField("Search By subject");
|
||||
searchField.setBounds(500, 30, 150, 40);
|
||||
composePanel.add(searchField);
|
||||
|
||||
JButton searchButton = new JButton("Search");
|
||||
searchButton.setBounds(660, 30, 80, 40);
|
||||
composePanel.add(searchButton);
|
||||
searchButton.addActionListener(e -> handleSearching());
|
||||
|
||||
}
|
||||
|
||||
public void handleSearching() {
|
||||
String getSubjct = searchField.getText();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void initNavigationPanel() {
|
||||
JPanel navigationPanel = createPanel(10, 273, 347, 451, new Color(230, 230, 230), true);
|
||||
contentPane.add(navigationPanel);
|
||||
|
@ -58,7 +75,7 @@ public class TrashWindow extends TemplateWindow {
|
|||
SentWindow sentWindow = new SentWindow();
|
||||
closeWindow();
|
||||
sentWindow.showWindow();
|
||||
sentWindow.getAllSentEmails();
|
||||
sentWindow.getAllSentEmails("");
|
||||
}
|
||||
});
|
||||
navigationPanel.add(sentEmails);
|
||||
|
|
|
@ -5,9 +5,7 @@ import gui.*;
|
|||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
EasyMailWindow easy = new EasyMailWindow();
|
||||
|
||||
|
||||
new EasyMailWindow();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue