View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.operation.catches.accidental;
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.ui.swing.content.operation.catches.AbstractTuttiBatchUIModel;
26  import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
27  import org.nuiton.jaxx.application.swing.tab.TabContentModel;
28  import org.apache.commons.collections4.CollectionUtils;
29  
30  import static org.nuiton.i18n.I18n.n;
31  
32  /**
33   * @author Tony Chemit - chemit@codelutin.com
34   * @since 0.2
35   */
36  public class AccidentalBatchUIModel extends AbstractTuttiBatchUIModel<AccidentalBatchRowModel, AccidentalBatchUIModel>
37          implements TabContentModel {
38  
39      private static final long serialVersionUID = 1L;
40  
41      public static final String PROPERTY_REMOVE_BATCH_ENABLED = "removeBatchEnabled";
42  
43      /** Can user remove a selected batch? */
44      protected boolean removeBatchEnabled;
45  
46      public AccidentalBatchUIModel(EditCatchesUIModel catchesUIModel) {
47          super(catchesUIModel);
48      }
49  
50      public boolean isRemoveBatchEnabled() {
51          return removeBatchEnabled;
52      }
53  
54      public void setRemoveBatchEnabled(boolean removeBatchEnabled) {
55          this.removeBatchEnabled = removeBatchEnabled;
56          firePropertyChange(PROPERTY_REMOVE_BATCH_ENABLED, null, removeBatchEnabled);
57      }
58  
59      //------------------------------------------------------------------------//
60      //-- TabContentModel                                                    --//
61      //------------------------------------------------------------------------//
62  
63      @Override
64      public boolean isEmpty() {
65          boolean result = true;
66          if (CollectionUtils.isNotEmpty(getRows())) {
67  
68              // check if every line is not valid
69              for (AccidentalBatchRowModel row : rows) {
70                  if (row.isValid()) {
71  
72                      // found a valid row so not empty
73                      result = false;
74                      break;
75                  }
76              }
77          }
78          return result;
79      }
80  
81      @Override
82      public String getTitle() {
83          return n("tutti.label.tab.accidental");
84      }
85  
86      @Override
87      public String getIcon() {
88          return null;
89      }
90  
91      @Override
92      public boolean isCloseable() {
93          return false;
94      }
95  
96  }