OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 94 | Rev 142 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
80 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.ui.light;
15
 
132 ilm 16
import java.awt.event.ActionEvent;
17
import java.awt.event.ActionListener;
18
import java.util.ArrayList;
19
import java.util.List;
20
 
21
import net.minidev.json.JSONObject;
22
 
80 ilm 23
public class LightUIButton extends LightUIElement {
132 ilm 24
    private List<ActionListener> clickListeners = new ArrayList<ActionListener>();
25
 
26
    public LightUIButton(final JSONObject json) {
27
        super(json);
80 ilm 28
    }
132 ilm 29
 
30
    public LightUIButton(final String id) {
31
        super(id);
32
        this.init(TYPE_BUTTON);
33
    }
34
 
35
    protected LightUIButton(final String id, final int buttonType) {
36
        super(id);
37
        this.init(buttonType);
38
    }
39
 
40
    private void init(final int buttonType) {
41
        this.setType(buttonType);
42
    }
43
 
44
    public LightUIButton(final LightUIButton button) {
45
        super(button);
46
    }
47
 
48
    public void addClickListener(final ActionListener listener) {
49
        this.clickListeners.add(listener);
50
    }
51
 
52
    public void removeClickListeners() {
53
        this.clickListeners.clear();
54
    }
55
 
56
    public void fireClick() {
57
        for (final ActionListener listener : this.clickListeners) {
58
            listener.actionPerformed(new ActionEvent(this, 1, "click"));
59
        }
60
    }
80 ilm 61
}