diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java index 1f7291b2b..4782501e8 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/CustomMenuController.java @@ -170,8 +170,12 @@ public class CustomMenuController extends Div implements IMenuItemsRegister { topItem(_("Planification"), "/planner/index.zul"); topItem(_("Resources"), "/resources/worker/worker.zul", - subItem( - _("Workers List"), "/resources/worker/worker.zul#list")); + subItem(_("Workers List"), + "/resources/worker/worker.zul#list"), + subItem(_("Machines List"), + "/resources/machine/machines.zul#list"), + subItem(_("Manage criterions"), + "/resources/criterions/criterions-V2.zul")); topItem(_("Work reports"), "/workreports/workReportTypes.zul", subItem( _("Work report types"), "/workreports/workReportTypes.zul"), diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/IMachineModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/IMachineModel.java new file mode 100644 index 000000000..887e4a993 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/IMachineModel.java @@ -0,0 +1,34 @@ +/* + * 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 . + */ + +package org.navalplanner.web.resources.machine; + +import java.util.List; + +import org.navalplanner.business.resources.entities.Machine; + +/* + * @author Diego Pino Garcia + */ +public interface IMachineModel { + + List getMachines(); + +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/MachineCRUDController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/MachineCRUDController.java new file mode 100644 index 000000000..d9a49dddb --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/MachineCRUDController.java @@ -0,0 +1,124 @@ +/* + * 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 . + */ + +package org.navalplanner.web.resources.machine; + +import static org.navalplanner.web.I18nHelper._; + +import java.util.List; + +import org.navalplanner.business.resources.entities.Machine; +import org.navalplanner.web.common.IMessagesForUser; +import org.navalplanner.web.common.Level; +import org.navalplanner.web.common.MessagesForUser; +import org.navalplanner.web.common.OnlyOneVisible; +import org.navalplanner.web.common.Util; +import org.navalplanner.web.common.entrypoints.IURLHandlerRegistry; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.util.GenericForwardComposer; +import org.zkoss.zul.api.Window; + +/** + * Controller for {@link Machine} resource
+ + * @author Diego Pino Garcia + */ +public class MachineCRUDController extends GenericForwardComposer { + + private Window listWindow; + + private Window editWindow; + + private IMachineModel machineModel; + + private IURLHandlerRegistry URLHandlerRegistry; + + private OnlyOneVisible visibility; + + private IMessagesForUser messagesForUser; + + private Component messagesContainer; + + public MachineCRUDController() { + + } + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + comp.setVariable("controller", this, true); + messagesForUser = new MessagesForUser(messagesContainer); + showListWindow(); + } + + private void showListWindow() { + getVisibility().showOnly(listWindow); + } + + private OnlyOneVisible getVisibility() { + if (visibility == null) { + visibility = new OnlyOneVisible(listWindow, editWindow); + } + return visibility; + } + + public void goToCreateForm() { + // entity.initCreate(); + editWindow.setTitle(_("Create machine")); + showEditWindow(); + Util.reloadBindings(editWindow); + } + + private void showEditWindow() { + getVisibility().showOnly(editWindow); + } + + public void goToEditForm(Machine machine) { + // model.initEdit(machine); + editWindow.setTitle(_("Edit machine")); + showEditWindow(); + Util.reloadBindings(editWindow); + } + + public void save() { + validate(); + // model.confirmSave(); + goToList(); + messagesForUser.showMessage(Level.INFO, _("Machine saved")); + } + + private void validate() { + // TODO: Validate + } + + private void goToList() { + getVisibility().showOnly(listWindow); + Util.reloadBindings(listWindow); + } + + public void close() { + goToList(); + } + + public List getMachines() { + return machineModel.getMachines(); + } + +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/MachineModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/MachineModel.java new file mode 100644 index 000000000..5a24c0b9d --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/resources/machine/MachineModel.java @@ -0,0 +1,49 @@ +/* + * 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 . + */ + +package org.navalplanner.web.resources.machine; + +import java.util.List; + +import org.navalplanner.business.resources.daos.IMachineDAO; +import org.navalplanner.business.resources.entities.Machine; +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; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author Diego Pino Garcia + */ +@Service +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class MachineModel implements IMachineModel { + + @Autowired + IMachineDAO machineDAO; + + @Override + @Transactional(readOnly = true) + public List getMachines() { + return machineDAO.getAll(); + } + +} diff --git a/navalplanner-webapp/src/main/webapp/resources/machine/_listMachines.zul b/navalplanner-webapp/src/main/webapp/resources/machine/_listMachines.zul new file mode 100644 index 000000000..12522fa1b --- /dev/null +++ b/navalplanner-webapp/src/main/webapp/resources/machine/_listMachines.zul @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + diff --git a/navalplanner-webapp/src/main/webapp/resources/machine/machines.zul b/navalplanner-webapp/src/main/webapp/resources/machine/machines.zul new file mode 100644 index 000000000..511cc2521 --- /dev/null +++ b/navalplanner-webapp/src/main/webapp/resources/machine/machines.zul @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + +