From: Frederic D. <de...@us...> - 2004-04-30 07:22:51
|
Update of /cvsroot/fudaa/fudaa_devel/ebli/src/org/fudaa/ebli/dialog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2966/src/org/fudaa/ebli/dialog Modified Files: EbliSimpleDialogPanel.java EbliSimpleDialog.java Log Message: Modif des dialogues Index: EbliSimpleDialog.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/ebli/src/org/fudaa/ebli/dialog/EbliSimpleDialog.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EbliSimpleDialog.java 31 Mar 2004 08:15:43 -0000 1.9 --- EbliSimpleDialog.java 30 Apr 2004 07:22:42 -0000 1.10 *************** *** 1,17 **** /* ! * @file EbliSimpleDialog.java ! * @creation 23 juin 2003 ! * @modification $Date$ ! * @license GNU General Public License 2 ! * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne ! * @mail de...@fu... */ package org.fudaa.ebli.dialog; - import java.awt.Component; import java.awt.Dialog; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.Toolkit; import java.awt.event.ActionEvent; --- 1,15 ---- /* ! * @file EbliSimpleDialog.java @creation 23 juin 2003 @modification $Date$ ! * @license GNU General Public License 2 @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 ! * Compiegne @mail de...@fu... */ package org.fudaa.ebli.dialog; import java.awt.Dialog; import java.awt.Dimension; import java.awt.FlowLayout; + import java.awt.FontMetrics; import java.awt.Frame; + import java.awt.Point; import java.awt.Toolkit; import java.awt.event.ActionEvent; *************** *** 20,30 **** --- 18,32 ---- import java.awt.event.WindowEvent; import java.awt.event.WindowListener; + import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JOptionPane; + import com.memoire.bu.BuBorderLayout; import com.memoire.bu.BuButton; import com.memoire.bu.BuPanel; + import com.memoire.bu.BuScrollPane; + import org.fudaa.ebli.ressource.EbliResource; /** *************** *** 32,38 **** * @version $Id$ */ ! public class EbliSimpleDialog ! extends EnhancedDialog ! implements WindowListener, ActionListener { public static final int CANCEL_OPTION = 4; --- 34,38 ---- * @version $Id$ */ ! public class EbliSimpleDialog extends EnhancedDialog implements WindowListener, ActionListener { public static final int CANCEL_OPTION = 4; *************** *** 42,47 **** /** ! * Option : uniquement un bouton ok sera affiche. Reponse donnee par le dialogue si le bouton ! * "ok" utilise. */ public static final int OK_OPTION = 0; --- 42,47 ---- /** ! * Option : uniquement un bouton ok sera affiche. Reponse donnee par le dialogue si le bouton "ok" ! * utilise. */ public static final int OK_OPTION = 0; *************** *** 54,63 **** init(_dial); } ! ! public void setValue(Object o){ dial_.setValue(o); } ! ! public Object getValue(){ return dial_.getValue(); } --- 54,63 ---- init(_dial); } ! ! public void setValue(Object o) { dial_.setValue(o); } ! ! public Object getValue() { return dial_.getValue(); } *************** *** 81,88 **** return response_; } public void afficheDialog() { setContentPane(construitDialogPanel()); ! pack(); Dimension dialogSize = getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); --- 81,104 ---- return response_; } + + public int afficheDialogModal(Point _loc,Dimension _d) { + setModal(true); + setLocation(_loc); + System.out.println(_d); + setSize(_d); + doLayout(); + afficheDialog(false); + + return response_; + } public void afficheDialog() { + afficheDialog(true); + } + + public void afficheDialog(boolean _modify) { setContentPane(construitDialogPanel()); ! if(_modify){ ! pack(); Dimension dialogSize = getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); *************** *** 96,104 **** dialogSize.height = screenSize.height * 3 / 4; } ! if (set) ! setSize(dialogSize); ! setLocation( ! (screenSize.width - dialogSize.width) / 2, ! (screenSize.height - dialogSize.height) / 2); show(); } --- 112,119 ---- dialogSize.height = screenSize.height * 3 / 4; } ! if (set) setSize(dialogSize); ! setLocation((screenSize.width - dialogSize.width) / 2, ! (screenSize.height - dialogSize.height) / 2); ! } show(); } *************** *** 116,123 **** BuPanel princ = new BuPanel(); princ.setLayout(new BuBorderLayout()); ! /* if (isoft_ != null) { ! princ.add(getInfosPanel(isoft_), BuBorderLayout.WEST); ! }*/ ! princ.add(dial_.getError(), BuBorderLayout.NORTH); princ.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); princ.add(dial_, BuBorderLayout.CENTER); --- 131,139 ---- BuPanel princ = new BuPanel(); princ.setLayout(new BuBorderLayout()); ! BuScrollPane sc=new BuScrollPane(dial_.getError()); ! sc.setBorder(null); ! FontMetrics fm=getFontMetrics(dial_.getError().getFont()); ! sc.setPreferredHeight(fm.getHeight()*2); ! princ.add(sc, BuBorderLayout.NORTH); princ.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); princ.add(dial_, BuBorderLayout.CENTER); *************** *** 132,135 **** --- 148,152 ---- break; case OK_CANCEL_OPTION: + System.out.println("ok cancel"); pnAction.add(construireOk()); pnAction.add(construireCancel()); *************** *** 156,164 **** setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); response_ = JOptionPane.DEFAULT_OPTION; ! option_ = JOptionPane.OK_CANCEL_OPTION; } /** ! * Construit un bouton ayant comme label <code>_text</code> et comme "ActionCommand" <code>_action</code>. */ protected JButton construireBuButton(String _text, String _action) { --- 173,182 ---- setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); response_ = JOptionPane.DEFAULT_OPTION; ! option_ = OK_CANCEL_OPTION; } /** ! * Construit un bouton ayant comme label <code>_text</code> et comme "ActionCommand" ! * <code>_action</code>. */ protected JButton construireBuButton(String _text, String _action) { *************** *** 181,185 **** } - /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) --- 199,202 ---- *************** *** 189,195 **** if ("OK".equals(com)) { ok(); ! } else if ("CANCEL".equals(com)) { cancel(); ! } else if ("APPLY".equals(com)) { apply(); } --- 206,214 ---- if ("OK".equals(com)) { ok(); ! } ! else if ("CANCEL".equals(com)) { cancel(); ! } ! else if ("APPLY".equals(com)) { apply(); } *************** *** 202,206 **** public void cancel() { response_ = JOptionPane.CANCEL_OPTION; ! dial_.actionCancel(); dispose(); } --- 221,225 ---- public void cancel() { response_ = JOptionPane.CANCEL_OPTION; ! dial_.cancel(); dispose(); } *************** *** 213,222 **** return response_ == JOptionPane.DEFAULT_OPTION; } public void ok() { ! response_ = JOptionPane.OK_OPTION; ! dial_.actionOK(); ! dispose(); } /** --- 232,245 ---- return response_ == JOptionPane.DEFAULT_OPTION; } + public void ok() { ! if (dial_.valide()) { ! response_ = JOptionPane.OK_OPTION; ! dial_.ok(); ! dispose(); ! } } + /** *************** *** 229,234 **** */ public void windowClosed(WindowEvent e) { ! if (isResponseUndefinied()) ! dial_.actionCancel(); } --- 252,256 ---- */ public void windowClosed(WindowEvent e) { ! if (isResponseUndefinied()) dial_.cancel(); } *************** *** 271,273 **** option_ = _option; } ! } --- 293,295 ---- option_ = _option; } ! } \ No newline at end of file Index: EbliSimpleDialogPanel.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/ebli/src/org/fudaa/ebli/dialog/EbliSimpleDialogPanel.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EbliSimpleDialogPanel.java 31 Mar 2004 08:15:43 -0000 1.15 --- EbliSimpleDialogPanel.java 30 Apr 2004 07:22:42 -0000 1.16 *************** *** 14,26 **** import java.awt.Dialog; import java.awt.Dimension; - import java.awt.FlowLayout; import java.awt.Font; import java.awt.Frame; - import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - import java.awt.event.KeyEvent; - import java.awt.event.WindowEvent; - import java.awt.event.WindowListener; import java.io.File; --- 14,21 ---- *************** *** 28,32 **** import javax.swing.JButton; import javax.swing.JComponent; - import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JLabel; --- 23,26 ---- *************** *** 35,39 **** import javax.swing.border.EmptyBorder; - import com.memoire.bu.BuBorderLayout; import com.memoire.bu.BuButton; import com.memoire.bu.BuCharValidator; --- 29,32 ---- *************** *** 48,51 **** --- 41,45 ---- import com.memoire.bu.BuPicture; import com.memoire.bu.BuStringValidator; + import com.memoire.bu.BuTextArea; import com.memoire.bu.BuTextField; import com.memoire.bu.BuValueValidator; *************** *** 53,57 **** import org.fudaa.ebli.filechooser.EbliFileChooser; - import org.fudaa.ebli.ressource.EbliResource; /** * Un panneau qui peut etre facilement affichable dans une boite de dialogue. Cette classe reprend --- 47,50 ---- *************** *** 64,68 **** public class EbliSimpleDialogPanel extends BuPanel ! implements ActionListener, WindowListener { public static final String CHOOSE_FILE_OPEN_DIR = "fudaaChooseFileopenDir"; --- 57,61 ---- public class EbliSimpleDialogPanel extends BuPanel ! implements ActionListener { public static final String CHOOSE_FILE_OPEN_DIR = "fudaaChooseFileopenDir"; *************** *** 102,118 **** return r == JOptionPane.OK_OPTION; } - private BuInformationsSoftware isoft_; private BuLabelMultiLine lbError_; protected boolean modale_; ! public EbliSimpleDialogPanel() { ! lbError_ = new BuLabelMultiLine(); ! lbError_.setVisible(false); ! lbError_.setWrapMode(BuLabelMultiLine.WORD); ! lbError_.setForeground(Color.red); } ! public Component getError(){ return lbError_; } --- 95,118 ---- return r == JOptionPane.OK_OPTION; } private BuLabelMultiLine lbError_; protected boolean modale_; ! /** ! * @param _errorText si true, un label est cree pour contenir les messages d'erreur eventuels. ! */ ! public EbliSimpleDialogPanel(boolean _errorText) { ! if(_errorText) ! setErrorTextEnable(); ! ! } ! ! /** ! * Appelle le constructeur en validant l'usage des messages d'erreur. ! */ public EbliSimpleDialogPanel() { ! this(true); } ! public JComponent getError(){ return lbError_; } *************** *** 251,277 **** /** - * intialise la reponse (JOptionPane.CANCEL_OPTION) puis ferme le dialogue. - */ - public final void actionCancel() { - cancel(); - } - - /** - * Si valide, intialise la reponse (JOptionPane.OK_OPTION) ,appelle la fonction actionApply() - * puis ferme le dialogue. - */ - public final void actionOK() { - if (valide()) { - ok(); - } - } - - public final void actionApply() { - if (valide()) { - apply(); - } - } - - /** * Recupere les evt des boutons ok,cancel et apply. bouton OK : valide(), * actionApply(),actionOK() et actionClose() )<br/>bouton cancel : actionCancel() et et --- 251,254 ---- *************** *** 606,624 **** public void setErrorText(String _error) { ! if ((!lbError_.isVisible()) || (!_error.equals(lbError_.getText()))) { ! lbError_.setVisible(true); lbError_.setText(_error); - doLayout(); lbError_.revalidate(); } } ! ! public void setInfos(BuCommonInterface _is) { ! if (_is != null) ! setInfos(_is.getInformationsSoftware()); } ! ! public void setInfos(BuInformationsSoftware _is) { ! isoft_ = _is; } --- 583,607 ---- public void setErrorText(String _error) { ! if(lbError_==null){ ! new Throwable().printStackTrace(); ! return; ! } ! if(!_error.equals(lbError_.getText())) { lbError_.setText(_error); lbError_.revalidate(); } } ! ! public final void setErrorTextEnable() { ! if (lbError_==null) { ! lbError_=new BuLabelMultiLine(); ! lbError_.setWrapMode(BuLabelMultiLine.WORD); ! lbError_.setForeground(Color.red); ! lbError_.revalidate(); ! } } ! ! public void setErrorTextUnable(){ ! lbError_=null; } *************** *** 634,646 **** } - /* *//** - * maj du layout et de la boite de dialogue. - *//* - public void updateGlobalView() { - doLayout(); - if (dialog_ != null) - dialog_.pack(); - dialog_.repaint(); - }*/ public boolean valide() { --- 617,620 ---- *************** *** 648,665 **** } - public void windowActivated(WindowEvent e) {} - - public void windowClosed(WindowEvent e) {} - - public void windowClosing(WindowEvent e) { - actionCancel(); - } - - public void windowDeactivated(WindowEvent e) {} - - public void windowDeiconified(WindowEvent e) {} - - public void windowIconified(WindowEvent e) {} - - public void windowOpened(WindowEvent e) {} } --- 622,624 ---- |