894 |
gduche |
1 |
package org.tela_botanica.client.composants;
|
|
|
2 |
|
|
|
3 |
|
1908 |
mathias |
4 |
import org.tela_botanica.client.Coel;
|
1105 |
jpm |
5 |
import org.tela_botanica.client.ComposantClass;
|
894 |
gduche |
6 |
import org.tela_botanica.client.ComposantId;
|
|
|
7 |
import org.tela_botanica.client.Mediateur;
|
|
|
8 |
import org.tela_botanica.client.RegistreId;
|
1104 |
jpm |
9 |
import org.tela_botanica.client.i18n.Constantes;
|
894 |
gduche |
10 |
import org.tela_botanica.client.images.Images;
|
|
|
11 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
12 |
import org.tela_botanica.client.modeles.Information;
|
|
|
13 |
|
|
|
14 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
15 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
1104 |
jpm |
16 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
|
17 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
894 |
gduche |
18 |
import com.extjs.gxt.ui.client.util.Format;
|
|
|
19 |
import com.extjs.gxt.ui.client.util.Params;
|
|
|
20 |
import com.extjs.gxt.ui.client.widget.Dialog;
|
|
|
21 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
|
22 |
import com.extjs.gxt.ui.client.widget.Text;
|
|
|
23 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
|
24 |
import com.extjs.gxt.ui.client.widget.form.CheckBox;
|
|
|
25 |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
|
|
|
26 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
27 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
|
|
28 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
|
|
29 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
30 |
|
|
|
31 |
public class LicenceFenetre extends Dialog implements Rafraichissable{
|
1104 |
jpm |
32 |
|
|
|
33 |
private Constantes i18nC = null;
|
|
|
34 |
protected Button validerBouton = null;
|
|
|
35 |
private Button annulerBouton = null;
|
|
|
36 |
|
1073 |
gduche |
37 |
private String messageErreurTpl = "<div id='" + ComposantId.DIV_IDENTIFICATION_MSG + "'>{message}</div>";
|
894 |
gduche |
38 |
private LayoutContainer messageErreur;
|
|
|
39 |
private HTML texteLicence;
|
1105 |
jpm |
40 |
private String licenceTpl = "<div class='{css_corps}'>{licence}</div>";
|
894 |
gduche |
41 |
private IdentificationFenetre fenetreIdentification;
|
|
|
42 |
private CheckBox accepter;
|
|
|
43 |
|
|
|
44 |
public LicenceFenetre(IdentificationFenetre vueARafraichir) {
|
|
|
45 |
|
|
|
46 |
fenetreIdentification = vueARafraichir;
|
|
|
47 |
|
|
|
48 |
setSize(500, 300);
|
|
|
49 |
setPlain(true);
|
1680 |
raphael |
50 |
setHeadingHtml("Licence d'utilisation");
|
894 |
gduche |
51 |
setIcon(Images.ICONES.application());
|
|
|
52 |
setLayout(new RowLayout());
|
|
|
53 |
setButtons(Dialog.OKCANCEL);
|
|
|
54 |
|
|
|
55 |
messageErreur = new LayoutContainer();
|
|
|
56 |
messageErreur.setLayout(new FitLayout());
|
|
|
57 |
add(messageErreur);
|
|
|
58 |
|
|
|
59 |
LayoutContainer licence = new LayoutContainer();
|
|
|
60 |
licence.setSize("98%", "75%");
|
|
|
61 |
licence.setStyleAttribute("padding", "5px");
|
|
|
62 |
licence.setLayout(new FlowLayout());
|
|
|
63 |
licence.setScrollMode(Scroll.AUTO);
|
|
|
64 |
|
|
|
65 |
texteLicence = new HTML();
|
|
|
66 |
licence.add(texteLicence);
|
|
|
67 |
add(licence);
|
|
|
68 |
|
|
|
69 |
LayoutContainer cbContainer = new LayoutContainer(new ColumnLayout());
|
|
|
70 |
accepter = new CheckBox();
|
|
|
71 |
cbContainer.add(accepter);
|
|
|
72 |
add(cbContainer);
|
|
|
73 |
|
1071 |
gduche |
74 |
Text txtAccepter = new Text(Mediateur.i18nC.licenceJaccepte());
|
894 |
gduche |
75 |
txtAccepter.setStyleAttribute("padding", "3px");
|
|
|
76 |
cbContainer.add(txtAccepter);
|
|
|
77 |
setClosable(false);
|
|
|
78 |
|
|
|
79 |
show();
|
|
|
80 |
initialiserComposants();
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public void initialiserComposants() {
|
|
|
84 |
Params licenceParam = new Params();
|
1071 |
gduche |
85 |
licenceParam.set("message", Mediateur.i18nC.licenceAccepter());
|
894 |
gduche |
86 |
messageErreur.el().setInnerHtml(Format.substitute(messageErreurTpl, licenceParam));
|
|
|
87 |
|
1105 |
jpm |
88 |
Params parametres = new Params();
|
894 |
gduche |
89 |
String licence = Mediateur.i18nC.licence();
|
1105 |
jpm |
90 |
parametres.set("licence", licence);
|
|
|
91 |
parametres.set("css_corps", ComposantClass.DETAIL_CORPS_CONTENU);
|
|
|
92 |
texteLicence.setHTML(Format.substitute(licenceTpl, parametres));
|
894 |
gduche |
93 |
}
|
|
|
94 |
|
|
|
95 |
@Override
|
|
|
96 |
protected void createButtons() {
|
1104 |
jpm |
97 |
// FIXME : l'instanciation dans le constructeur ne marche pas pour cette méthode...
|
|
|
98 |
i18nC = Mediateur.i18nC;
|
|
|
99 |
|
|
|
100 |
getButtonBar().removeAll();
|
|
|
101 |
|
|
|
102 |
validerBouton = new Button(i18nC.valider());
|
|
|
103 |
validerBouton.setItemId(OK);
|
|
|
104 |
validerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
105 |
public void componentSelected(ButtonEvent ce) {
|
|
|
106 |
onButtonPressed(ce.getButton());
|
|
|
107 |
}
|
|
|
108 |
});
|
|
|
109 |
|
|
|
110 |
annulerBouton = new Button(i18nC.annuler());
|
|
|
111 |
annulerBouton.setItemId(CANCEL);
|
|
|
112 |
annulerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
113 |
public void componentSelected(ButtonEvent ce) {
|
|
|
114 |
onButtonPressed(ce.getButton());
|
|
|
115 |
}
|
|
|
116 |
});
|
|
|
117 |
|
|
|
118 |
addButton(annulerBouton);
|
|
|
119 |
addButton(validerBouton);
|
894 |
gduche |
120 |
}
|
|
|
121 |
|
1104 |
jpm |
122 |
@Override
|
894 |
gduche |
123 |
protected void onButtonPressed(Button button) {
|
|
|
124 |
if (Dialog.OK.equals(button.getItemId())) {
|
|
|
125 |
button.setEnabled(false);
|
|
|
126 |
boolean licenceAcceptee = accepter.getValue();
|
|
|
127 |
if (licenceAcceptee == true) {
|
|
|
128 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).accepterLicence(this);
|
|
|
129 |
} else {
|
|
|
130 |
hide();
|
|
|
131 |
}
|
|
|
132 |
} else {
|
|
|
133 |
hide();
|
|
|
134 |
}
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
138 |
if (nouvellesDonnees instanceof Information) {
|
|
|
139 |
Information info = (Information) nouvellesDonnees;
|
|
|
140 |
if (info.getType().equals("maj_licence")) {
|
|
|
141 |
|
|
|
142 |
String licence = info.getDonnee(0).toString();
|
|
|
143 |
if (licence.equals("1")) {
|
|
|
144 |
hide();
|
|
|
145 |
fenetreIdentification.onSubmit();
|
|
|
146 |
|
|
|
147 |
} else {
|
|
|
148 |
//Licence non acceptée, on masque la fenêtre pour laisser
|
|
|
149 |
// affiché la fenêtre d'identification qui est en erreur.
|
|
|
150 |
hide();
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
}
|