View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.cruise;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * %%
7    * Copyright (C) 2012 - 2014 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the 
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public 
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
26  import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
27  import fr.ifremer.tutti.persistence.entities.referential.Gear;
28  import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
29  
30  import java.util.List;
31  
32  /**
33   * @author Kevin Morin - kmorin@codelutin.com
34   * @since 2.1
35   */
36  public class GearCaracteristicsEditorUIModel extends AbstractTuttiTableUIModel<Object, GearCaracteristicsEditorRowModel, GearCaracteristicsEditorUIModel> {
37  
38      public static final String PROPERTY_GEAR = "gear";
39  
40      public static final String PROPERTY_EDITABLE = "editable";
41  
42      public static final String PROPERTY_REMOVE_CARACTERISTIC_ENABLED = "removeCaracteristicEnabled";
43  
44      public static final String PROPERTY_AVAILABLE_CARACTERISTICS = "availableCaracteristics";
45  
46      private static final long serialVersionUID = 1L;
47  
48      protected List<Caracteristic> availableCaracteristics;
49  
50      protected Gear gear;
51  
52      protected boolean editable;
53  
54      protected CaracteristicMap caracteristicMap = new CaracteristicMap();
55  
56      /** Can user remove a selected caracteristic? */
57      protected boolean removeCaracteristicEnabled;
58  
59      public GearCaracteristicsEditorUIModel() {
60          super(Object.class, null, null);
61      }
62  
63      public List<Caracteristic> getAvailableCaracteristics() {
64          return availableCaracteristics;
65      }
66  
67      public void setAvailableCaracteristics(List<Caracteristic> availableCaracteristics) {
68          Object oldValue = getAvailableCaracteristics();
69          this.availableCaracteristics = availableCaracteristics;
70          firePropertyChange(PROPERTY_AVAILABLE_CARACTERISTICS, oldValue, availableCaracteristics);
71      }
72  
73      public Gear getGear() {
74          return gear;
75      }
76  
77      public void setGear(Gear gear) {
78          Object oldValue = getGear();
79          this.gear = gear;
80          firePropertyChange(PROPERTY_GEAR, oldValue, this.gear);
81      }
82  
83      public boolean isRemoveCaracteristicEnabled() {
84          return removeCaracteristicEnabled;
85      }
86  
87      public void setRemoveCaracteristicEnabled(boolean removeCaracteristicEnabled) {
88          Object oldValue = isRemoveCaracteristicEnabled();
89          this.removeCaracteristicEnabled = removeCaracteristicEnabled;
90          firePropertyChange(PROPERTY_REMOVE_CARACTERISTIC_ENABLED, oldValue, removeCaracteristicEnabled);
91      }
92  
93      public CaracteristicMap getCaracteristicMap() {
94          return caracteristicMap;
95      }
96  
97      public boolean isEditable() {
98          return editable;
99      }
100 
101     public void setEditable(boolean editable) {
102         Object oldValue = isEditable();
103         this.editable = editable;
104         firePropertyChange(PROPERTY_EDITABLE, oldValue, editable);
105     }
106 
107     @Override
108     protected Object newEntity() {
109         return null;
110     }
111 }