01: package org.objectweb.salome_tmf.ihm.main;
02:
03: import java.awt.GraphicsConfiguration;
04: import java.awt.GraphicsDevice;
05: import java.awt.GraphicsEnvironment;
06: import java.awt.Point;
07: import java.awt.Rectangle;
08: import java.awt.event.ActionEvent;
09: import java.awt.event.ActionListener;
10: import java.awt.event.WindowAdapter;
11: import java.awt.event.WindowEvent;
12:
13: import javax.swing.JDialog;
14:
15: import org.objectweb.salome_tmf.api.Api;
16: import org.objectweb.salome_tmf.api.Util;
17: import org.objectweb.salome_tmf.ihm.common.CommonLogin;
18: import org.objectweb.salome_tmf.ihm.languages.Language;
19:
20: public class AdminLogin extends JDialog implements ActionListener {
21: CommonLogin pCommonLogin;
22: String usedLocale = "";
23: String strPassword = null;
24:
25: boolean ok;
26:
27: public AdminLogin() {
28: setModal(true);
29: pCommonLogin = new CommonLogin(false, false, true, this );
30: setTitle("SalomeTMF Login");
31: initComponents();
32: }
33:
34: public void actionPerformed(ActionEvent e) {
35: ok = false;
36: if (e.getActionCommand().equals(
37: CommonLogin.ACTION_START_ADMIN_SALOME)) {
38: if (pCommonLogin.validPassword2()) {
39: try {
40: usedLocale = pCommonLogin.getUsedLocal();
41: Api.saveLocale(usedLocale);
42: ok = true;
43:
44: //Récupération du mot de passe
45: strPassword = pCommonLogin.getPassword2();
46:
47: setVisible(false);
48: } catch (Exception me) {
49: Util.log("[LoginSalomeTMF->b_startActionPerformed]"
50: + me);
51: }
52: } else {
53: pCommonLogin.error(Language.getInstance().getText(
54: "Mot_de_passe_invalide"));
55: }
56: }
57: }
58:
59: public String getSelectedPassword() {
60: return strPassword;
61: }
62:
63: public boolean isLoged() {
64: return ok;
65: }
66:
67: private void initComponents() {
68:
69: /*try {
70: GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
71: GraphicsDevice[] gs = ge.getScreenDevices();
72: GraphicsDevice gd = gs[0];
73: GraphicsConfiguration[] gc = gd.getConfigurations();
74: Rectangle r = gc[0].getBounds();
75: Point pt = new Point( r.width/2, r.height/2 );
76: Point loc = new Point( pt.x - 200, pt.y - 150 );
77:
78: // Affichage
79: setLocation(loc);
80:
81: } catch (Exception e){
82:
83: }
84: */
85: this .setLocationRelativeTo(this .getParent());
86: setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
87: addWindowListener(new WindowAdapter() {
88: public void windowClosing(WindowEvent we) {
89: System.exit(0);
90: }
91: });
92:
93: setContentPane(pCommonLogin);
94: pack();
95:
96: }
97: }
|