--- /dev/null
+/*****************************************************************************
+ * Copyright Igor Barma, Eric Brun, Alexandre Desoubeaux, Christian Martel,
+ * (2 décembre 2008)
+ *
+ * Ce logiciel est un programme informatique servant à l'évaluation des
+ * compétences.
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ *******************************************************************************/
+package com.pentila.evalcomp.client.plan.widget;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.RichTextArea;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.core.Position;
+import com.gwtext.client.data.SimpleStore;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.ComboBox;
+import com.gwtext.client.widgets.form.FieldSet;
+import com.gwtext.client.widgets.form.FormPanel;
+import com.gwtext.client.widgets.layout.ColumnLayout;
+import com.gwtext.client.widgets.layout.ColumnLayoutData;
+import com.gwtextux.client.widgets.window.ToastWindow;
+import com.pentila.evalcomp.client.ConnexionServer;
+import com.pentila.evalcomp.client.i18n.Messages;
+import com.pentila.evalcomp.client.widget.RichTextToolbar;
+import com.pentila.evalcomp.domain.plan.PlanRef;
+
+/**
+ * The Class TemplateWidget.
+ */
+public class TemplateWidget extends Panel{
+
+ /** The current plan ref. */
+ PlanRef currentPlanRef;
+
+ /** The body. */
+ private RichTextArea body;
+
+
+ /** The cb. */
+ private ComboBox cb;
+
+ TemplateFileWidget TFW;
+
+ /**
+ * Instantiates a new template widget.
+ *
+ * @param planRef the plan ref
+ */
+ public TemplateWidget(PlanRef planRef){
+ super();
+ this.currentPlanRef = planRef;
+
+
+ }
+
+
+ /**
+ * Initialize interface.
+ */
+ public void initializeInterface(){
+ FormPanel formPanel = new FormPanel();
+ formPanel.setFrame(true);
+
+ formPanel.setPaddings(5);
+
+ formPanel.setLabelAlign(Position.TOP);
+
+ Panel inner = new Panel();
+ inner.setLayout(new ColumnLayout());
+
+ inner.setPaddings(5);
+
+
+
+
+
+ FieldSet notif = new FieldSet(Messages.getString("notifications"));
+ notif.setPaddings(2);
+ body = new RichTextArea();
+ RichTextToolbar toolbar = new RichTextToolbar(body);
+
+ body.setPixelSize(565, 200);
+ Grid gridNotif = new Grid(2, 1);
+ gridNotif.setStyleName("cw-RichText");
+ gridNotif.setWidget(0, 0, toolbar);
+ gridNotif.setWidget(1, 0, body);
+
+ cb = new ComboBox(Messages.getString("frequence"));
+ cb.setDisplayField("label");
+ cb.setValueField("value");
+
+ Object[][] st = new Object[6][];
+ st[0] = new Object[]{new Integer(1), "Tous les jours"};
+ st[1] = new Object[]{new Integer(5), "5 jours"};
+ st[2] = new Object[]{new Integer(10), "10 jours"};
+ st[3] = new Object[]{new Integer(15), "15 jours"};
+ st[4] = new Object[]{new Integer(30), "Tous les mois"};
+ st[5] = new Object[]{new Integer(90), "Tous les trimestres"};
+
+
+ SimpleStore ss = new SimpleStore(new String[]{"value", "label"}, st);
+ ss.load();
+ cb.setStore(ss);
+
+ cb.setValue("" + currentPlanRef.getFrequency());
+ body.setHTML(currentPlanRef.getNotificationText());
+ notif.add(cb);
+
+ notif.add(gridNotif);
+
+ Panel p = new Panel();
+ p.setTitle("Legende");
+
+ String html = "{referentiel} : Nom du referentiel.<br>" +
+ "{signature} : Nom du responsable (createur) du plan.<br>" +
+ "{date} : Date de fin de certification.<br>" +
+ "{nb_personnes} : Nombre de candidats certificables<br>" +
+ "{frequence} : Frequence des notifications.<br>" +
+ "{plan} : Nom du plan.<br>";
+
+ p.setHtml(html);
+
+
+
+ notif.add(p);
+
+
+ inner.add(notif, new ColumnLayoutData(0.7));
+ FieldSet templates = new FieldSet(Messages.getString("modele_de_documents"));
+ templates.setPaddings(2);
+
+ TFW = new TemplateFileWidget(currentPlanRef.getId(), null, true);
+ TFW.initializeInterface();
+ TFW.setHeight(430);
+ templates.add(TFW);
+ inner.add(templates, new ColumnLayoutData(0.3));
+
+
+
+ formPanel.add(inner);
+
+
+ Button button = new Button(Messages.getString("Save"));
+
+ button.addListener(new ButtonListenerAdapter(){
+
+
+ public void onClick(Button button, EventObject e) {
+
+
+ savePlanRefInfo();
+
+
+ }
+
+
+
+ });
+
+
+
+
+ inner.addButton(button);
+
+
+ add(formPanel);
+
+
+
+
+ }
+
+
+ /**
+ * Save plan ref info.
+ */
+ private void savePlanRefInfo() {
+
+
+ currentPlanRef.setFrequency(new Integer(cb.getValue()));
+ currentPlanRef.setNotificationText(body.getHTML());
+
+
+ AsyncCallback callback = new AsyncCallback() {
+
+ public void onFailure(Throwable caught) {
+ // do some UI stuff to show failure
+ System.out
+ .println("Probleme dans la sauvegarde du plan ref");
+ }
+
+ public void onSuccess(Object result) {
+ ToastWindow tw = new ToastWindow(Messages
+ .getString("notification"), Messages
+ .getString("save_done"));
+ tw.show();
+
+ }
+ };
+ ConnexionServer.planService.editPlanRef(currentPlanRef, callback);
+
+ }
+
+
+ public void update() {
+ TFW.update();
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+}