| 1202 | 
           cyprien | 
           1 | 
           package org.tela_botanica.client.vues;
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           import java.util.ArrayList;
  | 
        
        
            | 
            | 
           4 | 
           import java.util.Date;
  | 
        
        
            | 
            | 
           5 | 
           import java.util.List;
  | 
        
        
            | 
            | 
           6 | 
              | 
        
        
            | 
            | 
           7 | 
           import org.tela_botanica.client.Mediateur;
  | 
        
        
            | 
            | 
           8 | 
           import org.tela_botanica.client.interfaces.Rafraichissable;
  | 
        
        
            | 
            | 
           9 | 
           import org.tela_botanica.client.modeles.Valeur;
  | 
        
        
            | 
            | 
           10 | 
              | 
        
        
            | 
            | 
           11 | 
           import com.extjs.gxt.ui.client.Style.SortDir;
  | 
        
        
            | 
            | 
           12 | 
           import com.extjs.gxt.ui.client.core.XTemplate;
  | 
        
        
            | 
            | 
           13 | 
           import com.extjs.gxt.ui.client.event.BaseEvent;
  | 
        
        
            | 
            | 
           14 | 
           import com.extjs.gxt.ui.client.event.ButtonEvent;
  | 
        
        
            | 
            | 
           15 | 
           import com.extjs.gxt.ui.client.event.Events;
  | 
        
        
            | 
            | 
           16 | 
           import com.extjs.gxt.ui.client.event.Listener;
  | 
        
        
            | 
            | 
           17 | 
           import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
  | 
        
        
            | 
            | 
           18 | 
           import com.extjs.gxt.ui.client.event.SelectionChangedListener;
  | 
        
        
            | 
            | 
           19 | 
           import com.extjs.gxt.ui.client.event.SelectionListener;
  | 
        
        
            | 
            | 
           20 | 
           import com.extjs.gxt.ui.client.store.ListStore;
  | 
        
        
            | 
            | 
           21 | 
           import com.extjs.gxt.ui.client.widget.Dialog;
  | 
        
        
            | 
            | 
           22 | 
           import com.extjs.gxt.ui.client.widget.InfoConfig;
  | 
        
        
            | 
            | 
           23 | 
           import com.extjs.gxt.ui.client.widget.button.Button;
  | 
        
        
            | 
            | 
           24 | 
           import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
  | 
        
        
            | 
            | 
           25 | 
           import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
  | 
        
        
            | 
            | 
           26 | 
           import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
  | 
        
        
            | 
            | 
           27 | 
           import com.extjs.gxt.ui.client.widget.grid.Grid;
  | 
        
        
            | 
            | 
           28 | 
           import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
  | 
        
        
            | 
            | 
           29 | 
           import com.extjs.gxt.ui.client.widget.grid.RowExpander;
  | 
        
        
            | 
            | 
           30 | 
           import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
  | 
        
        
            | 
            | 
           31 | 
           import com.extjs.gxt.ui.client.widget.layout.FitLayout;
  | 
        
        
            | 
            | 
           32 | 
           import com.google.gwt.i18n.client.DateTimeFormat;
  | 
        
        
            | 
            | 
           33 | 
           import com.google.gwt.i18n.client.Dictionary;
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           public class FenetreJournal extends Dialog implements Rafraichissable{
  | 
        
        
            | 
            | 
           36 | 
              | 
        
        
            | 
            | 
           37 | 
           	private int id = 0;
  | 
        
        
            | 
            | 
           38 | 
           	private EditorGrid<Valeur> grille;
  | 
        
        
           | 1206 | 
           cyprien | 
           39 | 
           	//private int nbLogs = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbLogs"));
  | 
        
        
           | 1202 | 
           cyprien | 
           40 | 
           	private ListStore<Valeur> store;
  | 
        
        
            | 
            | 
           41 | 
           	public FenetreJournal(Mediateur mediateur)	{
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
           | 1680 | 
           raphael | 
           43 | 
           		this.setHeadingHtml(mediateur.i18nC.titreJournal());
  | 
        
        
           | 1202 | 
           cyprien | 
           44 | 
           		this.setWidth(500);
  | 
        
        
            | 
            | 
           45 | 
           		this.setHeight(500);
  | 
        
        
            | 
            | 
           46 | 
           		setLayout(new FitLayout());
  | 
        
        
            | 
            | 
           47 | 
              | 
        
        
            | 
            | 
           48 | 
           		// Définition des colomnes de la grille:
  | 
        
        
            | 
            | 
           49 | 
           		RowNumberer numeroPlugin = new RowNumberer();
  | 
        
        
           | 1680 | 
           raphael | 
           50 | 
           		numeroPlugin.setHeaderHtml("#");
  | 
        
        
           | 1202 | 
           cyprien | 
           51 | 
              | 
        
        
            | 
            | 
           52 | 
           		XTemplate infoTpl = XTemplate.create("<p>"+
  | 
        
        
            | 
            | 
           53 | 
           			"<b>" + mediateur.i18nC.heureMessage() + " : </b>{heure}<br />" +
  | 
        
        
            | 
            | 
           54 | 
           			"<b>" + mediateur.i18nC.message() + " : </b>{description}<br />" +
  | 
        
        
            | 
            | 
           55 | 
           			"</p>");
  | 
        
        
            | 
            | 
           56 | 
           		RowExpander expansionPlugin = new RowExpander();
  | 
        
        
            | 
            | 
           57 | 
           		expansionPlugin.setTemplate(infoTpl);
  | 
        
        
            | 
            | 
           58 | 
              | 
        
        
            | 
            | 
           59 | 
           		List<ColumnConfig> lstColumns = new ArrayList<ColumnConfig>();
  | 
        
        
            | 
            | 
           60 | 
           		lstColumns.add(expansionPlugin);
  | 
        
        
            | 
            | 
           61 | 
           		lstColumns.add(new ColumnConfig("nom", mediateur.i18nC.publicationTitre(), 200));
  | 
        
        
            | 
            | 
           62 | 
           		lstColumns.add(new ColumnConfig("description", mediateur.i18nC.message() , 400));
  | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
           		ColumnModel modeleColonnes = new ColumnModel(lstColumns);
  | 
        
        
            | 
            | 
           65 | 
              | 
        
        
            | 
            | 
           66 | 
           		store = new ListStore<Valeur>();
  | 
        
        
            | 
            | 
           67 | 
              | 
        
        
            | 
            | 
           68 | 
           		grille = new EditorGrid<Valeur>(store, modeleColonnes);
  | 
        
        
            | 
            | 
           69 | 
           		grille.addPlugin(expansionPlugin);
  | 
        
        
            | 
            | 
           70 | 
              | 
        
        
            | 
            | 
           71 | 
           		grille.setAutoExpandColumn("description");
  | 
        
        
            | 
            | 
           72 | 
           		grille.getView().setAutoFill(true);
  | 
        
        
            | 
            | 
           73 | 
           		grille.getView().setForceFit(true);
  | 
        
        
            | 
            | 
           74 | 
              | 
        
        
            | 
            | 
           75 | 
           		store.sort("id", SortDir.DESC);
  | 
        
        
            | 
            | 
           76 | 
           		add(grille);
  | 
        
        
            | 
            | 
           77 | 
           	}
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
           	public void rafraichir(Object nouvellesDonnees) {
  | 
        
        
            | 
            | 
           80 | 
           		if (nouvellesDonnees instanceof InfoConfig)	{
  | 
        
        
            | 
            | 
           81 | 
           			InfoConfig info = (InfoConfig) nouvellesDonnees;
  | 
        
        
            | 
            | 
           82 | 
           			id++;
  | 
        
        
           | 1680 | 
           raphael | 
           83 | 
           			Valeur v = new Valeur(String.valueOf(id), info.titleHtml, null, info.html);
  | 
        
        
           | 1202 | 
           cyprien | 
           84 | 
           			v.set("heure", getDate());
  | 
        
        
            | 
            | 
           85 | 
           			store.add(v);
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
           | 1206 | 
           cyprien | 
           87 | 
           			//if (store.getModels().size() > nbLogs)	{
  | 
        
        
            | 
            | 
           88 | 
           				//store.remove(store.getAt(nbLogs));
  | 
        
        
            | 
            | 
           89 | 
           			//}
  | 
        
        
           | 1202 | 
           cyprien | 
           90 | 
           		}
  | 
        
        
            | 
            | 
           91 | 
           	}
  | 
        
        
            | 
            | 
           92 | 
              | 
        
        
            | 
            | 
           93 | 
           	public String getDate() {
  | 
        
        
            | 
            | 
           94 | 
           		Date date = new Date();
  | 
        
        
            | 
            | 
           95 | 
           		return String.valueOf(DateTimeFormat.getFormat("HH:mm:ss").format(date));
  | 
        
        
            | 
            | 
           96 | 
           	}
  | 
        
        
            | 
            | 
           97 | 
              | 
        
        
            | 
            | 
           98 | 
              | 
        
        
            | 
            | 
           99 | 
           	protected void createButtons() {
  | 
        
        
            | 
            | 
           100 | 
           		//Pas de boutons, merci
  | 
        
        
            | 
            | 
           101 | 
           	}
  | 
        
        
            | 
            | 
           102 | 
              | 
        
        
            | 
            | 
           103 | 
           }
  |