Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter für Mail View #235

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/de/jost_net/JVerein/gui/control/FilterControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public class FilterControl extends AbstractControl

protected DateInput abbuchungsdatumbis = null;

protected TextInput suchtext = null;

public enum Mitgliedstyp {
MITGLIED,
Expand Down Expand Up @@ -845,6 +846,23 @@ public boolean isAbbuchungsdatumbisAktiv()
return abbuchungsdatumbis != null;
}

public TextInput getSuchtext()
{
if (suchtext != null)
{
return suchtext;
}
this.suchtext = new TextInput(settings.getString(settingsprefix + "suchtext", ""),
50);
suchtext.setName("Text");
return suchtext;
}

public boolean isSuchtextAktiv()
{
return suchtext != null;
}

/**
* Buttons
*/
Expand Down Expand Up @@ -955,6 +973,8 @@ public void handleAction(Object context) throws ApplicationException
abbuchungsdatumvon.setValue(null);
if (abbuchungsdatumbis != null)
abbuchungsdatumbis.setValue(null);
if (suchtext != null)
suchtext.setValue("");
refresh();
}
}, null, false, "eraser.png");
Expand Down Expand Up @@ -1313,6 +1333,19 @@ public void saveFilterSettings() throws RemoteException
saveDate( (Date) abbuchungsdatumbis.getValue(), "abbuchungsdatum.bis");
}

if (suchtext != null)
{
String tmp = (String) suchtext.getValue();
if (tmp != null)
{
settings.setAttribute(settingsprefix + "suchtext", tmp);
}
else
{
settings.setAttribute(settingsprefix + "suchtext", "");
}
}

}

private void saveDate(Date tmp, String setting)
Expand Down
89 changes: 80 additions & 9 deletions src/de/jost_net/JVerein/gui/control/MailControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import de.jost_net.JVerein.util.JVDateFormatTTMMJJJJ;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.datasource.rmi.DBService;
import de.willuhn.jameica.gui.AbstractControl;
import de.willuhn.jameica.gui.AbstractView;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.GUI;
Expand All @@ -67,11 +66,9 @@
import de.willuhn.util.ApplicationException;
import de.willuhn.util.ProgressMonitor;

public class MailControl extends AbstractControl
public class MailControl extends FilterControl
{

private de.willuhn.jameica.system.Settings settings;

private TablePart empfaenger;

private TextInput betreff;
Expand All @@ -86,6 +83,7 @@ public class MailControl extends AbstractControl

private TablePart mailsList;


public MailControl(AbstractView view)
{
super(view);
Expand Down Expand Up @@ -613,11 +611,11 @@ public void handleStore(boolean mitversand)

public Part getMailList() throws RemoteException
{
DBService service = Einstellungen.getDBService();
DBIterator<Mail> mails = service.createList(Mail.class);
mails.setOrder("ORDER BY betreff");

mailsList = new TablePart(mails, new MailDetailAction());
if (mailsList != null)
{
return mailsList;
}
mailsList = new TablePart(getMails(), new MailDetailAction());
mailsList.addColumn("Betreff", "betreff");
mailsList.addColumn("Bearbeitung", "bearbeitung",
new DateFormatter(new JVDateFormatDATETIME()));
Expand All @@ -628,6 +626,79 @@ public Part getMailList() throws RemoteException
mailsList.setRememberOrder(true);
return mailsList;
}

public void TabRefresh()
{
try
{
if (mailsList == null)
{
return;
}
mailsList.removeAll();
DBIterator<Mail> mails = getMails();
while (mails.hasNext())
{
mailsList.addItem(mails.next());
}
}
catch (RemoteException e1)
{
Logger.error("Fehler", e1);
}
}

private DBIterator<Mail> getMails() throws RemoteException
{
DBService service = Einstellungen.getDBService();
DBIterator<Mail> mails = service.createList(Mail.class);
mails.join("mailempfaenger");
mails.addFilter("mailempfaenger.mail = mail.id");
mails.join("mitglied");
mails.addFilter("mitglied.id = mailempfaenger.mitglied");

if (isSuchnameAktiv() && getSuchname().getValue() != null)
{
String tmpSuchname = (String) getSuchname().getValue();
if (tmpSuchname.length() > 0)
{
mails.addFilter("(lower(betreff) like ?)",
new Object[] { "%" + tmpSuchname.toLowerCase() + "%" });
}
}
if (isSuchtextAktiv() && getSuchtext().getValue() != null)
{
String tmpSuchtext = (String) getSuchtext().getValue();
if (tmpSuchtext.length() > 0)
{
mails.addFilter("(lower(betreff) like ?)",
new Object[] { "%" + tmpSuchtext.toLowerCase() + "%" });
}
}
if (isEingabedatumvonAktiv() && getEingabedatumvon().getValue() != null)
{
Date d = (Date) getEingabedatumvon().getValue();
mails.addFilter("bearbeitung >= ?", new Object[] { new java.sql.Date(d.getTime()) });
}
if (isEingabedatumbisAktiv() && getEingabedatumbis().getValue() != null)
{
Date d = (Date) getEingabedatumbis().getValue();
mails.addFilter("bearbeitung <= ?", new Object[] { new java.sql.Date(d.getTime()) });
}
if (isDatumvonAktiv() && getDatumvon().getValue() != null)
{
Date d = (Date) getDatumvon().getValue();
mails.addFilter("mail.versand >= ?", new Object[] { new java.sql.Date(d.getTime()) });
}
if (isDatumbisAktiv() && getDatumbis().getValue() != null)
{
Date d = (Date) getDatumbis().getValue();
mails.addFilter("mail.versand <= ?", new Object[] { new java.sql.Date(d.getTime()) });
}
mails.setOrder("ORDER BY betreff");

return mails;
}

public class EvalMail
{
Expand Down
23 changes: 23 additions & 0 deletions src/de/jost_net/JVerein/gui/view/MailUebersichtView.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import de.willuhn.jameica.gui.AbstractView;
import de.willuhn.jameica.gui.GUI;
import de.willuhn.jameica.gui.parts.ButtonArea;
import de.willuhn.jameica.gui.util.ColumnLayout;
import de.willuhn.jameica.gui.util.LabelGroup;
import de.willuhn.jameica.gui.util.SimpleContainer;

public class MailUebersichtView extends AbstractView
{
Expand All @@ -32,6 +35,26 @@ public void bind() throws Exception
GUI.getView().setTitle("Mails");

MailControl control = new MailControl(this);

LabelGroup group = new LabelGroup(getParent(), "Filter");
ColumnLayout cl = new ColumnLayout(group.getComposite(), 3);

SimpleContainer left = new SimpleContainer(cl.getComposite());
left.addLabelPair("Mail Empf�nger", control.getSuchname());
left.addLabelPair("Betreff", control.getSuchtext());

SimpleContainer middle = new SimpleContainer(cl.getComposite());
middle.addLabelPair("Bearbeitung von", control.getEingabedatumvon());
middle.addLabelPair("Bearbeitung bis", control.getEingabedatumbis());

SimpleContainer right = new SimpleContainer(cl.getComposite());
right.addLabelPair("Versand von", control.getDatumvon());
right.addLabelPair("Versand bis", control.getDatumbis());

ButtonArea fbuttons = new ButtonArea();
fbuttons.addButton(control.getResetButton());
fbuttons.addButton(control.getSuchenButton());
group.addButtonArea(fbuttons);

control.getMailList().paint(this.getParent());

Expand Down