894 |
gduche |
1 |
package org.tela_botanica.client.composants;
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
import org.tela_botanica.client.ComposantId;
|
|
|
5 |
import org.tela_botanica.client.Mediateur;
|
|
|
6 |
import org.tela_botanica.client.RegistreId;
|
|
|
7 |
import org.tela_botanica.client.images.Images;
|
|
|
8 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
9 |
import org.tela_botanica.client.modeles.Information;
|
|
|
10 |
|
|
|
11 |
import com.extjs.gxt.ui.client.Registry;
|
|
|
12 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
|
|
13 |
import com.extjs.gxt.ui.client.util.Format;
|
|
|
14 |
import com.extjs.gxt.ui.client.util.Params;
|
|
|
15 |
import com.extjs.gxt.ui.client.widget.Dialog;
|
|
|
16 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
|
17 |
import com.extjs.gxt.ui.client.widget.Text;
|
|
|
18 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
|
|
19 |
import com.extjs.gxt.ui.client.widget.form.CheckBox;
|
|
|
20 |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
|
|
|
21 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
|
|
22 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
|
|
23 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
|
|
24 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
25 |
|
|
|
26 |
public class LicenceFenetre extends Dialog implements Rafraichissable{
|
|
|
27 |
|
|
|
28 |
private String messageErreurTpl = "<div id='" + ComposantId.DIV_IDENTIFICATION_MSG + ">{message}</div>";
|
|
|
29 |
private LayoutContainer messageErreur;
|
|
|
30 |
private HTML texteLicence;
|
|
|
31 |
private String licenceTpl = "<div style='padding:15px; width:400px;'>{licence}</div>";
|
|
|
32 |
private IdentificationFenetre fenetreIdentification;
|
|
|
33 |
private CheckBox accepter;
|
|
|
34 |
|
|
|
35 |
public LicenceFenetre(IdentificationFenetre vueARafraichir) {
|
|
|
36 |
|
|
|
37 |
fenetreIdentification = vueARafraichir;
|
|
|
38 |
|
|
|
39 |
setSize(500, 300);
|
|
|
40 |
setPlain(true);
|
|
|
41 |
setHeading("Licence d'utilisation");
|
|
|
42 |
setIcon(Images.ICONES.application());
|
|
|
43 |
setLayout(new RowLayout());
|
|
|
44 |
setButtons(Dialog.OKCANCEL);
|
|
|
45 |
|
|
|
46 |
messageErreur = new LayoutContainer();
|
|
|
47 |
messageErreur.setLayout(new FitLayout());
|
|
|
48 |
add(messageErreur);
|
|
|
49 |
|
|
|
50 |
LayoutContainer licence = new LayoutContainer();
|
|
|
51 |
licence.setSize("98%", "75%");
|
|
|
52 |
licence.setStyleAttribute("padding", "5px");
|
|
|
53 |
licence.setLayout(new FlowLayout());
|
|
|
54 |
licence.setScrollMode(Scroll.AUTO);
|
|
|
55 |
|
|
|
56 |
texteLicence = new HTML();
|
|
|
57 |
licence.add(texteLicence);
|
|
|
58 |
add(licence);
|
|
|
59 |
|
|
|
60 |
LayoutContainer cbContainer = new LayoutContainer(new ColumnLayout());
|
|
|
61 |
accepter = new CheckBox();
|
|
|
62 |
cbContainer.add(accepter);
|
|
|
63 |
add(cbContainer);
|
|
|
64 |
|
1071 |
gduche |
65 |
Text txtAccepter = new Text(Mediateur.i18nC.licenceJaccepte());
|
894 |
gduche |
66 |
txtAccepter.setStyleAttribute("padding", "3px");
|
|
|
67 |
cbContainer.add(txtAccepter);
|
|
|
68 |
setClosable(false);
|
|
|
69 |
|
|
|
70 |
show();
|
|
|
71 |
initialiserComposants();
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public void initialiserComposants() {
|
|
|
75 |
Params licenceParam = new Params();
|
|
|
76 |
|
1071 |
gduche |
77 |
licenceParam.set("message", Mediateur.i18nC.licenceAccepter());
|
894 |
gduche |
78 |
messageErreur.el().setInnerHtml(Format.substitute(messageErreurTpl, licenceParam));
|
|
|
79 |
|
|
|
80 |
String licence = Mediateur.i18nC.licence();
|
|
|
81 |
|
|
|
82 |
Params param = new Params();
|
|
|
83 |
param.set("licence", licence);
|
|
|
84 |
texteLicence.setHTML(Format.substitute(licenceTpl, param));
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
@Override
|
|
|
88 |
protected void createButtons() {
|
|
|
89 |
super.createButtons();
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
protected void onButtonPressed(Button button) {
|
|
|
93 |
if (Dialog.OK.equals(button.getItemId())) {
|
|
|
94 |
button.setEnabled(false);
|
|
|
95 |
boolean licenceAcceptee = accepter.getValue();
|
|
|
96 |
if (licenceAcceptee == true) {
|
|
|
97 |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).accepterLicence(this);
|
|
|
98 |
} else {
|
|
|
99 |
hide();
|
|
|
100 |
}
|
|
|
101 |
} else {
|
|
|
102 |
hide();
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
@Override
|
|
|
107 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
108 |
if (nouvellesDonnees instanceof Information) {
|
|
|
109 |
Information info = (Information) nouvellesDonnees;
|
|
|
110 |
if (info.getType().equals("maj_licence")) {
|
|
|
111 |
|
|
|
112 |
String licence = info.getDonnee(0).toString();
|
|
|
113 |
if (licence.equals("1")) {
|
|
|
114 |
hide();
|
|
|
115 |
fenetreIdentification.onSubmit();
|
|
|
116 |
|
|
|
117 |
} else {
|
|
|
118 |
//Licence non acceptée, on masque la fenêtre pour laisser
|
|
|
119 |
// affiché la fenêtre d'identification qui est en erreur.
|
|
|
120 |
hide();
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
}
|