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