From: <had...@us...> - 2009-01-27 17:13:02
|
Revision: 4412 http://fudaa.svn.sourceforge.net/fudaa/?rev=4412&view=rev Author: hadouxad Date: 2009-01-27 17:12:46 +0000 (Tue, 27 Jan 2009) Log Message: ----------- - Refonte totale de l'affichage des multi-fichiers: passage en swingx table-tree + design patter observer/observable -> permet d'afficher la liste des fichier r?\195?\169sultat pour un source donn?\195?\169 (m?\195?\169ga utile pour composite) -> plus jolie -> modif des suppressions: on force l'utilisateur a choisir un r?\195?\169pertoire(noeud non feuille=trpostSource) et non un fichier(feuille= File ) - Refactorisation id: IL FAUT LE METTRE DANS LES READER ET PAS LES SOURCES!!! -> les id sont stock?\195?\169s dans les reader et les TrPostSourceFromReader vont piocher dedans (surcharge de m?\195?\169thode) -> permet pour la persistance des donn?\195?\169es de g?\195?\169rer facilement les id des fichiers du composite: ils sont dans les readers. - PERSISTANCE DES SUITES DE CALCUL -> En attendant les retours de Didier, c'est positionn?\195?\169 dans le fichier SETUP, dans la balise SUITECALCUL:$ -> principe: - liste des id des fichiers r?\195?\169sultats qui sont utilis?\195?\169s - L'ID de la suite (MEGA IMPORTANT: est utilis?\195?\169 pour rep?\195?\169rer les ebliwidgetVueCalque qui utilise notre amie la suite de calcul) - ALGORITHME utilis?\195?\169: - RECHARGE 2 par 2 les fichiers pour faire une suites - Comme cela si a un moment il y a un probl?\195?\168me (fichier foireux) cela retourne la suite de calcul partielle MAIS VALIDE ! - Trie du tableau d affichage d infos de la vue 2d - Ajout des bonnes infos pour les cr?\195?\169ation de calques - Possibilit?\195?\169 de g?\195?\169rer le fichier virtuel composite comme un src normal: -> changement du nom en suite de calcul dans les onglets -> on peut ajouter une vue2d avec la fonction classique - MODIF de l'algorithme des suite de calculs: Intersection de pas de variable et non plus union au terme ensembliste. Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetsManagerFille.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderComposite.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderFromFileAbstract.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderInterface.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderReflux.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderSerafin.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionChooseAndCreateCalque.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionOpenSrc.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionRemoveSrc.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/data/TrPostDataCreatedExpr.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/persist/TrPostPersistenceManager.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/commun/EbliModelInfos.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostFlecheContentExpr.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourcePersistComposite.java Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java 2009-01-27 16:38:58 UTC (rev 4411) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -23,6 +23,8 @@ import java.awt.print.PageFormat; import java.awt.print.Printable; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -58,6 +60,7 @@ import org.fudaa.ebli.commun.EbliComponentFactory; import org.fudaa.ebli.commun.EbliFormatterInterface; import org.fudaa.ebli.commun.EbliLib; +import org.fudaa.ebli.commun.EbliModelInfos; import org.fudaa.ebli.find.EbliFindDialog; import org.fudaa.ebli.find.EbliFindable; import org.fudaa.ebli.find.EbliFindableItem; @@ -1032,91 +1035,15 @@ if(infosCreation_==null || infosCreation_.keySet()==null ||infosCreation_.keySet().size()==0) return new BuPanel(); - - String[] names=new String[]{"Nom","Valeur"};//infosCreation_.keySet().toArray(new String[infosCreation_.keySet().size()]); - String[][] data=new String[infosCreation_.keySet().size()][2]; - int i=0; - for(String key:infosCreation_.keySet()){ - data[i][0]=key; - data[i][1]=infosCreation_.get(key); - i++; - } + List<String> liste=new ArrayList<String>(infosCreation_.keySet()); + Collections.sort(liste); + List<String> col=new ArrayList<String>(); + col.add(EbliResource.EBLI.getString("Nom")); + col.add(EbliResource.EBLI.getString("Valeur")); + + EbliModelInfos modelInfos=new EbliModelInfos(liste,infosCreation_,col); + BuTable table=new BuTable(modelInfos); - DefaultTableModel modelInfos=new DefaultTableModel(data,names){ - - @Override - public int getRowCount() { - // TODO Auto-generated method stub - return infosCreation_.keySet().size()+1; - } - - @Override - public Object getValueAt(int row, int column) { - - if(row==getRowCount()-1){ - if(column==0) - return EbliResource.EBLI.getString("Editable"); - else - return EbliResource.EBLI.getString("Double-cliquez pour \xE9diter"); - }else - if(column==0) - return getKey(row); - else - return getValue(row); - - } - - @Override - public void setValueAt(Object value, int row, int column) { - - if(value==null)return; - - if(row==getRowCount()-1 && !((String)value).equals(EbliResource.EBLI.getString("Editable"))){ - //-- ajout --// - if(column==1) - infosCreation_.put("Note "+(infosCreation_.keySet().size()+1),(String)value); - else - infosCreation_.put((String)value,""); - - fireTableDataChanged(); - - }else{ - //-- modification --// - if(column==0){ - String res=infosCreation_.get(getKey(row)); - infosCreation_.remove(getKey(row)); - infosCreation_.put((String)value, res); - }else{ - infosCreation_.put(getKey(row),(String)value); - } - fireTableDataChanged(); - } - } - public String getKey(int row){ - int i=0; - if(row>=infosCreation_.keySet().size()) - return ""; - for(String key:infosCreation_.keySet()){ - if(i==row) - return key; - i++; - - } - return ""; - } - - public String getValue(int row){ - return infosCreation_.get(getKey(row)); - } - - @Override - public boolean isCellEditable(int row, int column) { - return true; - } - - }; - BuTable table=new BuTable(modelInfos); - table.getColumnModel().getColumn(0).setPreferredWidth(20); BuPanel conteneur=new BuPanel(new BorderLayout()); conteneur.add(new JScrollPane(table),BorderLayout.CENTER); @@ -1125,5 +1052,6 @@ return conteneur; } + } \ No newline at end of file Added: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/commun/EbliModelInfos.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/commun/EbliModelInfos.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/commun/EbliModelInfos.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -0,0 +1,159 @@ +package org.fudaa.ebli.commun; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; + +import javax.swing.event.TableModelListener; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; + +import org.fudaa.ebli.ressource.EbliResource; + + +/** + * Modele de tableau qui utilise une map <str, str>. + * Affiche des couple clef/valeurs de la map tri\xE9es. + * Utilis\xE9 en particulier pour les infos de creation des extends zeblicalquePanel. + * Prend en charge l'\xE9dition dans la map. + * Organise les infos par ordre lexicographique. + * Pour changer le trie a sa guise, faire son comparator et le placer dans le bon constructeur. + * @author Adrien Hadoux + * + */ +public class EbliModelInfos extends AbstractTableModel{ + + private static final long serialVersionUID = -2080709568281587469L; + private List<String> listeKey_; + private final List<String> colonnes_; + /** + * Les infos de la table. + */ + private Map<String,String> infos_; + private final Comparator<String> comparator_; + + public EbliModelInfos(List<String> liste,Map<String,String> map,List<String> colonnes){ + + this(liste,map,colonnes,null); + } + + public EbliModelInfos(List<String> liste,Map<String,String> map,List<String> colonnes,Comparator<String> comparator){ + super(); + listeKey_=liste; + infos_=map; + comparator_=comparator; + colonnes_=colonnes; + } + + + @Override + public String getColumnName(int column) { + // TODO Auto-generated method stub + return colonnes_.get(column); + } + + public int getRowCount() { + // TODO Auto-generated method stub + return infos_.keySet().size()+1; + } + + public Object getValueAt(int row, int column) { + + if(row==getRowCount()-1){ + if(column==0) + return EbliResource.EBLI.getString("Editable"); + else + return EbliResource.EBLI.getString("Double-cliquez pour \xE9diter"); + }else + + if(column==0) + return getKey(row); + else + return getValue(row); + + } + + + public void setValueAt(Object value, int row, int column) { + + if(value==null)return; + + if(row==getRowCount()-1 && !((String)value).equals(EbliResource.EBLI.getString("Editable"))){ + //-- ajout --// + if(column==1) + infos_.put("Note "+(infos_.keySet().size()+1),(String)value); + else + infos_.put((String)value,""); + + fireTableDataChanged(); + + }else{ + //-- modification --// + if(column==0){ + String res=infos_.get(getKey(row)); + infos_.remove(getKey(row)); + infos_.put((String)value, res); + }else{ + infos_.put(getKey(row),(String)value); + } + fireTableDataChanged(); + } + } + public String getKey(int row){ + + if(row>=infos_.keySet().size()) + return ""; + return listeKey_.get(row); + } + + + + public void fireTableDataChanged() { + + //-- on modif le tableau --// + listeKey_=new ArrayList<String>(infos_.keySet()); + //-- on ordonne la liste + if(comparator_==null) + Collections.sort(listeKey_); + else + Collections.sort(listeKey_,comparator_); + super.fireTableDataChanged(); + } + + public String getValue(int row){ + return infos_.get(getKey(row)); + } + + @Override + public boolean isCellEditable(int row, int column) { + return true; + } + + @Override + public void addTableModelListener(TableModelListener l) { + // TODO Auto-generated method stub + + } + + @Override + public Class<?> getColumnClass(int columnIndex) { + // TODO Auto-generated method stub + return String.class; + } + + @Override + public int getColumnCount() { + // TODO Auto-generated method stub + return colonnes_.size(); + } + + @Override + public void removeTableModelListener(TableModelListener l) { + // TODO Auto-generated method stub + + } + +} \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java 2009-01-27 16:38:58 UTC (rev 4411) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -10,6 +10,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -30,246 +31,319 @@ */ public class TrPostBuilderSuiteCalcul { - /** - * Action qui r\xE9alise la suite de calcul. - * - * @author Adrien Hadoux - */ - public static class ActionBuildSuite extends EbliActionSimple { + /** + * Action qui r\xE9alise la suite de calcul. + * + * @author Adrien Hadoux + */ + public static class ActionBuildSuite extends EbliActionSimple { - TrPostSource src_; - TrPostCommonImplementation impl_; + TrPostSource src_; + TrPostCommonImplementation impl_; - public ActionBuildSuite(TrPostSource src, String _name, Icon _ic, String _ac, TrPostCommonImplementation impl) { - super(_name, _ic, _ac); - // TODO Auto-generated constructor stub - src_ = src; - src_ = src; - impl_ = impl; - } + public ActionBuildSuite(TrPostSource src, String _name, Icon _ic, String _ac, TrPostCommonImplementation impl) { + super(_name, _ic, _ac); + // TODO Auto-generated constructor stub + src_ = src; + src_ = src; + impl_ = impl; + } - public void actionPerformed(ActionEvent _e) { + public void actionPerformed(ActionEvent _e) { - // -- test de comptabilit\xE9 de fichier source --// - if (!isCompatibleSuiteCalcul(src_)) { - impl_.error(TrResource.getS("Le fichier n'est pas valide.")); - return; - } + // -- test de comptabilit\xE9 de fichier source --// + if (!isCompatibleSuiteCalcul(src_)) { + impl_.error(TrResource.getS("Le fichier n'est pas valide.")); + return; + } - // -- on lance la dialog de choix des fichiers sources --// - final TrPostSource srcChoisie = impl_.getCurrentProject().getChooserMultiSources(-1); - if (srcChoisie == null) { - impl_.error(TrResource.getS(TrResource.getS("Aucune source choisie"))); - return; - } + // -- on lance la dialog de choix des fichiers sources --// + final TrPostSource srcChoisie = impl_.getCurrentProject().getChooserMultiSources(-1); + if (srcChoisie == null) { + impl_.error(TrResource.getS(TrResource.getS("Aucune source choisie"))); + return; + } - if (!isCompatibleSuiteCalcul(srcChoisie)) { - impl_.error(TrResource.getS("Le fichier n'est pas valide.")); - return; - } + if (!isCompatibleSuiteCalcul(srcChoisie)) { + impl_.error(TrResource.getS("Le fichier n'est pas valide.")); + return; + } - List<String> error = new ArrayList<String>(); + List<String> error = new ArrayList<String>(); - // -- creation de la suite de calcul --// - TrPostSource suiteCalcul = createSuiteCalcul((TrPostSourceFromReader) src_, impl_, - (TrPostSourceFromReader) srcChoisie, error); + // -- creation de la suite de calcul --// + TrPostSource suiteCalcul = createSuiteCalcul((TrPostSourceFromReader) src_, impl_, + (TrPostSourceFromReader) srcChoisie, error); - if (suiteCalcul == null) { - // -- il se passe des choses \xE9tranges.... --// - String maxiStringLeo = ""; - for (String err : error) - maxiStringLeo += err + "\n"; + if (suiteCalcul == null) { + // -- il se passe des choses \xE9tranges.... --// + String maxiStringLeo = ""; + for (String err : error) + maxiStringLeo += err + "\n"; - impl_.error(maxiStringLeo); - return; - } + impl_.error(maxiStringLeo); + return; + } - // -- on ajoute la nouvelle src r\xE9sultat comme \xE9tant une suite de calcul --// + // -- on ajoute la nouvelle src r\xE9sultat comme \xE9tant une suite de calcul --// - impl_.c_.ajouterSource(suiteCalcul); + impl_.c_.ajouterSource(suiteCalcul,suiteCalcul.getTitle()); - // -- on cree la vue 2d correspondante --// + // -- on cree la vue 2d correspondante --// - TrPostProjet projet = impl_.getCurrentProject(); - TrPostLayoutPanelController controller = impl_.getCurrentLayoutFille().controller_; - final CalqueLegendeWidgetAdapter legendeCalque = new CalqueLegendeWidgetAdapter(controller.getSceneCourante(), - null); - final TrPostVisuPanel pnVisu = new TrPostVisuPanel(projet.getImpl(), projet, legendeCalque, suiteCalcul); - final EbliNode node = controller.addCalque(TrResource.getS("Calque") - + (controller.getSceneCourante().getAllVue2d().size() + 1), pnVisu.getLocation(), pnVisu.getPreferredSize(), - pnVisu, legendeCalque); - // -- ajout de l INFO de la source utilis\xE9e --// - node.getWidget().getController().setDescription("Source: " + projet.formatInfoSource(srcChoisie)); + TrPostProjet projet = impl_.getCurrentProject(); + TrPostLayoutPanelController controller = impl_.getCurrentLayoutFille().controller_; + final CalqueLegendeWidgetAdapter legendeCalque = new CalqueLegendeWidgetAdapter(controller.getSceneCourante(), + null); + final TrPostVisuPanel pnVisu = new TrPostVisuPanel(projet.getImpl(), projet, legendeCalque, suiteCalcul); + final EbliNode node = controller.addCalque(TrResource.getS("Calque") + + (controller.getSceneCourante().getAllVue2d().size() + 1), pnVisu.getLocation(), pnVisu.getPreferredSize(), + pnVisu, legendeCalque); + // -- ajout de l INFO de la source utilis\xE9e --// + node.getWidget().getController().setDescription(suiteCalcul.getTitle()); - // -- ajout des infos de cr\xE9ation --// + // -- ajout des infos de cr\xE9ation --// - TrPostSourceReaderComposite.fillInfosWithComposite(pnVisu.infosCreation_, - (TrPostSourceReaderComposite) ((TrPostSourceFromReader) suiteCalcul).getReader()); + TrPostSourceReaderComposite.fillInfosWithComposite(pnVisu.infosCreation_, + (TrPostSourceReaderComposite) ((TrPostSourceFromReader) suiteCalcul).getReader()); - } + } - } + } - /** - * R\xE9cup\xE9rer l'interface \xE0 partir du fichier - * - * @param _f - * @param _impl - * @return - */ - public static TrPostSourceFromReader createSourceFromeFile(File _f, TrPostCommonImplementation _impl) { - TrPostSource src = TrPostSourceBuilder.activeSourceAction(_f, _impl, _impl.getMainProgression()); - if (src != null && src instanceof TrPostSourceFromReader) return ((TrPostSourceFromReader) src); - return null; + /** + * R\xE9cup\xE9rer l'interface \xE0 partir du fichier + * + * @param _f + * @param _impl + * @return + */ + public static TrPostSourceFromReader createSourceFromeFile(File _f, TrPostCommonImplementation _impl) { + TrPostSource src = TrPostSourceBuilder.activeSourceAction(_f, _impl, _impl.getMainProgression()); + if (src != null && src instanceof TrPostSourceFromReader) return ((TrPostSourceFromReader) src); + return null; - } + } - public static TrPostSource createSuiteCalcul(File _f, TrPostCommonImplementation _impl, - TrPostSourceFromReader _reader, List<String> error) { - // -- lecture de l'interface \xE0 ajouter --// - TrPostSourceFromReader srcToConcat = createSourceFromeFile(_f, _impl); - return createSuiteCalcul(_reader, _impl, srcToConcat, error); - } + public static TrPostSource createSuiteCalcul(File _f, TrPostCommonImplementation _impl, + TrPostSourceFromReader _reader, List<String> error) { + // -- lecture de l'interface \xE0 ajouter --// + TrPostSourceFromReader srcToConcat = createSourceFromeFile(_f, _impl); + return createSuiteCalcul(_reader, _impl, srcToConcat, error); + } - /** - * Algorithme de construction d'une suite de calcul. - * - * @param srcToConcat - * @param _impl - * @param _reader - * @param error - * @return - */ - public static TrPostSource createSuiteCalcul(TrPostSourceFromReader srcToConcat, TrPostCommonImplementation _impl, - TrPostSourceFromReader _reader, List<String> error) { - TrPostSource suiteCalcul = null; - if (srcToConcat == null) { - error.add(TrResource.getS("Le fichier n'est pas valide.")); - return null; - } + /** + * Algorithme de construction d'une suite de calcul. + * + * @param srcToConcat + * @param _impl + * @param _reader + * @param error + * @return + */ + public static TrPostSource createSuiteCalcul(TrPostSourceFromReader srcToConcat, TrPostCommonImplementation _impl, + TrPostSourceFromReader _reader, List<String> error) { + TrPostSourceReaderComposite suite = null; + if (srcToConcat == null) { + error.add(TrResource.getS("Le fichier n'est pas valide.")); + return null; + } - if (_reader.isRubar() || srcToConcat.isRubar()) { - error.add(TrResource.getS("Format Rubar non g\xE9r\xE9")); - return null; - } + if (_reader.isRubar() || srcToConcat.isRubar()) { + error.add(TrResource.getS("Format Rubar non g\xE9r\xE9")); + return null; + } - // -- comparaison des grilles --// - EfGridInterface grille = srcToConcat.getGrid(); - if (!grille.isSameStrict(_reader.getGrid(), _impl.getMainProgression(), 0.01)) { - error.add(TrResource.getS("Les grilles ne sont pas identiques")); - return null; - } + // -- comparaison des grilles --// + EfGridInterface grille = srcToConcat.getGrid(); + if (!grille.isSameStrict(_reader.getGrid(), _impl.getMainProgression(), 0.01)) { + error.add(TrResource.getS("Les grilles ne sont pas identiques")); + return null; + } - // -- comparaison des pas de temps d\xE9but et finaux --// - double[] time1 = TrPostSourceFromReader.getTimes(_reader.getReader()); - double[] time2 = TrPostSourceFromReader.getTimes(srcToConcat.getReader()); + // -- comparaison des pas de temps d\xE9but et finaux --// + double[] time1 = TrPostSourceFromReader.getTimes(_reader.getReader()); + double[] time2 = TrPostSourceFromReader.getTimes(srcToConcat.getReader()); - if (time1[time1.length - 1] != time2[0] && time2[time2.length - 1] != time1[0]) { - error.add(TrResource - .getS("Le dernier pas de temps de l'un doit \xEAtre \xE9quivalent au premier pas de temps de l'autre.")); - return null; - } + if (time1[time1.length - 1] != time2[0] && time2[time2.length - 1] != time1[0]) { + error.add(TrResource + .getS("Le dernier pas de temps de l'un doit \xEAtre \xE9quivalent au premier pas de temps de l'autre.")); + return null; + } - // -- recuperation des pas de temps et des variables --// - // double[] timeTotal= new double[time1.length+time2.length-1]; - // if(time1[0]>time2[0]){ - // //-- on permute pour garder l'ordre --// - // double[] temp=time1; - // time1=time2; - // time2=temp; - // } - // for(int i=0;i<time1.length;i++) - // timeTotal[i]=time1[i]; - // for(int i=0;i<time2.length-1;i++) - // timeTotal[time1.length+i]=time2[i+1]; + // -- recuperation des pas de temps et des variables --// + // double[] timeTotal= new double[time1.length+time2.length-1]; + // if(time1[0]>time2[0]){ + // //-- on permute pour garder l'ordre --// + // double[] temp=time1; + // time1=time2; + // time2=temp; + // } + // for(int i=0;i<time1.length;i++) + // timeTotal[i]=time1[i]; + // for(int i=0;i<time2.length-1;i++) + // timeTotal[time1.length+i]=time2[i+1]; - HashSet<H2dVariableType> listeVar = new HashSet<H2dVariableType>(); - H2dVariableType[] var = null; - for (int i = 0; i < _reader.getAvailableVar().length; i++) - listeVar.add(_reader.getVariable(i)); - for (int i = 0; i < srcToConcat.getAvailableVar().length; i++) - listeVar.add(srcToConcat.getVariable(i)); - var = new H2dVariableType[listeVar.size()]; - int k = 0; - for (H2dVariableType v : listeVar) - var[k++] = v; + HashSet<H2dVariableType> listeVar = new HashSet<H2dVariableType>(); + H2dVariableType[] var = null; +// for (int i = 0; i < _reader.getAvailableVar().length; i++) +// listeVar.add(_reader.getVariable(i)); +// for (int i = 0; i < srcToConcat.getAvailableVar().length; i++) +// listeVar.add(srcToConcat.getVariable(i)); + + + //-- intersection des variables des 2 fichiers --// + for (int i = 0; i < _reader.getAvailableVar().length; i++){ + boolean trouve=false; + for (int j = 0; !trouve && j < srcToConcat.getAvailableVar().length; j++) + if(srcToConcat.getVariable(j).equals(_reader.getVariable(i)) || srcToConcat.getVariable(j).getID().equals(_reader.getVariable(i).getID()) ) { + trouve=true; + listeVar.add(_reader.getVariable(i)); + } + } + + var = new H2dVariableType[listeVar.size()]; + int k = 0; + for (H2dVariableType v : listeVar) + var[k++] = v; - // var=srcToConcat.variable_; + // var=srcToConcat.variable_; - // -- initialisation de la liste de source --// - List<TrPostSourceReaderInterface> listeSourceInterface_ = new ArrayList<TrPostSourceReaderInterface>(); + // -- initialisation de la liste de source --// + List<TrPostSourceReaderInterface> listeSourceInterface_ = new ArrayList<TrPostSourceReaderInterface>(); - // -- on ajoute \xE0 la liste des interfaces l'interface 1 et l'intrface 2 --// - TrPostSourceReaderInterface interface1 = _reader.reader_; - TrPostSourceReaderInterface interface2 = srcToConcat.reader_; + // -- on ajoute \xE0 la liste des interfaces l'interface 1 et l'intrface 2 --// + TrPostSourceReaderInterface interface1 = _reader.reader_; + TrPostSourceReaderInterface interface2 = srcToConcat.reader_; - // -- attetion au cas particulier: si une interface1 est deja une suite, il faut ajouter toutes ses interfaces --// - if (interface1 instanceof TrPostSourceReaderComposite) listeSourceInterface_ - .addAll(((TrPostSourceReaderComposite) interface1).listeSourceInterface_); - else listeSourceInterface_.add(interface1); + // -- attetion au cas particulier: si une interface1 est deja une suite, il faut ajouter toutes ses interfaces --// + if (interface1 instanceof TrPostSourceReaderComposite) listeSourceInterface_ + .addAll(((TrPostSourceReaderComposite) interface1).listeSourceInterface_); + else listeSourceInterface_.add(interface1); - if (interface2 instanceof TrPostSourceReaderComposite) listeSourceInterface_ - .addAll(((TrPostSourceReaderComposite) interface2).listeSourceInterface_); - else listeSourceInterface_.add(interface2); + if (interface2 instanceof TrPostSourceReaderComposite) listeSourceInterface_ + .addAll(((TrPostSourceReaderComposite) interface2).listeSourceInterface_); + else listeSourceInterface_.add(interface2); - // -- ajout de tous les fichiers dans la collection --// - final Collection<File> file_ = new HashSet<File>(interface1.getFiles());; - file_.addAll(interface2.getFiles()); + // -- ajout de tous les fichiers dans la collection --// + final Collection<File> file_ = new HashSet<File>(interface1.getFiles());; + file_.addAll(interface2.getFiles()); - // -- on trie les listes dans l'ordre des timestep --// - Collections.sort(listeSourceInterface_, new ComparateurTrPostSourceReaderInterface()); + // -- on trie les listes dans l'ordre des timestep --// + Collections.sort(listeSourceInterface_, new ComparateurTrPostSourceReaderInterface()); - // - ajout des correspondances timestep/source avec nouveau timestep --// - Map<Integer, CoupleTimeStepData> mapTimeStep_ = new HashMap<Integer, CoupleTimeStepData>(); - // TODO utilise TDoubleArrayList - TDoubleArrayList times = new TDoubleArrayList(); - // int cpt = 0; - for (TrPostSourceReaderInterface data : listeSourceInterface_) { - for (int i = 0; i < data.getNbTimeStep(); i++) { - // LOGIquement, il faudrait prendre en compte les erreurs d'arrondi - // -- ICI, pour cet algo, on doit degager tout les doublons et ne conserver que des valeurs uniques --// - if (!times.contains(data.getTimeStep(i))) { - // le cpt vaut la taille des times - mapTimeStep_.put(times.size(), new CoupleTimeStepData(data, i)); - times.add(data.getTimeStep(i)); - // cpt++; - } - } - } + // - ajout des correspondances timestep/source avec nouveau timestep --// + Map<Integer, CoupleTimeStepData> mapTimeStep_ = new HashMap<Integer, CoupleTimeStepData>(); + // TODO utilise TDoubleArrayList + TDoubleArrayList times = new TDoubleArrayList(); + // int cpt = 0; + for (TrPostSourceReaderInterface data : listeSourceInterface_) { + for (int i = 0; i < data.getNbTimeStep(); i++) { + // LOGIquement, il faudrait prendre en compte les erreurs d'arrondi + // -- ICI, pour cet algo, on doit degager tout les doublons et ne conserver que des valeurs uniques --// + if (!times.contains(data.getTimeStep(i))) { + // le cpt vaut la taille des times + mapTimeStep_.put(times.size(), new CoupleTimeStepData(data, i)); + times.add(data.getTimeStep(i)); + // cpt++; + } + } + } - double[] timeTotal = times.toNativeArray(); - // -- creation de la suite de calcul - TrPostSourceReaderComposite suite = new TrPostSourceReaderComposite(timeTotal, var, mapTimeStep_, - listeSourceInterface_, file_); + double[] timeTotal = times.toNativeArray(); + // -- creation de la suite de calcul + suite = new TrPostSourceReaderComposite(timeTotal, var, mapTimeStep_, + listeSourceInterface_, file_); + + TrPostSource resultat=new TrPostSourceFromReader(suite, TrResource.getS("Suite de calcul"), grille, _impl); + _impl.getCurrentProject().deliverSourceSuiteId(resultat); + // -- creation du source Reader --// + return resultat; + } - // -- creation du source Reader --// - return new TrPostSourceFromReader(suite, TrResource.getS("Suite de calcul"), grille, _impl); - } - /** - * Methode appelee pour v\xE9rifier que ceci est bien compatible avec la suite de calcul. - * - * @param src - * @return - */ - public static boolean isCompatibleSuiteCalcul(TrPostSource src) { + /** + * Methode qui se charge de construire la suite de calcul a partir de la liste des id des fichiers. + * + * @param listeIdSrc + * @param projet + * @return + */ + public static TrPostSource createSuiteCalculFromPersistance(List<String> listeIdSrc,TrPostProjet projet,String idSrc){ + TrPostCommonImplementation impl=projet.getImpl(); + //- on met proprement en forme les donn\xE9es --// + List<TrPostSourceFromReader> listeReader=new ArrayList<TrPostSourceFromReader>(); + for(String id:listeIdSrc){ - if (src != null && src instanceof TrPostSourceFromReader) return true; - return false; - } + final TrPostSource srcChoisie = projet.findSourceById(id); + if (srcChoisie == null) { + impl.error(TrResource.getS(TrResource.getS("Le fichier r\xE9sultat d'id "+id+" est introuvable.\n Suite de calcul interrompue"))); + return null; + } + if (!isCompatibleSuiteCalcul(srcChoisie)) { + impl.error(TrResource.getS("Le fichier d'id "+id+" n'est pas valide pour la suite de calcul.")); + return null; + } + listeReader.add((TrPostSourceFromReader) srcChoisie) ; + } - public static class ComparateurTrPostSourceReaderInterface implements Comparator<TrPostSourceReaderInterface> { + //-- on demarre la suite de calcul --// + Iterator<TrPostSourceFromReader> it=listeReader.iterator(); + TrPostSourceFromReader suiteProgressive=it.next(); - public int compare(TrPostSourceReaderInterface o1, TrPostSourceReaderInterface o2) { + List<String> error=new ArrayList<String>(); + while(it.hasNext()){ + //-- on calcule la suite progressive que l'on stocke dans la suite progressive --// + TrPostSourceFromReader suite =(TrPostSourceFromReader) TrPostBuilderSuiteCalcul.createSuiteCalcul(suiteProgressive, impl, it.next(), error); + if(suite==null){ + String maxiStringLeo = ""; + for (String err : error) + maxiStringLeo += err + "\n"; + if(suiteProgressive!=null){ + maxiStringLeo+="La suite de calcul s'arrete donc avec les fichiers "+suiteProgressive.getTitle(); + suiteProgressive.setId(idSrc); + projet.ajouterSource(suiteProgressive); + } + + impl.error(maxiStringLeo); + return suiteProgressive; + }else + suiteProgressive=suite; - // -- on compare selon la valeur des timesteps -- - if (o1.getTimeStep(0) > o2.getTimeStep(0)) return 1; + } - if (o1.getTimeStep(0) < o2.getTimeStep(0)) return -1; - return 0; - } + //-- trigger signal modif --// + suiteProgressive.setId(idSrc); + projet.ajouterSource(suiteProgressive); + return suiteProgressive; + } - } + /** + * Methode appelee pour v\xE9rifier que ceci est bien compatible avec la suite de calcul. + * + * @param src + * @return + */ + public static boolean isCompatibleSuiteCalcul(TrPostSource src) { + + if (src != null && src instanceof TrPostSourceFromReader) return true; + return false; + } + + public static class ComparateurTrPostSourceReaderInterface implements Comparator<TrPostSourceReaderInterface> { + + public int compare(TrPostSourceReaderInterface o1, TrPostSourceReaderInterface o2) { + + // -- on compare selon la valeur des timesteps -- + if (o1.getTimeStep(0) > o2.getTimeStep(0)) return 1; + + if (o1.getTimeStep(0) < o2.getTimeStep(0)) return -1; + + return 0; + } + + } + } Added: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostFlecheContentExpr.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostFlecheContentExpr.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostFlecheContentExpr.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -0,0 +1,165 @@ +/* + * Bnp Paribas Services + * + * $Id$ + */ +package org.fudaa.fudaa.tr.post; + +import java.util.Set; + +import org.fudaa.dodico.ef.EfData; +import org.fudaa.dodico.h2d.type.H2dVariableType; +import org.fudaa.fudaa.tr.post.data.TrPostDataCreatedExpr; +import org.fudaa.fudaa.tr.post.data.TrPostDataCreatedSaver; +import org.fudaa.fudaa.tr.post.data.TrPostDataVecteur; +import org.nfunk.jep.Variable; + +/** + * @author denf01a + * @creation 27 janv. 2009 + * @version + * + */ +public class TrPostFlecheContentExpr implements TrPostFlecheContent { + + H2dVariableType varName_; + + TrPostDataCreatedExpr vx_; + TrPostDataCreatedExpr vy_; + + private TrPostDataVecteur lastValue_; + boolean isElementData_; + + private int lastTime_; + + protected TrPostFlecheContentExpr(boolean _isElementData, H2dVariableType varName_, TrPostDataCreatedExpr vx_, + TrPostDataCreatedExpr vy_) { + super(); + this.varName_ = varName_; + this.vx_ = vx_; + this.vy_ = vy_; + isElementData_ = _isElementData; + } + + /** + * + */ + public TrPostFlecheContent changeVar(H2dVariableType _name) { + return new TrPostFlecheContentExpr(isElementData_, _name, vx_, vy_); + } + + public void clearCache() { + vx_.clearCache(); + vy_.clearCache(); + } + + public TrPostDataCreatedSaver createSaver() { + return null; + } + + public TrPostFlecheContent duplicate(TrPostSource _src) { + return new TrPostFlecheContentExpr(isElementData_, varName_, vx_.createCopy(_src), vy_.createCopy(_src)); + } + + public TrPostFlecheContent duplicate(TrPostSource _src, H2dVariableType name) { + return new TrPostFlecheContentExpr(isElementData_, name, vx_.createCopy(_src), vy_.createCopy(_src)); + } + + public void fillWhithAllUsedVar(Set _res) { + vx_.fillWhithAllUsedVar(_res); + vy_.fillWhithAllUsedVar(_res); + } + + /** + * + */ + public EfData getDataFor(int time) { + return getValues(time); + } + + public String getDescription() { + return varName_.getName(); + } + + /** + * + */ + public double getValue(int time, int object) { + return Math.hypot(vx_.getValue(time, object), vy_.getValue(time, object)); + } + + /** + * + */ + public TrPostDataVecteur getValues(int _tIdx) { + if (_tIdx != lastTime_) { + lastTime_ = _tIdx; + lastValue_ = new TrPostDataVecteur(vx_.getDataFor(_tIdx), vy_.getDataFor(_tIdx), isElementData_); + } + return lastValue_; + } + + /** + * + */ + public H2dVariableType getVar() { + return varName_; + } + + /** + * + */ + public H2dVariableType getVx() { + return null; + } + + /** + * + */ + public String getVxDesc() { + return getDescription() + " X"; + } + + /** + * + */ + public H2dVariableType getVy() { + return null; + } + + /** + * + */ + public String getVyDesc() { + return getDescription() + " Y"; + } + + /** + * + */ + public boolean isEditable() { + return true; + } + + /** + * + */ + public boolean isExpr() { + return true; + } + + /** + * + */ + public TrPostFlecheContent isFleche() { + return this; + } + + /** + * + */ + public boolean updateConstantVar(Variable _var) { + return vx_.updateConstantVar(_var) | vy_.updateConstantVar(_var); + } + +} Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java 2009-01-27 16:38:58 UTC (rev 4411) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -385,21 +385,28 @@ * @param _src */ public void ajouterSource(final TrPostSource _src) { - _src.addVariableListener(new VariableListener()); - if (_src.getFiles() == null || !isOneSourceLoaded(_src.getFiles())) { - listeSrc_.add(_src); - _src.buildDefaultVarUpdateLists(); + ajouterSource(_src,null); - // -- ajout du menu correspondant uniquement a partir de la 2eme --// - // if (listeSrc_.size()>1 || (menuPost_!=null &&)) - construitMenuPostSpecifiqueSource(_src); + } + + public void ajouterSource(final TrPostSource _src,String title) { + _src.addVariableListener(new VariableListener()); + if (_src.getFiles() == null || !isOneSourceLoaded(_src.getFiles())) { + listeSrc_.add(_src); + _src.buildDefaultVarUpdateLists(); - } else { - // -- messqge d erreur: le fichier est deja ouvert --// - new BuDialogMessage(impl_.getApp(), impl_.getInformationsSoftware(), "Le fichier est deja ouvert.").activate(); + // -- ajout du menu correspondant uniquement a partir de la 2eme --// + // if (listeSrc_.size()>1 || (menuPost_!=null &&)) + construitMenuPostSpecifiqueSource(_src,title); - } + } else { + // -- messqge d erreur: le fichier est deja ouvert --// + new BuDialogMessage(impl_.getApp(), impl_.getInformationsSoftware(), "Le fichier est deja ouvert.").activate(); + } + // -- notify aux observers --// + this.notifyObservers(); + } public TrPostSource findSource(final String _file) { @@ -457,6 +464,32 @@ return null; } + + /** + * Retourne toutes les sources qui ne sont pas des composites + * @return + */ + public List<TrPostSource> getAllClassicalSource(){ + List<TrPostSource> res=new ArrayList<TrPostSource>(); + for(TrPostSource src:listeSrc_){ + if(!isAsuiteCalcul(src)) + res.add(src); + } + return res; + } + /** + * Retourne toutes les sources qui sont des composites + * @return + */ + public List<TrPostSourceFromReader> getAllCCompositeSource(){ + List<TrPostSourceFromReader> res=new ArrayList<TrPostSourceFromReader>(); + for(TrPostSource src:listeSrc_){ + if(isAsuiteCalcul(src)) + res.add((TrPostSourceFromReader)src); + } + return res; + } + public boolean isSourceLoaded(final String _file) { return isSourceLoaded(new File(_file)); @@ -546,9 +579,29 @@ public String formatInfoSource(final TrPostSource _src) { // --ajout dans la liste des titres --// Collection<File> files = _src.getFiles(); + if(!isAsuiteCalcul(_src)) return formatName(_src.getTitle()) + " | Fichier: " + formatFichier(files.iterator().next()); + else{ + +// String listeFiles=""; +// for(File f:files) +// listeFiles+="| "+f.getName(); + return _src.getTitle() ;//+ listeFiles; + } } + + public boolean isAsuiteCalcul(final TrPostSource _src){ + if(_src instanceof TrPostSourceFromReader){ + TrPostSourceFromReader s=(TrPostSourceFromReader) _src; + if(s.getReader() instanceof TrPostSourceReaderComposite) + return true; + + } + + return false; + } + public String formatFichier(final File file) { if (file == null) return ""; final String nomFichier = file.getAbsolutePath(); @@ -584,11 +637,15 @@ * * @param _src */ - public void construitMenuPostSpecifiqueSource(final TrPostSource _src) { + public void construitMenuPostSpecifiqueSource(final TrPostSource _src,String title) { - final BuMenu menuSimul = new BuMenu((listeSrc_.size()) + ". " + formatFichier(_src.getFiles().iterator().next()), + BuMenu menuSimul =null; + if(title==null) + menuSimul=new BuMenu((listeSrc_.size()) + ". " + formatFichier(_src.getFiles().iterator().next()), "SIMULATION" + (listeSrc_.size())); - + else + menuSimul=new BuMenu((listeSrc_.size()) + ". " + _src.getTitle(), + "SIMULATION" + (listeSrc_.size())); // -- ajout du menu au menu post --// getMenuPost().add(menuSimul); @@ -1374,7 +1431,28 @@ return src.getId(); } + + public String deliverSourceSuiteId(TrPostSource src) { + String idString = src.getTitle(); + if (src.getId() == null) { + String uniqueId = CtuluLibGenerator.getInstance().deliverUniqueStringId(idString); + src.setId(uniqueId); + } else { + + // -- on teste si l'id de base est 'parlant' => contient le nom du ficheir --// + String nameFormate = FuLib.clean(idString); + String id = src.getId(); + if (!id.startsWith(nameFormate)) { + String uniqueId = CtuluLibGenerator.getInstance().deliverUniqueStringId(idString); + src.setId(uniqueId); + } + + } + return src.getId(); + + } + /** * genere uniquement l id. * Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetsManagerFille.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetsManagerFille.java 2009-01-27 16:38:58 UTC (rev 4411) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetsManagerFille.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -2,11 +2,14 @@ import java.awt.BorderLayout; import java.awt.event.ActionEvent; +import java.io.File; import java.util.Date; import java.util.Observable; import java.util.Observer; import javax.swing.BorderFactory; +import javax.swing.JComboBox; +import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; @@ -14,11 +17,18 @@ import javax.swing.event.TableModelListener; import javax.swing.table.AbstractTableModel; +import org.fudaa.ebli.calque.ZCalqueSondeSynchroniserFusion.SondeCouple; +import org.fudaa.ebli.calque.ZCalqueSondeSynchroniserFusion.TreeTableModelGraphe; import org.fudaa.ebli.commun.EbliActionSimple; +import org.fudaa.ebli.visuallibrary.calque.EbliWidgetVueCalque; import org.fudaa.fudaa.tr.common.TrResource; import org.fudaa.fudaa.tr.post.actions.TrPostActionOpenSrc; import org.fudaa.fudaa.tr.post.actions.TrPostActionRemoveSrc; import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.JXTree; +import org.jdesktop.swingx.JXTreeTable; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; import com.memoire.bu.BuButton; import com.memoire.bu.BuInternalFrame; @@ -37,109 +47,16 @@ /** * projet contenant la liste des sources. */ - TrPostProjet projet_; + final TrPostProjet projet_; /** * La liste des projet afffichage graphique. */ - public JXTable listProjets_; + public JXTreeTable listProjets_; - /** - * Classe Model de la jlist - */ - class ModelTableProjets extends AbstractTableModel { + + TreeTableModelGraphe modelList_; - TrPostProjet p; - // FIXME traduire les lignes - String[] titres_ = { "N\xB0", "Nom", "Fichier", "Date de derni\xE8re modification" }; - - public ModelTableProjets(final TrPostProjet _p) { - p = _p; - - } - - @Override - public void addTableModelListener(final TableModelListener l) {} - - @Override - public Class<?> getColumnClass(final int columnIndex) { - - switch (columnIndex) { - case 0: - return Integer.class; - case 1: - return String.class; - case 2: - return String.class; - case 3: - return Date.class; - // case 4: - // return Boolean.class; - // case 5: - // return Boolean.class; - } - return null; - } - - public int getColumnCount() { - return titres_.length; - } - - @Override - public String getColumnName(final int columnIndex) { - return titres_[columnIndex]; - } - - public int getRowCount() { - return p.listeSrc_.size(); - } - - public Object getValueAt(final int rowIndex, final int columnIndex) { - - if (columnIndex >= getColumnCount()) return null; - final TrPostSource src = p.listeSrc_.get(rowIndex); - - switch (columnIndex) { - case 0: - return rowIndex + 1; - case 1: - return p.formatName(src.getTitle()); - case 2: - return src.getFiles().iterator().next().getAbsolutePath(); - case 3: - return new Date(src.getFiles().iterator().next().lastModified()); - // case 4: - // return src.isInspectable(); - // case 5: - // return src.isRubar(); - } - return null; - } - - /** - * Format le nom du fichier - * - * @param file - * @return - */ - - @Override - public boolean isCellEditable(final int rowIndex, final int columnIndex) { - return false; - } - - @Override - public void removeTableModelListener(final TableModelListener l) {} - - @Override - public void setValueAt(final Object value, final int rowIndex, final int columnIndex) {} - - // TODO utiliser CtuluCellTextRenderer - - } - - ModelTableProjets modelList_; - BuButton boutonAjoutSrc_ = new BuButton("Ajouter un projet", BuResource.BU.getIcon("crystal_ouvrirprojet")); BuButton boutonEnleveSrc_ = new BuButton("Enlever un projet", BuResource.BU.getIcon("crystal_enlever")); // BuButton boutonChangeSrc_ = new BuButton("Changer de donn\xE9es", BuResource.BU.getIcon("crystal_valider")); @@ -156,15 +73,15 @@ projet_.getObservable().addObserver(this); // --creation de la liste graphique des projets --// - modelList_ = new ModelTableProjets(projet_); + modelList_ = constructStructureModel() ;//new TreeTableModelGraphe(); - listProjets_ = new JXTable(modelList_); + listProjets_ = new JXTreeTable(modelList_); // listProjets_.setCellRenderer(modelList_); // -- mise en forme des colonnes --// - listProjets_.getColumnModel().getColumn(0).setPreferredWidth(5); - listProjets_.getColumnModel().getColumn(1).setPreferredWidth(250); - listProjets_.getColumnModel().getColumn(2).setPreferredWidth(100); +// listProjets_.getColumnModel().getColumn(0).setPreferredWidth(5); +// listProjets_.getColumnModel().getColumn(1).setPreferredWidth(250); +// listProjets_.getColumnModel().getColumn(2).setPreferredWidth(100); listProjets_.setBorder(BorderFactory.createEtchedBorder()); @@ -173,7 +90,7 @@ // -- oblige la selection unique pour ne pas ajouter qu un seul projet a la // fois--// - listProjets_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + // listProjets_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // -- selectionne par default le src courant --// // listProjets_.setSelectedValue(projet_.src_, true); @@ -230,19 +147,132 @@ public void valueChanged(final ListSelectionEvent e) { - // -- recuperation de l element selectionn\xE9 --// - // FuLog.warning("l'objet selectionne est: " + - // listProjets_.getSelectedValue()); + } + /** + * Construit le model du tableau. + * @return + */ + public TreeTableModelGraphe constructStructureModel() { + DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode("Gestion multi-fichiers"); + + for (int i = 0; i <projet_.listeSrc_.size(); i++) { + TrPostSource src= projet_.listeSrc_.get(i); + + + DefaultMutableTreeTableNode nodeCalque = new DefaultMutableTreeTableNode(src); + root.add(nodeCalque); + + //- ajout des fichiers associ\xE9s --// + for(File f:src.getFiles()) + nodeCalque.add(new DefaultMutableTreeTableNode(f)); + } + TreeTableModelGraphe model = new TreeTableModelGraphe(projet_); + model.setRoot(root); + + return model; + } + + + public class TreeTableModelGraphe extends DefaultTreeTableModel { + String[] titre_; + TrPostProjet projet; + + + + public Class<?> getColumnClass(final int columnIndex) { + + switch (columnIndex) { + case 0: + return Integer.class; + case 1: + return String.class; + } + return null; + } + + // -- data correspondant au x donn\xE9 --// + double[] dataY_ = new double[0]; + + public TreeTableModelGraphe(TrPostProjet p) { + String[] val = {"Fichiers", "Date modification" }; + titre_ = val; + projet=p; + } + + public int getColumnCount() { + + return titre_.length; + } + + @Override + public boolean isCellEditable(Object _node, int _column) { + return false; + } + + public String getColumnName(int _columnIndex) { + return titre_[_columnIndex]; + } + + public int getRowCount() { + return projet.listeSrc_.size(); + + } + + public Object getValueAt(Object node, int column) { + Object res = new DefaultMutableTreeTableNode("n/a"); + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode defNode = (DefaultMutableTreeTableNode) node; + if (defNode.getUserObject() instanceof TrPostSource) { + TrPostSource src=(TrPostSource)defNode.getUserObject(); + String label=(getRoot().getIndex(defNode)+1)+". "+ projet_.formatName(src.getTitle()); + if (column == 0) + return label; + else + return ""; + } else if (defNode.getUserObject() instanceof File) { + File fichier = (File) defNode.getUserObject(); + + if (column == 0) + return fichier.getAbsolutePath(); + else if (column == 1) + return new Date(fichier.lastModified()); + else + return ""; + } + else + return ""; + } + return res; + } + + public DefaultMutableTreeTableNode getTreeNode(int i) { + return (DefaultMutableTreeTableNode) getRoot().getChildAt(i); + + } + + public void reload() { + + this.modelSupport.fireTreeStructureChanged(listProjets_.getPathForRow(0)); + + } + + + } + public void update(final Observable o, final Object arg) { // mise a jour de la liste - modelList_.fireTableStructureChanged(); - + if(listProjets_==null)return; + listProjets_.setTreeTableModel(constructStructureModel()); + listProjets_.expandAll(); +// if(listProjets_.getModel() instanceof TreeTableModelGraphe) +// ((TreeTableModelGraphe)listProjets_.getModel()).reload(); // selection par defaut de la premiere simul listProjets_.clearSelection(); + this.revalidate(); } } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java 2009-01-27 16:38:58 UTC (rev 4411) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -332,4 +332,8 @@ * @param _d */ void setDefaultPaletteMinPalette(H2dVariableType[] _v, boolean[] _actived, double[] _d); + + + public void fillWithSourceCreationInfo(String _pref, Map _table) ; + } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java 2009-01-27 16:38:58 UTC (rev 4411) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -218,7 +218,7 @@ TrPostTimeModel time_; - private final String title_; + protected final String title_; protected ObjectContainer tmpContainer_; @@ -950,7 +950,7 @@ return time_.getTimeStep(_i); } - public final String getTitle() { + public String getTitle() { return title_; } @@ -1398,13 +1398,13 @@ // return CtuluLibGenerator.getInstance().deliverUniqueStringId(); // } - public final String getId() { + public String getId() { // if(id_==null) // id_=generateId(); return id_; } - public final void setId(String id) { + public void setId(String id) { id_ = id; } @@ -1448,5 +1448,10 @@ idx++; } } + + public void fillWithSourceCreationInfo(String _pref, Map _table){ + TrPostSourceAbstractFromIdx.fillWithSourceInfo(CtuluLibString.EMPTY_STRING, _table, this); + } + } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java 2009-01-27 16:38:58 UTC (rev 4411) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -7,7 +7,9 @@ import java.io.File; import java.io.IOException; import java.util.Collection; +import java.util.Map; +import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.CtuluUI; import org.fudaa.dodico.ef.EfData; import org.fudaa.dodico.ef.EfGridInterface; @@ -20,71 +22,92 @@ */ public class TrPostSourceFromReader extends TrPostSourceAbstract{ - TrPostSourceReaderInterface reader_; + TrPostSourceReaderInterface reader_; - /** - * @param _file - * @param _titre - * @param _g - * @param _time - * @param _v - * @param _impl - */ - public TrPostSourceFromReader(TrPostSourceReaderInterface _reader, String _titre, EfGridInterface _g, CtuluUI _impl) { - super(_titre, _g, getTimes(_reader), - _reader.getInitVar().toArray(new H2dVariableType[_reader.getInitVar().size()]), _impl); - reader_=_reader; - } + /** + * @param _file + * @param _titre + * @param _g + * @param _time + * @param _v + * @param _impl + */ + public TrPostSourceFromReader(TrPostSourceReaderInterface _reader, String _titre, EfGridInterface _g, CtuluUI _impl) { + super(_titre, _g, getTimes(_reader), + _reader.getInitVar().toArray(new H2dVariableType[_reader.getInitVar().size()]), _impl); + reader_=_reader; + } - public static double[] getTimes(TrPostSourceReaderInterface _init) { - if (_init == null || _init.getNbTimeStep() == 0) return FuEmptyArrays.DOUBLE0; - double[] res = new double[_init.getNbTimeStep()]; - for (int i = 0; i < res.length; i++) { - res[i] = _init.getTimeStep(i); - } - return res; + public static double[] getTimes(TrPostSourceReaderInterface _init) { + if (_init == null || _init.getNbTimeStep() == 0) return FuEmptyArrays.DOUBLE0; + double[] res = new double[_init.getNbTimeStep()]; + for (int i = 0; i < res.length; i++) { + res[i] = _init.getTimeStep(i); + } + return res; - } - - @Override - public final void close() { - super.close(); - reader_.close(); - } - - + } - public Collection<File> getFiles() { - return reader_.getFiles(); - } + @Override + public final void close() { + super.close(); + reader_.close(); + } - /** - * @return the reader - */ - public TrPostSourceReaderInterface getReader() { - return reader_; - } - /** - * @param _reader the reader to set - */ - public void setReader(TrPostSourceReaderInterface _reader) { - reader_ = _reader; - } - @Override - public EfData getInitData(H2dVariableType _varIdx, int _timeIdx) { - return reader_.getInitData(_varIdx, _timeIdx); - } + public final String getTitle() { + if(reader_.getTitle()!=null) + return reader_.getTitle(); + return title_; + } - @Override - public double getInitData(H2dVariableType _varIdx, int _timeIdx, int _ptIdx) throws IOException { - return reader_.getInitData(_varIdx, _timeIdx, _ptIdx); - } + public Collection<File> getFiles() { + return reader_.getFiles(); + } + /** + * @return the reader + */ + public TrPostSourceReaderInterface getReader() { + return reader_; + } - public boolean isRubar() { - return false; - } + /** + * @param _reader the reader to set + */ + public void setReader(TrPostSourceReaderInterface _reader) { + reader_ = _reader; + } + @Override + public EfData getInitData(H2dVariableType _varIdx, int _timeIdx) { + return reader_.getInitData(_varIdx, _timeIdx); + } + + @Override + public double getInitData(H2dVariableType _varIdx, int _timeIdx, int _ptIdx) throws IOException { + return reader_.getInitData(_varIdx, _timeIdx, _ptIdx); + } + + + public boolean isRubar() { + return false; + } + + public void fillWithSourceCreationInfo(String _pref, Map _table){ + + if(this.getReader() instanceof TrPostSourceReaderComposite) + ((TrPostSourceReaderComposite)getReader()).fillInfosWithComposite( _table, (TrPostSourceReaderComposite)getReader()); + } + + + public String getId() { + return reader_.getId(); + } + + public void setId(String id) { + reader_.SetId(id); + } + } Added: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourcePersistComposite.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourcePersistComposite.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourcePersistComposite.java 2009-01-27 17:12:46 UTC (rev 4412) @@ -0,0 +1,52 @@ +package org.fudaa.fudaa.tr.post; + +import java.util.ArrayList; +import java.util.List; + +/** + * Persistance du TrPostSourceReader composite utilis\xE9 pour les sauvegardes suites de calcul. + * Contient plusieurs ids vers les TrPostSourceReaderInterface correspondants. + * + * @author Adrien Hadoux + */ +public class TrPostSourcePersistComposite { + + /** + * Liste des id des fichiers qui composent la suite. + */ + public List<String> listeIdFicResu; + + public String Id; + + /** + * Utiliser par la serialization. + */ + TrPostSourcePersistComposite(){ + listeIdFicResu=new ArrayList<String>(); + } + + /** + * Constructeur qui se charge de remplir les donn\x... [truncated message content] |