ItEr35S15CUAdministracionCategoriaCosteItEr34S15: listing of CostCategories

Implemented the basics of the XXModel, XXController and .zul files to be able
to list the existing CostCategories.
This commit is contained in:
Jacobo Aragunde Pérez 2009-12-02 20:58:28 +01:00 committed by Javier Moran Rua
parent 407b777317
commit 4d4c565ba7
7 changed files with 324 additions and 0 deletions

View file

@ -0,0 +1,88 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.costcategories;
import java.util.List;
import org.navalplanner.business.costcategories.entities.CostCategory;
import org.navalplanner.web.common.IMessagesForUser;
import org.navalplanner.web.common.MessagesForUser;
import org.navalplanner.web.common.OnlyOneVisible;
import org.navalplanner.web.common.Util;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.api.Window;
/**
* Controller for CRUD actions over a {@link CostCategory}
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*/
@SuppressWarnings("serial")
public class CostCategoryCRUDController extends GenericForwardComposer
implements ICostCategoryCRUDController {
private Window listWindow;
private Window createWindow;
private ICostCategoryModel costCategoryModel;
private OnlyOneVisible visibility;
private IMessagesForUser messagesForUser;
private Component messagesContainer;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
comp.setVariable("controller", this, true);
messagesForUser = new MessagesForUser(messagesContainer);
getVisibility().showOnly(listWindow);
}
@Override
public void goToCreateForm() {
//TODO
}
@Override
public void goToEditForm(CostCategory costCategory) {
//TODO
}
@Override
public void goToList() {
getVisibility().showOnly(listWindow);
Util.reloadBindings(listWindow);
}
public List<CostCategory> getCostCategories() {
return costCategoryModel.getCostCategories();
}
private OnlyOneVisible getVisibility() {
return (visibility == null) ? new OnlyOneVisible(createWindow,
listWindow)
: visibility;
}
}

View file

@ -0,0 +1,48 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.costcategories;
import java.util.List;
import org.navalplanner.business.costcategories.daos.ICostCategoryDAO;
import org.navalplanner.business.costcategories.entities.CostCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
/**
* Model for UI operations related to {@link CostCategory}
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*/
@Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class CostCategoryModel implements ICostCategoryModel {
@Autowired
private ICostCategoryDAO costCategoryDAO;
@Override
public List<CostCategory> getCostCategories() {
return costCategoryDAO.list(CostCategory.class);
}
}

View file

@ -0,0 +1,39 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.costcategories;
import org.navalplanner.business.costcategories.entities.CostCategory;
import org.navalplanner.web.common.entrypoints.EntryPoint;
import org.navalplanner.web.common.entrypoints.EntryPoints;
@EntryPoints(page = "/costcategories/costCategory.zul", registerAs = "costCategoryCRUD")
public interface ICostCategoryCRUDController {
@EntryPoint("edit")
public abstract void goToEditForm(CostCategory costCategory);
@EntryPoint("create")
public abstract void goToCreateForm();
@EntryPoint("list")
public abstract void goToList();
}

View file

@ -0,0 +1,41 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.costcategories;
import java.util.List;
import org.navalplanner.business.costcategories.entities.CostCategory;
/**
* Model for UI operations related to {@link CostCategory}
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
*/
public interface ICostCategoryModel {
/**
* Get all {@link CostCategory} elements
*
* @return
*/
List<CostCategory> getCostCategories();
}

View file

@ -0,0 +1,25 @@
<!--
This file is part of ###PROJECT_NAME###
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
Desenvolvemento Tecnolóxico de Galicia
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<?taglib uri="/WEB-INF/tld/i18n.tld" prefix="i18n" ?>
<window id="${arg.top_id}" title="${i18n:_('Edit cost category')}">
</window>

View file

@ -0,0 +1,45 @@
<!--
This file is part of ###PROJECT_NAME###
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
Desenvolvemento Tecnolóxico de Galicia
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<window id="${arg.top_id}" title="${i18n:_('Cost categories listing')}">
<newdatasortablegrid id="listing" model="@{controller.costCategories}" mold="paging"
pageSize="10">
<columns sizable="true">
<newdatasortablecolumn label="${i18n:_('Category name')}" sort="auto(name)" />
<newdatasortablecolumn label="${i18n:_('Actions')}" />
</columns>
<rows>
<row self="@{each='costCategory'}" value="@{costCategories}">
<label value="@{costCategory.name}" />
<hbox>
<button sclass="icono" image="/common/img/ico_editar1.png"
hoverImage="/common/img/ico_editar.png"
tooltiptext="${i18n:_('Edit')}"
onClick="controller.goToEditForm(self.parent.parent.value);">
</button>
</hbox>
</row>
</rows>
</newdatasortablegrid>
<button id="show_create_form" onClick="controller.goToCreateForm();"
label="${i18n:_('Create')}">
</button>
</window>

View file

@ -0,0 +1,38 @@
<!--
This file is part of ###PROJECT_NAME###
Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
Desenvolvemento Tecnolóxico de Galicia
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?page id="work_report_admin"?>
<?init class="org.zkoss.zk.ui.util.Composition" arg0="/common/layout/template.zul"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_v01.css"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_zk.css"?>
<?link rel="stylesheet" type="text/css" href="/resources/css/resources.css"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?component name="list" inline="true" macroURI="_listCostCategories.zul"?>
<?component name="edition" inline="true" macroURI="_editCostCategory.zul"?>
<zk>
<window self="@{define(content)}"
apply="org.navalplanner.web.costcategories.CostCategoryCRUDController">
<vbox id="messagesContainer"></vbox>
<list top_id="listWindow" />
<edition top_id="createWindow" />
</window>
</zk>