Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/trunk/src/org/tela_botanica/client/vues/PanneauMetadonneesVue.java
New file
0,0 → 1,363
package org.tela_botanica.client.vues;
 
import org.tela_botanica.client.image.ImageMediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
 
import com.google.gwt.user.client.ui.Label;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.NameValuePair;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.DateField;
import com.gwtext.client.widgets.form.TextArea;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.grid.GridPanel;
import com.gwtext.client.widgets.grid.GridView;
import com.gwtext.client.widgets.grid.PropertyGridPanel;
import com.gwtext.client.widgets.grid.event.GridCellListenerAdapter;
import com.gwtext.client.widgets.layout.VerticalLayout;
 
/**
* Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
* @author aurelien
*
*/
public class PanneauMetadonneesVue extends TabPanel implements Rafraichissable {
 
/**
* Le médiateur associé à la vue
*/
private ImageMediateur imediateur = null ;
/**
* Le panneau des Exifs
*/
private PropertyGridPanel ExifGrid = null ;
/**
* Le panneau des Iptc
*/
private PropertyGridPanel IptcGrid = null ;
/**
* La grille pour le panneau des Exifs
*/
private GridView gViewExif = null ;
/**
* La grille pour le panneau de Iptc
*/
private GridView gViewIptc = null ;
/**
* L'onglet des Exifs
*/
private Panel panneauExifGrid = null;
/**
* L'onglet des Iptc
*/
private Panel panneauIptcGrid = null ;
/**
* L'onglet des infos
*/
private Panel panneauInfoGrid = null ;
/**
* L'onglet des mots clés
*/
private ArbreMotsClesVue panneauMotsCles = null ;
/**
* Le champ commentaire
*/
private TextField commentaireGeneral = null ;
/**
* Le champ date
*/
private DateField dateImage = null ;
/**
* Le bouton de validation
*/
Button validerInfo = null ;
/**
* Barre de notation
*/
BarreNotationVue noteVue = null ;
/**
* Booleen d'instanciation
*/
boolean estInstancie = false ;
/**
* Constructeur sans argument (privé car ne doit pas être utilisé)
*/
@SuppressWarnings("unused")
private PanneauMetadonneesVue()
{
super() ;
}
/**
* Constructeur avec argument
* @param im
*/
public PanneauMetadonneesVue(ImageMediateur im)
{
super() ;
// on associe le médiateur
imediateur = im ;
// on crée et dispose les panneaux et les champs
panneauExifGrid = new Panel("Exif") ;
panneauIptcGrid = new Panel("Iptc") ;
panneauInfoGrid = new Panel("info") ;
panneauMotsCles = new ArbreMotsClesVue(im) ;
panneauMotsCles.setHeight("500px") ;
Panel sousPanneauInfosGenerales = new Panel("Infos Générales") ;
sousPanneauInfosGenerales.setLayout(new VerticalLayout());
sousPanneauInfosGenerales.setBorder(false) ;
sousPanneauInfosGenerales.setHeight(200);
sousPanneauInfosGenerales.setAutoWidth(true) ;
sousPanneauInfosGenerales.setMargins(5) ;
sousPanneauInfosGenerales.setPaddings(5) ;
sousPanneauInfosGenerales.setCollapsible(true) ;
Label labelComm = new Label("Commentaires :") ;
labelComm.setHeight("20px") ;
commentaireGeneral = new TextArea() ;
commentaireGeneral.setWidth("90%") ;
Label labelDate = new Label("Date :") ;
Label labelNote = new Label("Note :") ;
panneauMotsCles.setBorder(false) ;
labelDate.setHeight("20px") ;
dateImage = new DateField() ;
dateImage.setAutoWidth(true) ;
dateImage.setFormat("d/m/Y") ;
validerInfo = new Button("OK") ;
noteVue = new BarreNotationVue(im, 5) ;
sousPanneauInfosGenerales.add(labelComm) ;
sousPanneauInfosGenerales.add(commentaireGeneral) ;
sousPanneauInfosGenerales.add(labelDate) ;
sousPanneauInfosGenerales.add(dateImage) ;
sousPanneauInfosGenerales.add(labelNote) ;
sousPanneauInfosGenerales.add(noteVue) ;
sousPanneauInfosGenerales.add(validerInfo) ;
sousPanneauInfosGenerales.setAutoHeight(true);
panneauMotsCles.setAutoHeight(true) ;
panneauInfoGrid.setBorder(false);
panneauInfoGrid.setAutoHeight(true);
panneauInfoGrid.add(sousPanneauInfosGenerales) ;
panneauInfoGrid.add(panneauMotsCles) ;
this.add(panneauInfoGrid) ;
this.add(panneauExifGrid) ;
this.add(panneauIptcGrid) ;
gViewExif = new GridView();
gViewExif.setForceFit(true);
ExifGrid = new PropertyGridPanel() ;
ExifGrid.setId("meta_exif");
ExifGrid.setView(gViewExif);
ExifGrid.setNameText("Métadonnées Exif");
ExifGrid.setAutoWidth(true);
ExifGrid.setAutoHeight(true);
ExifGrid.setSorted(false);
gViewIptc = new GridView();
gViewIptc.setForceFit(true);
IptcGrid = new PropertyGridPanel() ;
IptcGrid.setId("meta_iptc");
IptcGrid.setView(gViewIptc);
IptcGrid.setNameText("Métadonnées IPTC");
IptcGrid.setAutoWidth(true);
IptcGrid.setAutoHeight(true);
IptcGrid.setSorted(false);
panneauExifGrid.add(ExifGrid);
panneauIptcGrid.add(IptcGrid);
// on ajoute les listeners
ajouterListeners() ;
// on effectue le rendu
this.doLayout(true) ;
}
private void ajouterListeners()
{
// on ajoute un écouteur
validerInfo.addListener(new ButtonListenerAdapter() {
 
// gestion du clic
public void onClick(Button button, EventObject e) {
button.focus() ;
// lors du clic sur le bouton valider on met à jour les commentaires et la date
getIMediateur().mettreAJourInfo(commentaireGeneral.getText(), dateImage.getRawValue(), noteVue.getNote()) ;
}
});
// gestion des clics dans la grille
ExifGrid.addGridCellListener(new GridCellListenerAdapter() {
 
// lors d'un clic d'une cellule
public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
EventObject e) {
// on empeche l'édition
e.stopEvent() ;
ExifGrid.stopEditing() ;
}
 
// lors du double clic sur une cellule
public void onCellDblClick(GridPanel grid, int rowIndex,
int colIndex, EventObject e) {
// on empêche l'édition
e.stopEvent() ;
ExifGrid.stopEditing() ;
}
}) ;
IptcGrid.addGridCellListener(new GridCellListenerAdapter() {
 
// lors d'un clic d'une cellule
public void onCellClick(GridPanel grid, int rowIndex, int colIndex,
EventObject e) {
// on empeche l'édition
e.stopEvent() ;
ExifGrid.stopEditing() ;
}
 
// lors d'un double clic d'une cellule
public void onCellDblClick(GridPanel grid, int rowIndex,
int colIndex, EventObject e) {
// on empeche l'édition
e.stopEvent() ;
ExifGrid.stopEditing() ;
}
}) ;
}
/**
* Desactive visuellement ce panneau
*/
public void desactiverPanneau()
{
this.setDisabled(true) ;
}
/**
* Active visuellement ce panneau
*/
public void activerPanneau()
{
this.setDisabled(false) ;
}
/**
* Accesseur pour le médiateur
* @return le médiateur associé à la vue
*/
public ImageMediateur getIMediateur()
{
return imediateur ;
}
/**
* Méthode héritée de l'interface rafraichissable
* @param nouvelleDonnees les nouvelles données
* @param repandreRafraichissement le booleen de notification de mise à jour
*/
public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
// si on reçoit un tableau d'objets
if(nouvelleDonnees instanceof Object[])
{
// extrait infos, exifs et iptc
Object meta[] = (Object[])nouvelleDonnees ;
String[][] exif = (String[][])meta[0] ;
String[][] iptc = (String[][])meta[1] ;
String[][] gen = (String[][])meta[2] ;
NameValuePair[] exifSource = new NameValuePair[exif.length] ;
NameValuePair[] iptcSource = new NameValuePair[iptc.length] ;
int maxLength ;
if(exif.length <= iptc.length)
{
maxLength = iptc.length ;
}
else
{
maxLength = exif.length ;
}
for(int i = 0; i < maxLength ; i++)
{
if(i < exif.length && !exif[i][0].equals("null"))
{
exifSource[i] = new NameValuePair(exif[i][0],exif[i][1]) ;
}
if(i < iptc.length && !iptc[i][0].equals("null"))
{
iptcSource[i] = new NameValuePair(iptc[i][0],iptc[i][1]) ;
}
}
// on met à jour les champs avec la bonne valeur
commentaireGeneral.setValue(gen[0][1]) ;
dateImage.setRawValue(gen[1][1]) ;
// et on met à jour les données pour l'affichage
ExifGrid.setSource(exifSource);
IptcGrid.setSource(iptcSource);
 
}
}
 
/**
* Accesseur pour le panneau des mots clés
* @return the panneauMotsCles
*/
public ArbreMotsClesVue getPanneauMotsCles() {
return panneauMotsCles;
}
public BarreNotationVue getNoteVue() {
return noteVue ;
}
}