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