New file |
0,0 → 1,133 |
package org.tela_botanica.client.composants; |
|
|
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
|
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.event.EventType; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.WidgetListener; |
import com.extjs.gxt.ui.client.util.Format; |
import com.extjs.gxt.ui.client.util.Params; |
import com.extjs.gxt.ui.client.widget.Dialog; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.form.CheckBox; |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout; |
import com.extjs.gxt.ui.client.widget.layout.RowLayout; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.HTML; |
|
public class LicenceFenetre extends Dialog implements Rafraichissable{ |
|
private String messageErreurTpl = "<div id='" + ComposantId.DIV_IDENTIFICATION_MSG + ">{message}</div>"; |
private LayoutContainer messageErreur; |
private HTML texteLicence; |
private String licenceTpl = "<div style='padding:15px; width:400px;'>{licence}</div>"; |
private Rafraichissable vueARafraichir; |
private IdentificationFenetre fenetreIdentification; |
private CheckBox accepter; |
|
public LicenceFenetre(IdentificationFenetre vueARafraichir) { |
|
fenetreIdentification = vueARafraichir; |
|
setSize(500, 300); |
setPlain(true); |
setHeading("Licence d'utilisation"); |
setIcon(Images.ICONES.application()); |
setLayout(new RowLayout()); |
setButtons(Dialog.OKCANCEL); |
|
messageErreur = new LayoutContainer(); |
messageErreur.setLayout(new FitLayout()); |
add(messageErreur); |
|
LayoutContainer licence = new LayoutContainer(); |
licence.setSize("98%", "75%"); |
licence.setStyleAttribute("padding", "5px"); |
licence.setLayout(new FlowLayout()); |
licence.setScrollMode(Scroll.AUTO); |
|
texteLicence = new HTML(); |
licence.add(texteLicence); |
add(licence); |
|
LayoutContainer cbContainer = new LayoutContainer(new ColumnLayout()); |
accepter = new CheckBox(); |
cbContainer.add(accepter); |
add(cbContainer); |
|
Text txtAccepter = new Text("J'accepte les conditions de la licence utilisateur"); |
txtAccepter.setStyleAttribute("padding", "3px"); |
cbContainer.add(txtAccepter); |
setClosable(false); |
|
show(); |
initialiserComposants(); |
} |
|
public void initialiserComposants() { |
Params licenceParam = new Params(); |
|
licenceParam.set("message", "Vous devez accepter licence"); |
messageErreur.el().setInnerHtml(Format.substitute(messageErreurTpl, licenceParam)); |
|
String licence = Mediateur.i18nC.licence(); |
|
Params param = new Params(); |
param.set("licence", licence); |
texteLicence.setHTML(Format.substitute(licenceTpl, param)); |
} |
|
@Override |
protected void createButtons() { |
super.createButtons(); |
} |
|
protected void onButtonPressed(Button button) { |
if (Dialog.OK.equals(button.getItemId())) { |
button.setEnabled(false); |
boolean licenceAcceptee = accepter.getValue(); |
if (licenceAcceptee == true) { |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).accepterLicence(this); |
} else { |
hide(); |
} |
} else { |
hide(); |
} |
} |
|
@Override |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_licence")) { |
|
String licence = info.getDonnee(0).toString(); |
if (licence.equals("1")) { |
hide(); |
fenetreIdentification.onSubmit(); |
|
} else { |
//Licence non acceptée, on masque la fenêtre pour laisser |
// affiché la fenêtre d'identification qui est en erreur. |
hide(); |
} |
} |
} |
|
} |
|
|
} |