Rev 22 | Rev 32 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.vues;
import java.util.Date;
import java.util.HashMap;
import org.tela_botanica.client.image.ImageMediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.NameValuePair;
import com.gwtext.client.data.Store;
import com.gwtext.client.data.StringFieldDef;
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.ButtonListener;
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.GridView;
import com.gwtext.client.widgets.grid.PropertyGridPanel;
import com.gwtext.client.widgets.layout.RowLayout;
import com.gwtext.client.widgets.layout.RowLayoutData;
import com.gwtext.client.widgets.layout.VerticalLayout;
import com.gwtext.client.widgets.menu.DateItem;
import com.gwtext.client.widgets.menu.Menu;
import com.gwtext.client.widgets.tree.TreeNode;
import com.gwtext.client.widgets.tree.TreePanel;
public class PanneauMetadonneesVue extends TabPanel implements Rafraichissable {
private ImageMediateur imediateur = null ;
private PropertyGridPanel ExifGrid = null ;
private PropertyGridPanel IptcGrid = null ;
private GridView gViewExif = null ;
private GridView gViewIptc = null ;
private Panel panneauExifGrid = null;
private Panel panneauIptcGrid = null ;
private Panel panneauInfoGrid = null ;
private ArbreMotsClesVue panneauMotsCles = null ;
private TextField commentaireGeneral = null ;
private DateField dateImage = null ;
Button validerInfo = null ;
boolean estInstancie = false ;
public PanneauMetadonneesVue(ImageMediateur im)
{
super() ;
imediateur = im ;
panneauExifGrid = new Panel("Exif") ;
panneauIptcGrid = new Panel("Iptc") ;
panneauInfoGrid = new Panel("info") ;
panneauMotsCles = new ArbreMotsClesVue(im) ;
panneauInfoGrid.setLayout(new VerticalLayout());
panneauInfoGrid.setHeight(500);
Label labelComm = new Label("Commentaires :") ;
labelComm.setHeight("20px") ;
commentaireGeneral = new TextArea() ;
commentaireGeneral.setAutoWidth(true) ;
Label labelDate = new Label("Date :") ;
labelDate.setHeight("20px") ;
dateImage = new DateField() ;
dateImage.setAutoWidth(true) ;
dateImage.setFormat("d/m/y") ;
validerInfo = new Button("OK") ;
validerInfo.addListener(new ButtonListenerAdapter() {
public void onClick(Button button, EventObject e) {
getIMediateur().mettreAJourInfo(commentaireGeneral.getText(), dateImage.getRawValue()) ;
}
});
panneauInfoGrid.add(labelComm) ;
panneauInfoGrid.add(commentaireGeneral) ;
panneauInfoGrid.add(labelDate) ;
panneauInfoGrid.add(dateImage) ;
panneauInfoGrid.add(validerInfo) ;
this.add(panneauInfoGrid) ;
this.add(panneauExifGrid) ;
this.add(panneauIptcGrid) ;
this.add(panneauMotsCles) ;
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);
ExifGrid.setDisableSelection(true);
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);
this.doLayout(true) ;
}
public void desactiverPanneau()
{
this.setDisabled(true) ;
}
public void activerPanneau()
{
this.setDisabled(false) ;
}
public ImageMediateur getIMediateur()
{
return imediateur ;
}
public void rafraichir(Object nouvelleDonnees, boolean repandreRafraichissement) {
if(nouvelleDonnees instanceof Object[])
{
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)
{
exifSource[i] = new NameValuePair(exif[i][0],exif[i][1]) ;
}
if(i < iptc.length)
{
iptcSource[i] = new NameValuePair(iptc[i][0],iptc[i][1]) ;
}
}
commentaireGeneral.setValue(gen[0][1]) ;
dateImage.setValue(gen[1][1]) ;
ExifGrid.setSource(exifSource);
IptcGrid.setSource(iptcSource);
}
}
/**
* @return the panneauMotsCles
*/
public ArbreMotsClesVue getPanneauMotsCles() {
return panneauMotsCles;
}
}