package com.nexirius.ulc.example1.datamodel;
import com.nexirius.framework.datamodel.StructModel;
import com.nexirius.framework.datamodel.DefaultDataModelCommand;
import com.nexirius.framework.datamodel.DataModel;
import com.nexirius.ulc.example1.persistence.PersistenceManager;
public class ItemListModel extends StructModel {
private ItemArrayModel itemArray;
public static final String NEW_ITEM_COMMAND = "newItemCommand";
public static final String DELETE_ITEM_COMMAND = "deleteItemCommand";
public static final String EDIT_ITEM_COMMAND = "editItemCommand";
public static final String RELOAD_COMMAND = "reloadCommand";
private ItemModel highlighted;
public ItemListModel() {
super("ItemList");
init();
}
private void init() {
itemArray = new ItemArrayModel();
append(itemArray);
highlighted = new ItemModel();
append(highlighted);
appendMethod(new DefaultDataModelCommand(NEW_ITEM_COMMAND));
appendMethod(new DefaultDataModelCommand(DELETE_ITEM_COMMAND));
appendMethod(new DefaultDataModelCommand(EDIT_ITEM_COMMAND));
appendMethod(new DefaultDataModelCommand(RELOAD_COMMAND));
}
public void newItemCommand() {
// throws ModelEvent and is managed by the associated controller
}
public void deleteItemCommand() {
// throws ModelEvent and is managed by the associated controller
}
public void editItemCommand() {
// throws ModelEvent and is managed by the associated controller
}
public ItemArrayModel getArray() {
return itemArray;
}
public DataModel getSelected() {
return highlighted;
}
public void reloadCommand() throws Exception {
getArray().clear();
PersistenceManager.load(getArray());
}
}