Subversion Repositories eFlore/Applications.cel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 2756 → Rev 2757

/branches/v2.23-rouleau/src/org/tela_botanica/client/vues/image/PanneauMetadonneesVue.java
New file
0,0 → 1,526
package org.tela_botanica.client.vues.image;
 
import org.tela_botanica.client.i18n.Msg;
import org.tela_botanica.client.image.ImageMediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.vues.image.ImageMotsClesVue;
import org.tela_botanica.client.vues.image.filtres.RechercheFiltreTaxonVue;
 
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Ext;
import com.gwtext.client.core.NameValuePair;
import com.gwtext.client.widgets.BoxComponent;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Component;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.TabPanel;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
import com.gwtext.client.widgets.event.PanelListenerAdapter;
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.RowLayout;
import com.gwtext.client.widgets.layout.RowLayoutData;
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 ImageMotsClesVue panneauMotsCles = null;
/**
* l'onglet des observations
*/
private Panel panneauMiniListeObservation = null;
 
/**
* Le champ commentaire
*/
private TextField commentaireGeneral = null;
/**
* Le champ date
*/
private DateField dateImage = null;
/**
* La barre de recherche rapide des taxons
*/
private RechercheFiltreTaxonVue rechercheFiltreTaxonVue = null;
/**
* La mini liste des observations
*/
private MiniListeObservationVue miniListeObservation = null ;
/**
* Le bouton de validation
*/
Button validerInfo = null;
 
/**
* Barre de notation
*/
BarreNotationVue noteVue = null;
 
/**
* Booleen d'instanciation
*/
boolean estInstancie = false;
Timer timerRedimensionnement = null;
 
/**
* 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();
// TODO : un bug mystérieux n'apparait que lorsqu'on compile
// en obfuscated et empêche de consulter les exifs et iptc
 
// on associe le médiateur
imediateur = im;
 
// on crée et dispose les panneaux et les champs
panneauExifGrid = new Panel(Msg.get("infos-exif"));
panneauIptcGrid = new Panel(Msg.get("infos-iptc"));
panneauInfoGrid = new Panel(Msg.get("infos-generales"));
panneauMotsCles = new ImageMotsClesVue(im);
panneauMotsCles.setHeight("50%");
 
Panel sousPanneauInfosGenerales = new Panel(Msg.get("infos-generales"));
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(Msg.get("commentaires")+" :");
labelComm.setHeight("20px");
commentaireGeneral = new TextArea();
commentaireGeneral.setWidth("90%");
Label labelDate = new Label(Msg.get("date")+" :");
Label labelNote = new Label(Msg.get("note")+" :");
 
panneauMotsCles.setBorder(false);
 
labelDate.setHeight("20px");
 
dateImage = new DateField();
dateImage.setAutoWidth(true);
dateImage.setFormat("d/m/Y");
 
validerInfo = new Button(Msg.get("ok"));
 
noteVue = new BarreNotationVue(im, 5);
panneauMiniListeObservation = new Panel(Msg.get("observations")) ;
if(!Ext.isIE()) {
panneauMiniListeObservation.setLayout(new RowLayout());
}
miniListeObservation = new MiniListeObservationVue(im);
rechercheFiltreTaxonVue = new RechercheFiltreTaxonVue(im);
rechercheFiltreTaxonVue.setTitle(Msg.get("recherche-dans-observations"));
if(Ext.isIE()) {
panneauMiniListeObservation.add(rechercheFiltreTaxonVue);
rechercheFiltreTaxonVue.setHeight(90);
} else {
panneauMiniListeObservation.add(rechercheFiltreTaxonVue, new RowLayoutData(90));
}
rechercheFiltreTaxonVue.setWidth("100%") ;
rechercheFiltreTaxonVue.setBorder(false);
if(Ext.isIE()) {
panneauMiniListeObservation.add(miniListeObservation, new RowLayoutData(400)) ;
} else {
panneauMiniListeObservation.add(miniListeObservation, new RowLayoutData()) ;
}
 
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);
panneauExifGrid.setAutoScroll(true);
panneauIptcGrid.setAutoScroll(true);
 
panneauInfoGrid.add(sousPanneauInfosGenerales);
panneauInfoGrid.add(panneauMotsCles);
 
this.add(panneauMiniListeObservation) ;
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(Msg.get("exif-metadonnees"));
ExifGrid.setAutoWidth(true);
ExifGrid.setHeight(500);
ExifGrid.setSorted(false);
ExifGrid.setAutoScroll(true);
 
gViewIptc = new GridView();
gViewIptc.setForceFit(true);
 
IptcGrid = new PropertyGridPanel();
IptcGrid.setId("meta_iptc");
IptcGrid.setView(gViewIptc);
 
IptcGrid.setNameText(Msg.get("iptc-metadonnees"));
IptcGrid.setAutoWidth(true);
IptcGrid.setHeight(500);
IptcGrid.setSorted(false);
IptcGrid.setAutoScroll(true);
 
panneauExifGrid.add(ExifGrid);
panneauIptcGrid.add(IptcGrid);
 
// on ajoute les listeners
ajouterListeners();
}
 
private void ajouterListeners() {
// on ajoute un écouteur
validerInfo.addListener(new ButtonListenerAdapter() {
 
// gestion du clic
 
@Override
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
 
@Override
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
 
@Override
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
 
@Override
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
@Override
public void onCellDblClick(GridPanel grid, int rowIndex,
int colIndex, EventObject e) {
// on empeche l'édition
e.stopEvent();
ExifGrid.stopEditing();
 
}
 
});
panneauMiniListeObservation.addListener(new ContainerListenerAdapter() {
@Override
public void onResize(BoxComponent component, int adjWidth, int adjHeight,
int rawWidth, int rawHeight) {
timerRedimensionnement = new Timer() {
@Override
public void run() {
int taille = 500;
if(Window.getClientHeight() > 800 ) {
taille = Window.getClientHeight() - 226;
}
panneauMiniListeObservation.setHeight(taille);
}
};
timerRedimensionnement.schedule(300);
}
});
panneauExifGrid.addListener(new ContainerListenerAdapter() {
@Override
public void onResize(BoxComponent component, int adjWidth, int adjHeight,
int rawWidth, int rawHeight) {
timerRedimensionnement = new Timer() {
@Override
public void run() {
int taille = 500;
taille = Window.getClientHeight() - 150;
ExifGrid.setHeight(taille);
panneauExifGrid.setHeight(taille);
}
};
timerRedimensionnement.schedule(300);
}
});
panneauExifGrid.addListener(new ContainerListenerAdapter() {
@Override
public void onResize(BoxComponent component, int adjWidth, int adjHeight,
int rawWidth, int rawHeight) {
timerRedimensionnement = new Timer() {
@Override
public void run() {
int taille = 500;
taille = Window.getClientHeight() - 150;
IptcGrid.setHeight(taille);
panneauIptcGrid.setHeight(taille);
}
};
timerRedimensionnement.schedule(300);
}
});
}
 
/**
* Desactive visuellement ce panneau
*/
public void desactiverPanneau() {
panneauInfoGrid.setDisabled(true);
panneauExifGrid.setDisabled(true);
panneauIptcGrid.setDisabled(true);
}
 
/**
* Active visuellement ce panneau
*/
public void activerPanneau() {
panneauInfoGrid.setDisabled(false);
panneauExifGrid.setDisabled(false);
panneauIptcGrid.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
*/
@Override
public void rafraichir(Object nouvelleDonnees,
boolean repandreRafraichissement) {
 
// si on reçoit un tableau d'objets
if (nouvelleDonnees instanceof Object[]) {
final Object ressourceObject = nouvelleDonnees;
if(!this.isRendered()) {
addListener(new PanelListenerAdapter() {
@Override
public void onRender(Component component) {
rafraichir(ressourceObject, false);
}
});
return ;
}
// extrait infos, exifs et iptc
Object meta[] = (Object[]) nouvelleDonnees;
String[][] exif = (String[][]) meta[0];
String[][] iptc = (String[][]) meta[1];
final 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.setValue(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 ImageMotsClesVue getPanneauMotsCles() {
return panneauMotsCles;
}
 
public BarreNotationVue getNoteVue() {
return noteVue;
}
public MiniListeObservationVue getMiniListeObservation()
{
return miniListeObservation ;
}
public RechercheFiltreTaxonVue getRechercheFiltreTaxonVue()
{
return rechercheFiltreTaxonVue ;
}
 
public void redimensionner() {
if(panneauMiniListeObservation.isCreated() && panneauMiniListeObservation.isVisible()) {
panneauMiniListeObservation.doLayout();
//panneauMiniListeObservation.show();
miniListeObservation.redimensionner();
}
}
}
Property changes:
Added: svn:mergeinfo