From: <had...@us...> - 2008-08-26 16:06:33
|
Revision: 3839 http://fudaa.svn.sourceforge.net/fudaa/?rev=3839&view=rev Author: hadouxad Date: 2008-08-26 16:06:40 +0000 (Tue, 26 Aug 2008) Log Message: ----------- - Panel de Gestion des projets utilisant un jxtable et model associ?\195?\169 - Panel de chooser des projet pour la fonction de creation du calque: on choisit dans la liste le jeux de donn?\195?\169es a utiliser - Implementation du design pattern observer observable pour les modifs de la liste des src. - Mise en place des modifs auto en cas de suppression ou ajout de jeux de donn?\195?\169es. - Creation de l action TrPostActionChooseAndCreateCalque qui permet de choisir le jeux de donn?\195?\169es et de cr?\195?\169er le widget correspondant. Fonctionne OK - Modif de TRPOSTVISUPANEL: il prend en parametre l indice de la source utilis?\195?\169e, et utilise l accesseur getSource(int index) pour r?\195?\169cup?\195?\169rer le bon jeu de donn?\195?\169es. - Information du jeux de donn?\195?\169e utilis?\195?\169e: indiqu?\195?\169 en toolTip sur la widget - Menu 'Info' suppl?\195?\169mentaire ajout?\195?\169 a la widget pour indiquer entre autre le jeux de donn?\195?\169es utilis?\195?\169es. - Creation des menus sp?\195?\169cifiques pour chaque simulation: - chaque simulation a son onglet de menu qui porte le nom du fichier - les evenements sont numerotes dans le meme ordre que le rangement des simulations - Refonte de la fonction "ouvrir" qui ouvre un source dans le multi-source dans le projet. Un truc sympa car il fallait tenir compte des plusieurs simul et de la possibilite d en supprimer: - refonte des evenements liees au multi-sources: - on gere une liste de menu qui representent chacun une simulation - pour retrouver l evenement du bon menu enclench?\195?\169, on parcours la liste et onv?\195?\169rifie 2 choses: le menuitem est le bon et l'event est bon. Au final la complexit?\195?\169 de l algo: lin?\195?\169aire (* par constante ?\195?\169gale au nombre de sous menus de post donc n?\195?\169gligeable...) Refonte des fonctions li?\195?\169es au post pour gere le multi osurce: - Export data OK. Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ctulu/src/com/memoire/bu/BuDialogChoice.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/Tr.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChangeSrc.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionOpenSrc.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionRemoveSrc.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCommonImplementation.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutFille.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutPanelController.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostMinMaxTableModel.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/TrPostVisuPanel.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChooseAndCreateCalque.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetChooser.java Modified: branches/Prepro-0.92-SNAPSHOT/ctulu/src/com/memoire/bu/BuDialogChoice.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ctulu/src/com/memoire/bu/BuDialogChoice.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/ctulu/src/com/memoire/bu/BuDialogChoice.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -123,6 +123,10 @@ public String getValue() { return valeur_; } + public int getSelectedIndex() { + return chValeur_.getSelectedIndex(); + } + public void setValue(String _value) { chValeur_.setSelectedItem(_value); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -11,6 +11,7 @@ import javax.swing.JDialog; import javax.swing.JMenuItem; +import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import org.fudaa.ctulu.CtuluLibString; @@ -28,6 +29,8 @@ import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.Widget; +import com.memoire.bu.BuResource; + /** * Widget version EBLI * @@ -43,6 +46,17 @@ */ public Map propGraphique; + private String description_; + + public String getDescription_() { + return description_; + } + + public void setDescription_(String description_) { + this.description_ = description_; + setToolTipText(description_); + } + /** * Liste des clef utilisees pour les composants graphiques */ @@ -205,6 +219,8 @@ // menu clic droit basique (fermeture, duplication) setMenu(); + + } /** @@ -214,12 +230,23 @@ */ public void constructPopupMenuBase(JPopupMenu _popup) { - JMenuItem menuItem3 = _popup.add("Masquer l'objet"); - menuItem3.setIcon(CtuluResource.CTULU.getIcon("crystal22_visibilite")); + JMenuItem menuItem3 = _popup.add("Informations"); + menuItem3.setIcon(BuResource.BU.getIcon("crystal_aide")); menuItem3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(null, getDescription_(), "Informations", JOptionPane.DEFAULT_OPTION, null); + } + + }); + + menuItem3 = _popup.add("Masquer l'objet"); + menuItem3.setIcon(CtuluResource.CTULU.getIcon("crystal_visibilite")); + menuItem3.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + EbliWidget.this.setVisible(false); } @@ -227,7 +254,7 @@ }); JMenuItem menuItem1 = _popup.add("Dupliquer l'objet"); - menuItem1.setIcon(CtuluResource.CTULU.getIcon("crystal22_cascade")); + menuItem1.setIcon(CtuluResource.CTULU.getIcon("crystal_cascade")); menuItem1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/Tr.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/Tr.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/Tr.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -7,6 +7,7 @@ */ package org.fudaa.fudaa.tr; + /** * Classe de lancement de l'application Tr. Contient la methode main. * @@ -21,5 +22,26 @@ TrLauncherDefault.init(); TrLauncherDefault.launch(_args, null, new TrSupervisorImplementation()); + // EbliNodeDefault srcCourant=new EbliNodeDefault(); + // srcCourant.setTitle("moumoune"); + // + // EbliNodeDefault newCourant = new EbliNodeDefault(); + // srcCourant.setTitle("marmitte"); + // + // EbliNodeDefault pnVisu = new EbliNodeDefault(); + // pnVisu.setTitle("pnVisu"); + // + // // on donne la ref de srcCourant a pnVisu + // pnVisu = srcCourant; + // + // // on test pnVisu + // FuLog.warning("test pnVisu= " + pnVisu.getTitle()); + // + // // on donne la ref de newCourant a srcCourant + // srcCourant = newCourant; + // + // // on verif que pnVisu a pas change + // FuLog.warning("test pnVisu= " + pnVisu.getTitle()); + } } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChangeSrc.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChangeSrc.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChangeSrc.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -36,13 +36,13 @@ // -- recuperation de la source a supprimer --// // -- cas rien de selectionnee --// - if (projet_.filleProjetctManager_.listProjets_.getSelectedIndex() == -1) { + if (projet_.filleProjetctManager_.listProjets_.getSelectedRow() == -1) { new BuDialogMessage(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), "Il faut selectionner le fichier dans la liste avant de cliquer.").activate(); } else { // -- recupeation de la source a enlever --// - TrPostSource src = (TrPostSource) projet_.filleProjetctManager_.listProjets_.getSelectedValue(); + TrPostSource src = (TrPostSource) projet_.getSource(projet_.filleProjetctManager_.listProjets_.getSelectedRow()); // -- demande confirmationa l user --// int confirmation = new BuDialogConfirmation(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), Added: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChooseAndCreateCalque.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChooseAndCreateCalque.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionChooseAndCreateCalque.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -0,0 +1,102 @@ +package org.fudaa.fudaa.tr.post; + +import java.awt.event.ActionEvent; +import java.util.Iterator; + +import org.fudaa.ebli.calque.BCalqueLegende; +import org.fudaa.ebli.commun.EbliActionSimple; +import org.fudaa.ebli.ressource.EbliResource; +import org.fudaa.ebli.visuallibrary.EbliNode; + +import com.memoire.bu.BuDialogChoice; +import com.memoire.bu.BuDialogError; +import com.memoire.bu.BuResource; + +/** + * Action qui permet de cr\xE9er un widget calque en choisissant un jeu de donn\xE9es. + * Le jeux de donn\xE9es est donn\xE9 par le chooser. Il est choisi par l utilisateur. + * Le calque correspondant est alors cr\xE9\xE9. + * + * @author Adrien Hadoux + * + */ +public class TrPostActionChooseAndCreateCalque extends EbliActionSimple { + + TrPostProjet projet_; + + /** + * Chooser associ\xE9 au projet. + */ + public TrPostProjetChooser filleProjetctChooser_; + + public TrPostActionChooseAndCreateCalque(TrPostProjet _projet) { + super(EbliResource.EBLI.getString("Calque principal"), BuResource.BU.getToolIcon("crystal_graphe"), + "WIDGETRECALQUE"); + + projet_ = _projet; + + + + } + + /** + * Methode qui formatte les donnees de la liste. + * + * @return + */ + String[] formattageDonnees() { + + String[] listeSimul = new String[projet_.listeSrc_.size()]; + int cpt = 0; + for (Iterator<TrPostSource> it = projet_.listeSrc_.iterator(); it.hasNext();) { + + TrPostSource src = it.next(); + + + // --ajout dans la liste des titres --// + listeSimul[cpt++] = projet_.formatInfoSource(src); + } + + return listeSimul; + } + + public void actionPerformed(ActionEvent _evt) { + + // -- recuperation de la liste des src sous forme de liste --// + String[] values = formattageDonnees(); + + // -- ouverture du chooser --// + BuDialogChoice chooser = new BuDialogChoice(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), + "Le fichier a \xE9t\xE9 correctement enlev\xE9 du projet", "S\xE9lectionnez le jeux de donn\xE9es ", values); + + int response = chooser.activate(); + + if (response == 0) { + + int indiceSOURCESelect = chooser.getSelectedIndex(); + + if (indiceSOURCESelect >= projet_.listeSrc_.size()) { + new BuDialogError(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), + "La source s\xE9lecionn\xE9e n'existe pas.").activate(); + return; + } + + + + + // -- TRES IMPORTANT: on cree le calque en precisant l indice de la SOURCE + // SELECTIONNEE --// + TrPostVisuPanel pnVisu = new TrPostVisuPanel(projet_.getImpl(), projet_, new BCalqueLegende(), indiceSOURCESelect); + EbliNode node = projet_.filleLayout_.controller_.addCalque("Calque principal", pnVisu.getLocation(), pnVisu + .getPreferredSize(), + pnVisu); + + + // -- ajout de l INFO de la source utilis\xE9e --// + node.getCreator().getWidget().setDescription_("Source: " + values[indiceSOURCESelect]); + + + } + } + +} Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionOpenSrc.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionOpenSrc.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionOpenSrc.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -66,6 +66,9 @@ multiProjectActivator_.active(fichierAbsolu, projet_.impl_); + // -- notify aux observers --// + projet_.notifyObservers(); + testAfficheMesSimu(); Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionRemoveSrc.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionRemoveSrc.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostActionRemoveSrc.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -6,6 +6,7 @@ import org.fudaa.ebli.commun.EbliActionSimple; import com.memoire.bu.BuDialogConfirmation; +import com.memoire.bu.BuDialogError; import com.memoire.bu.BuDialogMessage; import com.memoire.bu.BuResource; import com.memoire.fu.FuLog; @@ -44,13 +45,20 @@ //-- recuperation de la source a supprimer --// // -- cas rien de selectionnee --// - if (projet_.filleProjetctManager_.listProjets_.getSelectedIndex() == -1) { - new BuDialogMessage(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), + if (projet_.listeSrc_.size() <= 1) { + new BuDialogError(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), + "Ce fichier ne peut \xEAtre supprim\xE9.\n Il faut garder au moins un fichier de donn\xE9es.").activate(); + return; + } + + if (projet_.filleProjetctManager_.listProjets_.getSelectedRow() == -1) { + new BuDialogError(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), "Il faut selectionner le fichier \xE0 retirer de la liste avant de cliquer.").activate(); } else { // -- recupeation de la source a enlever --// - TrPostSource src = (TrPostSource) projet_.filleProjetctManager_.listProjets_.getSelectedValue(); + TrPostSource src = (TrPostSource) projet_.listeSrc_.get(projet_.filleProjetctManager_.listProjets_ + .getSelectedRow()); // -- demande confirmationa l user --// @@ -64,9 +72,13 @@ if (projet_.removeSource(src)) { new BuDialogMessage(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), "Le fichier a \xE9t\xE9 correctement enlev\xE9 du projet").activate(); + + // -- notify aux observers --// + projet_.notifyObservers(); + } else { - new BuDialogMessage(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), - "Le fichier n'a pas \xE9t\xE9t correctement enlev\xE9 du projet.").activate(); + new BuDialogError(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), + "Le fichier n'a pas \xE9t\xE9 correctement enlev\xE9 du projet.").activate(); } testAfficheMesSimu(); Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCommonImplementation.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCommonImplementation.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCommonImplementation.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -13,18 +13,17 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; -import com.memoire.bu.BuLib; -import com.memoire.bu.BuMenu; - import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.gui.CtuluLibDialog; import org.fudaa.ctulu.gui.CtuluTaskOperationGUI; - import org.fudaa.fudaa.tr.common.TrCommonImplementation; import org.fudaa.fudaa.tr.common.TrLib; import org.fudaa.fudaa.tr.common.TrResource; +import com.memoire.bu.BuLib; +import com.memoire.bu.BuMenu; + /** * @author Fred Deniger * @version $Id: TrPostCommonImplementation.java,v 1.24 2007-05-04 14:01:51 deniger Exp $ @@ -115,6 +114,12 @@ public void actionPerformed(final ActionEvent _evt) { final String com = _evt.getActionCommand(); + + if ("OUVRIR".equals(com)) { + // -- ouverture d un multi source --// + new TrPostActionOpenSrc(c_).actionPerformed(_evt); + } else + if ("FERMER".equals(com)) { new CtuluTaskOperationGUI(this, TrResource.getS("Fermer")) { Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutFille.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutFille.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutFille.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -191,7 +191,7 @@ if (!projet_.filleProjetctManager_.isVisible()) projet_.impl_.addInternalFrame(projet_.filleProjetctManager_); - projet_.filleProjetctManager_.setSize(500, 250); + // projet_.filleProjetctManager_.setSize(500, 250); } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutPanelController.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutPanelController.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutPanelController.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -54,9 +54,14 @@ import com.memoire.bu.BuDesktop; import com.memoire.bu.BuMenu; import com.memoire.bu.BuPanel; -import com.memoire.bu.BuResource; import com.memoire.bu.BuSeparator; +/** + * Controller des actions pour les ebliWidget. + * + * @author genesis + * + */ public class TrPostLayoutPanelController { @@ -424,15 +429,7 @@ // -- ajout d'une action specifique de recreation du calque en cas de // suppression --// - init.add(new EbliActionSimple(EbliResource.EBLI.getString("Calque principal"), BuResource.BU - .getToolIcon("crystal_graphe"), - "WIDGETRECALQUE") { - public void actionPerformed(ActionEvent _evt) { - - TrPostVisuPanel pnVisu = new TrPostVisuPanel(projet_.getImpl(), projet_, null); - addCalque("Calque principal", pnVisu.getLocation(), pnVisu.getPreferredSize(), pnVisu); - } - }); + init.add(new TrPostActionChooseAndCreateCalque(projet_)); Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostMinMaxTableModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostMinMaxTableModel.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostMinMaxTableModel.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -26,20 +26,18 @@ import javax.swing.table.AbstractTableModel; import javax.swing.table.TableCellEditor; -import com.memoire.bu.BuPanel; -import com.memoire.bu.BuScrollPane; -import com.memoire.bu.BuTextArea; - import org.fudaa.ctulu.CtuluLib; import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.ProgressionUpdater; - import org.fudaa.dodico.h2d.type.H2dVariableType; - import org.fudaa.fudaa.tr.common.TrCommonImplementation; import org.fudaa.fudaa.tr.common.TrResource; +import com.memoire.bu.BuPanel; +import com.memoire.bu.BuScrollPane; +import com.memoire.bu.BuTextArea; + /** * @author Fred Deniger * @version $Id: TrPostMinMaxTableModel.java,v 1.14 2007-03-30 15:39:29 deniger Exp $ @@ -264,9 +262,12 @@ boolean apply_; protected void apply(final ProgressionInterface _inter, final TrCommonImplementation _impl) { + + if (apply_) { return; } + apply_ = true; _impl.setMainMessage(TrResource.getS("Calcul des extrema")); final TIntArrayList list = new TIntArrayList(); 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 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -15,8 +15,9 @@ import java.beans.PropertyVetoException; import java.io.File; import java.io.IOException; -import java.util.HashSet; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Observable; import java.util.Observer; import java.util.Set; @@ -67,6 +68,7 @@ import org.fudaa.ebli.courbe.EGFillePanel; import org.fudaa.ebli.courbe.EGGraphe; import org.fudaa.ebli.ressource.EbliResource; +import org.fudaa.ebli.visuallibrary.EbliNode; import org.fudaa.ebli.visuallibrary.EbliNodeDefault; import org.fudaa.ebli.visuallibrary.EbliScene; import org.fudaa.ebli.visuallibrary.calque.EbliWidgetCalqueLegende; @@ -105,6 +107,7 @@ import com.memoire.bu.BuLib; import com.memoire.bu.BuMenu; import com.memoire.bu.BuMenuBar; +import com.memoire.bu.BuMenuItem; import com.memoire.bu.BuPanel; import com.memoire.bu.BuResource; import com.memoire.bu.BuScrollPane; @@ -283,7 +286,48 @@ */ public TrPostProjetsManagerFille filleProjetctManager_; + /** + * Le menu du post qui contient tout les sous menus des projets + */ + BuMenu menuPost_; + List<BuMenu> listeMenuProjets_; + + List<ArrayList<BuMenuItem>> listeSousMenuProjets_; + + /** + * Observable custom reserv\xE9 aux modifs apport\xE9es a la liste des src. + * + * @author Adrien Hadoux + * + */ + class observableSupport extends Observable { + public void notifyObservers() { + this.setChanged(); + super.notifyObservers(); + } + public void notifyObservers(Object arg) { + this.setChanged(); + super.notifyObservers(arg); + } + + } + + private observableSupport observable; + + public observableSupport getObservable() { + if (observable == null) + observable = new observableSupport(); + return observable; + } + + public void notifyObservers() { + // getObservable().setChanged(); + getObservable().notifyObservers(); + + } + + int idx_; transient int idxFilleG_; @@ -300,7 +344,7 @@ /** * liste des sources pour le multiProjet. */ - transient Set<TrPostSource> listeSrc_ = new HashSet<TrPostSource>(); + transient ArrayList<TrPostSource> listeSrc_ = new ArrayList<TrPostSource>(); transient TimeContentUpdater timeUpdater_; @@ -317,6 +361,7 @@ // -- creation de la frame de gestion multi projet --// filleProjetctManager_ = new TrPostProjetsManagerFille(this); + } @@ -326,20 +371,23 @@ impl_ = _impl; } - + /** * Permet d ajouter une source dans le projet afin de gerer le multi source. + * On doit toujorus passer par cette methode pour ajouter une source. * * @param _src */ public void ajouterSource(TrPostSource _src) { if (!isSourceExist(_src.getFile().getAbsolutePath())) { listeSrc_.add(_src); + + + + // -- ajout du menu correspondant uniquement a partir de la 2eme --// + if (listeSrc_.size() > 1) + construitMenuPostSpecifiqueSource(_src); - // -- mise a jour de la jlist graphique --// - if (filleProjetctManager_ != null && filleProjetctManager_.modelList_ != null) - filleProjetctManager_.modelList_.addElement(_src); - } else { // -- messqge d erreur: le fichier est deja ouvert --// new BuDialogMessage(impl_.getApp(), impl_.getInformationsSoftware(), @@ -385,18 +433,6 @@ } -// public boolean changeSource(String _file) { - // - // TrPostSource newSrcCourante = findSource(_file); - // if (newSrcCourante == null) - // return false; - // else { - // src_ = newSrcCourante; - // return true; - // } - // - // } - /** * methode qui change la source courante et retourne true si la source existe * bien, false sinon @@ -412,19 +448,6 @@ return true; } - // public boolean removeSource(String _file) { - // for (Iterator<TrPostSource> it = listeSrc_.iterator(); it.hasNext();) { - // - // TrPostSource src = it.next(); - // if (src.getFile().getAbsolutePath().equals(_file)) { - // it.remove(); - // return true; - // } - // - // } - // return false; - // - // } /** * Methode de suppression de la source @@ -438,9 +461,7 @@ if (isSourceExist(src.getFile().getAbsolutePath())) { listeSrc_.remove(src); - // -- mise a jour de la jlist graphique --// - if (filleProjetctManager_ != null && filleProjetctManager_.modelList_ != null) - filleProjetctManager_.modelList_.removeElement(src); + return true; } else { @@ -453,19 +474,147 @@ } } + + /** + * methode qui formatte les infos de la source + * + * @param _src + * @return + */ + public String formatInfoSource(TrPostSource _src) { + // --ajout dans la liste des titres --// + return formatName(_src.getTitle()) + " | Fichier: " + formatFichier(_src.getFile()); + } + + public String formatFichier(File file) { + String nomFichier = file.getAbsolutePath(); + int position = nomFichier.lastIndexOf(File.separator) + 1; + if (position != -1) { + nomFichier = nomFichier.substring(position); + } + position = nomFichier.lastIndexOf(CtuluLibString.DOT); + if (position != -1) { + nomFichier = nomFichier.substring(0, position); + } + FuLog.warning("nom du fichier: " + nomFichier); + return nomFichier; + } /** - * Methode qui affiche la frame de gestion des multi projets. + * formatte le titre + * + * @param file + * @return */ - public void showProjectFrame() { + public String formatName(String title) { + // --suppression des trop long espaces du titre --// + + title = title.replaceAll(" ", ""); - if (filleProjetctManager_ == null) - filleProjetctManager_ = new TrPostProjetsManagerFille(this); + return title; + } + + /** + * Construit un menu specifique a la source choisie. A chaque fois que l on + * ajoute une source au projet, il faut ajouter un menu sp\xE9cifique. + * + * @param _src + */ + public void construitMenuPostSpecifiqueSource(TrPostSource _src){ + + BuMenu menuSimul = new BuMenu((listeSrc_.size()) + ". " + formatFichier(_src.getFile()), "SIMULATION" + + (listeSrc_.size())); + + // -- ajout du menu au menu post --// + menuPost_.add(menuSimul); - filleProjetctManager_.setVisible(true); + // -- sauvegarde d une trace du menu dans la liste pour une suppression + // ulterieure --// + listeMenuProjets_.add(menuSimul); + + ArrayList<BuMenuItem> listSousMenus = new ArrayList<BuMenuItem>(); + + final BuIcon ic = BuResource.BU.getIcon("aucun"); + + listSousMenus.add(menuSimul.addMenuItem(TrResource.getS("Extrema..."), "COMPUTE_EXTREMA", ic, TrPostProjet.this)); + listSousMenus.add(menuSimul.addMenuItem(CtuluLib.getS("Editer les variables..."), "VARIABLES", ic, TrPostProjet.this)); + menuSimul.addSeparator(); + listSousMenus.add( menuSimul.addMenuItem(TrResource.getS("Palettes de couleurs"), "PALETTE_DEFAULT", ic, TrPostProjet.this)); + listSousMenus.add( menuSimul.addMenuItem(TrResource.getS("Formater/modifier les pas de temps..."), "TIME_FORMAT", ic, + TrPostProjet.this)); + + menuSimul.addSeparator(); + listSousMenus.add( menuSimul.addMenuItem(TrResource.getS("Comparer..."), "COMPARE", ic, TrPostProjet.this)); + listSousMenus.get(listSousMenus.size()-1).setToolTipText(TrResource.getS("Comparer les r\xE9sultats avec ceux d'un autre projet")); + listSousMenus.add(menuSimul.addMenuItem(TrResource.getS("Projeter..."), "PROJECT", ic, TrPostProjet.this)); + listSousMenus.get(listSousMenus.size()-1).setToolTipText(TrResource.getS("Projeter les r\xE9sultats sur un maillage diff\xE9rent")); + if (src_ != null && src_.isInspectable()) { + menuSimul.addSeparator(); + listSousMenus.add( menuSimul.addMenuItem(TrResource.getS("Rafra\xEEchir les r\xE9sultats"), "MAJ_DATA", ic, TrPostProjet.this)); + listSousMenus.get(listSousMenus.size()-1).setToolTipText(TrResource.getS("Les fichiers de r\xE9sultats seront relus")); + listSousMenus.add(menuSimul.addMenuItem(TrResource.getS("Rafra\xEEchir automatiquement"), "MAJ_DATA_ALWAYS", ic, TrPostProjet.this)); + listSousMenus.get(listSousMenus.size()-1).setToolTipText(TrResource.getS("Les fichiers sont surveill\xE9s p\xE9riodiquement")); + menuSimul.addSeparator(); + listSousMenus.add(menuSimul.addMenuItem(TrResource.getS("Exporter"), "EXPORTDATA", TrPostProjet.this)); + + // -- ajout de la sous liste de menus pour la garder en memoire --// + listeSousMenuProjets_.add(listSousMenus); + +} } + /** + * Creation par defaut du menu post de l interface. Cette methdoe est appelee + * une seule dfois au moment de la creation de l impl. + */ + public void setMenuPost() { + final BuMenuBar menubar = impl_.getMainMenuBar(); + + + menuPost_ = new BuMenu(TrResource.getS("Post"), "POST"); + menuPost_.setIcon(null); + menuPost_.setName("mnPost"); + + addSpecificItemInMainMenu(menuPost_); + menubar.add(menuPost_, 2); + + + //-- ajout de l action de gestion des simus dans post --// + BuMenuItem item=new BuMenuItem("Gestion Multi-projets"); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + // -- affichage de la fenetre de gestion multi projet --// + if (!filleProjetctManager_.isVisible()) + impl_.addInternalFrame(filleProjetctManager_); + + // projet_.filleProjetctManager_.setSize(500, 250); + + } + + }); + + menuPost_.add(item); + menuPost_.addSeparator("Cr\xE9ation calque"); + //-- ajout de l action de creation du calque --// + menuPost_.add(new TrPostActionChooseAndCreateCalque(this)); + menuPost_.addMenuItem(TrResource.getS("Vue 2D"), "VIEW_2D", BuResource.BU.getIcon("aucun"), TrPostProjet.this); + menuPost_.addSeparator("Liste des projets"); + // -- init de la liste des menus --// + listeMenuProjets_ = new ArrayList<BuMenu>(); + + + listeSousMenuProjets_ = new ArrayList<ArrayList<BuMenuItem>>(); + // -- construction par defaut du premier menu de simulation --// + construitMenuPostSpecifiqueSource(getSource(0)); + + + } + + + + + private void showError(final CtuluUI _ui, final File _dbFile, final String _err) { String mess = TrResource.getS("Les sauvegardes ne seront pas effectu\xE9es") + CtuluLibString.LINE_SEP @@ -474,8 +623,13 @@ _ui.warn(FudaaSaveLib.getActionSaveTitle(), mess, false); } - private void showExtremum() { - final JTable table = TrPostMinMaxTableModel.createTableFor(src_); + /** + * calcul les extrema en fonction de la source proposee + * + * @param indiceSource_ + */ + private void showExtremum(int indiceSource_) { + final JTable table = TrPostMinMaxTableModel.createTableFor(getSource(indiceSource_)); final TrPostMinMaxTableModel model = (TrPostMinMaxTableModel) table.getModel(); final CtuluDialogPanel panel = new CtuluDialogPanel(); final CtuluDialog dial = new CtuluDialog(getImpl().getFrame(), panel); @@ -695,34 +849,7 @@ } - // TODO adrien a redefinir - // protected void addFille(final TrPostCourbeTreeModel _model, final String - // _titre, final ProgressionInterface _prog) { - // final EGGraphe graphe = new EGGraphe(_model); - // graphe.setXAxe(buildDefaultTimeAxe()); - // final FudaaGrapheTimeAnimatedVisuPanel pn = new - // FudaaGrapheTimeAnimatedVisuPanel(graphe, TrPostCourbeBuilder - // .getSpecActions(graphe, impl_, (TrPostVisuPanel) fille_.getVisuPanel())); - // graphe.setCmd(new CtuluCommandManager()); - // final TrPostCourbeFille fille = new TrPostCourbeFille(pn, _titre, impl_, - // null); - // fille.setPreferredSize(new Dimension(600, 400)); - // fille.setName("fille" + idxFilleG_++); - // fille.setTitle(_titre + CtuluLibString.ESPACE + - // CtuluLibString.getString(idxFilleG_)); - // fille.setFrameIcon(EbliResource.EBLI.getToolIcon("curves")); - // // pour charger les icones dans un autre thread. - // pn.getSpecificActions(); - // BuLib.invokeLater(new Runnable() { - // - // public void run() { - // fille.pack(); - // //TODO ne plus gerer de fille mais un Node dans la scene - // impl_.addInternalFrame(fille); - // graphe.restore(); - // } - // }); - // } + /** * refonte de addFille qui ajoute des widgets * @@ -814,69 +941,20 @@ * Methode qui parametre la frame layout ainsi que le menu associe. */ protected void decoreFilleVisu() { - // fille_.setFrameIcon(EbliResource.EBLI.getToolIcon("lissage")); + - // fille_.setClosable(true); - // fille_.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - // -- realisation idem pour fillelayout --// filleLayout_.setFrameIcon(EbliResource.EBLI.getToolIcon("lissage")); - // filleLayout_.setTitle(getTitle()); + filleLayout_.setClosable(true); filleLayout_.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - // -- agrandissement du panel droit --// - // impl_.getMainPanel().getRightColumn().setPreferredSize(new - // Dimension(400,impl_.getMainPanel().getPreferredSize().height)); + // -- creation du menu POST de base --// + setMenuPost(); + + + - // -- ajout de la vue sattelite de la scene --// - // JComponent satt = filleLayout_.getScene().createSatelliteView(); - - // FIXME Adrien: si je decommente ci-dessous, ca plante, je ne comprends - // pas!!!!!!! - // impl_.getMainPanel().getRightColumn().addToggledComponent("Aper\xE7u", - // "SCENEAPERCU", satt, this); - - // filleLayout_.getScene().refresh(); - - // -- ajout du tree de la fille layout dans impl --// - // impl_.getMainPanel().getRightColumn().addToggledComponent("Calques", - // "SCENECALQUES", - // new BuScrollPane(filleLayout_.getTree_()), this); - // - // filleLayout_.getScene().refresh(); - // filleLayout_.getScene_().refresh(); - // TODO modifier - final BuMenuBar menubar = impl_.getMainMenuBar(); - final BuMenu menu = new BuMenu(TrResource.getS("Post"), "POST"); - menu.setIcon(null); - menu.setName("mnPost"); - final BuIcon ic = BuResource.BU.getIcon("aucun"); - menu.addMenuItem(TrResource.getS("Vue 2D"), "VIEW_2D", ic, TrPostProjet.this); - menu.addMenuItem(TrResource.getS("Extrema..."), "COMPUTE_EXTREMA", ic, TrPostProjet.this); - menu.addMenuItem(CtuluLib.getS("Editer les variables..."), "VARIABLES", ic, TrPostProjet.this); - menu.addSeparator(); - menu.addMenuItem(TrResource.getS("Palettes de couleurs"), "PALETTE_DEFAULT", ic, TrPostProjet.this); - menu.addMenuItem(TrResource.getS("Formater/modifier les pas de temps..."), "TIME_FORMAT", ic, TrPostProjet.this); - addSpecificItemInMainMenu(menu); - menu.addSeparator(); - menu.addMenuItem(TrResource.getS("Comparer..."), "COMPARE", ic, TrPostProjet.this).setToolTipText( - TrResource.getS("Comparer les r\xE9sultats avec ceux d'un autre projet")); - menu.addMenuItem(TrResource.getS("Projeter..."), "PROJECT", ic, TrPostProjet.this).setToolTipText( - TrResource.getS("Projeter les r\xE9sultats sur un maillage diff\xE9rent")); - if (src_ != null && src_.isInspectable()) { - menu.addSeparator(); - menu.addMenuItem(TrResource.getS("Rafra\xEEchir les r\xE9sultats"), "MAJ_DATA", ic, TrPostProjet.this).setToolTipText( - TrResource.getS("Les fichiers de r\xE9sultats seront relus")); - menu.addMenuItem(TrResource.getS("Rafra\xEEchir automatiquement"), "MAJ_DATA_ALWAYS", ic, TrPostProjet.this) - .setToolTipText(TrResource.getS("Les fichiers sont surveill\xE9s p\xE9riodiquement")); - menu.addSeparator(); - menu.addMenuItem(TrResource.getS("Exporter"), "EXPORTDATA", TrPostProjet.this); - - } - - menubar.add(menu, 2); - } protected Runnable getRunnableForVisu(final Runnable _other) { @@ -922,36 +1000,104 @@ } } + /** + * performed d action pour toutes les simulations charg\xE9es. compl\xE9xit\xE9 de l + * algo: lin\xE9aire Cette methode est robuste en cas de suppression de sources + * et donc de menus. + */ public void actionPerformed(final ActionEvent _event) { - final String com = _event.getActionCommand(); - if ("VIEW_2D".equals(com)) { + final String commandeBrute = _event.getActionCommand(); + + // -- cas de base ou c est la vue 2d + if ("VIEW_2D".equals(commandeBrute) ) { activeFille(); - } else if ("COMPUTE_EXTREMA".equals(com)) { - showExtremum(); - } else if ("PALETTE_DEFAULT".equals(com)) { - updatePaletteMin(); - } else if ("TIME_FORMAT".equals(com)) { - TrPostTimeFmtPanel.updateTimeStepFmt(this, getImpl().getFrame()); - } else if ("VARIABLES".equals(com)) { - activeVarFrame(); - } else if ("EXPORTDATA".equals(com)) { - TrPostVisuPanel.startExport(getImpl(), getSource(), null); - } else if ("COMPARE".equals(com)) { - compareWith(); - } else if ("PROJECT".equals(com)) { - projectOn(); - } else if ("IMPORTER_RESULTS".equals(com)) { - importerVars(); - } else if ("MAJ_DATA_ALWAYS".equals(com)) { - if (src_.isInspected()) { return; } - new TrPostInspector(this).start(); - } else if ("MAJ_DATA".equals(com)) { - final TrPostInspectorReader watcher = src_.createWatcher(this, false); - if (watcher != null) { - watcher.read(); - watcher.close(); + return; + } + + // -- gestion des actions en fonction de la simul choisie --// + int indiceSimulation = 0; + + for (int i = 0; i < listeSousMenuProjets_.size(); i++) { + + // --recuperation de la liste des sousmenu de la simulation i --// + ArrayList<BuMenuItem> listeSousMenus = listeSousMenuProjets_.get(i); + + indiceSimulation = i; + + // -- on recherche si l action provient d un des fils --// + for (int j = 0; j < listeSousMenus.size(); j++) { + BuMenuItem item = listeSousMenus.get(j); + + //-- on essaie de matcher a la fois la commande et l objet pour savoir si c est le bon --// + // -- si une clause du if est v\xE9rifi\xE9 alors on gere la simulation i --// + if ("COMPUTE_EXTREMA".equals(commandeBrute) && item == _event.getSource()) { + + FuLog.warning("je fais partie de la simulation " + indiceSimulation); + showExtremum(indiceSimulation); + } else if ("PALETTE_DEFAULT".equals(commandeBrute) && item == _event.getSource()) { + updatePaletteMin(); + } else if ("TIME_FORMAT".equals(commandeBrute) && item == _event.getSource()) { + TrPostTimeFmtPanel.updateTimeStepFmt(this, getImpl().getFrame()); + } else if ("VARIABLES".equals(commandeBrute) && item == _event.getSource()) { + activeVarFrame(); + } else if ("EXPORTDATA".equals(commandeBrute) && item == _event.getSource()) { + TrPostVisuPanel.startExport(getImpl(), getSource(indiceSimulation), null); + } else if ("COMPARE".equals(commandeBrute) && item == _event.getSource()) { + compareWith(); + } else if ("PROJECT".equals(commandeBrute) && item == _event.getSource()) { + projectOn(); + } else if ("IMPORTER_RESULTS".equals(commandeBrute) && item == _event.getSource()) { + importerVars(); + } else if ("MAJ_DATA_ALWAYS".equals(commandeBrute) && item == _event.getSource()) { + if (src_.isInspected()) { return; } + new TrPostInspector(this).start(); + } else if ("MAJ_DATA".equals(commandeBrute) && item == _event.getSource()) { + final TrPostInspectorReader watcher = getSource(indiceSimulation).createWatcher(this, false); + if (watcher != null) { + watcher.read(); + watcher.close(); + } + } + + + } + + } + + +// if ("VIEW_2D".equals(commandeBrute)) { + // activeFille(); + // } else if ("COMPUTE_EXTREMA".equals(commandeBrute)) { + // showExtremum(0); + // } else if ("PALETTE_DEFAULT".equals(commandeBrute)) { + // updatePaletteMin(); + // } else if ("TIME_FORMAT".equals(commandeBrute)) { + // TrPostTimeFmtPanel.updateTimeStepFmt(this, getImpl().getFrame()); + // } else if ("VARIABLES".equals(commandeBrute)) { + // activeVarFrame(); + // } else if ("EXPORTDATA".equals(commandeBrute)) { + // TrPostVisuPanel.startExport(getImpl(), getSource(), null); + // } else if ("COMPARE".equals(commandeBrute)) { + // compareWith(); + // } else if ("PROJECT".equals(commandeBrute)) { + // projectOn(); + // } else if ("IMPORTER_RESULTS".equals(commandeBrute)) { + // importerVars(); + // } else if ("MAJ_DATA_ALWAYS".equals(commandeBrute)) { + // if (src_.isInspected()) { return; } + // new TrPostInspector(this).start(); + // } else if ("MAJ_DATA".equals(commandeBrute)) { + // final TrPostInspectorReader watcher = src_.createWatcher(this, false); + // if (watcher != null) { + // watcher.read(); + // watcher.close(); + // } + // } + + + } public void activate(final File _f) {} @@ -986,8 +1132,10 @@ // -- ajout du visuPanel au layout --// - filleLayout_.addCalque("Calque principal", pnVisu.getLocation(), pnVisu.getPreferredSize(), pnVisu); - + EbliNode node = filleLayout_.addCalque("Calque principal", pnVisu.getLocation(), pnVisu.getPreferredSize(), + pnVisu); + // -- ajout de l INFO de la source utilis\xE9e --// + node.getCreator().getWidget().setDescription_(formatInfoSource(getSource(0))); // -- decoration de la fille layout --// decoreFilleVisu(); @@ -1157,12 +1305,25 @@ } /** - * @return la source utilisee + * @return la source courante utilisee */ public TrPostSource getSource() { return src_; } + /** + * retourne la source de la liste des sources + * + * @param i + * @return + */ + public TrPostSource getSource(int i) { + if (i < listeSrc_.size()) + return listeSrc_.get(i); + else + return null; + } + public FudaaCourbeTimeListModel getTimeModel() { return getSource().getNewTimeListModel(); } Added: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetChooser.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetChooser.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetChooser.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -0,0 +1,176 @@ +package org.fudaa.fudaa.tr.post; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.io.File; +import java.util.Observable; +import java.util.Observer; + +import javax.swing.AbstractListModel; +import javax.swing.BorderFactory; +import javax.swing.JList; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.border.Border; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import org.fudaa.ctulu.CtuluLibString; +import org.jdesktop.swingx.JXList; + +import com.memoire.bu.BuInternalFrame; +import com.memoire.bu.BuLabel; +import com.memoire.fu.FuLog; + +/** + * chooser qui demande a l user de choisir la simulation a prendre pour la + * selection. + * + * @author Adrien Hadoux + * + */ +public class TrPostProjetChooser extends BuInternalFrame implements ListSelectionListener, Observer { + + /** + * projet contenant la liste des sources. + */ + TrPostProjet projet_; + + /** + * La liste des projet afffichage graphique. + */ + JXList listProjets_; + + + JScrollPane listScroller_; + /** + * Classe Model de la jlist + */ + class ModelProjets extends AbstractListModel implements /* ListModel, */ListCellRenderer { + + TrPostProjet p; + BuLabel labelTexte = new BuLabel(""); + Color background; + Color foreground; + + public ModelProjets(TrPostProjet _p) { + p = _p; + labelTexte.setOpaque(true); + } + + public Object getElementAt(int index) { + + TrPostSource src = (TrPostSource) p.listeSrc_.toArray()[index]; + return src; + } + + public int getSize() { + return p.listeSrc_.size(); + } + + // TODO utiliser CtuluCellTextRenderer + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + Border border = null; + + // -- recuperation du simple nom du fichier --// + String nomFichier = ((TrPostSource) value).getFile().getAbsolutePath(); + int position = nomFichier.lastIndexOf(File.separator) + 1; + if (position != -1) { + nomFichier = nomFichier.substring(position); + } + position = nomFichier.lastIndexOf(CtuluLibString.DOT); + if (position != -1) { + nomFichier = nomFichier.substring(0, position); + } + FuLog.warning("nom du fichier: " + nomFichier); + + // --suppression des trop long espaces du titre --// + String title = ((TrPostSource) value).getTitle(); + title = title.replaceAll(" ", ""); + + // -- on ajoute un indicateur pour le projet selectionn\xE9 --// + if ((TrPostSource) value != projet_.src_) + labelTexte.setText(title + " | Fichier: " + nomFichier); + else { + labelTexte.setText("-> " + title + " | Fichier: " + nomFichier); + // labelTexte.setForeground(Color.YELLOW); + } + + labelTexte.setBackground(list.getBackground()); + labelTexte.setForeground(list.getForeground()); + labelTexte.setOpaque(true); + if (isSelected) { + labelTexte.setBackground(list.getSelectionBackground()); + labelTexte.setForeground(list.getSelectionForeground()); + } + + return labelTexte; + } + + } + + ModelProjets modelList_; + + + + + public TrPostProjetChooser(TrPostProjet _projet) { + super(); + + // -- recuperation du projet --// + projet_ = _projet; + + + // -- ajout comme observer --// + projet_.getObservable().addObserver(this); + + // --creation de la liste graphique des projets --// + modelList_ = new ModelProjets(projet_); + listProjets_ = new JXList(modelList_); + listProjets_.setCellRenderer(modelList_); + + listProjets_.setBorder(BorderFactory.createEtchedBorder()); + + // -- ajoute un selecteur --// + // listProjets_.addListSelectionListener(this); + + // -- oblige la selection unique pour ne pas ajouter qu un seul projet a la + // fois--// + listProjets_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + // -- selectionne par default le src courant --// + listProjets_.setSelectedValue(projet_.src_, true); + + // --creation graphique --// + + + // setSize(500, 250); + // setPreferredSize(new Dimension(500, 250)); + setLayout(new BorderLayout()); + listScroller_ = new JScrollPane(listProjets_); + this.add(listScroller_, BorderLayout.CENTER); + } + + public void valueChanged(ListSelectionEvent e) { + + // -- recuperation de l element selectionn\xE9 --// + FuLog.warning("l'objet selectionne est: " + listProjets_.getSelectedValue()); + + } + + public void update(Observable o, Object arg) { + FuLog.warning("je suis entre dans le update()"); + // mise a jour de la liste + listProjets_.revalidate(); + + } + + + + + + +} 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 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjetsManagerFille.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -1,24 +1,23 @@ package org.fudaa.fudaa.tr.post; import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; +import java.util.Date; +import java.util.Observable; +import java.util.Observer; import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; -import javax.swing.JList; import javax.swing.JScrollPane; -import javax.swing.ListCellRenderer; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelListener; +import javax.swing.table.AbstractTableModel; import org.fudaa.fudaa.tr.common.TrResource; -import org.jdesktop.swingx.JXList; +import org.jdesktop.swingx.JXTable; import com.memoire.bu.BuButton; import com.memoire.bu.BuInternalFrame; -import com.memoire.bu.BuLabel; import com.memoire.bu.BuPanel; import com.memoire.bu.BuResource; import com.memoire.fu.FuLog; @@ -29,7 +28,7 @@ * @author Adrien Hadoux * */ -public class TrPostProjetsManagerFille extends BuInternalFrame implements ListSelectionListener { +public class TrPostProjetsManagerFille extends BuInternalFrame implements ListSelectionListener, Observer { /** * projet contenant la liste des sources. @@ -39,7 +38,7 @@ /** * La liste des projet afffichage graphique. */ - JXList listProjets_; + JXTable listProjets_; @@ -48,63 +47,112 @@ /** * Classe Model de la jlist */ - class ModelProjets extends DefaultListModel implements /* ListModel, */ListCellRenderer { + class ModelTableProjets extends AbstractTableModel { TrPostProjet p; - BuLabel labelTexte = new BuLabel(""); - Color background; - Color foreground; + + String[] titres_ = { "N\xB0", "Nom", "Fichier", "Date de derni\xE8re modification", "Statut", "Donn\xE9es Rubar" }; - public ModelProjets(TrPostProjet _p) { + public ModelTableProjets(TrPostProjet _p) { p = _p; - labelTexte.setOpaque(true); + } - - public Object getElementAt(int index) { + + + public void addTableModelListener(TableModelListener l) { + } + + public Class<?> getColumnClass(int columnIndex) { - TrPostSource src = (TrPostSource) p.listeSrc_.toArray()[index]; - return src; + 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 getSize() { - return p.listeSrc_.size(); + public int getColumnCount() { + return titres_.length; } - - // TODO utiliser CtuluCellTextRenderer - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, - boolean cellHasFocus) { - - if (isSelected) { - background = Color.BLUE; - foreground = Color.WHITE; + public String getColumnName(int columnIndex) { + return titres_[columnIndex]; + } - } else { - background = Color.WHITE; - foreground = Color.BLUE; + public int getRowCount() { + return p.listeSrc_.size(); + } - } - labelTexte.setBackground(background); - labelTexte.setForeground(foreground); - - // -- on ajoute un indicateur pour le projet selectionn\xE9 --// - if ((TrPostSource) value != projet_.src_) - labelTexte.setText(((TrPostSource) value).getTitle()); - else { - labelTexte.setText("-> " + ((TrPostSource) value).getTitle()); - labelTexte.setForeground(Color.YELLOW); - } + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex >= getColumnCount()) + return null; + TrPostSource src = p.listeSrc_.get(rowIndex); + + + - return labelTexte; + switch (columnIndex) { + case 0: + return rowIndex + 1; + case 1: + return p.formatName(src.getTitle()); + case 2: + return p.formatFichier(src.getFile()); + case 3: + return new Date(src.getFile().lastModified()); + case 4: + return src.isInspectable(); + case 5: + return src.isRubar(); + } + return null; } + + + /** + * Format le nom du fichier + * + * @param file + * @return + */ + + + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + + public void removeTableModelListener(TableModelListener l) { + } + + public void setValueAt(Object value, int rowIndex, int columnIndex) { + } + + + + + + // TODO utiliser CtuluCellTextRenderer + + } - ModelProjets modelList_; + 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")); @@ -119,24 +167,34 @@ projet_ = _projet; - + // -- ajout de la fenetre comme observer du projet --// + projet_.getObservable().addObserver(this); // --creation de la liste graphique des projets --// - modelList_ = new ModelProjets(projet_); - listProjets_ = new JXList(modelList_); - listProjets_.setCellRenderer(modelList_); + modelList_ = new ModelTableProjets(projet_); + + + + listProjets_ = new JXTable(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_.setBorder(BorderFactory.createEtchedBorder()); // -- ajoute un selecteur --// - listProjets_.addListSelectionListener(this); + // listProjets_.addListSelectionListener(this); // -- oblige la selection unique pour ne pas ajouter qu un seul projet a la // fois--// listProjets_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // -- selectionne par default le src courant --// - listProjets_.setSelectedValue(projet_.src_, true); + // listProjets_.setSelectedValue(projet_.src_, true); // --creation graphique --// // setSize(500, 250); @@ -157,7 +215,7 @@ this.add(operationPanel, BorderLayout.SOUTH); operationPanel.add(boutonAjoutSrc_); operationPanel.add(boutonEnleveSrc_); - operationPanel.add(boutonChangeSrc_); + // operationPanel.add(boutonChangeSrc_); // -- ajout du listener du bouton d ajout d'un element source this.boutonAjoutSrc_.setAction(new TrPostActionOpenSrc(projet_)); @@ -171,11 +229,23 @@ public void valueChanged(ListSelectionEvent e) { // -- recuperation de l element selectionn\xE9 --// - FuLog.warning("l'objet selectionne est: " + listProjets_.getSelectedValue()); + // FuLog.warning("l'objet selectionne est: " + + // listProjets_.getSelectedValue()); } + + + + public void update(Observable o, Object arg) { + FuLog.warning("je suis entre dans le update()"); + // mise a jour de la liste + modelList_.fireTableStructureChanged(); + + // selection par defaut de la premiere simul + listProjets_.clearSelection(); + } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostVisuPanel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostVisuPanel.java 2008-08-25 20:39:03 UTC (rev 3838) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostVisuPanel.java 2008-08-26 16:06:40 UTC (rev 3839) @@ -24,7 +24,6 @@ import org.fudaa.ctulu.CtuluUI; import org.fudaa.ctulu.gui.CtuluLibDialog; import org.fudaa.ctulu.gui.CtuluLibSwing; -import org.fudaa.ctulu.gui.CtuluTaskOperationGUI; import org.fudaa.dodico.h2d.type.H2dVariableType; import org.fudaa.ebli.animation.ActionAnimationTreeSelection; import org.fudaa.ebli.animation.EbliAnimatedInterface; @@ -44,7 +43,6 @@ import org.fudaa.ebli.commun.EbliActionPaletteAbstract; import org.fudaa.ebli.commun.EbliActionSimple; import org.fudaa.ebli.commun.EbliLib; -import org.fudaa.ebli.geometrie.GrBoite; import org.fudaa.ebli.visuallibrary.EbliScene; import org.fudaa.ebli.visuallibrary.calque.EbliWidgetCalqueLegende; import org.fudaa.fudaa.commun.impl.FudaaCommonImplementation; @@ -111,23 +109,53 @@ TrPostInfoDelegate info_; final JComponent suiviPanel_; + + /** + * Tres important!!! c'est l'indice de la source utilisee par le + * trpostvisupanel. Il est automatiquement plac\xE9 en param du constructeur. Si + * rien n est mis apr defaut ce sera 0, donc le cas ou il y a une seule simul. + */ + private int indiceSOURCECourant_ = 0; + public int getIndiceSOURCECourant_() { + return indiceSOURCECourant_; + } + public TrPostVisuPanel(final FudaaCommonImplementation _impl, final TrPostProjet _controller, BCalqueLegende _leg) { - this(_impl, _controller, false, _leg); + this(_impl, _controller, false, _leg, 0); } + + public TrPostVisuPanel(final FudaaCommonImplementation _impl, final TrPostProjet _controller, BCalqueLegende _leg, + int _indiceSOURCECourant) { + this(_impl, _controller, false, _leg, _indiceSOURCECourant); + + + } + public TrPostVisuPanel(final FudaaCommonImplementation _impl, final TrPostProjet _controller, boolean _simplified, + BCalqueLegende _leg) { + this(_impl, _controller, _simplified, _leg, 0); + + + } + /** * @param _impl l'impl parent * @param _controller le controller contenant la source + * @param _indiceSOURCECourant : l indice de la source courante utilis\xE9e */ public TrPostVisuPanel(final FudaaCommonImplementation _impl, final TrPostProjet _controller, boolean _simplified, - BCalqueLegende _leg) { + BCalqueLegende _leg, int _indiceSOURCECourant) { super(new TrPostActionController(_impl), _impl); + + // -- mise a jour de l indice de ls source courante --// + indiceSOURCECourant_ = _indiceSOURCECourant; + srcCont_ = _controller; - info_ = new TrPostInfo... [truncated message content] |