From: <emm...@us...> - 2008-10-21 09:36:33
|
Revision: 4085 http://fudaa.svn.sourceforge.net/fudaa/?rev=4085&view=rev Author: emmanuel_martin Date: 2008-10-21 08:36:50 +0000 (Tue, 21 Oct 2008) Log Message: ----------- pr?\195?\169 commit sur la modification du panel d'information Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BCalquePaletteInfo.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/palette/BPaletteInfo.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BCalquePaletteInfo.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BCalquePaletteInfo.java 2008-10-20 16:31:59 UTC (rev 4084) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BCalquePaletteInfo.java 2008-10-21 08:36:50 UTC (rev 4085) @@ -7,12 +7,13 @@ */ package org.fudaa.ebli.calque; +import java.util.ArrayList; + import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; -import org.fudaa.ctulu.CtuluLibMessage; import org.fudaa.ctulu.CtuluLibString; - +import org.fudaa.ebli.commun.EbliLib; import org.fudaa.ebli.palette.BPaletteInfo; /** * Un panel affichant les infos envoyes par TrPanelInfoSender. @@ -21,63 +22,108 @@ */ public class BCalquePaletteInfo extends BPaletteInfo implements TreeSelectionListener, ZSelectionListener { - BCalque layer_; - BArbreCalqueModel m_; + private ArrayList<ZCalqueAffichageDonneesInterface> calqueWithGeometriesSelected_; + private BArbreCalqueModel treeModel_; - /** - * - */ + private class CalqueVisitor implements BCalqueVisitor { + private ArrayList<ZCalqueAffichageDonneesInterface> calques=new ArrayList<ZCalqueAffichageDonneesInterface>(); + public boolean visit(BCalque _cq) { + if(_cq instanceof ZCalqueAffichageDonneesInterface) + calques.add((ZCalqueAffichageDonneesInterface)_cq); + return true; + } + public ZCalqueAffichageDonneesInterface[] getCalques(){ + return calques.toArray(new ZCalqueAffichageDonneesInterface[0]); + } + } + public BCalquePaletteInfo(final BArbreCalqueModel _m) { super(); - m_ = _m; - m_.addTreeSelectionListener(this); + treeModel_ = _m; + treeModel_.addTreeSelectionListener(this); + + calqueWithGeometriesSelected_=new ArrayList<ZCalqueAffichageDonneesInterface>(); + ZCalqueAffichageDonneesInterface[] calques = getCalques(); + for(int i=0;i<calques.length;i++) + calques[i].addSelectionListener(this); } - /** - * + * @return les calques de type ZCalqueAffichageDonneesInterface contenus dans l'arbre de calque. */ - public void selectionChanged(final ZSelectionEvent _evt){ - if (isAvailable() && (_evt.getSource() == layer_) && layer_ != null) { - txtTitle_.setText(CtuluLibString.EMPTY_STRING); - tableModel_.clear(); - layer_.fillWithInfo(tableModel_); + private ZCalqueAffichageDonneesInterface[] getCalques(){ + CalqueVisitor visitor=new CalqueVisitor(); + treeModel_.getRootCalque().apply(visitor); + return visitor.getCalques(); + } + + /** + * Met \xE0 jour les informations contenues dans le tableau. + */ + private void updateTableModel(){ + // Suppression des anciennes informations + txtTitle_.setText(CtuluLibString.EMPTY_STRING); + tableModel_.clear(); + // Ajout des nouvelles informations \\ + // Informations g\xE9n\xE9rales + ZCalqueAffichageDonneesInterface[] calques = getCalques(); + int nbGeom=0; + int nbGeomSelected=0; + for(int i=0;i<calques.length;i++){ + nbGeom+=calques[i].modeleDonnees().getNombre(); + if(calques[i].getLayerSelection()!=null) + nbGeomSelected+=calques[i].getLayerSelection().getNbSelectedIndex(); + } + if(nbGeomSelected>0) + tableModel_.put(EbliLib.getS("nombre total de s\xE9lections"), Integer.toString(nbGeomSelected)+"/"+Integer.toString(nbGeom)); + // Informations relatives aux calques + switch (calqueWithGeometriesSelected_.size()) { + case 0: + treeModel_.getSelectedCalque().fillWithInfo(tableModel_); tableModel_.fireTableDataChanged(); - updateSize(); - + break; + case 1: + calqueWithGeometriesSelected_.get(0).fillWithInfo(tableModel_); + tableModel_.fireTableDataChanged(); + break; + default: + tableModel_.setTitle(EbliLib.getS("Selection Multicalque")); } + updateSize(); } - - public void updateState(){ - if (!isAvailable()) { - return; - } - if (CtuluLibMessage.DEBUG) { - CtuluLibMessage.debug(getClass().getName() + " maj info"); - } - final BCalque newLa= m_.getSelectedCalque(); - if (newLa != layer_) { - if (layer_ != null) { - layer_.removeSelectionListener(this); + public void selectionChanged(final ZSelectionEvent _evt) { + if (isAvailable()) { + if (_evt.getSource().getLayerSelection()!=null&&_evt.getSource().getLayerSelection().getNbSelectedIndex()>0) { + if (!calqueWithGeometriesSelected_.contains(_evt.getSource())) + calqueWithGeometriesSelected_.add(_evt.getSource()); } - if (newLa != null) { - newLa.addSelectionListener(this); + else { + if (calqueWithGeometriesSelected_.contains(_evt.getSource())) + calqueWithGeometriesSelected_.remove(_evt.getSource()); } + updateTableModel(); } - layer_ = newLa; - tableModel_.clear(); - txtTitle_.setText(CtuluLibString.EMPTY_STRING); - if (layer_ != null) { - layer_.fillWithInfo(tableModel_); - } - tableModel_.fireTableDataChanged(); - updateSize(); } - public void valueChanged(final TreeSelectionEvent _e){ + + public void updateState() { if (isAvailable()) { - updateState(); + calqueWithGeometriesSelected_.clear(); + // R\xE9cup\xE9ration des calques ayant une selection + ZCalqueAffichageDonneesInterface[] calques=getCalques(); + for (int i=0; i<calques.length; i++) + if (calques[i].getLayerSelection()!=null&&calques[i].getLayerSelection().getNbSelectedIndex()>0) + calqueWithGeometriesSelected_.add(calques[i]); + // Mise \xE0 jour du tableau des informations + updateTableModel(); } } + + + + public void valueChanged(final TreeSelectionEvent _e) { + if (isAvailable()&&calqueWithGeometriesSelected_.size()==0) + updateTableModel(); + } } \ No newline at end of file Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java 2008-10-20 16:31:59 UTC (rev 4084) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java 2008-10-21 08:36:50 UTC (rev 4085) @@ -111,6 +111,7 @@ public void fillWithInfo(final InfoData _m) { if (_m != null) { final BCalque[] cqs = getCalques(); + _m.setTitle(getTitle()); _m.put(EbliLib.getS("Nombre de calques"), cqs == null ? CtuluLibString.ZERO : CtuluLibString .getString(cqs.length)); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/palette/BPaletteInfo.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/palette/BPaletteInfo.java 2008-10-20 16:31:59 UTC (rev 4084) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/palette/BPaletteInfo.java 2008-10-21 08:36:50 UTC (rev 4085) @@ -57,12 +57,12 @@ */ public final class PanelTableModel extends AbstractTableModel implements InfoData { - private List name_; - private List value_; + private List<String> name_; + private List<String> value_; public PanelTableModel() { - name_ = new ArrayList(); - value_ = new ArrayList(); + name_ = new ArrayList<String>(); + value_ = new ArrayList<String>(); } public void clear() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |