001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.login;
025:
026: import java.awt.event.KeyEvent;
027: import java.awt.event.KeyListener;
028: import java.io.File;
029: import java.net.URL;
030: import java.util.Enumeration;
031: import java.util.Locale;
032: import java.util.Vector;
033:
034: import javax.swing.text.html.HTMLDocument;
035: import javax.swing.text.html.HTMLEditorKit;
036:
037: import org.objectweb.salome_tmf.api.Api;
038: import org.objectweb.salome_tmf.api.JavaScriptUtils;
039: import org.objectweb.salome_tmf.api.Util;
040: import org.objectweb.salome_tmf.api.data.ProjectWrapper;
041: import org.objectweb.salome_tmf.api.data.UserWrapper;
042: import org.objectweb.salome_tmf.api.sql.ISQLPersonne;
043: import org.objectweb.salome_tmf.api.sql.ISQLProject;
044: import org.objectweb.salome_tmf.api.sql.ISQLSession;
045: import org.objectweb.salome_tmf.login.languages.Language;
046:
047: public class LoginSalomeTMF extends javax.swing.JApplet {
048:
049: Vector porjectsList;
050: Vector usersProject;
051: Vector adminsProject;
052: UserWrapper super User = null;
053:
054: Vector languages = new Vector();
055:
056: ISQLSession pISQLSession;
057: ISQLProject pISQLProject;
058: ISQLPersonne pISQLPersonne;
059:
060: File salome_html = null;
061:
062: boolean init;
063: String proj;
064: String proj1;
065: String admin_pwd = "";
066: String usedLocale = "";
067: boolean closeDB = true;
068:
069: //boolean salome_redirect;
070: JavaScriptUtils pJSUtils;
071:
072: void connectToAPI() {
073: //
074: pJSUtils = new JavaScriptUtils(this );
075: try {
076: pJSUtils.setCookies("", Api.DEFAULT_LOGIN,
077: Api.DEFAULT_PASSWORD);
078: } catch (Exception e) {
079: }
080: Util.log("[LoginSalomeTMF->connectToAPI] connection");
081: if (Api.getNbConnect() > 0) {
082: quit();
083: closeDB = false;
084: //return false;
085: }
086: Util
087: .log("[LoginSalomeTMF->connectToAPI] nb connection active : "
088: + Api.getNbConnect());
089: Api.openConnection(getDocumentBase());
090: pISQLSession = Api.getISQLObjectFactory().getISQLSession();
091: pISQLProject = Api.getISQLObjectFactory().getISQLProject();
092: pISQLPersonne = Api.getISQLObjectFactory().getISQLPersonne();
093:
094: usedLocale = Api.getUsedLocale();
095: Util.log("[LoginSalomeTMF->connectToAPI] Used Local is "
096: + usedLocale);
097: Language.getInstance().setLocale(new Locale(usedLocale));
098: languages = Api.getLocales();
099: Util
100: .log("[LoginSalomeTMF->connectToAPI] Available Languages is "
101: + languages);
102: if (languages == null) {
103: Util
104: .log("[LoginSalomeTMF->connectToAPI] Set default languages list to fr");
105: languages = new Vector();
106: languages.add("fr");
107: }
108: }
109:
110: void quit() {
111: try {
112: getAppletContext().showDocument(
113: new URL("http://wiki.objectweb.org/salome-tmf"));
114: } catch (Exception e) {
115: }
116: }
117:
118: void onStart() {
119: //
120: }
121:
122: void onInit() {
123:
124: //salome_redirect = false;
125: connectToAPI();
126: System.runFinalization();
127: System.gc();
128: if (Api.isConnected()) {
129: initData();
130: initComponents();
131: init = true;
132: initList();
133: init = false;
134: }
135: }
136:
137: void onStop() {
138: //
139: }
140:
141: void initData() {
142: //
143: try {
144: ProjectWrapper[] tmpProjectArray = pISQLProject
145: .getAllProjects();
146: Vector tmpProjectVector = new Vector();
147: for (int i = 0; i < tmpProjectArray.length; i++) {
148: tmpProjectVector.add(tmpProjectArray[i]);
149: }
150: porjectsList = tmpProjectVector;
151: Util.log("[LoginSalomeTMF->initData] Projects list is "
152: + porjectsList);
153: if (porjectsList.size() > 0) {
154: ProjectWrapper pProjectWrapper = (ProjectWrapper) porjectsList
155: .elementAt(0);
156: UserWrapper[] tmpUserArray = pISQLProject
157: .getUsersOfProject(pProjectWrapper.getName());
158: Vector tmpUserVector = new Vector();
159: for (int i = 0; i < tmpUserArray.length; i++) {
160: tmpUserVector.add(tmpUserArray[i]);
161: }
162: usersProject = tmpUserVector;
163: Util
164: .log("[LoginSalomeTMF->initData] Users Project list is "
165: + usersProject
166: + ", for project "
167: + pProjectWrapper.getName());
168: UserWrapper[] tmpAdminArray = pISQLProject
169: .getAdminsOfProject(pProjectWrapper.getName());
170: Vector tmpAdminVector = new Vector();
171: for (int i = 0; i < tmpAdminArray.length; i++) {
172: tmpAdminVector.add(tmpAdminArray[i]);
173: }
174: adminsProject = tmpAdminVector;
175: Util
176: .log("[LoginSalomeTMF->initData] Admins project list is "
177: + adminsProject
178: + ", for project "
179: + pProjectWrapper.getName());
180: } else {
181: usersProject = new Vector();
182: adminsProject = new Vector();
183: }
184: super User = pISQLPersonne.getUserByLogin("AdminSalome");
185: if (super User != null) {
186: admin_pwd = super User.getPassword();
187: Util.log("[LoginSalomeTMF->initData] superUser is "
188: + super User);
189: }
190: } catch (Exception e) {
191: Util.log("[LoginSalomeTMF->initData]" + e);
192: porjectsList = null;
193: }
194: }
195:
196: /** Initializes the applet Salome */
197: public void init() {
198: Util.log("[LoginSalomeTMF] init");
199: onInit();
200: }
201:
202: public void destroy() {
203: Util.log("[LoginSalomeTMF] destroy");
204: Util.log("[LoginSalomeTMF->destroy] closeConnection");
205: if (closeDB) {
206: Api.closeConnection();
207: }
208: }
209:
210: public void stop() {
211: Util.log("[LoginSalomeTMF] stop");
212: if (salome_html != null) {
213: salome_html.delete();
214: }
215: }
216:
217: public void start() {
218: Util.log("[LoginSalomeTMF] start");
219: }
220:
221: private void error(String err) {
222: javax.swing.JOptionPane.showMessageDialog(this , err, Language
223: .getInstance().getText("Authentification"),
224: javax.swing.JOptionPane.ERROR_MESSAGE);
225:
226: }
227:
228: private void projectChange(ProjectWrapper pProjectWrapper) {
229: String project = pProjectWrapper.getName();
230: proj = project;
231: if (!init) {
232: try {
233: proj = project;
234: //users = db_AdminVT.getAllUserOfProject(proj);
235:
236: UserWrapper[] tmpUserArray = pISQLProject
237: .getUsersOfProject(project);
238: Vector tmpUserVector = new Vector();
239: for (int i = 0; i < tmpUserArray.length; i++) {
240: tmpUserVector.add(tmpUserArray[i]);
241: }
242: usersProject = tmpUserVector;
243:
244: user_List.removeAllItems();
245:
246: //Enumeration e = users.keys();
247: Enumeration e = usersProject.elements();
248: while (e.hasMoreElements()) {
249: Object pUser = e.nextElement();
250: Util
251: .log("[LoginSalomeTMF->projectChange] add user_List "
252: + pUser);
253: user_List.addItem(pUser);
254: }
255: } catch (Exception e) {
256:
257: }
258: }
259: }
260:
261: private void projectChange1(ProjectWrapper pProjectWrapper) {
262: String project = pProjectWrapper.getName();
263: proj1 = project;
264: if (!init) {
265: try {
266: proj1 = project;
267: //users1 = db_AdminVT.getAllAdminOfProject(proj1);
268:
269: UserWrapper[] tmpAdminArray = pISQLProject
270: .getAdminsOfProject(project);
271: Vector tmpAdminVector = new Vector();
272: for (int i = 0; i < tmpAdminArray.length; i++) {
273: tmpAdminVector.add(tmpAdminArray[i]);
274: }
275: adminsProject = tmpAdminVector;
276: user_List1.removeAllItems();
277:
278: //Enumeration e = users1.keys();
279: Enumeration e = adminsProject.elements();
280: while (e.hasMoreElements()) {
281: Object pUser = e.nextElement();
282: Util
283: .log("[LoginSalomeTMF->projectChange1] add user_List1 "
284: + pUser);
285: user_List1.addItem(pUser);
286: }
287: } catch (Exception e) {
288:
289: }
290: }
291: }
292:
293: private UserWrapper getUser() {
294: return (UserWrapper) user_List.getSelectedItem();
295: }
296:
297: private UserWrapper getUser1() {
298: return (UserWrapper) user_List1.getSelectedItem();
299: }
300:
301: private boolean validPassword() {
302: //String paswd = (String) users.get(getUser());
303: String paswd = getUser().getPassword();
304: String typed_paswd = new String(password_Field.getPassword());
305: if (paswd != null) {
306: try {
307: return org.objectweb.salome_tmf.api.MD5paswd
308: .testPassword(typed_paswd, paswd);
309: } catch (Exception e) {
310: Util.log("[LoginSalomeTMF->validPassword]" + e);
311: }
312: }
313: return false;
314: }
315:
316: private boolean validPassword1() {
317: //String paswd = (String) users1.get(getUser1());
318: String paswd = getUser1().getPassword();
319: String typed_paswd = new String(password_Field1.getPassword());
320: if (paswd != null) {
321: try {
322: return org.objectweb.salome_tmf.api.MD5paswd
323: .testPassword(typed_paswd, paswd);
324: } catch (Exception e) {
325: Util.log("[LoginSalomeTMF->validPassword1]" + e);
326: }
327: }
328: return false;
329: }
330:
331: private boolean validPassword2() {
332: String typed_paswd = new String(password_Field2.getPassword());
333: Util.log("[LoginSalomeTMF->validPassword2] verify paswd "
334: + typed_paswd + " with " + admin_pwd);
335: if (admin_pwd != null) {
336: try {
337: return org.objectweb.salome_tmf.api.MD5paswd
338: .testPassword(typed_paswd, admin_pwd);
339: } catch (Exception e) {
340: Util.log("[LoginSalomeTMF->validPassword2]" + e);
341: }
342:
343: }
344: return false;
345: }
346:
347: private void initList() {
348: project_List.removeAllItems();
349: project_List1.removeAllItems();
350: user_List.removeAllItems();
351: user_List1.removeAllItems();
352: languages_List.removeAllItems();
353: user_List.removeAllItems();
354: for (int i = 0; i < porjectsList.size(); i++) {
355: project_List.addItem(porjectsList.elementAt(i));
356: project_List1.addItem(porjectsList.elementAt(i));
357: }
358:
359: Enumeration e = usersProject.elements();
360: while (e.hasMoreElements()) {
361: Object pUser = e.nextElement();
362: Util.log("[LoginSalomeTMF->initList] add user_List "
363: + pUser);
364: user_List.addItem(pUser);
365: }
366: e = adminsProject.elements();
367: while (e.hasMoreElements()) {
368: Object pUser = e.nextElement();
369: Util.log("[LoginSalomeTMF->initList] add user_List1 "
370: + pUser);
371: user_List1.addItem(pUser);
372: }
373:
374: for (int j = 0; j < languages.size(); j++) {
375: /*Locale locale = new Locale((String)languages.elementAt(j));
376: languages_List.addItem(locale.getDisplayName());*/
377: languages_List.addItem(((String) languages.elementAt(j))
378: .trim());
379: }
380: //languages_List.setSelectedItem(new Locale(Api.LOCALE).getDisplayName());
381: languages_List.setSelectedItem(usedLocale);
382:
383: }
384:
385: /** This method is called from within the init() method to
386: * initialize the form.
387: * WARNING: Do NOT modify this code. The content of this method is
388: * always regenerated by the Form Editor.
389: */
390: private void initComponents() {//GEN-BEGIN:initComponents
391: jTabbedPane1 = new javax.swing.JTabbedPane();
392: jPanel4 = new javax.swing.JPanel();
393: jPanel1 = new javax.swing.JPanel();
394: jLabel2 = new javax.swing.JLabel();
395: jLabel3 = new javax.swing.JLabel();
396: jLabel4 = new javax.swing.JLabel();
397: project_List = new javax.swing.JComboBox();
398: user_List = new javax.swing.JComboBox();
399: password_Field = new javax.swing.JPasswordField();
400: password_Field.addKeyListener(new passwordKeyListener(0));
401:
402: jPanel2 = new javax.swing.JPanel();
403: jLabel1 = new javax.swing.JLabel();
404: jPanel3 = new javax.swing.JPanel();
405: b_start = new javax.swing.JButton();
406: jPanel5 = new javax.swing.JPanel();
407: jPanel7 = new javax.swing.JPanel();
408: jLabel5 = new javax.swing.JLabel();
409: jLabel6 = new javax.swing.JLabel();
410: jLabel7 = new javax.swing.JLabel();
411: project_List1 = new javax.swing.JComboBox();
412: user_List1 = new javax.swing.JComboBox();
413: password_Field1 = new javax.swing.JPasswordField();
414: password_Field1.addKeyListener(new passwordKeyListener(1));
415:
416: jPanel8 = new javax.swing.JPanel();
417: b_start1 = new javax.swing.JButton();
418: jPanel9 = new javax.swing.JPanel();
419: jLabel8 = new javax.swing.JLabel();
420: jPanel6 = new javax.swing.JPanel();
421: jPanel10 = new javax.swing.JPanel();
422: jPanel11 = new javax.swing.JPanel();
423: jLabel10 = new javax.swing.JLabel();
424: jLabel11 = new javax.swing.JLabel();
425: jTextField1 = new javax.swing.JTextField();
426: password_Field2 = new javax.swing.JPasswordField();
427: password_Field2.addKeyListener(new passwordKeyListener(2));
428:
429: jPanel12 = new javax.swing.JPanel();
430: b_start2 = new javax.swing.JButton();
431: jPanel13 = new javax.swing.JPanel();
432: jLabel12 = new javax.swing.JLabel();
433: jPanel14 = new javax.swing.JPanel();
434: jPanel16 = new javax.swing.JPanel();
435: jPanel19 = new javax.swing.JPanel();
436: jLabel15 = new javax.swing.JLabel();
437: jPanel17 = new javax.swing.JPanel();
438: jLabel13 = new javax.swing.JLabel();
439: jLabel14 = new javax.swing.JLabel();
440: jLabel16 = new javax.swing.JLabel();
441: jLabel17 = new javax.swing.JLabel();
442: languages_List = new javax.swing.JComboBox();
443: jLabel19 = new javax.swing.JLabel();
444: jPanel18 = new javax.swing.JPanel();
445: jLabel9 = new javax.swing.JLabel();
446: jLabel18 = new javax.swing.JLabel();
447: jPanel15 = new javax.swing.JPanel();
448: jEditorPane2 = new javax.swing.JEditorPane();
449:
450: setForeground(new java.awt.Color(51, 51, 51));
451: jTabbedPane1.setBackground(new java.awt.Color(255, 255, 255));
452: jTabbedPane1.setBorder(new javax.swing.border.EmptyBorder(
453: new java.awt.Insets(1, 1, 1, 1)));
454: jTabbedPane1.setForeground(new java.awt.Color(255, 102, 0));
455: jTabbedPane1.setOpaque(true);
456: jPanel4.setLayout(new java.awt.BorderLayout());
457:
458: jPanel4.setBackground(new java.awt.Color(255, 255, 255));
459: jPanel4.setForeground(new java.awt.Color(51, 51, 51));
460: jPanel1.setLayout(new java.awt.GridLayout(2, 3, 10, 0));
461:
462: jPanel1.setBackground(new java.awt.Color(255, 255, 255));
463: jPanel1.setForeground(new java.awt.Color(51, 51, 51));
464: jLabel2.setBackground(new java.awt.Color(255, 255, 255));
465: jLabel2.setText(Language.getInstance().getText("Projet"));
466: jLabel2.setOpaque(true);
467: jPanel1.add(jLabel2);
468:
469: jLabel3.setBackground(new java.awt.Color(255, 255, 255));
470: jLabel3.setText(Language.getInstance().getText("Utilisateur"));
471: jLabel3.setOpaque(true);
472: jPanel1.add(jLabel3);
473:
474: jLabel4.setBackground(new java.awt.Color(255, 255, 255));
475: jLabel4.setText(Language.getInstance().getText("Mot_de_passe"));
476: jLabel4.setOpaque(true);
477: jPanel1.add(jLabel4);
478:
479: project_List.setBackground(new java.awt.Color(255, 204, 0));
480: project_List.setName("l_projet");
481: project_List
482: .addActionListener(new java.awt.event.ActionListener() {
483: public void actionPerformed(
484: java.awt.event.ActionEvent evt) {
485: project_ListActionPerformed(evt);
486: }
487: });
488: project_List.addItemListener(new java.awt.event.ItemListener() {
489: public void itemStateChanged(java.awt.event.ItemEvent evt) {
490: project_ListItemStateChanged(evt);
491: }
492: });
493:
494: jPanel1.add(project_List);
495:
496: user_List.setBackground(new java.awt.Color(255, 204, 0));
497: user_List.addItemListener(new java.awt.event.ItemListener() {
498: public void itemStateChanged(java.awt.event.ItemEvent evt) {
499: user_ListItemStateChanged(evt);
500: }
501: });
502:
503: jPanel1.add(user_List);
504:
505: jPanel1.add(password_Field);
506:
507: jPanel4.add(jPanel1, java.awt.BorderLayout.CENTER);
508:
509: jPanel2.setBackground(new java.awt.Color(255, 255, 255));
510: jPanel2.setForeground(new java.awt.Color(51, 51, 51));
511: jLabel1.setBackground(new java.awt.Color(255, 255, 255));
512: jLabel1.setFont(new java.awt.Font("Dialog", 1, 24));
513: jLabel1.setText(Language.getInstance().getText(
514: "Se_connecter_à_Salom\u00e9_TMF"));
515: jPanel2.add(jLabel1);
516:
517: jPanel4.add(jPanel2, java.awt.BorderLayout.NORTH);
518:
519: jPanel3.setBackground(new java.awt.Color(255, 255, 255));
520: jPanel3.setForeground(new java.awt.Color(51, 51, 51));
521: b_start.setText(Language.getInstance().getText(
522: "Démarrer_Salom\u00e9_TMF"));
523: b_start.addActionListener(new java.awt.event.ActionListener() {
524: public void actionPerformed(java.awt.event.ActionEvent evt) {
525: b_startActionPerformed(evt);
526: }
527: });
528:
529: jPanel3.add(b_start);
530:
531: jPanel4.add(jPanel3, java.awt.BorderLayout.SOUTH);
532:
533: jTabbedPane1.addTab(Language.getInstance().getText(
534: "Démarrer_Salom\u00e9_TMF"), jPanel4);
535:
536: jPanel5.setLayout(new java.awt.BorderLayout());
537:
538: jPanel5.setBackground(new java.awt.Color(255, 255, 255));
539: jPanel5.setForeground(new java.awt.Color(51, 51, 51));
540: jPanel7.setLayout(new java.awt.GridLayout(2, 3, 10, 0));
541:
542: jPanel7.setBackground(new java.awt.Color(255, 255, 255));
543: jPanel7.setForeground(new java.awt.Color(51, 51, 51));
544: jLabel5.setBackground(new java.awt.Color(255, 255, 255));
545: jLabel5.setText(Language.getInstance().getText("Projet"));
546: jLabel5.setOpaque(true);
547: jPanel7.add(jLabel5);
548:
549: jLabel6.setBackground(new java.awt.Color(255, 255, 255));
550: jLabel6.setText(Language.getInstance().getText("Utilisateur"));
551: jLabel6.setOpaque(true);
552: jPanel7.add(jLabel6);
553:
554: jLabel7.setBackground(new java.awt.Color(255, 255, 255));
555: jLabel7.setText(Language.getInstance().getText("Mot_de_passe"));
556: jLabel7.setOpaque(true);
557: jPanel7.add(jLabel7);
558:
559: project_List1.setBackground(new java.awt.Color(255, 204, 0));
560: project_List1.setName("l_projet");
561: project_List1
562: .addItemListener(new java.awt.event.ItemListener() {
563: public void itemStateChanged(
564: java.awt.event.ItemEvent evt) {
565: project_List1ItemStateChanged(evt);
566: }
567: });
568:
569: jPanel7.add(project_List1);
570:
571: user_List1.setBackground(new java.awt.Color(255, 204, 0));
572: jPanel7.add(user_List1);
573:
574: jPanel7.add(password_Field1);
575:
576: jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER);
577:
578: jPanel8.setBackground(new java.awt.Color(255, 255, 255));
579: b_start1.setText(Language.getInstance().getText(
580: "Administrer_le_projet"));
581: b_start1.addActionListener(new java.awt.event.ActionListener() {
582: public void actionPerformed(java.awt.event.ActionEvent evt) {
583: b_start1ActionPerformed(evt);
584: }
585: });
586:
587: jPanel8.add(b_start1);
588:
589: jPanel5.add(jPanel8, java.awt.BorderLayout.SOUTH);
590:
591: jPanel9.setBackground(new java.awt.Color(255, 255, 255));
592: jLabel8.setBackground(new java.awt.Color(255, 255, 255));
593: jLabel8.setFont(new java.awt.Font("Dialog", 1, 24));
594: jLabel8.setText(Language.getInstance().getText(
595: "Se_connecter_en_Administrateur_de_projet"));
596: jPanel9.add(jLabel8);
597: jLabel8.getAccessibleContext().setAccessibleName(
598: Language.getInstance().getText(
599: "Se_connecter_en_Administrateur_de_projet"));
600:
601: jPanel5.add(jPanel9, java.awt.BorderLayout.NORTH);
602:
603: jTabbedPane1.addTab(Language.getInstance().getText(
604: "Administrer_un_projet"), jPanel5);
605:
606: jPanel6.setLayout(new java.awt.BorderLayout());
607:
608: jPanel6.setBackground(new java.awt.Color(255, 255, 255));
609: jPanel6.setForeground(new java.awt.Color(51, 51, 51));
610: jPanel10.setLayout(new java.awt.BorderLayout());
611:
612: jPanel10.setBackground(new java.awt.Color(255, 255, 255));
613: jPanel11.setLayout(new java.awt.GridLayout(2, 2, 10, 0));
614:
615: jPanel11.setBackground(new java.awt.Color(255, 255, 255));
616: jPanel11.setForeground(new java.awt.Color(51, 51, 51));
617: jLabel10.setBackground(new java.awt.Color(255, 255, 255));
618: jLabel10.setText(Language.getInstance().getText("Utilisateur"));
619: jLabel10.setOpaque(true);
620: jPanel11.add(jLabel10);
621:
622: jLabel11.setBackground(new java.awt.Color(255, 255, 255));
623: jLabel11
624: .setText(Language.getInstance().getText("Mot_de_passe"));
625: jLabel11.setOpaque(true);
626: jPanel11.add(jLabel11);
627:
628: jTextField1.setBackground(new java.awt.Color(255, 204, 0));
629: jTextField1.setEditable(false);
630: jTextField1.setFont(new java.awt.Font("Dialog", 1, 12));
631: jTextField1.setText("AdminSalome");
632: jPanel11.add(jTextField1);
633:
634: jPanel11.add(password_Field2);
635:
636: jPanel10.add(jPanel11, java.awt.BorderLayout.CENTER);
637:
638: jPanel12.setBackground(new java.awt.Color(255, 255, 255));
639: b_start2.setText(Language.getInstance().getText(
640: "Administrer_Salom\u00e9_TMF"));
641: b_start2.addActionListener(new java.awt.event.ActionListener() {
642: public void actionPerformed(java.awt.event.ActionEvent evt) {
643: b_start2ActionPerformed(evt);
644: }
645: });
646:
647: jPanel12.add(b_start2);
648:
649: jPanel10.add(jPanel12, java.awt.BorderLayout.SOUTH);
650:
651: jPanel13.setBackground(new java.awt.Color(255, 255, 255));
652: jLabel12.setBackground(new java.awt.Color(255, 255, 255));
653: jLabel12.setFont(new java.awt.Font("Dialog", 1, 24));
654: jLabel12.setText(Language.getInstance().getText(
655: "Se_connecter_en_administrateur_de_Salom\u00e9_TMF"));
656: jPanel13.add(jLabel12);
657:
658: jPanel10.add(jPanel13, java.awt.BorderLayout.NORTH);
659:
660: jPanel6.add(jPanel10, java.awt.BorderLayout.CENTER);
661:
662: jTabbedPane1.addTab(Language.getInstance().getText(
663: "Administrer_Salom\u00e9_TMF"), jPanel6);
664:
665: jPanel14.setLayout(new java.awt.BorderLayout());
666:
667: jPanel14.setBackground(new java.awt.Color(255, 255, 255));
668: jPanel16.setLayout(new java.awt.BorderLayout());
669:
670: jPanel16.setBackground(new java.awt.Color(255, 255, 255));
671: jPanel19.setBackground(new java.awt.Color(255, 255, 255));
672: jLabel15.setBackground(new java.awt.Color(255, 255, 255));
673: jLabel15.setFont(new java.awt.Font("Dialog", 1, 24));
674: jLabel15.setText(Language.getInstance().getText(
675: "Choissisez_votre_langue_:"));
676: jPanel19.add(jLabel15);
677:
678: jPanel16.add(jPanel19, java.awt.BorderLayout.NORTH);
679:
680: jPanel17.setLayout(new java.awt.GridLayout(2, 3, 10, 0));
681:
682: jPanel17.setBackground(new java.awt.Color(255, 255, 255));
683: jPanel17.setForeground(new java.awt.Color(51, 51, 51));
684: jPanel17.add(jLabel13);
685:
686: jLabel14.setText(Language.getInstance().getText("Langue_:"));
687: jPanel17.add(jLabel14);
688:
689: jPanel17.add(jLabel16);
690:
691: jPanel17.add(jLabel17);
692:
693: languages_List.setBackground(new java.awt.Color(255, 204, 0));
694: jPanel17.add(languages_List);
695:
696: jPanel17.add(jLabel19);
697:
698: jPanel16.add(jPanel17, java.awt.BorderLayout.CENTER);
699:
700: jPanel18.setBackground(new java.awt.Color(255, 255, 255));
701: jPanel18.setPreferredSize(new java.awt.Dimension(15, 33));
702: jPanel18.add(jLabel9);
703:
704: jPanel18.add(jLabel18);
705:
706: jPanel16.add(jPanel18, java.awt.BorderLayout.SOUTH);
707:
708: jPanel14.add(jPanel16, java.awt.BorderLayout.CENTER);
709:
710: jTabbedPane1.addTab(Language.getInstance().getText("Langues"),
711: jPanel14);
712:
713: jPanel15.setLayout(new java.awt.BorderLayout());
714:
715: jEditorPane2.setEditable(false);
716: HTMLDocument m_oDocument;
717: HTMLEditorKit m_oHTML;
718: m_oDocument = new HTMLDocument();
719: m_oHTML = new HTMLEditorKit();
720: jEditorPane2.setEditorKit(m_oHTML);
721: jEditorPane2.setDocument(m_oDocument);
722: jEditorPane2.setText(htmlAbout());
723:
724: jPanel15.setBackground(new java.awt.Color(255, 255, 255));
725: jPanel15.add(jEditorPane2, java.awt.BorderLayout.CENTER);
726:
727: jTabbedPane1.addTab(Language.getInstance().getText("A_propos"),
728: jPanel15);
729:
730: getContentPane()
731: .add(jTabbedPane1, java.awt.BorderLayout.CENTER);
732:
733: }//GEN-END:initComponents
734:
735: String htmlAbout() {
736: return "<body>"
737: + "<div style=\"text-align: center;\">"
738: + "<div style=\"text-align: left;\">"
739: + "<div style=\"text-align: center;\"><small><small><span style=\"font-weight: bold;\"><big><big>Salome-TMF</big></big></span>"
740: + "</small></small></div>"
741: + "<div style=\"text-align: center;\"><small><small><span style=\"font-weight: bold;\">version 3 <a href=\"https://wiki.objectweb.org/salome-tmf/\">https://wiki.objectweb.org/salome-tmf/</a></span>"
742: + "<span style=\"font-weight: bold;\"></span></small></small></div>"
743: + "<div style=\"text-align: left;\"><small><small><span style=\"font-weight: bold;\">SalomeTMF is a Test Management Framework, Copyright (C) 2005 France Telecom R&D"
744: + " <li>Mikaël Marche (Project Manager, Developer, Plug-in developer, Documentation)</li>"
745: + "<li>Fayçal Sougrati (Developer, Plug-in developer, Documentation)</li>"
746: + "<li>Aurore Penault (Developer, Plug-in developer, Documentation)</li>"
747: + "<li>Yves-Marie Quemener (English documentation)</li>"
748: + "<li>Vincent Pautret (Developer)</li>"
749: + "<li>Jean-Marie Hallouët (Localization and Validation)</li>"
750: + "</span>" + "</body>";
751: //"</html>";
752: }
753:
754: private void project_List1ItemStateChanged(
755: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_project_List1ItemStateChanged
756: // TODO add your handling code here:
757: projectChange1((ProjectWrapper) evt.getItem());
758: //projectChange1((String)evt.getItem());
759: }//GEN-LAST:event_project_List1ItemStateChanged
760:
761: private void b_start1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_start1ActionPerformed
762: // TODO add your handling code here:
763: if (validPassword1()) {
764: URL recup;
765: try {
766: usedLocale = ((String) languages_List.getSelectedItem())
767: .trim();
768: Api.saveLocale(usedLocale);
769: /*int idConnection = pISQLSession.addSession(proj1, getUser1().getLogin());
770: recup = new URL(getDocumentBase(), "AdminProject.html?id=" + idConnection);
771: getAppletContext().showDocument(recup);
772: */
773: pJSUtils.setCookies(proj1, getUser1().getLogin(),
774: new String(password_Field1.getPassword()));
775: recup = new URL(getDocumentBase(), "AdminProject.html");
776: getAppletContext().showDocument(recup);
777:
778: repaint();
779: } catch (Exception me) {
780: }
781: } else {
782: error(Language.getInstance().getText(
783: "Mot_de_passe_invalide"));
784: }
785:
786: }//GEN-LAST:event_b_start1ActionPerformed
787:
788: private void b_start2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_start2ActionPerformed
789: // TODO add your handling code here:
790: if (validPassword2()) {
791: URL recup;
792: try {
793: usedLocale = ((String) languages_List.getSelectedItem())
794: .trim();
795: Api.saveLocale(usedLocale);
796: //int idConnection = Api.addConnection("ALL", "AdminSalome");
797:
798: /*int idConnection = pISQLSession.addSession("ALL", "AdminSalome");
799: recup = new URL(getDocumentBase(), "Administration.html?id=" + idConnection );
800: getAppletContext().showDocument(recup);
801: */
802:
803: pJSUtils.setCookies("ALL", "AdminSalome", new String(
804: password_Field2.getPassword()));
805: recup = new URL(getDocumentBase(),
806: "Administration.html");
807: getAppletContext().showDocument(recup);
808:
809: repaint();
810: } catch (Exception me) {
811: Util.log("[LoginSalomeTMF->b_start2ActionPerformed]"
812: + me);
813: }
814: } else {
815: error(Language.getInstance().getText(
816: "Mot_de_passe_invalide"));
817: }
818: }//GEN-LAST:event_b_start2ActionPerformed
819:
820: private void project_ListActionPerformed(
821: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_project_ListActionPerformed
822: // TODO add your handling code here:
823: }//GEN-LAST:event_project_ListActionPerformed
824:
825: private void project_ListItemStateChanged(
826: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_project_ListItemStateChanged
827: // TODO add your handling code here:
828:
829: projectChange((ProjectWrapper) evt.getItem());
830: }//GEN-LAST:event_project_ListItemStateChanged
831:
832: private void user_ListItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_user_ListItemStateChanged
833: // TODO add your handling code here:
834: }//GEN-LAST:event_user_ListItemStateChanged
835:
836: private void b_startActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_startActionPerformed
837: // TODO add your handling code here:
838: if (validPassword()) {
839: URL recup;
840: try {
841: usedLocale = ((String) languages_List.getSelectedItem())
842: .trim();
843: Api.saveLocale(usedLocale);
844: //int idConnection = Api.addConnection(proj, getUser());
845: /*int idConnection = pISQLSession.addSession(proj, getUser().getLogin());
846: recup = new URL(getDocumentBase(), "Salome.html?id=" + idConnection);
847: getAppletContext().showDocument(recup);
848: */
849:
850: pJSUtils.setCookies(proj, getUser().getLogin(),
851: new String(password_Field.getPassword()));
852: recup = new URL(getDocumentBase(), "Salome.html");
853: getAppletContext().showDocument(recup);
854:
855: repaint();
856: } catch (Exception me) {
857: Util.log("[LoginSalomeTMF->b_startActionPerformed]"
858: + me);
859: }
860: } else {
861: error(Language.getInstance().getText(
862: "Mot_de_passe_invalide"));
863: }
864: }//GEN-LAST:event_b_startActionPerformed
865:
866: // Variables declaration - do not modify//GEN-BEGIN:variables
867: private javax.swing.JButton b_start;
868: private javax.swing.JButton b_start1;
869: private javax.swing.JButton b_start2;
870: private javax.swing.JEditorPane jEditorPane2;
871: private javax.swing.JLabel jLabel1;
872: private javax.swing.JLabel jLabel10;
873: private javax.swing.JLabel jLabel11;
874: private javax.swing.JLabel jLabel12;
875: private javax.swing.JLabel jLabel13;
876: private javax.swing.JLabel jLabel14;
877: private javax.swing.JLabel jLabel15;
878: private javax.swing.JLabel jLabel16;
879: private javax.swing.JLabel jLabel17;
880: private javax.swing.JLabel jLabel18;
881: private javax.swing.JLabel jLabel19;
882: private javax.swing.JLabel jLabel2;
883: private javax.swing.JLabel jLabel3;
884: private javax.swing.JLabel jLabel4;
885: private javax.swing.JLabel jLabel5;
886: private javax.swing.JLabel jLabel6;
887: private javax.swing.JLabel jLabel7;
888: private javax.swing.JLabel jLabel8;
889: private javax.swing.JLabel jLabel9;
890: private javax.swing.JPanel jPanel1;
891: private javax.swing.JPanel jPanel10;
892: private javax.swing.JPanel jPanel11;
893: private javax.swing.JPanel jPanel12;
894: private javax.swing.JPanel jPanel13;
895: private javax.swing.JPanel jPanel14;
896: private javax.swing.JPanel jPanel15;
897: private javax.swing.JPanel jPanel16;
898: private javax.swing.JPanel jPanel17;
899: private javax.swing.JPanel jPanel18;
900: private javax.swing.JPanel jPanel19;
901: private javax.swing.JPanel jPanel2;
902: private javax.swing.JPanel jPanel3;
903: private javax.swing.JPanel jPanel4;
904: private javax.swing.JPanel jPanel5;
905: private javax.swing.JPanel jPanel6;
906: private javax.swing.JPanel jPanel7;
907: private javax.swing.JPanel jPanel8;
908: private javax.swing.JPanel jPanel9;
909: private javax.swing.JTabbedPane jTabbedPane1;
910: private javax.swing.JTextField jTextField1;
911: private javax.swing.JComboBox languages_List;
912: private javax.swing.JPasswordField password_Field;
913: private javax.swing.JPasswordField password_Field1;
914: private javax.swing.JPasswordField password_Field2;
915: private javax.swing.JComboBox project_List;
916: private javax.swing.JComboBox project_List1;
917: private javax.swing.JComboBox user_List;
918: private javax.swing.JComboBox user_List1;
919:
920: // End of variables declaration//GEN-END:variables
921:
922: class passwordKeyListener implements KeyListener {
923: int paswdType = -1;
924:
925: passwordKeyListener(int t) {
926: paswdType = t;
927: }
928:
929: public void keyTyped(KeyEvent ke) {
930:
931: }
932:
933: public void keyPressed(KeyEvent ke) {
934:
935: }
936:
937: public void keyReleased(KeyEvent ke) {
938: if (ke.getKeyCode() == KeyEvent.VK_ENTER) {
939: if (paswdType == 0) {
940: b_startActionPerformed(null);
941: } else if (paswdType == 1) {
942: b_start1ActionPerformed(null);
943: } else if (paswdType == 2) {
944: b_start2ActionPerformed(null);
945: }
946: }
947: }
948: }
949:
950: }
|