Update of /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico
In directory sc8-pr-cvs1:/tmp/cvs-serv3074/commun/dodico
Modified Files:
FudaaDodicoMonitor.java FudaaDodicoSelectionServeur.java
FudaaInfoConnexion.java FudaaPersonneServeur.java
Log Message:
reformat all files
Index: FudaaDodicoMonitor.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico/FudaaDodicoMonitor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FudaaDodicoMonitor.java 23 Sep 2003 21:08:04 -0000 1.2
--- FudaaDodicoMonitor.java 25 Nov 2003 10:13:33 -0000 1.3
***************
*** 1,105 ****
! /*
! * @file FudaaDodicoMonitor.java
! * @creation 2000-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.*;
! 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$
! * @author Axel von Arnim
! */
! public class FudaaDodicoMonitor
! extends JComponent
! implements Runnable
! {
! protected int[] actu_;
!
! public FudaaDodicoMonitor()
! {
! super();
!
! actu_=new int[] { 0,0 };
!
! setName("FUDAA_DODICO_MONITOR");
! setBackground(Color.gray);
! setForeground(new Color(64,32,96));
! setBorder(new LineBorder(Color.black));
! setPreferredSize(new Dimension(64,14));
!
! Thread monitor = new Thread(this,"Fudaa dodico monitor");
! monitor.setDaemon(true);
! monitor.setPriority(Thread.MIN_PRIORITY);
! monitor.start();
! }
!
! public Point getToolTipLocation(MouseEvent _evt)
! {
! Point r=super.getToolTipLocation(_evt);
! if(r==null)
! {
! JToolTip tt=new JToolTip();
! tt.setToolTipText(getToolTipText());
! r=new Point(0,-tt.getPreferredSize().height-1);
! }
! return r;
! }
!
! public void paint(Graphics _g)
! {
! Dimension size =getSize();
! Insets insets=getInsets();
!
! int w=size.width -insets.left-insets.right;
! int h=size.height-insets.top-insets.bottom;
!
! Color bg=getBackground();
! Color fg=getForeground();
!
! BuLib.setColor(_g,bg);
! _g.fillRect(insets.left,insets.top,w,h);
!
! int xmax=w*actu_[0]/Math.max(1,actu_[0]+actu_[1]);
! BuLib.setColor(_g,bg.brighter());
! _g.fillRect(insets.left,insets.top,xmax,h);
!
! String m=actu_[0]+" - "+actu_[1];
! int xm=(w-_g.getFontMetrics().stringWidth(m))/2+insets.left;
! int ym=insets.top+h;
!
! BuLib.setColor(_g,fg.darker());
! _g.drawString(m,xm+2,ym-1);
! _g.drawString(m,xm+2,ym-2);
! _g.drawString(m,xm+1,ym-1);
! BuLib.setColor(_g,fg.brighter().brighter());
! _g.drawString(m,xm+1,ym-2);
!
! super.paint(_g);
! }
!
! public void run()
! {
! while(true)
! {
! actu_=DDiffuseur.getNumbers();
! BuUpdateGUI.repaintLater(this);
! setToolTipText
! (actu_[0]+" valid corba objects, "+actu_[1]+" invalid");
!
! try { Thread.sleep(5000); }
! catch(Exception ex) { }
! }
! }
! }
--- 1,78 ----
! /*
! * @file FudaaDodicoMonitor.java
! * @creation 2000-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.*;
! 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$
! * @author Axel von Arnim
! */
! public class FudaaDodicoMonitor extends JComponent implements Runnable {
! protected int[] actu_;
! public FudaaDodicoMonitor() {
! super();
! actu_= new int[] { 0, 0 };
! setName("FUDAA_DODICO_MONITOR");
! setBackground(Color.gray);
! setForeground(new Color(64, 32, 96));
! setBorder(new LineBorder(Color.black));
! setPreferredSize(new Dimension(64, 14));
! Thread monitor= new Thread(this, "Fudaa dodico monitor");
! monitor.setDaemon(true);
! monitor.setPriority(Thread.MIN_PRIORITY);
! monitor.start();
! }
! public Point getToolTipLocation(MouseEvent _evt) {
! Point r= super.getToolTipLocation(_evt);
! if (r == null) {
! JToolTip tt= new JToolTip();
! tt.setToolTipText(getToolTipText());
! r= new Point(0, -tt.getPreferredSize().height - 1);
! }
! return r;
! }
! public void paint(Graphics _g) {
! Dimension size= getSize();
! Insets insets= getInsets();
! int w= size.width - insets.left - insets.right;
! int h= size.height - insets.top - insets.bottom;
! Color bg= getBackground();
! Color fg= getForeground();
! BuLib.setColor(_g, bg);
! _g.fillRect(insets.left, insets.top, w, h);
! int xmax= w * actu_[0] / Math.max(1, actu_[0] + actu_[1]);
! BuLib.setColor(_g, bg.brighter());
! _g.fillRect(insets.left, insets.top, xmax, h);
! String m= actu_[0] + " - " + actu_[1];
! int xm= (w - _g.getFontMetrics().stringWidth(m)) / 2 + insets.left;
! int ym= insets.top + h;
! BuLib.setColor(_g, fg.darker());
! _g.drawString(m, xm + 2, ym - 1);
! _g.drawString(m, xm + 2, ym - 2);
! _g.drawString(m, xm + 1, ym - 1);
! BuLib.setColor(_g, fg.brighter().brighter());
! _g.drawString(m, xm + 1, ym - 2);
! super.paint(_g);
! }
! public void run() {
! while (true) {
! actu_= DDiffuseur.getNumbers();
! BuUpdateGUI.repaintLater(this);
! setToolTipText(
! actu_[0] + " valid corba objects, " + actu_[1] + " invalid");
! try {
! Thread.sleep(5000);
! } catch (Exception ex) {}
! }
! }
! }
Index: FudaaDodicoSelectionServeur.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico/FudaaDodicoSelectionServeur.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** FudaaDodicoSelectionServeur.java 6 Oct 2003 08:09:00 -0000 1.3
--- FudaaDodicoSelectionServeur.java 25 Nov 2003 10:13:33 -0000 1.4
***************
*** 1 ****
! /*
* @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 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.corba.usine.IUsine;
import org.fudaa.dodico.objet.CDodico;
import org.fudaa.dodico.usine.UsineHelper;
import org.fudaa.fudaa.ressource.FudaaResource;
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;
/**
* 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_, 4000);
String[] personnames= CDodico.findServerNames("::objet::IPersonne", 4000);
if (servernames.length == 0) {
servernames= CDodico.findServerNames("::objet::IActivateur", 4000);
for (int i= 0; i < servernames.length; i++) {
IActivateur activateur=
IActivateurHelper.narrow(
CDodico.findServerByName(servernames[i], 4000));
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 {
IUsine u= UsineHelper.creeUsineLocale();
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 {
System.out.println(
"SelectionPersonne: création de CPersonne(" + LOCAL_PERSON + ")");
IUsine u= UsineHelper.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);
}
}
\ No newline at end of file
--- 1,383 ----
! /*
! * @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 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.corba.usine.IUsine;
! import org.fudaa.dodico.objet.CDodico;
! import org.fudaa.dodico.usine.UsineHelper;
! import org.fudaa.fudaa.ressource.FudaaResource;
! 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;
! /**
! * 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_, 4000);
! String[] personnames= CDodico.findServerNames("::objet::IPersonne", 4000);
! if (servernames.length == 0) {
! servernames= CDodico.findServerNames("::objet::IActivateur", 4000);
! for (int i= 0; i < servernames.length; i++) {
! IActivateur activateur=
! IActivateurHelper.narrow(
! CDodico.findServerByName(servernames[i], 4000));
! 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 {
! IUsine u= UsineHelper.creeUsineLocale();
! 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 {
! System.out.println(
! "SelectionPersonne: création de CPersonne(" + LOCAL_PERSON + ")");
! IUsine u= UsineHelper.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);
! }
! }
Index: FudaaInfoConnexion.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico/FudaaInfoConnexion.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** FudaaInfoConnexion.java 6 Oct 2003 08:09:00 -0000 1.3
--- FudaaInfoConnexion.java 25 Nov 2003 10:13:33 -0000 1.4
***************
*** 1 ****
! /*
* @file FudaaInfoConnexion.java
* @creation 2001-07-18
* @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 org.fudaa.dodico.corba.objet.*;
import org.fudaa.dodico.corba.calcul.*;
import org.fudaa.dodico.commun.DodicoLib;
import org.fudaa.fudaa.ressource.FudaaResource;
import javax.swing.event.*;
/**
* Cette classe stocke les informations du serveur utilise. Les donnees sont
* initialisees par la fenetre popConnexion (FudaaImplementation) et recuperees
* dans l'implementation grace a un evenement ChangeEvent envoye par
* popConnexion.
*
* @version $Revision$ $Date$ by $Author$
* @author Axel von Arnim
*/
public class FudaaInfoConnexion {
public final static boolean ERROR= true;
public final static boolean NO_ERROR= false;
public ITache SERVEUR;
public IParametres PARAMS;
public IResultats RESULTS;
public IPersonne PERSONNE;
public IConnexion CONNEXION;
private ChangeListener l;
private boolean error_;
public void addChangeListener(ChangeListener _l) {
l= _l;
}
public void printInfo() {
try {
String s= DodicoLib.ESPACE + DodicoLib.ESPACE;
String egal= " = ";
System.err.println(FudaaResource.getS("Informations sur la connexion"));
System.err.println(
s + FudaaResource.getS("SERVEUR") + egal + SERVEUR.enChaine());
System.err.println(
s + FudaaResource.getS("CONNEXION") + egal + CONNEXION.enChaine());
System.err.println(
s + FudaaResource.getS("PERSONNE") + egal + PERSONNE.enChaine());
if (ICalculHelper.narrow(SERVEUR) != null) {
if (PARAMS == null)
System.out.println(FudaaResource.getS("Erreur: paramètres nulles"));
if (RESULTS == null)
System.out.println(FudaaResource.getS("Erreur: Résultats nuls"));
}
} catch (Throwable t) {}
}
public boolean errorOccurred() {
return error_;
}
public void fireChangeEvent(boolean errorOccured) {
error_= errorOccured;
ChangeEvent e= new ChangeEvent(this);
l.stateChanged(e);
}
}
\ No newline at end of file
--- 1,64 ----
! /*
! * @file FudaaInfoConnexion.java
! * @creation 2001-07-18
! * @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 org.fudaa.dodico.corba.objet.*;
! import org.fudaa.dodico.corba.calcul.*;
! import org.fudaa.dodico.commun.DodicoLib;
! import org.fudaa.fudaa.ressource.FudaaResource;
! import javax.swing.event.*;
! /**
! * Cette classe stocke les informations du serveur utilise. Les donnees sont
! * initialisees par la fenetre popConnexion (FudaaImplementation) et recuperees
! * dans l'implementation grace a un evenement ChangeEvent envoye par
! * popConnexion.
! *
! * @version $Revision$ $Date$ by $Author$
! * @author Axel von Arnim
! */
! public class FudaaInfoConnexion {
! public final static boolean ERROR= true;
! public final static boolean NO_ERROR= false;
! public ITache SERVEUR;
! public IParametres PARAMS;
! public IResultats RESULTS;
! public IPersonne PERSONNE;
! public IConnexion CONNEXION;
! private ChangeListener l;
! private boolean error_;
! public void addChangeListener(ChangeListener _l) {
! l= _l;
! }
! public void printInfo() {
! try {
! String s= DodicoLib.ESPACE + DodicoLib.ESPACE;
! String egal= " = ";
! System.err.println(FudaaResource.getS("Informations sur la connexion"));
! System.err.println(
! s + FudaaResource.getS("SERVEUR") + egal + SERVEUR.enChaine());
! System.err.println(
! s + FudaaResource.getS("CONNEXION") + egal + CONNEXION.enChaine());
! System.err.println(
! s + FudaaResource.getS("PERSONNE") + egal + PERSONNE.enChaine());
! if (ICalculHelper.narrow(SERVEUR) != null) {
! if (PARAMS == null)
! System.out.println(FudaaResource.getS("Erreur: paramètres nulles"));
! if (RESULTS == null)
! System.out.println(FudaaResource.getS("Erreur: Résultats nuls"));
! }
! } catch (Throwable t) {}
! }
! public boolean errorOccurred() {
! return error_;
! }
! public void fireChangeEvent(boolean errorOccured) {
! error_= errorOccured;
! ChangeEvent e= new ChangeEvent(this);
! l.stateChanged(e);
! }
! }
Index: FudaaPersonneServeur.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/dodico/FudaaPersonneServeur.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FudaaPersonneServeur.java 23 Sep 2003 21:08:04 -0000 1.2
--- FudaaPersonneServeur.java 25 Nov 2003 10:13:33 -0000 1.3
***************
*** 1,45 ****
! /*
! * @file FudaaPersonneServeur.java
! * @creation 2000-02-23
! * @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 com.memoire.bu.BuPreferences;
!
! import org.fudaa.dodico.corba.objet.IOrganisme;
! import org.fudaa.dodico.corba.objet.IPersonne;
! import org.fudaa.dodico.corba.usine.IUsine;
! import org.fudaa.dodico.objet.CDodico;
! import org.fudaa.dodico.usine.UsineHelper;
!
! /**
! * @version $Revision$ $Date$ by $Author$
! * @author Axel von Arnim
! */
! public class FudaaPersonneServeur
! {
! public static void main(String[] args)
! {
! IUsine u=UsineHelper.findUsine();
! IOrganisme o=u.creeObjetOrganisme();
! o.sigle ("CETMEF");
! o.intitule("Centre d'Etudes Techniques Maritimes et Fluviales");
! o.adresse ("2 bd Gambetta, 60200 COMPIEGNE");
! CDodico.rebind(o.sigle(),o);
!
! IPersonne p=u.creeObjetPersonne();
! p.prenom(BuPreferences.BU.getStringProperty("user.firstname",null));
! p.nom (BuPreferences.BU.getStringProperty("user.lastname" ,null));
! p.mel (BuPreferences.BU.getStringProperty("user.email" ,null));
! p.telephone("03.44.92.60.34");
! p.organisme(o);
!
! String n=""+p.prenom()+" "+p.nom();
! CDodico.rebind(n,p);
! }
! }
--- 1,37 ----
! /*
! * @file FudaaPersonneServeur.java
! * @creation 2000-02-23
! * @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 com.memoire.bu.BuPreferences;
! import org.fudaa.dodico.corba.objet.IOrganisme;
! import org.fudaa.dodico.corba.objet.IPersonne;
! import org.fudaa.dodico.corba.usine.IUsine;
! import org.fudaa.dodico.objet.CDodico;
! import org.fudaa.dodico.usine.UsineHelper;
! /**
! * @version $Revision$ $Date$ by $Author$
! * @author Axel von Arnim
! */
! public class FudaaPersonneServeur {
! public static void main(String[] args) {
! IUsine u= UsineHelper.findUsine();
! IOrganisme o= u.creeObjetOrganisme();
! o.sigle("CETMEF");
! o.intitule("Centre d'Etudes Techniques Maritimes et Fluviales");
! o.adresse("2 bd Gambetta, 60200 COMPIEGNE");
! CDodico.rebind(o.sigle(), o);
! IPersonne p= u.creeObjetPersonne();
! p.prenom(BuPreferences.BU.getStringProperty("user.firstname", null));
! p.nom(BuPreferences.BU.getStringProperty("user.lastname", null));
! p.mel(BuPreferences.BU.getStringProperty("user.email", null));
! p.telephone("03.44.92.60.34");
! p.organisme(o);
! String n= "" + p.prenom() + " " + p.nom();
! CDodico.rebind(n, p);
! }
! }
|