Update
parent
c71bece39b
commit
715b55276c
|
@ -81,6 +81,21 @@ public class EasyMail {
|
||||||
Email email = this.currentUser.getUsermail().getInbox().getEmailBySubject(subject);
|
Email email = this.currentUser.getUsermail().getInbox().getEmailBySubject(subject);
|
||||||
return email.showEmails();
|
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() {
|
public String[] sendUserDetails() {
|
||||||
String[] details = new String[2];
|
String[] details = new String[2];
|
||||||
|
|
|
@ -97,6 +97,7 @@ public class EasyMailWindow extends TemplateWindow {
|
||||||
getAllInboxEmails(email);
|
getAllInboxEmails(email);
|
||||||
} catch (EmailNotFoundException e) {
|
} catch (EmailNotFoundException e) {
|
||||||
this.showError(e.getMessage());
|
this.showError(e.getMessage());
|
||||||
|
getAllInboxEmails("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ public class EasyMailWindow extends TemplateWindow {
|
||||||
SentWindow sentWindow = new SentWindow();
|
SentWindow sentWindow = new SentWindow();
|
||||||
closeWindow();
|
closeWindow();
|
||||||
sentWindow.showWindow();
|
sentWindow.showWindow();
|
||||||
sentWindow.getAllSentEmails();
|
sentWindow.getAllSentEmails("");
|
||||||
showUserDetails();
|
showUserDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,22 +143,20 @@ public class EasyMailWindow extends TemplateWindow {
|
||||||
|
|
||||||
public void getAllInboxEmails(String foundedEmail) {
|
public void getAllInboxEmails(String foundedEmail) {
|
||||||
if (foundedEmail.trim().isEmpty()) {
|
if (foundedEmail.trim().isEmpty()) {
|
||||||
inboxTableModel.setRowCount(0);
|
inboxTableModel.setRowCount(0);
|
||||||
ArrayList<String> getEmails = fassade.sendAllEmailsToInboxWindow();
|
ArrayList<String> getEmails = fassade.sendAllEmailsToInboxWindow();
|
||||||
if (getEmails != null && !getEmails.isEmpty())
|
if (getEmails != null && !getEmails.isEmpty())
|
||||||
for (String tempEmail : getEmails) {
|
for (String tempEmail : getEmails) {
|
||||||
String[] splitEmail = tempEmail.split(",");
|
String[] splitEmail = tempEmail.split(",");
|
||||||
Object[] newEmail = { splitEmail[0], splitEmail[1], splitEmail[2] };
|
Object[] newEmail = { splitEmail[0], splitEmail[1], splitEmail[2] };
|
||||||
inboxTableModel.addRow(newEmail);
|
inboxTableModel.addRow(newEmail);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
String[] splitEmail = foundedEmail.split(",");
|
String[] splitEmail = foundedEmail.split(",");
|
||||||
Object[] newEmail = { splitEmail[0], splitEmail[1], splitEmail[2] };
|
Object[] newEmail = { splitEmail[0], splitEmail[1], splitEmail[2] };
|
||||||
inboxTableModel.addRow(newEmail);
|
inboxTableModel.addRow(newEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@ package gui;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import domain.email.EmailNotFoundException;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
@ -41,8 +44,14 @@ public class SentWindow extends TemplateWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSearching() {
|
public void handleSearching() {
|
||||||
String getSubjct = searchField.getText();
|
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() {
|
private void initNavigationPanel() {
|
||||||
|
@ -90,17 +99,25 @@ public class SentWindow extends TemplateWindow {
|
||||||
tablePanel.add(scrollPane);
|
tablePanel.add(scrollPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAllSentEmails() {
|
public void getAllSentEmails(String email) {
|
||||||
ArrayList<String> getEmails = fassade.sendAllEmailsToSentWindow();
|
if (email.trim().isEmpty()) {
|
||||||
String[] splitEmail;
|
ArrayList<String> getEmails = fassade.sendAllEmailsToSentWindow();
|
||||||
if (getEmails.size() > 0)
|
String[] splitEmail;
|
||||||
for (String tempEmail : getEmails) {
|
if (getEmails.size() > 0)
|
||||||
splitEmail = tempEmail.split(",");
|
for (String tempEmail : getEmails) {
|
||||||
String to = splitEmail[0].toString();
|
splitEmail = tempEmail.split(",");
|
||||||
String subject = splitEmail[1];
|
String to = splitEmail[0].toString();
|
||||||
String date = splitEmail[2];
|
String subject = splitEmail[1];
|
||||||
Object[] newEmail = { to, subject, date };
|
String date = splitEmail[2];
|
||||||
inboxTableModel.addRow(newEmail);
|
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,7 +10,8 @@ import java.util.ArrayList;
|
||||||
public class TrashWindow extends TemplateWindow {
|
public class TrashWindow extends TemplateWindow {
|
||||||
|
|
||||||
private DefaultTableModel inboxTableModel;
|
private DefaultTableModel inboxTableModel;
|
||||||
|
private JTextField searchField;
|
||||||
|
|
||||||
public TrashWindow() {
|
public TrashWindow() {
|
||||||
super("Trash - EasyMail");
|
super("Trash - EasyMail");
|
||||||
initUI();
|
initUI();
|
||||||
|
@ -24,11 +25,27 @@ public class TrashWindow extends TemplateWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComposePanel() {
|
private void initComposePanel() {
|
||||||
JPanel composePanel = createPanel(367, 11, 750, 86, new Color(230, 230, 230), true);
|
JPanel composePanel = createPanel(367, 11, 750, 86, new Color(230, 230, 230), true);
|
||||||
contentPane.add(composePanel);
|
contentPane.add(composePanel);
|
||||||
composePanel.setLayout(null);
|
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() {
|
private void initNavigationPanel() {
|
||||||
JPanel navigationPanel = createPanel(10, 273, 347, 451, new Color(230, 230, 230), true);
|
JPanel navigationPanel = createPanel(10, 273, 347, 451, new Color(230, 230, 230), true);
|
||||||
|
@ -58,7 +75,7 @@ public class TrashWindow extends TemplateWindow {
|
||||||
SentWindow sentWindow = new SentWindow();
|
SentWindow sentWindow = new SentWindow();
|
||||||
closeWindow();
|
closeWindow();
|
||||||
sentWindow.showWindow();
|
sentWindow.showWindow();
|
||||||
sentWindow.getAllSentEmails();
|
sentWindow.getAllSentEmails("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
navigationPanel.add(sentEmails);
|
navigationPanel.add(sentEmails);
|
||||||
|
|
|
@ -5,9 +5,7 @@ import gui.*;
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
EasyMailWindow easy = new EasyMailWindow();
|
new EasyMailWindow();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue