### Eclipse Workspace Patch 1.0 #P jverein diff --git src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java index b45e712..d4dbef5 100644 --- src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java +++ src/de/jost_net/JVerein/gui/control/MitgliedskontoControl.java @@ -41,6 +41,7 @@ import de.jost_net.JVerein.io.Mahnungsausgabe; import de.jost_net.JVerein.io.Rechnungsausgabe; import de.jost_net.JVerein.keys.Ausgabeart; +import de.jost_net.JVerein.keys.Ausgabesortierung; import de.jost_net.JVerein.keys.FormularArt; import de.jost_net.JVerein.keys.Zahlungsweg; import de.jost_net.JVerein.rmi.Mitglied; @@ -148,6 +149,8 @@ private CheckboxInput ohneabbucher = null; private SelectInput ausgabeart = null; + + private SelectInput ausgabesortierung = null; private TextInput suchname = null; @@ -451,6 +454,18 @@ Ausgabeart.valueOf(settings.getString("ausgabeart", "DRUCK"))); ausgabeart.setName("Ausgabe"); return ausgabeart; + } + + public SelectInput getAusgabesortierung() + { + if (ausgabesortierung != null) + { + return ausgabesortierung; + } + ausgabesortierung = new SelectInput(Ausgabesortierung.values(), + Ausgabesortierung.getByKey(settings.getInt("ausgabesortierung", 1))); + ausgabesortierung.setName("Sortierung"); + return ausgabesortierung; } public TextInput getBetreff(String verwendung) @@ -839,6 +854,8 @@ { Ausgabeart aa = (Ausgabeart) getAusgabeart().getValue(); settings.setAttribute("ausgabeart", aa.toString()); + Ausgabesortierung as = (Ausgabesortierung) getAusgabesortierung().getValue(); + settings.setAttribute("ausgabesortierung", as.getKey()); settings.setAttribute(TYP.RECHNUNG.name() + ".mail.betreff", (String) getBetreff(TYP.RECHNUNG.name()).getValue()); settings.setAttribute(TYP.RECHNUNG.name() + ".mail.text", diff --git src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java index afa9f1b..5e8f934 100644 --- src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java +++ src/de/jost_net/JVerein/gui/view/MitgliedskontoRechnungView.java @@ -49,6 +49,7 @@ } cont.addLabelPair("Formular", control.getFormular(FormularArt.RECHNUNG)); cont.addInput(control.getAusgabeart()); + cont.addInput(control.getAusgabesortierung()); cont.addHeadline("Mail"); cont.addInput(control.getBetreff(MitgliedskontoControl.TYP.RECHNUNG.name())); diff --git src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java index 78adbc2..774b468 100644 --- src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java +++ src/de/jost_net/JVerein/io/AbstractMitgliedskontoDokument.java @@ -36,6 +36,7 @@ import de.jost_net.JVerein.Variable.MitgliedskontoMap; import de.jost_net.JVerein.gui.control.MitgliedskontoControl; import de.jost_net.JVerein.keys.Ausgabeart; +import de.jost_net.JVerein.keys.Ausgabesortierung; import de.jost_net.JVerein.rmi.Formular; import de.jost_net.JVerein.rmi.Mitglied; import de.jost_net.JVerein.rmi.Mitgliedskonto; @@ -166,35 +167,76 @@ if (currentObject instanceof Mitgliedskonto[]) { Mitgliedskonto[] mkn = (Mitgliedskonto[]) currentObject; - Arrays.sort(mkn, new Comparator() - { - @Override - public int compare(Mitgliedskonto mk1, Mitgliedskonto mk2) - { - try + Ausgabesortierung as = (Ausgabesortierung) control.getAusgabesortierung().getValue(); + switch (as) + { + case NAME: + // Sortiere nach Nachname und Vorname + Arrays.sort(mkn, new Comparator() { - int c = mk1.getMitglied().getName() - .compareTo(mk2.getMitglied().getName()); - if (c != 0) + + @Override + public int compare(Mitgliedskonto mk1, Mitgliedskonto mk2) { - return c; + try + { + int c = mk1.getMitglied().getName() + .compareTo(mk2.getMitglied().getName()); + if (c != 0) + { + return c; + } + c = mk1.getMitglied().getVorname() + .compareTo(mk2.getMitglied().getVorname()); + if (c != 0) + { + return c; + } + return mk1.getMitglied().getID() + .compareTo(mk2.getMitglied().getID()); + } + catch (RemoteException e) + { + throw new RuntimeException(e); + } } - c = mk1.getMitglied().getVorname() - .compareTo(mk2.getMitglied().getVorname()); - if (c != 0) - { - return c; - } - return mk1.getMitglied().getID() - .compareTo(mk2.getMitglied().getID()); - } - catch (RemoteException e) + }); + break; + case PLZ: + // Sortiere nach PLZ und Straße + Arrays.sort(mkn, new Comparator() { - throw new RuntimeException(e); - } - } - }); + + @Override + public int compare(Mitgliedskonto mk1, Mitgliedskonto mk2) + { + try + { + int c = mk1.getMitglied().getPlz() + .compareTo(mk2.getMitglied().getPlz()); + if (c != 0) + { + return c; + } + c = mk1.getMitglied().getStrasse() + .compareTo(mk2.getMitglied().getStrasse()); + if (c != 0) + { + return c; + } + return mk1.getMitglied().getID() + .compareTo(mk2.getMitglied().getID()); + } + catch (RemoteException e) + { + throw new RuntimeException(e); + } + } + }); + break; + } + try { ArrayList r = new ArrayList(); diff --git src/de/jost_net/JVerein/keys/Ausgabesortierung.java src/de/jost_net/JVerein/keys/Ausgabesortierung.java new file mode 100644 index 0000000..1208b32 --- /dev/null +++ src/de/jost_net/JVerein/keys/Ausgabesortierung.java @@ -0,0 +1,75 @@ +/********************************************************************** + * JVerein - Mitgliederverwaltung und einfache Buchhaltung für Vereine + * Copyright (c) by Heiner Jostkleigrewe + * Copyright (c) 2015 by Thomas Hooge + * Main Project: heiner@jverein.dem http://www.jverein.de/ + * Module Author: thomas@hoogi.de, http://www.hoogi.de/ + * + * This file is part of JVerein. + * + * JVerein is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JVerein is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + **********************************************************************/ +package de.jost_net.JVerein.keys; + +/** + * Sortierung einer Ausgabe + * Z.B. Reihenfolge der Seiten in einem Dokument mit mehreren Rechnungen + * + * @author thooge + * + */ +public enum Ausgabesortierung +{ + + NAME(1, "Nach Name und Vorname"), + PLZ(2, "Nach Posteitzahl und Straße"); + + private final String text; + private final int key; + + Ausgabesortierung(int key, String text) + { + this.key = key; + this.text = text; + } + + public int getKey() + { + return key; + } + + public String getText() + { + return text; + } + + public static Ausgabesortierung getByKey(int key) + { + for (Ausgabesortierung sort : Ausgabesortierung.values()) + { + if (sort.getKey() == key) + { + return sort; + } + } + return null; + } + + @Override + public String toString() + { + return getText(); + } +}