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