View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.manage.referential.unit.national;
2   
3   /*-
4    * #%L
5    * Reef DB :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2022 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  
27  import fr.ifremer.quadrige3.ui.swing.ApplicationUI;
28  import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
29  import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
30  import fr.ifremer.reefdb.ui.swing.ReefDbHelpBroker;
31  import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
32  import fr.ifremer.reefdb.ui.swing.content.manage.referential.unit.menu.ReferentialUnitsMenuUI;
33  import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
34  import java.awt.BorderLayout;
35  import java.awt.Container;
36  import java.awt.FlowLayout;
37  import java.awt.LayoutManager;
38  import java.util.ArrayList;
39  import java.util.HashMap;
40  import java.util.List;
41  import java.util.Map;
42  import java.util.TreeMap;
43  import javax.swing.Box;
44  import javax.swing.BoxLayout;
45  import javax.swing.JPanel;
46  import javax.swing.JScrollPane;
47  import jaxx.runtime.JAXXBinding;
48  import jaxx.runtime.JAXXContext;
49  import jaxx.runtime.JAXXObject;
50  import jaxx.runtime.JAXXObjectDescriptor;
51  import jaxx.runtime.JAXXUtil;
52  import jaxx.runtime.SwingUtil;
53  import jaxx.runtime.context.DefaultJAXXContext;
54  import org.apache.commons.logging.Log;
55  import org.apache.commons.logging.LogFactory;
56  
57  public class ReferentialUnitsNationalUI extends JPanel implements ReefDbUI<ReferentialUnitsNationalUIModel, ReferentialUnitsNationalUIHandler>, JAXXObject {
58  
59      /*-----------------------------------------------------------------------*/
60      /*------------------------- Other static fields -------------------------*/
61      /*-----------------------------------------------------------------------*/
62  
63      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAALVUTU8UQRCtHd2FBfGLgBghQSExSuzVeFyjKIQA2VXDiiFuYuzZ6V0ae3qanh4ZLsaf4E/QuxcTb56MB88evBj/gjEevBqrZz9mFxY1Mc6hZ6arXr3X1VX16itkQw1nt2gcEx1Jw31GVm9ubNxxt1jNLLKwprkygYbmk3HAqcKw19kPDcxUSxZeaMELC4GvAslkF7pYgqHQ7AoWbjJmDEz1ImphWKh0zMVYRbodtSOqX9QX3785z71nLx2AWKG6ATzK9J9Q6UkOl8DhnoGTyPSEFgSVDZShuWyg3hG7tyBoGN6mPtuGpzBQgpyiGoMZOPf3R05iJPhYGRicXb1LJROXDTysa8LrmvlME81Y3XNJxEm4g/ykFkiD4YhPJW0wNNeZJeZUkEhyQyQ1PJD4t5Za1tGAYpuG9RWlEtacgawfeEwYqP1fwrJlSVlzrg4eM21g7je0a/i/6C4j7lbi3QX3mYzWVwzc/wfVNsY+xeUksKXJd9ja13IFq8FefNwiaO72+o7MrlZqOhDC2vAeT/UAUpN1H+ugpvQBibtHXcEMkK5jbkfU07zBrqYnNdaLVOx3ArBRJxTW+5meesdOImknpaWeqUJWR7htYKK6v/nW0NRsu4k9bWcDJtaf46Of3n55s9TuNQe5x/q6do0K7AGlA4VVwC31sWajRYaLQpmqYhXyIRM4Z5I5MtlHWKVlRnHId8LCiYWTZRpuYojswOd378cffTwEzhIMiYB6S9T6r0DebGrMQiC8WN2YTxQd2RnE9bjVhvUl6G4QYSsfveZRQ6ddLj1M7vUYkzDZJwkdJW7+w4/Ryuv5diIyKOz0ge5pMrIPIMel4JIlY6c1UfqOmWEVssgL0snRb5Zk7HtItTpmJlnP7z+p3b5gl4txZF9ziWT7dSmxjWOEXxRR0qkGBgAA";
64      private static final Log log = LogFactory.getLog(ReferentialUnitsNationalUI.class);
65      private static final long serialVersionUID = 1L;
66  
67      /*-----------------------------------------------------------------------*/
68      /*--------------------------- Internal states ---------------------------*/
69      /*-----------------------------------------------------------------------*/
70  
71      protected List<Object> $activeBindings = new ArrayList<Object>();
72      protected Map<String, Object> $bindingSources = new HashMap<String, Object>();
73      protected final Map<String, JAXXBinding> $bindings = new TreeMap<String, JAXXBinding>();
74      protected Map<String, Object> $objectMap = new HashMap<String, Object>();
75      protected Map<?, ?> $previousValues = new HashMap<Object, Object>();
76      private boolean allComponentsCreated;
77      protected final JAXXContext delegateContext = new DefaultJAXXContext();
78  
79      /*-----------------------------------------------------------------------*/
80      /*------------------------ Protected components  ------------------------*/
81      /*-----------------------------------------------------------------------*/
82  
83      protected ReefDbHelpBroker broker;
84      protected final ReferentialUnitsNationalUIHandler handler = createHandler();
85      protected ReferentialUnitsMenuUI menuUI;
86      protected ReferentialUnitsNationalUIModel model;
87      protected SwingTable referentialUnitsNationalTable;
88  
89      /*-----------------------------------------------------------------------*/
90      /*------------------------- Private components  -------------------------*/
91      /*-----------------------------------------------------------------------*/
92  
93      private ReferentialUnitsNationalUI $JPanel0 = this;
94      private JPanel $JPanel1;
95      private JScrollPane $JScrollPane0;
96  
97      /*-----------------------------------------------------------------------*/
98      /*---------------------------- Constructors  ----------------------------*/
99      /*-----------------------------------------------------------------------*/
100 
101     public ReferentialUnitsNationalUI(ApplicationUI parentUI) {
102         ApplicationUIUtil.setParentUI(this, parentUI);
103             $initialize();
104     }
105 
106     public ReferentialUnitsNationalUI(LayoutManager param0, boolean param1) {
107         super(param0 ,param1);
108         $initialize();
109     }
110 
111     public ReferentialUnitsNationalUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
112         super(param1 ,param2);
113         JAXXUtil.initContext(this, parentContext);
114         $initialize();
115     }
116 
117     public ReferentialUnitsNationalUI(boolean param0) {
118         super(param0);
119         $initialize();
120     }
121 
122     public ReferentialUnitsNationalUI(JAXXContext parentContext, boolean param1) {
123         super(param1);
124         JAXXUtil.initContext(this, parentContext);
125         $initialize();
126     }
127 
128     public ReferentialUnitsNationalUI() {
129         $initialize();
130     }
131 
132     public ReferentialUnitsNationalUI(JAXXContext parentContext) {
133         JAXXUtil.initContext(this, parentContext);
134         $initialize();
135     }
136 
137     public ReferentialUnitsNationalUI(LayoutManager param0) {
138         super(param0);
139         $initialize();
140     }
141 
142     public ReferentialUnitsNationalUI(JAXXContext parentContext, LayoutManager param1) {
143         super(param1);
144         JAXXUtil.initContext(this, parentContext);
145         $initialize();
146     }
147 
148     /*-----------------------------------------------------------------------*/
149     /*--------------------------- Statics methods ---------------------------*/
150     /*-----------------------------------------------------------------------*/
151 
152     public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
153         return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
154     }
155 
156     /*-----------------------------------------------------------------------*/
157     /*---------------------- JAXXObject implementation ----------------------*/
158     /*-----------------------------------------------------------------------*/
159 
160     @Override
161     public void applyDataBinding(String $binding) {
162         if (allComponentsCreated && $bindings.containsKey($binding)) {
163             getDataBinding($binding).applyDataBinding();
164         }
165         processDataBinding($binding);
166     }
167 
168     @Override
169     public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
170         super.firePropertyChange(propertyName, oldValue, newValue);
171     }
172 
173     @Override
174     public Map<String, Object> get$objectMap() {
175         return $objectMap;
176     }
177 
178     @Override
179     public JAXXBinding getDataBinding(String bindingId) {
180         return $bindings.get(bindingId);
181     }
182 
183     @Override
184     public JAXXBinding[] getDataBindings() {
185         return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
186     }
187 
188     @Override
189     public Object getObjectById(String id) {
190         return $objectMap.get(id);
191     }
192 
193     @Override
194     public void processDataBinding(String $binding, boolean $force) {
195         if (!$force && $activeBindings.contains($binding)) { 
196             return;
197         }
198         $activeBindings.add($binding);
199         try {
200             if (allComponentsCreated && $bindings.containsKey($binding)) {
201                 getDataBinding($binding).processDataBinding();
202             }
203         } finally {
204             $activeBindings.remove($binding);
205         }
206     }
207 
208     @Override
209     public void processDataBinding(String $binding) {
210         processDataBinding($binding, false);
211     }
212 
213     @Override
214     public void registerDataBinding(JAXXBinding binding) {
215         $bindings.put(binding.getId(), binding);
216     }
217 
218     @Override
219     public void removeDataBinding(String $binding) {
220         if (allComponentsCreated && $bindings.containsKey($binding)) {
221             getDataBinding($binding).removeDataBinding();
222         }
223     }
224 
225     /*-----------------------------------------------------------------------*/
226     /*--------------------- JAXXContext implementation  ---------------------*/
227     /*-----------------------------------------------------------------------*/
228 
229     @Override
230     public <T> T getContextValue(Class<T> clazz) {
231         return delegateContext.getContextValue(clazz, null);
232     }
233 
234     @Override
235     public <T> T getContextValue(Class<T> clazz, String name) {
236         return delegateContext.getContextValue(clazz, name);
237     }
238 
239     @Override
240     public JAXXContext getDelegateContext() {
241         return delegateContext;
242     }
243 
244     @Override
245     public <O extends Container> O getParentContainer(Class<O> clazz) {
246         return SwingUtil.getParentContainer(this, clazz);
247     }
248 
249     @Override
250     public <O extends Container> O getParentContainer(Object source, Class<O> clazz) {
251         return SwingUtil.getParentContainer(source, clazz);
252     }
253 
254     @Override
255     public <T> void removeContextValue(Class<T> clazz) {
256         delegateContext.removeContextValue(clazz, null);
257     }
258 
259     @Override
260     public <T> void removeContextValue(Class<T> clazz, String name) {
261         delegateContext.removeContextValue(clazz, name);
262     }
263 
264     @Override
265     public <T> void setContextValue(T o) {
266         delegateContext.setContextValue(o, null);
267     }
268 
269     @Override
270     public <T> void setContextValue(T o, String name) {
271         delegateContext.setContextValue(o, name);
272     }
273 
274     /*-----------------------------------------------------------------------*/
275     /*----------------------- Public acessor methods  -----------------------*/
276     /*-----------------------------------------------------------------------*/
277 
278     public ReefDbHelpBroker getBroker() {
279         return broker;
280     }
281 
282     public ReferentialUnitsNationalUIHandler getHandler() {
283         return handler;
284     }
285 
286     public ReferentialUnitsMenuUI getMenuUI() {
287         return menuUI;
288     }
289 
290     public ReferentialUnitsNationalUIModel getModel() {
291         return model;
292     }
293 
294     public SwingTable getReferentialUnitsNationalTable() {
295         return referentialUnitsNationalTable;
296     }
297 
298     /*-----------------------------------------------------------------------*/
299     /*--------------------- Protected acessors methods  ---------------------*/
300     /*-----------------------------------------------------------------------*/
301 
302     protected JPanel get$JPanel1() {
303         return $JPanel1;
304     }
305 
306     protected JScrollPane get$JScrollPane0() {
307         return $JScrollPane0;
308     }
309 
310     /*-----------------------------------------------------------------------*/
311     /*--------------------- Components creation methods ---------------------*/
312     /*-----------------------------------------------------------------------*/
313 
314     protected void createBroker() {
315         $objectMap.put("broker", broker = new ReefDbHelpBroker("reefdb.home.help"));
316     }
317 
318     protected ReferentialUnitsNationalUIHandler createHandler() {
319         return new ReferentialUnitsNationalUIHandler();
320     }
321 
322     protected void createMenuUI() {
323         $objectMap.put("menuUI", menuUI = new ReferentialUnitsMenuUI(this));
324         
325         menuUI.setName("menuUI");
326     }
327 
328     protected void createModel() {
329         $objectMap.put("model", model = getContextValue(ReferentialUnitsNationalUIModel.class));
330     }
331 
332     protected void createReferentialUnitsNationalTable() {
333         $objectMap.put("referentialUnitsNationalTable", referentialUnitsNationalTable = new SwingTable());
334         
335         referentialUnitsNationalTable.setName("referentialUnitsNationalTable");
336     }
337 
338     /*-----------------------------------------------------------------------*/
339     /*------------------------ Internal jaxx methods ------------------------*/
340     /*-----------------------------------------------------------------------*/
341 
342     private void $completeSetup() {
343         allComponentsCreated = true;
344         if (log.isDebugEnabled()) {
345             log.debug(this);
346         }
347         // inline complete setup of $JPanel0
348         add(menuUI, BorderLayout.LINE_START);
349         add($JPanel1, BorderLayout.CENTER);
350         // inline complete setup of $JPanel1
351         $JPanel1.add($JScrollPane0);
352         // inline complete setup of $JScrollPane0
353         $JScrollPane0.getViewport().add(referentialUnitsNationalTable);
354     }
355 
356     private void $initialize() {
357         if (allComponentsCreated) {
358             return;
359         }
360         if (log.isDebugEnabled()) {
361             log.debug(this);
362         }
363         handler.beforeInit(this);
364         $objectMap.put("$JPanel0", $JPanel0);
365         createModel();
366         createBroker();
367         createMenuUI();
368         // inline creation of $JPanel1
369         $objectMap.put("$JPanel1", $JPanel1 = new JPanel());
370         
371         $JPanel1.setName("$JPanel1");
372         $JPanel1.setLayout(new BorderLayout());
373         // inline creation of $JScrollPane0
374         $objectMap.put("$JScrollPane0", $JScrollPane0 = new JScrollPane());
375         
376         $JScrollPane0.setName("$JScrollPane0");
377         createReferentialUnitsNationalTable();
378         // inline creation of $JPanel0
379         setName("$JPanel0");
380         setLayout(new BorderLayout());
381         
382         $completeSetup();
383         handler.afterInit(this);
384     }
385 
386 }