From: Frederic D. <de...@us...> - 2004-04-30 07:33:59
|
Update of /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5002/src/org/fudaa/fudaa/commun/dodico Modified Files: FudaaDodicoMonitor.java FudaaDodicoSelectionServeur.java Added Files: FudaaDodicoSearchPanel.java FudaaDodicoTacheConnexion.java FudaaDodicoSelectionFirstPanel.java Removed Files: FudaaPersonneServeur.java FudaaInfoConnexion.java Log Message: Connexion automatique Index: FudaaDodicoMonitor.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico/FudaaDodicoMonitor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FudaaDodicoMonitor.java 25 Nov 2003 10:13:33 -0000 1.3 --- FudaaDodicoMonitor.java 30 Apr 2004 07:33:19 -0000 1.4 *************** *** 8,17 **** */ package org.fudaa.fudaa.commun.dodico; ! import java.awt.*; ! import java.awt.event.*; ! import javax.swing.*; ! import javax.swing.border.*; ! import com.memoire.bu.*; ! import org.fudaa.dodico.objet.*; /** * @version $Revision$ $Date$ by $Author$ --- 8,26 ---- */ package org.fudaa.fudaa.commun.dodico; ! import java.awt.Color; ! import java.awt.Dimension; ! import java.awt.Graphics; ! import java.awt.Insets; ! import java.awt.Point; ! import java.awt.event.MouseEvent; ! ! import javax.swing.JComponent; ! import javax.swing.JToolTip; ! import javax.swing.border.LineBorder; ! ! import com.memoire.bu.BuLib; ! import com.memoire.bu.BuUpdateGUI; ! ! import org.fudaa.dodico.objet.DDiffuseur; /** * @version $Revision$ $Date$ by $Author$ --- NEW FILE: FudaaDodicoTacheConnexion.java --- /** * @file TacheConnexion.java * @creation 29 avr. 2004 * @modification $Date: 2004/04/30 07:33:19 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail fud...@li... */ package org.fudaa.fudaa.commun.dodico; import org.fudaa.dodico.corba.objet.IConnexion; import org.fudaa.dodico.corba.objet.ITache; public class FudaaDodicoTacheConnexion { private ITache tache_; private IConnexion connexion_; public FudaaDodicoTacheConnexion(ITache _t,IConnexion _c){ tache_=_t; connexion_=_c; } public boolean isAllSet(){ return (tache_!=null) && (connexion_!=null); } public boolean isConnecte(){ return (connexion_!=null) && (connexion_.connecte()); } /** * @return Returns the personne. */ public IConnexion getPersonne() { return connexion_; } /** * @return Returns the tache. */ public ITache getTache() { return tache_; } public boolean isAllSetAndConnected(){ return isAllSet() && isConnecte(); } public void deconnecte(){ if(isAllSet()) tache_.deconnexion(connexion_); } } --- FudaaPersonneServeur.java DELETED --- --- NEW FILE: FudaaDodicoSelectionFirstPanel.java --- /** * @file ZFudaaDodicoFirstPanel.java * @creation 28 avr. 2004 * @modification $Date: 2004/04/30 07:33:19 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail fud...@li... */ package org.fudaa.fudaa.commun.dodico; import java.awt.event.ActionEvent; import javax.swing.BorderFactory; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; import com.memoire.bu.BuCheckBox; import com.memoire.bu.BuScrollPane; import com.memoire.bu.BuTable; import com.memoire.bu.BuVerticalLayout; import org.fudaa.ebli.dialog.EbliSimpleDialogPanel; import org.fudaa.ebli.tableau.EbliCellBooleanEditor; import org.fudaa.ebli.tableau.EbliCellBooleanRenderer; import org.fudaa.fudaa.ressource.FudaaResource; /** * @author Fred Deniger * @version $Id: FudaaDodicoSelectionFirstPanel.java,v 1.1 2004/04/30 07:33:19 deniger Exp $ */ public class FudaaDodicoSelectionFirstPanel extends EbliSimpleDialogPanel { FudaaDodicoSelectionServeur srv_; boolean[] distant_; BuCheckBox allLocal_; BuCheckBox doNotAsk_; JTable t; /** * */ public FudaaDodicoSelectionFirstPanel(FudaaDodicoSelectionServeur _s) { srv_ = _s; distant_ = new boolean[srv_.getNbServeur()]; setLayout(new BuVerticalLayout(5)); allLocal_ = new BuCheckBox(FudaaResource.getS("Connexion(s) locale(s) uniquement")); allLocal_.addActionListener(this); add(allLocal_); doNotAsk_ = new BuCheckBox(FudaaResource.getS("Toujours se connecter localement")); doNotAsk_.setBorder(BorderFactory.createEmptyBorder(0, 10, 15, 0)); add(doNotAsk_); doNotAsk_.setEnabled(false); add(doNotAsk_); t = new JTable(new ServeurTypeTableModel()); t.getColumnModel().getColumn(0).setCellRenderer(srv_.getServeurCellRenderer()); TableColumn c2 = t.getColumnModel().getColumn(1); c2.setCellEditor(new EbliCellBooleanEditor()); c2.setCellRenderer(new EbliCellBooleanRenderer() { public void setValue(Object value) { setSelected(((Boolean) value).booleanValue()); } }); BuScrollPane sp = new BuScrollPane(t); sp.setPreferredHeight(300); add(sp); } public boolean isAllLocalSet() { return allLocal_.isSelected(); } public boolean[] getResults() { return distant_; } private class ServeurTypeTableModel extends AbstractTableModel { /** * @see javax.swing.table.TableModel#getColumnCount() */ public int getColumnCount() { return 2; } /** * @see javax.swing.table.TableModel#getRowCount() */ public int getRowCount() { return srv_.getNbServeur(); } /** * @see javax.swing.table.TableModel#getValueAt(int, int) */ public Object getValueAt(int _row, int _column) { if (_column == 0) { return srv_.getServeurClass(_row); } else { if (distant_[_row]) return Boolean.TRUE; else return Boolean.FALSE; } } /** * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int) */ public void setValueAt(Object _value, int _row, int _column) { super.setValueAt(_value, _row, _column); if (_column == 1) { distant_[_row] = ((Boolean) _value).booleanValue(); fireTableCellUpdated(_row, _column); } } /** * @see javax.swing.table.TableModel#isCellEditable(int, int) */ public boolean isCellEditable(int _row, int _column) { return _column == 1; } /** * @see javax.swing.table.TableModel#getColumnName(int) */ public String getColumnName(int _column) { if (_column == 0) return FudaaResource.getS("Serveurs"); else return FudaaResource.getS("Connexion à distance"); } /** * @see javax.swing.table.TableModel#getColumnClass(int) */ public Class getColumnClass(int _columnIndex) { if (_columnIndex == 1) return Boolean.TYPE; else return String.class; } } public boolean isDoNotAskEnable() { return doNotAsk_.isEnabled(); } public boolean getDoNotAskValue() { return doNotAsk_.isSelected(); } /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent _evt) { if (_evt.getSource() == allLocal_) { boolean b = allLocal_.isSelected(); doNotAsk_.setEnabled(b); t.setEnabled(!b); if (b) { for (int i = 0; i < this.distant_.length; i++) { distant_[i] = false; } ((AbstractTableModel) t.getModel()).fireTableDataChanged(); } } else super.actionPerformed(_evt); } /** * @see org.fudaa.ebli.dialog.EbliSimpleDialogPanel#apply() */ } --- NEW FILE: FudaaDodicoSearchPanel.java --- /** * @file ZFudaaDodicoSearchPanel.java * @creation 29 avr. 2004 * @modification $Date: 2004/04/30 07:33:19 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail fud...@li... */ package org.fudaa.fudaa.commun.dodico; import java.awt.event.ActionEvent; import javax.swing.JDialog; import javax.swing.JList; import javax.swing.JProgressBar; import javax.swing.ListSelectionModel; import com.memoire.bu.BuBorderLayout; import com.memoire.bu.BuButton; import com.memoire.bu.BuEmptyList; import com.memoire.bu.BuGlassPaneStop; import com.memoire.bu.BuScrollPane; import com.memoire.bu.BuVerticalLayout; import org.fudaa.dodico.objet.CDodico; import org.fudaa.ebli.dialog.EbliSimpleDialogPanel; import org.fudaa.fudaa.ressource.FudaaResource; /** * @author Fred Deniger * @version $Id: FudaaDodicoSearchPanel.java,v 1.1 2004/04/30 07:33:19 deniger Exp $ */ public class FudaaDodicoSearchPanel extends EbliSimpleDialogPanel { String servName_; boolean localAuthorized_; BuGlassPaneStop glassPane_; boolean isSearch_; String[] srvObject_; int time = 7000; JList list_; String localName_; JProgressBar b_; BuButton btSearch_; /** * */ public FudaaDodicoSearchPanel(String _srvName, boolean local) { servName_ = _srvName; localAuthorized_ = local; if (localAuthorized_) localName_ = FudaaResource.getS("Local"); setErrorTextEnable(); setLayout(new BuVerticalLayout(5)); list_ = new JList(); list_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list_.setListData(new Object[] { FudaaResource.getS("recherche...")}); BuScrollPane sp = new BuScrollPane(list_); add(sp, BuBorderLayout.CENTER); b_ = new JProgressBar(); add(b_); btSearch_ = new BuButton(FudaaResource.getS("Rechercher")); btSearch_.addActionListener(this); add(btSearch_); findServers(); } public boolean isLocal() { return list_.getSelectedIndex() == 0; } public String getSelectedElt() { return (String) list_.getSelectedValue(); } public void setDialog(JDialog _d) { if (isSearch_) { if (glassPane_ == null) glassPane_ = new BuGlassPaneStop(); _d.setGlassPane(glassPane_); glassPane_.setVisible(true); } } private void findServers() { if (isSearch_) return; Thread t = new Thread() { public void run() { b_.setIndeterminate(true); if (glassPane_ != null) glassPane_.setVisible(true); srvObject_ = CDodico.findServerNames(servName_, time); if (localAuthorized_) { String[] fs = new String[srvObject_.length + 1]; fs[0] = localName_; System.arraycopy(srvObject_, 0, fs, 1, srvObject_.length); srvObject_ = fs; } list_.setListData(srvObject_); if (glassPane_ != null) glassPane_.setVisible(false); b_.setIndeterminate(false); doLayout(); isSearch_ = false; } }; isSearch_ = true; t.start(); } /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent _e) { if (_e.getSource() == btSearch_) { if (!isSearch_) findServers(); } else super.actionPerformed(_e); } /** * @see org.fudaa.ebli.dialog.EbliSimpleDialogPanel#valide() */ public boolean valide() { boolean r = list_.getSelectedIndex() >= 0; if (!r) { setErrorText(FudaaResource.getS("Choisir au moins un élément")); } return r; } } --- FudaaInfoConnexion.java DELETED --- Index: FudaaDodicoSelectionServeur.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico/FudaaDodicoSelectionServeur.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FudaaDodicoSelectionServeur.java 27 Apr 2004 16:09:32 -0000 1.6 --- FudaaDodicoSelectionServeur.java 30 Apr 2004 07:33:19 -0000 1.7 *************** *** 1,394 **** ! /* ! * @file FudaaDodicoSelectionServeur.java ! * @creation 2001-07-15 ! * @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.fudaa.commun.dodico; - import java.awt.Dimension; - import java.awt.FlowLayout; - import java.awt.Graphics; - import java.awt.event.ActionEvent; - import java.awt.event.ActionListener; - import java.lang.reflect.Method; - import java.util.StringTokenizer; ! import javax.swing.JComponent; import javax.swing.JOptionPane; ! import javax.swing.JPanel; ! import javax.swing.border.BevelBorder; ! import javax.swing.border.EmptyBorder; ! import javax.swing.event.ListSelectionEvent; ! import javax.swing.event.ListSelectionListener; ! import com.memoire.bu.BuBorderLayout; ! import com.memoire.bu.BuButton; ! import com.memoire.bu.BuCommonInterface; ! import com.memoire.bu.BuDialog; ! import com.memoire.bu.BuDialogError; ! import com.memoire.bu.BuEmptyList; ! import com.memoire.bu.BuInformationsSoftware; ! import com.memoire.bu.BuLabel; ! import com.memoire.bu.BuLib; ! import com.memoire.bu.BuPanel; ! import com.memoire.bu.BuResource; ! import com.memoire.bu.BuScrollPane; ! import com.memoire.bu.BuUpdateGUI; ! import com.memoire.bu.BuVerticalLayout; ! import org.fudaa.dodico.boony.BoonyLib; ! import org.fudaa.dodico.corba.boony.IUsine; ! import org.fudaa.dodico.corba.objet.IActivateur; ! import org.fudaa.dodico.corba.objet.IActivateurHelper; ! import org.fudaa.dodico.corba.objet.IObjet; ! import org.fudaa.dodico.corba.objet.IObjetHelper; ! import org.fudaa.dodico.corba.objet.IOrganisme; import org.fudaa.dodico.corba.objet.IPersonne; import org.fudaa.dodico.corba.objet.IPersonneHelper; import org.fudaa.dodico.objet.CDodico; import org.fudaa.fudaa.ressource.FudaaResource; /** ! * A standard dialog to select an active server. ! * ! * @version $Revision$ $Date$ by $Author$ ! * @author Axel von Arnim */ ! public class FudaaDodicoSelectionServeur ! extends BuDialog ! implements ActionListener, ListSelectionListener { ! private final static String LOCAL_SERVER= FudaaResource.getS("serveur local"); ! private final static String LOCAL_PERSON= ! FudaaResource.getS("utilisateur local"); ! protected BuButton btValider_; ! protected BuButton btAnnuler_; ! protected BuEmptyList ltServeurs_, ltPersonnes_; ! protected String label_; ! protected String interface_; ! private IObjet serveur_; ! private IPersonne personne_; ! private BuPanel component_; ! private FudaaProgress fp_; ! public FudaaDodicoSelectionServeur( ! BuCommonInterface _parent, ! BuInformationsSoftware _isoft, ! String _title, ! String _label, ! String _interface) { ! super(_parent, _isoft, _title); ! interface_= _interface; ! serveur_= null; ! personne_= null; ! label_= _label; ! ltServeurs_.setListData(new String[] { LOCAL_SERVER }); ! ltServeurs_.setSelectedIndex(0); ! ltPersonnes_.setListData(new String[] { LOCAL_PERSON }); ! ltPersonnes_.setSelectedIndex(0); ! JPanel pnb= new JPanel(new FlowLayout(FlowLayout.RIGHT)); ! btValider_= ! new BuButton( ! BuLib.loadCommandIcon("VALIDER"), ! BuResource.BU.getString("Valider")); ! btValider_.addActionListener(this); ! getRootPane().setDefaultButton(btValider_); ! pnb.add(btValider_); ! btAnnuler_= ! new BuButton( ! BuLib.loadCommandIcon("ANNULER"), ! BuResource.BU.getString("Annuler")); ! btAnnuler_.addActionListener(this); ! pnb.add(btAnnuler_); ! content_.add(pnb, BuBorderLayout.SOUTH); } ! public void findServers() { ! String[] servernames= CDodico.findServerNames(interface_, 7000); ! String[] personnames= CDodico.findServerNames("::objet::IPersonne", 7000); ! if (servernames.length == 0) { ! servernames= CDodico.findServerNames("::objet::IActivateur", 7000); ! for (int i= 0; i < servernames.length; i++) { ! IActivateur activateur= ! IActivateurHelper.narrow( ! CDodico.findServerByName(servernames[i], 7000)); ! activateur.active(interface_); ! activateur.active("::objet::IPersonne"); ! } } ! String[] allservernames= new String[servernames.length + 1]; ! for (int i= 0; i < servernames.length; i++) ! allservernames[i]= servernames[i]; ! allservernames[servernames.length]= LOCAL_SERVER; ! ltServeurs_.setListData(allservernames); ! String[] allpersonnames= new String[personnames.length + 1]; ! for (int i= 0; i < personnames.length; i++) ! allpersonnames[i]= personnames[i]; ! allpersonnames[personnames.length]= LOCAL_PERSON; ! ltPersonnes_.setListData(allpersonnames); ! repaint(); ! } ! public JComponent getComponent() { ! initComponent(); ! return component_; ! } ! private void initComponent() { ! if (ltServeurs_ == null) { ! ltServeurs_= new BuEmptyList(); ! ltServeurs_.setEmptyText(FudaaResource.getS("aucun serveur")); ! // ltServeurs_.addListSelectionListener(this); } ! if (ltPersonnes_ == null) { ! ltPersonnes_= new BuEmptyList(); ! ltPersonnes_.setEmptyText(FudaaResource.getS("aucune personne")); ! // ltPersonnes_.addListSelectionListener(this); } ! BuButton b= new BuButton(BuResource.BU.getString("rechercher")); ! b.setActionCommand("RECHERCHER"); ! b.addActionListener(this); ! fp_= new FudaaProgress(); ! fp_.setSpeed(3); ! BuPanel p= new BuPanel(); ! p.setLayout(new BuVerticalLayout()); ! p.setBorder(new EmptyBorder(5, 5, 5, 5)); ! p.add(new BuLabel(label_)); ! p.add(new BuScrollPane(ltServeurs_)); ! p.add(new JPanel()); ! p.add(new BuLabel(FudaaResource.getS("Authentification"))); ! p.add(new BuScrollPane(ltPersonnes_)); ! p.add(new JPanel()); ! p.add(b); ! p.add(fp_); ! component_= p; ! } ! public void valueChanged(ListSelectionEvent _evt) { ! // JComponent source=(JComponent)_evt.getSource(); ! /* ! String serverStr=(String)ltServeurs_.getSelectedValue(); ! String personStr=(String)ltPersonnes_.getSelectedValue(); ! if( serverStr==null && personStr==null ) return; ! ! System.err.println(serverStr+" "+personStr); ! if( source==ltServeurs_ ) { ! if( LOCAL_SERVER.equals(serverStr) ) ! ltPersonnes_.setSelectedValue(LOCAL_PERSON, true); ! else { ! ltPersonnes_.setSelectedValue(LOCAL_PERSON, false); ! ltServeurs_.setSelectedValue(LOCAL_SERVER, false); ! } ! } else ! if( source==ltPersonnes_ ) { ! if( LOCAL_PERSON.equals(personStr) ) ! ltServeurs_.setSelectedValue(LOCAL_SERVER, true); ! else { ! ltPersonnes_.setSelectedValue(LOCAL_PERSON, false); ! ltServeurs_.setSelectedValue(LOCAL_SERVER, false); ! } ! } ! */ ! } ! public void actionPerformed(ActionEvent _evt) { ! JComponent source= (JComponent)_evt.getSource(); ! String cmd= _evt.getActionCommand(); ! if ((source == btValider_)) { ! String serverStr= (String)ltServeurs_.getSelectedValue(); ! String personStr= (String)ltPersonnes_.getSelectedValue(); ! if (serverStr == null || personStr == null) ! return; ! reponse_= JOptionPane.OK_OPTION; ! // SERVEUR ! if (!LOCAL_SERVER.equals(serverStr)) { ! try { ! serveur_= ! IObjetHelper.narrow(CDodico.findServerByName(serverStr, 2000)); ! } catch (Throwable t) { ! new BuDialogError( ! null, ! null, ! FudaaResource.getS("Impossible de connecter le serveur") ! + ":\n" ! + serverStr ! + "\n" ! + BuResource.BU.getString("Erreur") ! + ": " ! + t.getMessage()) ! .activate(); ! reponse_= JOptionPane.CANCEL_OPTION; ! serveur_= null; } ! } else { ! if(!BoonyLib.isUsinePolicySet()){ ! BoonyLib.setAllLocal(true); } ! else{ ! if(!BoonyLib.isAllLocal()) new Throwable("pas correct pour l'instant"); } - IUsine u= BoonyLib.findUsine(); - StringTokenizer tok= new StringTokenizer(new String(interface_), "::"); - String packagename= capitalize(tok.nextToken()); - String classname= tok.nextToken().substring(1); - try { - //System.out.println("SelectionServeur: démarrage du serveur local "+classname); - Class uc= u.getClass(); - Method um= - uc.getMethod("cree" + packagename + classname, new Class[0]); - serveur_= (IObjet)um.invoke(u, new Object[0]); ! } catch (Throwable t) { ! new BuDialogError( ! null, ! null, ! FudaaResource.getS("Impossible de lancer le serveur local") ! + ":\n" ! + classname ! + "\n" ! + BuResource.BU.getString("Erreur") ! + ": " ! + t.getMessage()) ! .activate(); ! reponse_= JOptionPane.CANCEL_OPTION; ! serveur_= null; ! t.printStackTrace(); ! } ! } ! // PERSONNE ! // if( !LOCAL_PERSON.equals(personStr) ) { ! if (!LOCAL_SERVER.equals(serverStr)) { ! try { ! personne_= ! IPersonneHelper.narrow(CDodico.findServerByName(personStr, 2000)); ! } catch (Throwable t) { ! new BuDialogError( ! null, ! null, ! FudaaResource.getS("Impossible de connecter la personne") ! + ":\n" ! + personStr ! + "\n" ! + BuResource.BU.getString("Erreur") ! + ": " ! + t.getMessage()) ! .activate(); ! reponse_= JOptionPane.CANCEL_OPTION; ! personne_= null; ! } ! } else { ! ! IUsine u= BoonyLib.findUsine(); ! IOrganisme o= u.creeObjetOrganisme(); ! o.sigle(FudaaResource.getS("organisme local")); ! personne_= u.creeObjetPersonne(); ! personne_.organisme(o); ! personne_.nom(LOCAL_PERSON); ! } ! setVisible(false); ! } ! if (source == btAnnuler_) { ! reponse_= JOptionPane.CANCEL_OPTION; ! serveur_= null; ! setVisible(false); ! } - if ("RECHERCHER".equals(cmd)) { - Thread t= new Thread() { - public void run() { - findServers(); } ! }; ! t.start(); ! fp_.start(t); } } ! public IObjet getServeur() { ! return serveur_; } ! public IPersonne getPersonne() { ! return personne_; } ! private String capitalize(String msg) { ! return msg.substring(0, 1).toUpperCase() + msg.substring(1); } ! public static void main(String[] args) { ! FudaaDodicoSelectionServeur s= ! new FudaaDodicoSelectionServeur(null, null, "", "", "::vag::ICalculVag"); ! s.activate(); } ! } ! class FudaaProgress extends JComponent { ! int value_= -1; ! boolean forwards_= true; ! int speed_= 1; ! boolean stop_= true; ! Thread t_= null; ! int cursorValue_= 20; ! public FudaaProgress() { ! setPreferredSize(new Dimension(50, 20)); ! setSize(getPreferredSize()); ! setBorder(new BevelBorder(BevelBorder.LOWERED)); } ! public void setSpeed(int s) { ! if (s <= 0) ! speed_= 1; ! else if (s > 10) ! speed_= 10; ! else ! speed_= s; } ! public int getSpeed() { ! return speed_; } ! public void setCursorWidth(int s) { ! if (s <= 0) ! cursorValue_= 20; ! cursorValue_= s; } ! public int getCursorWidth() { ! return cursorValue_; } ! public void start(Thread t) { ! stop_= false; ! final Thread ft= t; ! if (ft != null) { ! Thread th= new Thread() { ! public void run() { ! value_= 0; ! boolean ftRunning= (ft == null) || (ft.isAlive()); ! while (!stop_ && ftRunning) { ! if (value_ >= 100 - cursorValue_) ! forwards_= false; ! if (value_ <= 0) ! forwards_= true; ! if (forwards_) ! value_ += speed_; ! else ! value_ -= speed_; ! BuUpdateGUI.repaintNow(FudaaProgress.this); ! try { ! sleep(50); ! } catch (InterruptedException ie) { ! System.err.println("interrupted"); ! } ! ftRunning= (ft == null) || (ft.isAlive()); ! } ! value_= -1; ! repaint(); ! } ! }; ! th.setPriority(Thread.MIN_PRIORITY); ! th.start(); } } ! public void stop() { ! stop_= true; ! } ! public void paintComponent(Graphics g) { ! super.paintComponent(g); ! if (value_ < 0) ! return; ! Dimension d= getSize(); ! g.fillRect( ! (d.width * value_) / 100, ! 0, ! (d.width * cursorValue_) / 100, ! d.height); ! } ! } --- 1,253 ---- ! /** ! * @file ZFudaaDodicoServeur.java ! * @creation 28 avr. 2004 ! * @modification $Date$ ! * @license GNU General Public License 2 ! * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne ! * @mail fud...@li... */ package org.fudaa.fudaa.commun.dodico; ! import java.awt.Component; ! import java.util.ArrayList; ! import java.util.HashMap; ! import java.util.Iterator; ! import java.util.List; ! import java.util.Map; ! ! import javax.swing.JFrame; import javax.swing.JOptionPane; ! import javax.swing.JTable; ! import javax.swing.table.TableCellRenderer; ! import com.memoire.bu.BuCommonImplementation; ! import com.memoire.bu.BuGlassPaneStop; ! import org.fudaa.ctulu.CtuluLib; ! import org.fudaa.dodico.corba.objet.IConnexion; import org.fudaa.dodico.corba.objet.IPersonne; import org.fudaa.dodico.corba.objet.IPersonneHelper; + import org.fudaa.dodico.corba.objet.ITache; + import org.fudaa.dodico.corba.objet.ITacheHelper; import org.fudaa.dodico.objet.CDodico; + import org.fudaa.dodico.objet.UsineLib; + import org.fudaa.ebli.dialog.EbliSimpleDialog; + import org.fudaa.ebli.tableau.EbliCellTextRenderer; + import org.fudaa.fudaa.commun.FudaaCommonImplementation; + import org.fudaa.fudaa.commun.FudaaImplementation; import org.fudaa.fudaa.ressource.FudaaResource; + /** ! * @author Fred Deniger ! * @version $Id$ */ ! public class FudaaDodicoSelectionServeur { ! ! private Class[] serviceClass_; ! private FudaaCommonImplementation impl_; ! BuGlassPaneStop glasspane_; ! public static boolean forceCorba_ = false; ! public static boolean forceNoCorba_ = false; ! ! /** ! * ! */ ! public FudaaDodicoSelectionServeur(FudaaCommonImplementation _impl, Class[] serviceClass) { ! super(); ! impl_ = _impl; ! serviceClass_ = serviceClass; } ! ! public Map findServer() { ! boolean allLocal = false; ! Map r = null; ! if (UsineLib.isUsinePolicySet()) {} ! ! if (forceCorba_) { ! if (CtuluLib.DEBUG) CtuluLib.debug("distant par parametres"); ! allLocal = false; } ! else if (forceNoCorba_) { ! if (CtuluLib.DEBUG) CtuluLib.debug("local par parametres"); ! allLocal = true; } ! else { ! allLocal = getAllLocalPref(); ! if (CtuluLib.DEBUG) CtuluLib.debug("local par pref=" + allLocal); } ! if (allLocal) { ! r = doLocal(); ! } ! else { ! FudaaDodicoSelectionFirstPanel firstPn = new FudaaDodicoSelectionFirstPanel(this); ! EbliSimpleDialog j = new EbliSimpleDialog(impl_.getFrame(), firstPn); ! int resp = j.afficheDialogModal(); ! j.dispose(); ! if (resp != JOptionPane.OK_OPTION) return null; ! if (CtuluLib.DEBUG) CtuluLib.debug("ok response"); ! boolean[] dist = firstPn.getResults(); ! if (firstPn.isDoNotAskEnable()) { ! setAllLocalPref(firstPn.getDoNotAskValue()); ! impl_.getApplicationPreferences().writeIniFile(); ! } ! if (firstPn.isAllLocalSet()) r = doLocal(); ! List distSrv = new ArrayList(dist.length); ! List localSrv = new ArrayList(dist.length); ! for (int i = 0; i < dist.length; i++) { ! if (dist[i]) { ! distSrv.add(serviceClass_[i]); } ! else { ! localSrv.add(serviceClass_[i]); } ! } ! if (distSrv.size() == 0) { ! r = doLocal(); ! } ! else { ! r = new HashMap(serviceClass_.length); ! UsineLib.setAllLocal(false); ! if (localSrv.size() > 0) { ! Class[] clocal = new Class[localSrv.size()]; ! localSrv.toArray(clocal); ! doLocal(clocal, r); ! impl_.unsetMainMessage(); } ! //recherche de la personne ! FudaaDodicoSearchPanel spn = new FudaaDodicoSearchPanel("::objet::IPersonne", false); ! j = new EbliSimpleDialog(impl_.getFrame(), spn); ! spn.setDialog(j); ! j.setTitle(FudaaResource.getS("Recherche identité")); ! resp = j.afficheDialogModal(); ! j.dispose(); ! if (resp != JOptionPane.OK_OPTION) return null; ! String pers = spn.getSelectedElt(); ! IPersonne distPers = IPersonneHelper.narrow(CDodico.findServerByName(pers, 2000)); ! if (distPers == null) return null; ! for (Iterator it = distSrv.iterator(); it.hasNext();) { ! Class c = (Class) it.next(); ! String serveur = CDodico.mainCorbaInteface(c); ! spn = new FudaaDodicoSearchPanel(serveur, true); ! j = new EbliSimpleDialog(impl_.getFrame(), spn); ! spn.setDialog(j); ! j.setTitle(FudaaResource.getS("Recherche") + CtuluLib.ESPACE + serveur); ! resp = j.afficheDialogModal(); ! j.dispose(); ! if (resp != JOptionPane.OK_OPTION) return null; ! ITache t = null; ! if (spn.isLocal()) { ! t = UsineLib.createService(c); ! } ! else { ! String tache = spn.getSelectedElt(); ! t = ITacheHelper.narrow(CDodico.findServerByName(tache, 2000)); ! } ! FudaaDodicoTacheConnexion tp = new FudaaDodicoTacheConnexion(t,t.connexion(distPers)); ! r.put(c, tp); } ! j.dispose(); ! ! } } + if (r.size() != serviceClass_.length) return null; + else impl_.setMainMessageAndClear(FudaaResource.getS("Connexion(s) réussie(s)")); + return r; } ! ! private Map doLocal() { ! UsineLib.setAllLocal(true); ! Map r = new HashMap(serviceClass_.length); ! doLocal(serviceClass_, r); ! return r; } ! ! private void doLocal(Class[] _srvClass, Map r) { ! if (glasspane_ == null) glasspane_ = new BuGlassPaneStop(); ! glasspane_.setVisible(true); ! ((JFrame) impl_.getFrame()).setGlassPane(glasspane_); ! impl_.setMainMessage(FudaaResource.getS("Connexions locales...")); ! impl_.setMainProgression(10); ! IPersonne p = UsineLib.createLocalPers(); ! impl_.setMainProgression(30); ! int pro = 70 / serviceClass_.length; ! for (int i = 0; i < _srvClass.length; i++) { ! ITache s = UsineLib.createService(_srvClass[i]); ! if (s == null) new Throwable().printStackTrace(); ! FudaaDodicoTacheConnexion sp = new FudaaDodicoTacheConnexion(s,s.connexion(p)); ! r.put(_srvClass[i], sp); ! impl_.setMainProgression(20 + pro * (i + 1)); ! } ! impl_.unsetMainProgression(); ! impl_.unsetMainMessage(); ! glasspane_.setVisible(false); } ! ! TableCellRenderer srvCellRenderer_; ! ! public TableCellRenderer getServeurCellRenderer() { ! if (srvCellRenderer_ == null) { ! srvCellRenderer_ = new ServeurCellRenderer(); ! } ! return srvCellRenderer_; ! } ! ! public static class ServeurCellRenderer extends EbliCellTextRenderer { ! ! Map classNameMap = new HashMap(); ! ! /** ! * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, ! * java.lang.Object, boolean, boolean, int, int) ! */ ! public Component getTableCellRendererComponent(JTable _table, Object _value, ! boolean _isSelected, boolean _hasFocus, int _row, int _column) { ! super.getTableCellRendererComponent(_table, _value, _isSelected, _hasFocus, _row, _column); ! String s = (String) classNameMap.get(_value); ! if (s == null) { ! String className = ((Class) _value).getName(); ! s = className.substring(className.lastIndexOf('.') + 1); ! String dcal = "DCalcul"; ! if (s.startsWith(dcal)) s = s.substring(dcal.length()); ! else{ ! dcal = "DService"; ! if (s.startsWith(dcal)) s = s.substring(dcal.length()); ! } ! classNameMap.put(_value, s); ! } ! setText(s); ! return this; ! } } ! ! public final boolean getAllLocalPref() { ! return impl_.getApplicationPreferences().getBooleanProperty("dodico.local.only", false); } ! ! public final void setAllLocalPref(boolean _b) { ! impl_.getApplicationPreferences().putBooleanProperty("dodico.local.only", _b); } ! ! public int getNbServeur() { ! return serviceClass_.length; } ! ! public Class getServeurClass(int _i) { ! return serviceClass_[_i]; } ! ! public static void setForceCorba() { ! forceCorba_ = true; } ! ! public static void setForceNoCorba() { ! if (forceCorba_) { ! System.err.println("Corba already set"); } + forceNoCorba_ = true; } ! ! } \ No newline at end of file |