1 package fr.ifremer.quadrige3.ui.swing.table; 2 3 /*- 4 * #%L 5 * Quadrige3 Core :: Quadrige3 UI Common 6 * $Id:$ 7 * $HeadURL:$ 8 * %% 9 * Copyright (C) 2017 Ifremer 10 * %% 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Affero General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU Affero General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. 23 * #L% 24 */ 25 26 27 import fr.ifremer.quadrige3.core.dao.technical.Beans; 28 29 /** 30 * override version of ColumnIdentifier with property type 31 * 32 * @param <R> 33 * @author Ludovic Pecquot <ludovic.pecquot@e-is.pro> 34 */ 35 public class ColumnIdentifier<R extends AbstractRowUIModel> extends org.nuiton.jaxx.application.swing.table.ColumnIdentifier<R> { 36 37 private static final long serialVersionUID = 1L; 38 39 private final Class propertyType; 40 private final String decoratorName; 41 private final boolean mandatory; 42 43 /** 44 * <p>Constructor for ColumnIdentifier.</p> 45 * 46 * @param propertyName a {@link java.lang.String} object. 47 * @param headerI18nKey a {@link java.lang.String} object. 48 * @param headerTipI18nKey a {@link java.lang.String} object. 49 * @param propertyType a {@link java.lang.Class} object. 50 * @param decoratorName a {@link java.lang.String} object. 51 * @param mandatory a boolean. 52 */ 53 protected ColumnIdentifier(String propertyName, String headerI18nKey, String headerTipI18nKey, Class propertyType, String decoratorName, boolean mandatory) { 54 super(propertyName, headerI18nKey, headerTipI18nKey); 55 this.propertyType = propertyType; 56 this.decoratorName = decoratorName; 57 this.mandatory = mandatory; 58 } 59 60 /** 61 * <p>Getter for the field <code>propertyType</code>.</p> 62 * 63 * @return a {@link java.lang.Class} object. 64 */ 65 public Class<?> getPropertyType() { 66 return propertyType; 67 } 68 69 /** 70 * <p>Getter for the field <code>decoratorName</code>.</p> 71 * 72 * @return a {@link java.lang.String} object. 73 */ 74 public String getDecoratorName() { 75 return decoratorName; 76 } 77 78 /** 79 * <p>isMandatory.</p> 80 * 81 * @return a boolean. 82 */ 83 public boolean isMandatory() { 84 return mandatory; 85 } 86 87 /** 88 * {@inheritDoc} 89 */ 90 @Override 91 public Object getValue(R entry) { 92 Object result = null; 93 if (getPropertyName() != null && entry != null) { 94 result = Beans.getProperty(entry, getPropertyName()); 95 } 96 return result; 97 } 98 99 /** 100 * {@inheritDoc} 101 */ 102 @Override 103 public void setValue(R entry, Object value) { 104 if (getPropertyName() != null) { 105 Beans.setProperty(entry, getPropertyName(), value); 106 } 107 } 108 }