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

Sollbuchungen Menu Update #255

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public void handleAction(Object context) throws ApplicationException
"Fehler beim Editieren einer Sollbuchung");
}
}
else if (context != null && (context instanceof Mitgliedskonto))
{
mk = (Mitgliedskonto) context;
}
else
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class MitgliedskontoSollbuchungLoeschenAction implements Action
@Override
public void handleAction(Object context) throws ApplicationException
{
if (context == null || !(context instanceof MitgliedskontoNode))
if (context == null || !((context instanceof MitgliedskontoNode)
|| context instanceof Mitgliedskonto))
{
throw new ApplicationException("Keine Sollbuchung ausgew�hlt");
}
Expand All @@ -60,25 +61,28 @@ public void handleAction(Object context) throws ApplicationException
}
MitgliedskontoNode mkn = null;
Mitgliedskonto mk = null;

if (context != null && (context instanceof MitgliedskontoNode))
try
{
mkn = (MitgliedskontoNode) context;
try
if (context instanceof MitgliedskontoNode)
{
mkn = (MitgliedskontoNode) context;
mk = (Mitgliedskonto) Einstellungen.getDBService().createObject(
Mitgliedskonto.class, mkn.getID());
Mitglied mitglied = mk.getMitglied();
mk.delete();
GUI.getStatusBar().setSuccessText("Sollbuchung gel�scht.");
Application.getMessagingFactory().sendMessage(
new MitgliedskontoMessage(mitglied));
}
catch (RemoteException e)
else
{
throw new ApplicationException(
"Fehler beim L�schen einer Sollbuchung");
mk = (Mitgliedskonto) context;
}
Mitglied mitglied = mk.getMitglied();
mk.delete();
GUI.getStatusBar().setSuccessText("Sollbuchung gel�scht.");
Application.getMessagingFactory().sendMessage(
new MitgliedskontoMessage(mitglied));
}
catch (RemoteException e)
{
throw new ApplicationException(
"Fehler beim L�schen einer Sollbuchung");
}
}
}
58 changes: 56 additions & 2 deletions src/de/jost_net/JVerein/gui/menu/Mitgliedskonto2Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@

package de.jost_net.JVerein.gui.menu;

import java.rmi.RemoteException;

import de.jost_net.JVerein.Einstellungen;
import de.jost_net.JVerein.gui.action.MitgliedDetailAction;
import de.jost_net.JVerein.gui.action.MitgliedskontoMahnungAction;
import de.jost_net.JVerein.gui.action.MitgliedskontoRechnungAction;
import de.jost_net.JVerein.gui.action.MitgliedskontoSollbuchungEditAction;
import de.jost_net.JVerein.gui.action.MitgliedskontoSollbuchungLoeschenAction;
import de.jost_net.JVerein.rmi.Buchung;
import de.jost_net.JVerein.rmi.Mitgliedskonto;
import de.willuhn.datasource.rmi.DBIterator;
import de.willuhn.jameica.gui.Action;
import de.willuhn.jameica.gui.parts.CheckedContextMenuItem;
import de.willuhn.jameica.gui.parts.CheckedSingleContextMenuItem;
import de.willuhn.jameica.gui.parts.ContextMenu;
import de.willuhn.jameica.gui.parts.ContextMenuItem;
import de.willuhn.logging.Logger;

/**
* Kontext-Menu zu den Mitgliedskonten.
Expand All @@ -33,9 +46,50 @@ public class Mitgliedskonto2Menu extends ContextMenu
*/
public Mitgliedskonto2Menu()
{
addItem(new CheckedContextMenuItem("Rechnung...",
addItem(new CheckedSingleContextMenuItem("Sollbuchung bearbeiten",
new MitgliedskontoSollbuchungEditAction(), "text-x-generic.png"));
addItem(new SollOhneIstItem("Sollbuchung l�schen",
new MitgliedskontoSollbuchungLoeschenAction(), "user-trash-full.png"));
addItem(ContextMenuItem.SEPARATOR);
addItem(new CheckedSingleContextMenuItem("Mitglied anzeigen",
new MitgliedDetailAction(), "text-x-generic.png"));
addItem(new CheckedContextMenuItem("Rechnung erstellen",
new MitgliedskontoRechnungAction(), "file-invoice.png"));
addItem(new CheckedContextMenuItem("Mahnung...",
addItem(new CheckedContextMenuItem("Mahnung erstellen",
new MitgliedskontoMahnungAction(), "file-invoice.png"));
}

private static class SollOhneIstItem extends CheckedContextMenuItem
{

private SollOhneIstItem(String text, Action action, String icon)
{
super(text, action, icon);
}

@Override
public boolean isEnabledFor(Object o)
{
if (o instanceof Mitgliedskonto)
{
Mitgliedskonto mk = (Mitgliedskonto) o;
DBIterator<Buchung> it;
try
{
it = Einstellungen.getDBService().createList(Buchung.class);
it.addFilter("mitgliedskonto = ?", new Object[] { mk.getID() });
if (it.size() == 0)
{
return true;
}
}
catch (RemoteException e)
{
Logger.error("Fehler", e);
}
return false;
}
return false;
}
}
}
2 changes: 1 addition & 1 deletion src/de/jost_net/JVerein/gui/menu/MitgliedskontoMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public MitgliedskontoMenu()
addItem(new SollItem("Sollbuchung bearbeiten",
new MitgliedskontoSollbuchungEditAction(), "text-x-generic.png"));
addItem(new SollOhneIstItem("Sollbuchung l�schen",
new MitgliedskontoSollbuchungLoeschenAction(), "list-remove.png"));
new MitgliedskontoSollbuchungLoeschenAction(), "user-trash-full.png"));
addItem(new SollMitIstItem("Istbuchung von Sollbuchung l�sen",
new MitgliedskontoIstbuchungLoesenAction(), "unlocked.png"));
addItem(ContextMenuItem.SEPARATOR);
Expand Down