View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.program;
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.data.Program;
26  import fr.ifremer.tutti.persistence.entities.data.Programs;
27  import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
28  import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
29  import org.nuiton.util.beans.Binder;
30  import org.nuiton.util.beans.BinderFactory;
31  
32  /**
33   * Bean to edit a program.
34   *
35   * @author Tony Chemit - chemit@codelutin.com
36   * @since 0.1
37   */
38  public class EditProgramUIModel extends AbstractTuttiBeanUIModel<Program, EditProgramUIModel> implements Program {
39  
40      private static final long serialVersionUID = 1L;
41  
42      /**
43       * Delegate edit object.
44       *
45       * @since 1.3
46       */
47      protected final Program editObject = Programs.newProgram();
48  
49      protected static Binder<EditProgramUIModel, Program> toBeanBinder =
50              BinderFactory.newBinder(EditProgramUIModel.class,
51                                      Program.class);
52  
53      protected static Binder<Program, EditProgramUIModel> fromBeanBinder =
54              BinderFactory.newBinder(Program.class, EditProgramUIModel.class);
55  
56  
57      public EditProgramUIModel() {
58          super(fromBeanBinder, toBeanBinder);
59      }
60  
61      @Override
62      protected Program newEntity() {
63          return Programs.newProgram();
64      }
65  
66      //------------------------------------------------------------------------//
67      //-- Program methods                                                    --//
68      //------------------------------------------------------------------------//
69  
70      @Override
71      public String getName() {
72          return editObject.getName();
73      }
74  
75      @Override
76      public void setName(String name) {
77          Object oldValue = getName();
78          editObject.setName(name);
79          firePropertyChange(PROPERTY_NAME, oldValue, name);
80      }
81  
82      @Override
83      public String getDescription() {
84          return editObject.getDescription();
85      }
86  
87      @Override
88      public void setDescription(String description) {
89          Object oldValue = getDescription();
90          editObject.setDescription(description);
91          firePropertyChange(PROPERTY_DESCRIPTION, oldValue, description);
92      }
93  
94      @Override
95      public TuttiLocation getZone() {
96          return editObject.getZone();
97      }
98  
99      @Override
100     public void setZone(TuttiLocation zone) {
101         Object oldValue = getZone();
102         editObject.setZone(zone);
103         firePropertyChange(PROPERTY_ZONE, oldValue, zone);
104     }
105 }