diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserCRUDController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserCRUDController.java new file mode 100644 index 000000000..1d5f16536 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserCRUDController.java @@ -0,0 +1,31 @@ +/* + * 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.users; + +import org.navalplanner.web.common.entrypoints.EntryPoint; +import org.navalplanner.web.common.entrypoints.EntryPoints; + +@EntryPoints(page = "/users/users.zul", registerAs = "userCRUD") +public interface IUserCRUDController { + + @EntryPoint("list") + public abstract void goToList(); +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserModel.java new file mode 100644 index 000000000..a8c5f17f5 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/IUserModel.java @@ -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 . + */ + +package org.navalplanner.web.users; + +import java.util.List; + +import org.navalplanner.business.users.entities.User; + +/** + * Model for UI operations related to {@link User} + * + * @author Jacobo Aragunde Perez + */ +public interface IUserModel { + + /** + * Get all {@link User} elements + * + * @return + */ + List getUsers(); + +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserCRUDController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserCRUDController.java new file mode 100644 index 000000000..ef94ec39f --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserCRUDController.java @@ -0,0 +1,78 @@ +/* + * 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.users; + +import java.util.List; + +import org.navalplanner.business.users.entities.User; +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 User} + * + * @author Jacobo Aragunde Perez + */ +@SuppressWarnings("serial") +public class UserCRUDController extends GenericForwardComposer implements + IUserCRUDController { + + private Window createWindow; + + private Window listWindow; + + private IUserModel userModel; + + 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 goToList() { + getVisibility().showOnly(listWindow); + Util.reloadBindings(listWindow); + } + + public List getUsers() { + return userModel.getUsers(); + } + + private OnlyOneVisible getVisibility() { + return (visibility == null) ? new OnlyOneVisible(createWindow, + listWindow) + : visibility; + } +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserModel.java new file mode 100644 index 000000000..8d562aec8 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/users/UserModel.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.users; + +import java.util.List; + +import org.navalplanner.business.users.daos.IUserDAO; +import org.navalplanner.business.users.entities.User; +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 User} + * + * @author Jacobo Aragunde Perez + */ +@Service +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class UserModel implements IUserModel { + + @Autowired + private IUserDAO userDAO; + + @Override + public List getUsers() { + return userDAO.list(User.class); + } + +} diff --git a/navalplanner-webapp/src/main/webapp/users/_listUsers.zul b/navalplanner-webapp/src/main/webapp/users/_listUsers.zul new file mode 100644 index 000000000..507c587e6 --- /dev/null +++ b/navalplanner-webapp/src/main/webapp/users/_listUsers.zul @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + diff --git a/navalplanner-webapp/src/main/webapp/users/users.zul b/navalplanner-webapp/src/main/webapp/users/users.zul new file mode 100644 index 000000000..a914ada67 --- /dev/null +++ b/navalplanner-webapp/src/main/webapp/users/users.zul @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + +