OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 149 | Rev 174 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 149 Rev 156
Line 13... Line 13...
13
 
13
 
14
 package org.openconcerto.ui.light;
14
 package org.openconcerto.ui.light;
15
 
15
 
16
import org.openconcerto.utils.io.JSONConverter;
16
import org.openconcerto.utils.io.JSONConverter;
17
 
17
 
-
 
18
import java.io.IOException;
-
 
19
import java.io.ObjectInput;
-
 
20
import java.io.ObjectOutput;
18
import java.io.PrintStream;
21
import java.io.PrintStream;
19
import java.util.ArrayList;
22
import java.util.ArrayList;
20
import java.util.List;
23
import java.util.List;
21
 
24
 
22
import net.minidev.json.JSONArray;
25
import net.minidev.json.JSONArray;
Line 33... Line 36...
33
    private LightUIPanel contentPanel;
36
    private LightUIPanel contentPanel;
34
    private LightUIPanel footerPanel = new LightUIPanel(this.getId() + ".footer.panel");
37
    private LightUIPanel footerPanel = new LightUIPanel(this.getId() + ".footer.panel");
35
 
38
 
36
    private List<LightUIFrame> childrenFrame;
39
    private List<LightUIFrame> childrenFrame;
37
 
40
 
-
 
41
    public LightUIFrame() {
-
 
42
        // Serialization
-
 
43
    }
-
 
44
 
38
    // Init from json constructor
45
    // Init from json constructor
39
    public LightUIFrame(final JSONObject json) {
46
    public LightUIFrame(final JSONObject json) {
40
        super(json);
47
        super(json);
41
    }
48
    }
42
 
49
 
Line 48... Line 55...
48
        this.childrenFrame = frame.childrenFrame;
55
        this.childrenFrame = frame.childrenFrame;
49
        this.contentPanel = frame.contentPanel;
56
        this.contentPanel = frame.contentPanel;
50
        this.setFooterPanel(frame.footerPanel);
57
        this.setFooterPanel(frame.footerPanel);
51
    }
58
    }
52
 
59
 
-
 
60
    @Override
-
 
61
    public void destroy() {
-
 
62
        super.destroy();
-
 
63
        if (this.titlePanel != null) {
-
 
64
            this.titlePanel.destroy();
-
 
65
        }
-
 
66
        if (this.footerPanel != null) {
-
 
67
            this.footerPanel.destroy();
-
 
68
        }
-
 
69
        if (this.childrenFrame != null) {
-
 
70
            for (LightUIFrame frame : childrenFrame) {
-
 
71
                frame.destroy();
-
 
72
            }
-
 
73
        }
-
 
74
    }
-
 
75
 
53
    /**
76
    /**
54
     * Creation of an instance of a frame, this one is initialized with an empty main panel
77
     * Creation of an instance of a frame, this one is initialized with an empty main panel
55
     * 
78
     * 
56
     * @param id Id of the frame
79
     * @param id Id of the frame
57
     */
80
     */
Line 226... Line 249...
226
        this.clear();
249
        this.clear();
227
        super.insertChild(index, child);
250
        super.insertChild(index, child);
228
    }
251
    }
229
 
252
 
230
    @Override
253
    @Override
231
    public JSONToLightUIConvertor getConvertor() {
-
 
232
        return new JSONToLightUIConvertor() {
-
 
233
            @Override
-
 
234
            public LightUIElement convert(final JSONObject json) {
-
 
235
                return new LightUIFrame(json);
-
 
236
            }
-
 
237
        };
-
 
238
    }
-
 
239
 
-
 
240
    @Override
-
 
241
    public void dump(final PrintStream out, final int depth) {
254
    public void dump(final PrintStream out, final int depth) {
242
        out.println("------------- LightUIFrame -------------");
255
        out.println("------------- LightUIFrame -------------");
243
        super.dump(out, 0);
256
        super.dump(out, 0);
244
 
257
 
245
        out.println("footer-panel: ");
258
        out.println("footer-panel: ");
Line 267... Line 280...
267
 
280
 
268
    @Override
281
    @Override
269
    public void fromJSON(final JSONObject json) {
282
    public void fromJSON(final JSONObject json) {
270
        super.fromJSON(json);
283
        super.fromJSON(json);
271
        this.active = JSONConverter.getParameterFromJSON(json, KEY_ACTIVE, Boolean.class, false);
284
        this.active = JSONConverter.getParameterFromJSON(json, KEY_ACTIVE, Boolean.class, false);
272
 
-
 
-
 
285
        this.createTitlePanel();
273
        final JSONObject jsonTitlePanel = JSONConverter.getParameterFromJSON(json, KEY_TITLE_PANEL, JSONObject.class);
286
        final JSONObject jsonTitlePanel = JSONConverter.getParameterFromJSON(json, KEY_TITLE_PANEL, JSONObject.class);
274
        if (jsonTitlePanel != null) {
287
        if (jsonTitlePanel != null) {
275
            this.titlePanel.fromJSON(jsonTitlePanel);
288
            this.titlePanel.fromJSON(jsonTitlePanel);
276
        }
289
        }
277
 
290
 
Line 288... Line 301...
288
                final LightUIFrame childFrame = new LightUIFrame(jsonFrame);
301
                final LightUIFrame childFrame = new LightUIFrame(jsonFrame);
289
                this.childrenFrame.add(childFrame);
302
                this.childrenFrame.add(childFrame);
290
            }
303
            }
291
        }
304
        }
292
    }
305
    }
-
 
306
 
-
 
307
    @Override
-
 
308
    public void writeExternal(ObjectOutput out) throws IOException {
-
 
309
        super.writeExternal(out);
-
 
310
        out.writeBoolean(this.active);
-
 
311
        // Title panel
-
 
312
        if (this.titlePanel != null) {
-
 
313
            out.writeBoolean(true);
-
 
314
            out.writeObject(this.titlePanel);
-
 
315
        } else {
-
 
316
            out.writeBoolean(false);
-
 
317
        }
-
 
318
        // Footer panel
-
 
319
        if (this.footerPanel != null) {
-
 
320
            out.writeBoolean(true);
-
 
321
            out.writeObject(this.footerPanel);
-
 
322
        } else {
-
 
323
            out.writeBoolean(false);
-
 
324
        }
-
 
325
    }
-
 
326
 
-
 
327
    @Override
-
 
328
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-
 
329
        super.readExternal(in);
-
 
330
        this.active = in.readBoolean();
-
 
331
        if (in.readBoolean()) {
-
 
332
            this.titlePanel = (LightUIPanel) in.readObject();
-
 
333
        }
-
 
334
        if (in.readBoolean()) {
-
 
335
            this.footerPanel = (LightUIPanel) in.readObject();
-
 
336
        }
-
 
337
    }
-
 
338
 
293
}
339
}