Package com.nexirius.theteam.datamodel

Source Code of com.nexirius.theteam.datamodel.AddressListModel

package com.nexirius.theteam.datamodel;

import com.nexirius.framework.application.DialogManager;
import com.nexirius.framework.datamodel.DataModel;
import com.nexirius.framework.datamodel.DataModelEnumeration;
import com.nexirius.framework.datamodel.DefaultDataModelCommand;


public class AddressListModel extends EditListModel {
    public static final String FIELD_ADDRESS_LIST = "AddressList";

    AddressListModel() {
        super(FIELD_ADDRESS_LIST, new AddressArrayModel());
        appendMethod(new DefaultDataModelCommand("setMainAddress"));
    }

    public String getMemberId() {
        return ((MemberModel) getParentDataModel()).getInstanceName();
    }

    public DataModel addItem() {
        AddressModel address = new AddressModel();

        if (DialogManager.getPopupEditorAdaptor().popupEdit(address)) {

            return address;
        }

        return null;
    }

    public boolean editItem(DataModel model) {
        AddressModel a = (AddressModel) model;

        if (DialogManager.getPopupEditorAdaptor().popupEdit(a)) {
            return true;
        }

        return false;
    }

    public void setMainAddress() {
        DataModel highlighted = getHighlightedItem();

        if (highlighted != null) {
            DataModelEnumeration en = getList().getEnumeration();

            while (en.hasMore()) {
                AddressModel address = (AddressModel) en.next();

                address.setMainAddress(address == highlighted);
            }
        } else {
            DialogManager.error("NothingHighlighted");
        }
    }
}

TOP

Related Classes of com.nexirius.theteam.datamodel.AddressListModel

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.