OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 144 Rev 156
Line 27... Line 27...
27
    private static final String URL_PARAMETER_KEY = "url-parameter";
27
    private static final String URL_PARAMETER_KEY = "url-parameter";
28
 
28
 
29
    private Boolean openNewFrame = false;
29
    private Boolean openNewFrame = false;
30
    private Map<String, String> urlParameters = new HashMap<String, String>();
30
    private Map<String, String> urlParameters = new HashMap<String, String>();
31
 
31
 
-
 
32
    public LightUIButtonLink() {
-
 
33
        // Serialization
-
 
34
    }
-
 
35
 
32
    public LightUIButtonLink(final String id, final String filePath, final boolean openNewFrame) {
36
    public LightUIButtonLink(final String id, final String filePath, final boolean openNewFrame) {
33
        super(id);
37
        super(id);
34
        this.setType(LightUIElement.TYPE_BUTTON_LINK);
38
        this.setType(LightUIElement.TYPE_BUTTON_LINK);
35
        this.setValue(filePath);
39
        this.setValue(filePath);
36
        this.setOpenNewFrame(openNewFrame);
40
        this.setOpenNewFrame(openNewFrame);
Line 42... Line 46...
42
 
46
 
43
    public LightUIButtonLink(final LightUIButtonLink button) {
47
    public LightUIButtonLink(final LightUIButtonLink button) {
44
        super(button);
48
        super(button);
45
    }
49
    }
46
 
50
 
-
 
51
    @Override
-
 
52
    public void destroy() {
-
 
53
        super.destroy();
-
 
54
        urlParameters = null;
-
 
55
    }
-
 
56
 
47
    public Boolean isOpenNewFrame() {
57
    public Boolean isOpenNewFrame() {
48
        return this.openNewFrame;
58
        return this.openNewFrame;
49
    }
59
    }
50
 
60
 
51
    public void setOpenNewFrame(final Boolean openNewFrame) {
61
    public void setOpenNewFrame(final Boolean openNewFrame) {
Line 79... Line 89...
79
        this.openNewFrame = button.openNewFrame;
89
        this.openNewFrame = button.openNewFrame;
80
        this.urlParameters = button.urlParameters;
90
        this.urlParameters = button.urlParameters;
81
    }
91
    }
82
 
92
 
83
    @Override
93
    @Override
84
    public JSONToLightUIConvertor getConvertor() {
-
 
85
        return new JSONToLightUIConvertor() {
-
 
86
            @Override
-
 
87
            public LightUIElement convert(final JSONObject json) {
-
 
88
                return new LightUIButtonLink(json);
-
 
89
            }
-
 
90
        };
-
 
91
    }
-
 
92
 
-
 
93
    @Override
-
 
94
    public JSONObject toJSON() {
94
    public JSONObject toJSON() {
95
        final JSONObject json = super.toJSON();
95
        final JSONObject json = super.toJSON();
96
 
96
 
97
        if (this.openNewFrame) {
97
        if (this.openNewFrame) {
98
            json.put(OPEN_NEW_FRAME_KEY, true);
98
            json.put(OPEN_NEW_FRAME_KEY, true);
99
        }
99
        }
100
        if (!this.urlParameters.isEmpty()) {
100
        if (!this.urlParameters.isEmpty()) {
101
            json.put(URL_PARAMETER_KEY, this.urlParameters);
101
            json.put(URL_PARAMETER_KEY, this.urlParameters);
102
        }
102
        }
103
 
-
 
104
        return json;
103
        return json;
105
    }
104
    }
106
 
105
 
107
    @Override
106
    @Override
108
    public void fromJSON(JSONObject json) {
107
    public void fromJSON(JSONObject json) {
109
        super.fromJSON(json);
108
        super.fromJSON(json);
110
        this.openNewFrame = JSONConverter.getParameterFromJSON(json, OPEN_NEW_FRAME_KEY, Boolean.class, false);
109
        this.openNewFrame = JSONConverter.getParameterFromJSON(json, OPEN_NEW_FRAME_KEY, Boolean.class, false);
111
        this.urlParameters = CollectionUtils.castMap(JSONConverter.getParameterFromJSON(json, URL_PARAMETER_KEY, Map.class), String.class, String.class);
110
        this.urlParameters = CollectionUtils.castMap(JSONConverter.getParameterFromJSON(json, URL_PARAMETER_KEY, Map.class), String.class, String.class);
112
    }
111
    }
-
 
112
 
113
}
113
}