Package de.chris_soft.fyllgen.menu.edit

Source Code of de.chris_soft.fyllgen.menu.edit.DeleteConnection

/**
* FyLLGen - A Java based tool for collecting and distributing family data
*
* Copyright (C) 2007-2011 Christian Packenius
*
* This program 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
* any later version.
*
* This program 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 <http://www.gnu.org/licenses/>.
*/
package de.chris_soft.fyllgen.menu.edit;

import java.util.List;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

import de.chris_soft.fyllgen.GUI;
import de.chris_soft.fyllgen.data.Family;
import de.chris_soft.fyllgen.data.Person;
import de.chris_soft.fyllgen.widget.dialog.MultiPersonChoiceShell;

/**
* Befehl zum L�schen der aktuellen Person.
* @author Christian Packenius, Juni 2008.
*/
public class DeleteConnection implements Listener {
  /**
   * Person l�schen lassen (nach Anfrage).
   * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
   */
  public void handleEvent(Event event) {
    Person person = Family.instance.getCurrentPerson();
    String msgText = "Zu welchen der folgenden Personen soll die Verbindung zu <" + person.getValueView(Person.NAME)
        + "> gel�scht werden?";
    MultiPersonChoiceShell mpcs = new MultiPersonChoiceShell(GUI.instance.shell, "Verbindung l�schen", msgText);

    // Alle Zuordnungen der aktuellen Person angeben.
    Person[] conns = person.getPartner();
    for (Person conn : conns) {
      mpcs.add(conn, " (Partner)", false, false);
    }
    conns = person.getParents();
    for (Person conn : conns) {
      mpcs.add(conn, " (Elternteil)", false, false);
    }
    conns = person.getChildren();
    for (Person conn : conns) {
      mpcs.add(conn, " (Kind)", false, false);
    }

    // Dialog �ffnen.
    mpcs.open();

    // Hat der User den Dialog �ber den OK-Button verlassen?
    if (mpcs.bPressedOkay) {
      // Ja, also hier bei allen angeklickten Personen die Zuordnung l�schen.
      List<Person> list = mpcs.getCheckedPersons();
      for (Person p : list) {
        person.removePerson(p);
        p.removePerson(person);
      }
      Family.instance.review();
    }
  }
}
TOP

Related Classes of de.chris_soft.fyllgen.menu.edit.DeleteConnection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.