From: Frederic D. <de...@us...> - 2004-05-05 12:43:19
|
Update of /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/projet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3787/src/org/fudaa/fudaa/commun/projet Modified Files: FudaaProjet.java Added Files: FudaaDialogNewProject.java FudaaFiltreFichier.java Log Message: Suppression inter-dépendances Index: FudaaProjet.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/projet/FudaaProjet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FudaaProjet.java 19 Mar 2004 17:40:25 -0000 1.6 --- FudaaProjet.java 5 May 2004 12:42:35 -0000 1.7 *************** *** 36,41 **** import javax.swing.JOptionPane; - import org.fudaa.ctulu.CtuluLib; - import com.memoire.bu.BuCommonInterface; import com.memoire.bu.BuDialogConfirmation; --- 36,39 ---- *************** *** 50,57 **** import fr.dyade.koala.xml.koml.KOMLSerializer; ! import org.fudaa.ebli.filechooser.EbliFileChooser; ! ! import org.fudaa.fudaa.commun.FudaaDialogNewProject; ! import org.fudaa.fudaa.commun.FudaaFiltreFichier; import org.fudaa.fudaa.ressource.FudaaResource; /** --- 48,53 ---- import fr.dyade.koala.xml.koml.KOMLSerializer; ! import org.fudaa.ctulu.CtuluLib; ! import org.fudaa.ebli.dialog.EbliFileChooser; import org.fudaa.fudaa.ressource.FudaaResource; /** --- NEW FILE: FudaaDialogNewProject.java --- /* * @file FudaaDialogNewProject.java * @creation 1998-10-06 * @modification $Date: 2004/05/05 12:42:35 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail de...@fu... */ package org.fudaa.fudaa.commun.projet; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.GridLayout; import java.awt.Insets; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.io.File; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import com.memoire.bu.BuBorderLayout; import com.memoire.bu.BuButton; import com.memoire.bu.BuFileChooser; import com.memoire.bu.BuGridLayout; import com.memoire.bu.BuLib; import com.memoire.bu.BuResource; import org.fudaa.ctulu.CtuluLib; import org.fudaa.ebli.dialog.EbliFileChooser; import org.fudaa.fudaa.ressource.FudaaResource; /** * Une boite d'entree de texte. * * @version $Revision: 1.1 $ $Date: 2004/05/05 12:42:35 $ by $Author: deniger $ * @author Axel von Arnim */ public class FudaaDialogNewProject extends JDialog implements ActionListener, WindowListener { // Donnees membres publiques public final static int CANCEL= 0; public final static int OK= 1; // Donnees membres privees protected JTextField tf_titre_, tf_fichier_, tf_comment_; protected JPanel p_titre_, p_fichier_, p_comment_, p_ok_; protected GridLayout lo_; protected JButton b_ok_, b_cancel_, b_fichier_; protected String titre_; protected String fichier_; protected FudaaFiltreFichier filtre_; protected String comment_; protected String dirOpen_; protected Frame parent_; protected int status_; // Constructeurs public FudaaDialogNewProject(Frame _parent) { this(_parent, null, null); status_= 2; } public FudaaDialogNewProject( Frame _parent, FudaaFiltreFichier f, String _dirOpen) { super(_parent, BuResource.BU.getString("Nouveau"), true); parent_= _parent; titre_= null; fichier_= null; filtre_= f; comment_= null; if ((_dirOpen != null) && (new File(_dirOpen).exists())) dirOpen_= _dirOpen; else dirOpen_= null; BuGridLayout lo= new BuGridLayout(); lo.setColumns(3); lo.setVgap(5); lo.setHgap(5); JPanel panel= new JPanel(); panel.setLayout(lo); panel.setBorder(new EmptyBorder(5, 5, 5, 5)); int n= 0; tf_titre_= new JTextField(); tf_titre_.setColumns(20); String s= ":"; panel.add( new JLabel(BuResource.BU.getString("Titre") + s, JLabel.RIGHT), n++); panel.add(tf_titre_, n++); panel.add(new JLabel(CtuluLib.EMPTY_STRING), n++); tf_fichier_= new JTextField(); tf_fichier_.setColumns(20); panel.add( new JLabel(BuResource.BU.getString("Fichier") + s, JLabel.RIGHT), n++); panel.add(tf_fichier_, n++); b_fichier_= new JButton(FudaaResource.getS("Parcourir")); b_fichier_.setMargin(new Insets(0, 0, 0, 0)); b_fichier_.setActionCommand("PARCOURIR"); b_fichier_.addActionListener(this); panel.add(b_fichier_, n++); tf_comment_= new JTextField(); tf_comment_.setColumns(20); panel.add( new JLabel(BuResource.BU.getString("Commentaires") + s, JLabel.RIGHT), n++); panel.add(tf_comment_, n++); panel.add(new JLabel(""), n++); b_ok_= new BuButton(); b_ok_.setText(BuResource.BU.getString("Valider")); b_ok_.setIcon(BuLib.loadCommandIcon("VALIDER")); b_ok_.setActionCommand("VALIDER"); b_ok_.addActionListener(this); b_cancel_= new BuButton(); b_cancel_.setText(BuResource.BU.getString("Annuler")); b_cancel_.setIcon(BuLib.loadCommandIcon("ANNULER")); b_cancel_.setActionCommand("ANNULER"); b_cancel_.addActionListener(this); p_ok_= new JPanel(new FlowLayout(FlowLayout.RIGHT)); p_ok_.add(b_cancel_); p_ok_.add(b_ok_); getRootPane().setDefaultButton(b_ok_); Container content= getContentPane(); content.setLayout(new BuBorderLayout()); content.add(panel, BuBorderLayout.NORTH); content.add(p_ok_, BuBorderLayout.SOUTH); pack(); setResizable(false); if (_parent instanceof Component){ Dimension dParent= Toolkit.getDefaultToolkit().getScreenSize(); Dimension dThis= getPreferredSize(); setLocation((dParent.width - dThis.width) / 2,(dParent.height - dThis.height) / 2); // super.setLocationRelativeTo(_parent); } } // Methodes publiques public String getTitre() { return titre_; } public void setTitre(String _titre) { if ((_titre == null) || (_titre.equals(titre_))) return; titre_= _titre; tf_titre_.setText(titre_); } public String getFichier() { return fichier_; } public void setFichier(String _fichier) { if ((_fichier == null) || (_fichier.equals(fichier_))) return; fichier_= _fichier; tf_fichier_.setText(fichier_); } public String getComment() { return comment_; } public void setComment(String _comment) { if ((_comment == null) || (_comment.equals(comment_))) return; comment_= _comment; tf_comment_.setText(comment_); } public int getStatus() { return status_; } // Actions public void actionPerformed(ActionEvent _evt) { String action= _evt.getActionCommand(); System.err.println("ACTION=" + action); if (action.equals("ANNULER")) { titre_= null; fichier_= null; comment_= null; dispose(); status_= CANCEL; } else if (action.equals("VALIDER")) { titre_= tf_titre_.getText(); fichier_= tf_fichier_.getText(); comment_= tf_comment_.getText(); if (fichier_.equals("")); // A FAIRE: pop fenetre erreur fichier! dispose(); status_= OK; } else if (action.equals("PARCOURIR")) { String text= popFileChooser(); tf_fichier_.setText(text == null ? "" : text); } } // Window events public void windowActivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { titre_= null; fichier_= null; comment_= null; dispose(); } public void windowDeactivated(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} // Methodes privees private String popFileChooser() { BuFileChooser chooser= new EbliFileChooser(false); if (filtre_ != null) chooser.setFileFilter(filtre_); if (dirOpen_ == null) dirOpen_= System.getProperty("user.dir") + File.separator + "exemples"; if (dirOpen_ != null) chooser.setCurrentDirectory(new File(dirOpen_)); int returnVal= chooser.showOpenDialog(this); dirOpen_= chooser.getCurrentDirectory().getAbsolutePath(); String filename= null; if (returnVal == BuFileChooser.APPROVE_OPTION) { filename= chooser.getSelectedFile().getAbsolutePath(); } return filename; } } --- NEW FILE: FudaaFiltreFichier.java --- /* * @file FudaaFiltreFichier.java * @creation 1999-01-07 * @modification $Date: 2004/05/05 12:42:35 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail de...@fu... */ package org.fudaa.fudaa.commun.projet; /** * Le filtre de fichiers generique de Fudaa. * * @version $Revision: 1.1 $ $Date: 2004/05/05 12:42:35 $ by $Author: deniger $ * @author Axel von Arnim */ public class FudaaFiltreFichier extends javax.swing.filechooser.FileFilter { private String[] ext_; private int mode_; public FudaaFiltreFichier(String _ext) { ext_= new String[1]; ext_[0]= _ext; mode_= FudaaProjet.BIN; } public FudaaFiltreFichier(String[] _ext) { if (_ext.length == 0) { ext_= new String[1]; ext_[0]= "fud"; } else ext_= _ext; mode_= FudaaProjet.BIN; } public String toString() { return "FudaaFiltreFichier : *." + ext_[0]; } public void setMode(int _mode) { if (_mode == mode_) return; mode_= _mode; } public int getMode() { return mode_; } public boolean accept(java.io.File fic) { boolean res= fic.isDirectory(); String name= fic.getName(); for (int i= 0; i < ext_.length; i++) { String ext= ext_[i]; if (mode_ == FudaaProjet.ASC) ext += ".asc"; else if (mode_ == FudaaProjet.ASCGZ) ext += ".asc.gz"; else if (mode_ == FudaaProjet.XML) ext += ".xml"; else if (mode_ == FudaaProjet.XMLGZ) ext += ".xml.gz"; res= res || (name.endsWith("." + ext.toLowerCase()) || name.endsWith("." + ext.toUpperCase())); } return res; } public String getDescription() { switch (mode_) { case FudaaProjet.BIN : return "*." + ext_[0]; case FudaaProjet.ASC : return "*." + ext_[0] + ".asc"; case FudaaProjet.XML : return "*." + ext_[0] + ".xml"; case FudaaProjet.ASCGZ : return "*." + ext_[0] + ".asc.gz"; case FudaaProjet.XMLGZ : return "*." + ext_[0] + ".xml.gz"; } return ""; } public String fudify(String name) { switch (mode_) { case FudaaProjet.BIN : { name += "." + ext_[0]; break; } case FudaaProjet.ASC : case FudaaProjet.XML : { int mode= mode_; mode_= FudaaProjet.BIN; name= fudify(name); mode_= mode; if (mode_ == FudaaProjet.ASC) name += ".asc"; else if (mode_ == FudaaProjet.XML) name += ".xml"; break; } case FudaaProjet.ASCGZ : { int mode= mode_; mode_= FudaaProjet.ASC; name= fudify(name); mode_= mode; name += ".gz"; break; } case FudaaProjet.XMLGZ : { int mode= mode_; mode_= FudaaProjet.XML; name= fudify(name); mode_= mode; name += ".gz"; break; } default : break; } return name; } public String unfudify(String name) { int index= name.toLowerCase().indexOf("." + ext_[0]); if (index > 0) return name.substring(0, index); else return name; } } |