1 package fr.ifremer.dali.ui.swing.content.manage.filter.element.menu; 2 3 /* 4 * #%L 5 * Dali :: UI 6 * $Id:$ 7 * $HeadURL:$ 8 * %% 9 * Copyright (C) 2014 - 2015 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 import fr.ifremer.quadrige3.ui.core.dto.QuadrigeBean; 27 import fr.ifremer.dali.dto.configuration.filter.FilterDTO; 28 import fr.ifremer.quadrige3.ui.swing.model.AbstractEmptyUIModel; 29 import org.apache.commons.collections4.CollectionUtils; 30 31 import java.util.List; 32 33 /** 34 * Model. 35 */ 36 public class ApplyFilterUIModel extends AbstractEmptyUIModel<ApplyFilterUIModel> { 37 38 /** 39 * Filtered elements. 40 */ 41 private List<? extends QuadrigeBean> elements; 42 /** Constant <code>PROPERTY_ELEMENTS="elements"</code> */ 43 public static final String PROPERTY_ELEMENTS = "elements"; 44 45 private FilterDTO filter; 46 /** Constant <code>PROPERTY_FILTER="filter"</code> */ 47 public static final String PROPERTY_FILTER = "filter"; 48 49 /** 50 * Called by FilterUI validator (FilterUIModel-error-validation.xml) 51 * 52 * @return a boolean. 53 */ 54 public boolean isElementsNotEmpty() { 55 return CollectionUtils.isNotEmpty(elements); 56 } 57 58 /** 59 * <p>Getter for the field <code>elements</code>.</p> 60 * 61 * @return a {@link java.util.List} object. 62 */ 63 public List<? extends QuadrigeBean> getElements() { 64 return elements; 65 } 66 67 /** 68 * <p>Setter for the field <code>elements</code>.</p> 69 * 70 * @param elements a {@link java.util.List} object. 71 */ 72 public void setElements(List<? extends QuadrigeBean> elements) { 73 this.elements = elements; 74 firePropertyChange(PROPERTY_ELEMENTS, null, elements); 75 firePropertyChange(PROPERTY_MODIFY, false, true); 76 } 77 78 /** 79 * <p>Getter for the field <code>filter</code>.</p> 80 * 81 * @return a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object. 82 */ 83 public FilterDTO getFilter() { 84 return filter; 85 } 86 87 /** 88 * <p>Setter for the field <code>filter</code>.</p> 89 * 90 * @param filter a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object. 91 */ 92 public void setFilter(FilterDTO filter) { 93 FilterDTO oldValue = getFilter(); 94 this.filter = filter; 95 firePropertyChange(PROPERTY_FILTER, oldValue, filter); 96 } 97 98 }