View Javadoc
1   package fr.ifremer.dali.ui.swing.content.observation.operation.measurement;
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.swing.model.AbstractEmptyUIModel;
27  import fr.ifremer.dali.dto.data.sampling.SamplingOperationDTO;
28  import fr.ifremer.dali.ui.swing.content.observation.ObservationUIModel;
29  import fr.ifremer.dali.ui.swing.content.observation.operation.measurement.grouped.OperationMeasurementsGroupedTableUIModel;
30  import fr.ifremer.dali.ui.swing.content.observation.operation.measurement.ungrouped.OperationMeasurementsUngroupedTableUIModel;
31  import org.nuiton.jaxx.application.swing.tab.TabContentModel;
32  
33  import java.util.List;
34  
35  import static org.nuiton.i18n.I18n.n;
36  
37  /**
38   * Modele pour l onglet prelevement mesures.
39   */
40  public class OperationMeasurementsTabUIModel extends AbstractEmptyUIModel<OperationMeasurementsTabUIModel> implements TabContentModel {
41  
42      /** Constant <code>PROPERTY_OBSERVATION_MODEL="observationModel"</code> */
43      public static final String PROPERTY_OBSERVATION_MODEL = "observationModel";
44      /** Constant <code>PROPERTY_SAMPLING="sampling"</code> */
45      public static final String PROPERTY_SAMPLING = "sampling";
46  //    public static final String PROPERTY_TAXON_GROUP = "taxonGroup";
47  //    public static final String PROPERTY_TAXON = "taxon";
48      private ObservationUIModel observationModel;
49      private SamplingOperationDTO sampling;
50  //    private TaxonGroupDTO taxonGroup;
51  //    private TaxonDTO taxon;
52      private boolean adjusting;
53  
54      private OperationMeasurementsUngroupedTableUIModel ungroupedTableUIModel;
55  
56      private OperationMeasurementsGroupedTableUIModel groupedTableUIModel;
57  
58      /** {@inheritDoc} */
59      @Override
60      public void setModify(boolean modify) {
61  
62          if (!modify) {
63              ungroupedTableUIModel.setModify(false);
64              groupedTableUIModel.setModify(false);
65          }
66  
67          super.setModify(modify);
68      }
69  
70      /**
71       * <p>Getter for the field <code>observationModel</code>.</p>
72       *
73       * @return a {@link fr.ifremer.dali.ui.swing.content.observation.ObservationUIModel} object.
74       */
75      public ObservationUIModel getObservationModel() {
76          return observationModel;
77      }
78  
79      /**
80       * <p>Setter for the field <code>observationModel</code>.</p>
81       *
82       * @param observationModel a {@link fr.ifremer.dali.ui.swing.content.observation.ObservationUIModel} object.
83       */
84      public void setObservationModel(ObservationUIModel observationModel) {
85          this.observationModel = observationModel;
86          firePropertyChange(PROPERTY_OBSERVATION_MODEL, null, observationModel);
87      }
88  
89      /**
90       * <p>Getter for the field <code>sampling</code>.</p>
91       *
92       * @return a {@link fr.ifremer.dali.dto.data.sampling.SamplingOperationDTO} object.
93       */
94      public SamplingOperationDTO getSampling() {
95          return sampling;
96      }
97  
98      /**
99       * <p>Setter for the field <code>sampling</code>.</p>
100      *
101      * @param sampling a {@link fr.ifremer.dali.dto.data.sampling.SamplingOperationDTO} object.
102      */
103     public void setSampling(SamplingOperationDTO sampling) {
104         SamplingOperationDTO oldValue = getSampling();
105         this.sampling = sampling;
106         firePropertyChange(PROPERTY_SAMPLING, oldValue, sampling);
107     }
108 
109     /**
110      * <p>getSamplingOperations.</p>
111      *
112      * @return a {@link java.util.List} object.
113      */
114     public List<SamplingOperationDTO> getSamplings() {
115         return observationModel == null ? null : (List<SamplingOperationDTO>) observationModel.getSamplingOperations();
116     }
117 
118 //    /**
119 //     * <p>Getter for the field <code>taxonGroup</code>.</p>
120 //     *
121 //     * @return a {@link fr.ifremer.dali.dto.referential.TaxonGroupDTO} object.
122 //     */
123 //    public TaxonGroupDTO getTaxonGroup() {
124 //        return taxonGroup;
125 //    }
126 //
127 //    /**
128 //     * <p>Setter for the field <code>taxonGroup</code>.</p>
129 //     *
130 //     * @param taxonGroup a {@link fr.ifremer.dali.dto.referential.TaxonGroupDTO} object.
131 //     */
132 //    public void setTaxonGroup(TaxonGroupDTO taxonGroup) {
133 //        TaxonGroupDTO oldValue = getTaxonGroup();
134 //        this.taxonGroup = taxonGroup;
135 //        firePropertyChange(PROPERTY_TAXON_GROUP, oldValue, taxonGroup);
136 //    }
137 //
138 //    /**
139 //     * <p>Getter for the field <code>taxon</code>.</p>
140 //     *
141 //     * @return a {@link fr.ifremer.dali.dto.referential.TaxonDTO} object.
142 //     */
143 //    public TaxonDTO getTaxon() {
144 //        return taxon;
145 //    }
146 //
147 //    /**
148 //     * <p>Setter for the field <code>taxon</code>.</p>
149 //     *
150 //     * @param taxon a {@link fr.ifremer.dali.dto.referential.TaxonDTO} object.
151 //     */
152 //    public void setTaxon(TaxonDTO taxon) {
153 //        TaxonDTO oldValue = getTaxon();
154 //        this.taxon = taxon;
155 //        firePropertyChange(PROPERTY_TAXON, oldValue, taxon);
156 //    }
157 
158     /**
159      * <p>isAdjusting.</p>
160      *
161      * @return a boolean.
162      */
163     public boolean isAdjusting() {
164         return adjusting;
165     }
166 
167     /**
168      * <p>Setter for the field <code>adjusting</code>.</p>
169      *
170      * @param adjusting a boolean.
171      */
172     public void setAdjusting(boolean adjusting) {
173         this.adjusting = adjusting;
174     }
175 
176     /**
177      * <p>Getter for the field <code>ungroupedTableUIModel</code>.</p>
178      *
179      * @return a {@link fr.ifremer.dali.ui.swing.content.observation.operation.measurement.ungrouped.OperationMeasurementsUngroupedTableUIModel} object.
180      */
181     public OperationMeasurementsUngroupedTableUIModel getUngroupedTableUIModel() {
182         return ungroupedTableUIModel;
183     }
184 
185     /**
186      * <p>Setter for the field <code>ungroupedTableUIModel</code>.</p>
187      *
188      * @param ungroupedTableUIModel a {@link fr.ifremer.dali.ui.swing.content.observation.operation.measurement.ungrouped.OperationMeasurementsUngroupedTableUIModel} object.
189      */
190     public void setUngroupedTableUIModel(OperationMeasurementsUngroupedTableUIModel ungroupedTableUIModel) {
191         this.ungroupedTableUIModel = ungroupedTableUIModel;
192     }
193 
194     /**
195      * <p>Getter for the field <code>groupedTableUIModel</code>.</p>
196      *
197      * @return a {@link fr.ifremer.dali.ui.swing.content.observation.operation.measurement.grouped.OperationMeasurementsGroupedTableUIModel} object.
198      */
199     public OperationMeasurementsGroupedTableUIModel getGroupedTableUIModel() {
200         return groupedTableUIModel;
201     }
202 
203     /**
204      * <p>Setter for the field <code>groupedTableUIModel</code>.</p>
205      *
206      * @param groupedTableUIModel a {@link fr.ifremer.dali.ui.swing.content.observation.operation.measurement.grouped.OperationMeasurementsGroupedTableUIModel} object.
207      */
208     public void setGroupedTableUIModel(OperationMeasurementsGroupedTableUIModel groupedTableUIModel) {
209         this.groupedTableUIModel = groupedTableUIModel;
210         if (groupedTableUIModel != null) {
211             groupedTableUIModel.setParentModel(this);
212         }
213     }
214 
215     /** {@inheritDoc} */
216     @Override
217     public boolean isEmpty() {
218         return false;
219 //        return (ungroupedTableUIModel == null || ungroupedTableUIModel.getRowCount() == 0)
220 //                && (groupedTableUIModel == null || groupedTableUIModel.getRowCount() == 0);
221     }
222 
223     /** {@inheritDoc} */
224     @Override
225     public String getTitle() {
226         return n("dali.samplingOperation.measurements.title");
227     }
228 
229     /** {@inheritDoc} */
230     @Override
231     public String getIcon() {
232         return null;
233     }
234 
235     /** {@inheritDoc} */
236     @Override
237     public boolean isCloseable() {
238         return false;
239     }
240 
241 }