View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.parameter.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.pmfm.parameter.menu.ManageParametersMenuUI;
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 ManageParametersNationalUI extends JPanel implements ReefDbUI<ManageParametersNationalUIModel, ManageParametersNationalUIHandler>, JAXXObject {
58  
59      /*-----------------------------------------------------------------------*/
60      /*------------------------- Other static fields -------------------------*/
61      /*-----------------------------------------------------------------------*/
62  
63      private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAL1US28TMRCeBJI2LeVVtRRRpEIrIahwQByLoNCqaqsEKkKlilzqzTqJi9frer10e0H8BH4C3LkgceOEOHDmwAXxFxDiwBUxdh6b0PA4IHLwOp755vvGnpkXnyEXaTi3Q5OE6FgaHjCyfmtr6663w2pmmUU1zZUJNbR+mSxkqzDqd88jA7PVkoUX2/DiUhioUDLZg14owUhk9gWLmowZA2f7EbUoKla65oVExboTtStqUNRnX79kn/pPnmcBEoXqhjCVmT+h0kwOlyDLfQMnkekRLQoqGyhDc9lAvWP2bEnQKLpDA7YLj2GoBHlFNQYzcP7vU3YxHD5RBobn1jeoZOKKgWZdE17XLGCaaMbqvkdiTqI95Ce1UBoMRwIqaYOhuc4sMaeCqKAeENSBqgwiJTU8lHhedq4bHQPKbhk215Ry/HkDuSD0mTAQ/C/qsuVL+fOeDh8ybWD+NwLu4f9lbxVxt513DzxgMt5cM7D9T/TbaAe0lx2FJSx0eTuPdhVrxZZF0qZqnfb7js2tV2o6FMLa8JVP9QFSk3WfSB/GUE8wA6Qnsd2Y+po32LU0N+dFKnZ/324tekph1Z/pq3rsJ5L2U1rwmSrkdIzHBqaqB1vwHppazTf1U/PZgM76fXL8w+tPr1Y6HZdF7omBrj0DAztB6VDhu3NLfazVbrHholimaqEKhYgJnDZumkwPEFZpm1Ec8p2wcGLhZJVGTQyRG/r45u3k9vtDkF2BERFSf4Va/zUomKbGWwiFn6ibi07Rkb1hXI9bbVhRgu6HMTb00es+NXTG49LHy72R4CVMD7iErhKv8O7beOXlYuciMijs9C/d08vIPYA8l4JL5oZPe64MHDajKmKxH6bzY9BEydjviGr3yKxbLxzM1B5ftMulJLafeSfZ7i472yRG+AGP8SnFDAYAAA==";
64      private static final Log log = LogFactory.getLog(ManageParametersNationalUI.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 ManageParametersNationalUIHandler handler = createHandler();
85      protected ManageParametersMenuUI menuUI;
86      protected ManageParametersNationalUIModel model;
87      protected SwingTable table;
88  
89      /*-----------------------------------------------------------------------*/
90      /*------------------------- Private components  -------------------------*/
91      /*-----------------------------------------------------------------------*/
92  
93      private ManageParametersNationalUI $JPanel0 = this;
94      private JPanel $JPanel1;
95      private JScrollPane $JScrollPane0;
96  
97      /*-----------------------------------------------------------------------*/
98      /*---------------------------- Constructors  ----------------------------*/
99      /*-----------------------------------------------------------------------*/
100 
101     public ManageParametersNationalUI(ApplicationUI parentUI) {
102         ApplicationUIUtil.setParentUI(this, parentUI);
103             $initialize();
104     }
105 
106     public ManageParametersNationalUI(LayoutManager param0, boolean param1) {
107         super(param0 ,param1);
108         $initialize();
109     }
110 
111     public ManageParametersNationalUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
112         super(param1 ,param2);
113         JAXXUtil.initContext(this, parentContext);
114         $initialize();
115     }
116 
117     public ManageParametersNationalUI(boolean param0) {
118         super(param0);
119         $initialize();
120     }
121 
122     public ManageParametersNationalUI(JAXXContext parentContext, boolean param1) {
123         super(param1);
124         JAXXUtil.initContext(this, parentContext);
125         $initialize();
126     }
127 
128     public ManageParametersNationalUI() {
129         $initialize();
130     }
131 
132     public ManageParametersNationalUI(JAXXContext parentContext) {
133         JAXXUtil.initContext(this, parentContext);
134         $initialize();
135     }
136 
137     public ManageParametersNationalUI(LayoutManager param0) {
138         super(param0);
139         $initialize();
140     }
141 
142     public ManageParametersNationalUI(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 ManageParametersNationalUIHandler getHandler() {
283         return handler;
284     }
285 
286     public ManageParametersMenuUI getMenuUI() {
287         return menuUI;
288     }
289 
290     public ManageParametersNationalUIModel getModel() {
291         return model;
292     }
293 
294     public SwingTable getTable() {
295         return table;
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 ManageParametersNationalUIHandler createHandler() {
319         return new ManageParametersNationalUIHandler();
320     }
321 
322     protected void createMenuUI() {
323         $objectMap.put("menuUI", menuUI = new ManageParametersMenuUI(this));
324         
325         menuUI.setName("menuUI");
326     }
327 
328     protected void createModel() {
329         $objectMap.put("model", model = getContextValue(ManageParametersNationalUIModel.class));
330     }
331 
332     protected void createTable() {
333         $objectMap.put("table", table = new SwingTable());
334         
335         table.setName("table");
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(table);
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         createTable();
378         // inline creation of $JPanel0
379         setName("$JPanel0");
380         setLayout(new BorderLayout());
381         
382         $completeSetup();
383         handler.afterInit(this);
384     }
385 
386 }