001: package org.objectweb.salome_tmf.ihm.main;
002:
003: import java.awt.GraphicsConfiguration;
004: import java.awt.GraphicsDevice;
005: import java.awt.GraphicsEnvironment;
006: import java.awt.Point;
007: import java.awt.Rectangle;
008: import java.awt.event.ActionEvent;
009: import java.awt.event.ActionListener;
010: import java.awt.event.WindowAdapter;
011: import java.awt.event.WindowEvent;
012:
013: import javax.swing.JDialog;
014:
015: import org.objectweb.salome_tmf.api.Api;
016: import org.objectweb.salome_tmf.api.Util;
017: import org.objectweb.salome_tmf.ihm.common.CommonLogin;
018: import org.objectweb.salome_tmf.ihm.languages.Language;
019:
020: public class ProjectAdminLogin extends JDialog implements
021: ActionListener {
022: CommonLogin pCommonLogin;
023: String usedLocale = "";
024: String strProjet = null;
025: String strUser = null;
026: String strPassword = null;
027:
028: public ProjectAdminLogin() {
029: setModal(true);
030: pCommonLogin = new CommonLogin(false, true, false, this );
031: setTitle("SalomeTMF Login");
032: initComponents();
033: }
034:
035: public void actionPerformed(ActionEvent e) {
036: if (e.getActionCommand().equals(
037: CommonLogin.ACTION_START_PROJECT_ADMIN)) {
038: if (pCommonLogin.validPassword1()) {
039: try {
040: usedLocale = pCommonLogin.getUsedLocal();
041: Api.saveLocale(usedLocale);
042: strProjet = pCommonLogin
043: .getSelectedAdminSalomeProject();
044: strUser = pCommonLogin.getSelectedAdminSalomeUser()
045: .getLogin();
046: strPassword = pCommonLogin.getPassword1();
047: setVisible(false);
048: } catch (Exception me) {
049: Util.log("[LoginSalomeTMF->b_startActionPerformed]"
050: + me);
051: }
052: } else {
053: strProjet = null;
054: strUser = null;
055: pCommonLogin.error(Language.getInstance().getText(
056: "Mot_de_passe_invalide"));
057: }
058: }
059: }
060:
061: public String getSelectedProject() {
062: return strProjet;
063: }
064:
065: public String getSelectedUser() {
066: return strUser;
067: }
068:
069: public String getSelectedPassword() {
070: return strPassword;
071: }
072:
073: private void initComponents() {
074: /*
075: try {
076: GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
077: GraphicsDevice[] gs = ge.getScreenDevices();
078: GraphicsDevice gd = gs[0];
079: GraphicsConfiguration[] gc = gd.getConfigurations();
080: Rectangle r = gc[0].getBounds();
081: Point pt = new Point( r.width/2, r.height/2 );
082: Point loc = new Point( pt.x - 200, pt.y - 150 );
083:
084: // Affichage
085: setLocation(loc);
086: } catch (Exception e){
087:
088: }*/
089:
090: this .setLocationRelativeTo(this .getParent());
091: setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
092: addWindowListener(new WindowAdapter() {
093: public void windowClosing(WindowEvent we) {
094: System.exit(0);
095: }
096: });
097:
098: setContentPane(pCommonLogin);
099: pack();
100:
101: }
102: }
|