001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.apps.modules; 029 030import org.opencms.module.CmsModule; 031import org.opencms.ui.apps.Messages; 032import org.opencms.ui.components.OpenCmsTheme; 033import org.opencms.ui.util.table.Column; 034 035import com.google.common.base.Strings; 036import com.vaadin.server.Resource; 037 038/** 039 * Represents a row of the modules overview table.<p> 040 * 041 * The equals() and hashCode() methods are overridden to only compare/hash the module name. 042 */ 043public class CmsModuleRow { 044 045 /** The module which this row represents. */ 046 private CmsModule m_module; 047 048 /** 049 * Creates a new instance.<p> 050 * 051 * @param module the module for which this is a row 052 */ 053 public CmsModuleRow(CmsModule module) { 054 055 m_module = module; 056 } 057 058 /** 059 * @see java.lang.Object#equals(java.lang.Object) 060 */ 061 @Override 062 public boolean equals(Object other) { 063 064 return (other instanceof CmsModuleRow) && ((CmsModuleRow)other).getName().equals(getName()); 065 } 066 067 /** 068 * Gets the module group.<p> 069 * 070 * @return the module group 071 */ 072 @Column(header = Messages.GUI_MODULES_HEADER_GROUP_0, order = 40, width = 200) 073 public String getGroup() { 074 075 return Strings.nullToEmpty(m_module.getGroup()); 076 } 077 078 /** 079 * Gets the icon to display.<p> 080 * 081 * @return the icon to display 082 */ 083 public Resource getIcon() { 084 085 return CmsModuleApp.Icons.LIST_ICON; 086 } 087 088 /** 089 * Gets the module.<p> 090 * 091 * @return the module 092 */ 093 public CmsModule getModule() { 094 095 return m_module; 096 } 097 098 /** 099 * Gets the name of the module.<p> 100 * 101 * @return the module name 102 */ 103 @Column(header = Messages.GUI_MODULES_HEADER_NAME_0, styleName = OpenCmsTheme.HOVER_COLUMN, width = 350, order = 10) 104 public String getName() { 105 106 return m_module.getName(); 107 } 108 109 /** 110 * Gets the nice name of the module.<p> 111 * 112 * @return the nice name of the module 113 */ 114 @Column(header = Messages.GUI_MODULES_HEADER_TITLE_0, expandRatio = 1.0f, order = 20) 115 public String getTitle() { 116 117 return Strings.nullToEmpty(m_module.getNiceName()); 118 } 119 120 /** 121 * Gets the number of resource types defined.<p> 122 * 123 * @return the number of resource types 124 */ 125 @Column(header = Messages.GUI_MODULES_HEADER_TYPES_0, order = 50) 126 public int getTypes() { 127 128 return m_module.getResourceTypes().size(); 129 } 130 131 /** 132 * Gets the version.<p> 133 * 134 * @return the module version 135 */ 136 @Column(header = Messages.GUI_MODULES_HEADER_VERSION_0, width = 80, order = 30) 137 public String getVersion() { 138 139 return m_module.getVersion().toString(); 140 } 141 142 /** 143 * @see java.lang.Object#hashCode() 144 */ 145 @Override 146 public int hashCode() { 147 148 return getName().hashCode(); 149 } 150 151}