View Javadoc
1   package fr.ifremer.dali.ui.swing.content.home.map;
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 com.google.common.collect.ImmutableList;
27  import fr.ifremer.dali.dto.data.survey.SurveyDTO;
28  import fr.ifremer.dali.map.MapMode;
29  import fr.ifremer.dali.ui.swing.util.map.MapParentUIModel;
30  import fr.ifremer.dali.ui.swing.util.map.MapUIModel;
31  import fr.ifremer.dali.ui.swing.util.table.AbstractDaliTableUIModel;
32  import fr.ifremer.quadrige3.ui.swing.model.AbstractEmptyUIModel;
33  
34  import java.util.Collection;
35  
36  /**
37   * UI Model for surveys map
38   */
39  public class SurveysMapUIModel extends AbstractEmptyUIModel<SurveysMapUIModel> implements MapUIModel {
40  
41      private MapMode mapMode;
42  
43      private MapParentUIModel parentUIModel;
44  
45      private AbstractDaliTableUIModel<SurveyDTO, ? extends SurveyDTO, ?> selectionModel;
46  
47      private Collection<? extends SurveyDTO> selectedSurveys;
48  
49      private boolean buildMapOnSelectionChanged = true;
50  
51      /**
52       * Constructor.
53       */
54      public SurveysMapUIModel() {
55          super();
56      }
57  
58      @Override
59      public MapParentUIModel getParentUIModel() {
60          return parentUIModel;
61      }
62  
63      public void setParentUIModel(MapParentUIModel parentModel) {
64          this.parentUIModel = parentModel;
65      }
66  
67      public AbstractDaliTableUIModel<SurveyDTO, ? extends SurveyDTO, ?> getSelectionModel() {
68          return selectionModel;
69      }
70  
71      public void setSelectionModel(AbstractDaliTableUIModel<SurveyDTO, ? extends SurveyDTO, ?> selectionModel) {
72          this.selectionModel = selectionModel;
73      }
74  
75      public Collection<? extends SurveyDTO> getSelectedSurveys() {
76          if (selectionModel != null) return selectionModel.getSelectedRows();
77          return selectedSurveys;
78      }
79  
80      public void setSelectedSurvey(SurveyDTO selectedSurvey) {
81          this.selectedSurveys = ImmutableList.of(selectedSurvey);
82      }
83  
84      public MapMode getMapMode() {
85          return mapMode;
86      }
87  
88      public void setMapMode(MapMode mapMode) {
89          this.mapMode = mapMode;
90      }
91  
92      public boolean isBuildMapOnSelectionChanged() {
93          return buildMapOnSelectionChanged;
94      }
95  
96      public void setBuildMapOnSelectionChanged(boolean buildMapOnSelectionChanged) {
97          this.buildMapOnSelectionChanged = buildMapOnSelectionChanged;
98      }
99  }