Source Code Cross Referenced for GardeDialog.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » docXML » common » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » salomeTMF_plug.docXML.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 Aurore PENAULT
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package salomeTMF_plug.docXML.common;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Container;
028:        import java.awt.Dimension;
029:        import java.awt.FlowLayout;
030:        import java.awt.Font;
031:        import java.awt.GridLayout;
032:        import java.awt.Rectangle;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:        import java.io.File;
036:        import java.net.URL;
037:
038:        import javax.swing.BorderFactory;
039:        import javax.swing.Box;
040:        import javax.swing.BoxLayout;
041:        import javax.swing.JButton;
042:        import javax.swing.JDialog;
043:        import javax.swing.JFileChooser;
044:        import javax.swing.JLabel;
045:        import javax.swing.JOptionPane;
046:        import javax.swing.JPanel;
047:        import javax.swing.JScrollPane;
048:        import javax.swing.JTextArea;
049:        import javax.swing.JTextField;
050:
051:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
052:        import org.objectweb.salome_tmf.ihm.models.ScriptFileFilter;
053:        import org.objectweb.salome_tmf.ihm.tools.Tools;
054:
055:        import salomeTMF_plug.docXML.data.GardePage;
056:        import salomeTMF_plug.docXML.languages.Language;
057:
058:        import com.toedter.calendar.JDateChooser;
059:
060:        /**
061:         * Classe créant l'IMM permettant à l'utilisateur de remplir un formulaire
062:         * afin de pouvoir générer à partir de ces informations une page de garde
063:         * @author  vapu8214
064:         */
065:        public class GardeDialog extends JDialog implements  ActionListener {
066:
067:            JLabel logoLabel;
068:            JTextField logoTextField;
069:            JButton logoButton;
070:            String logoFile = "";
071:            URL urlLogo;
072:
073:            JLabel entrepriseLabel;
074:            JTextArea entrepriseArea;
075:
076:            JLabel auteurLabel;
077:            JTextField auteurTextField;
078:
079:            JLabel emailLabel;
080:            JTextField emailTextField;
081:
082:            JLabel titreLabel;
083:            JTextField titreTextField;
084:
085:            JLabel versionLabel;
086:            JTextField versionTextField;
087:
088:            JDateChooser date;
089:
090:            JLabel infosLabel;
091:            JTextArea infosArea;
092:
093:            JButton annuler;
094:            JButton valider;
095:
096:            JLabel champ;
097:
098:            GenDocDialog g;
099:
100:            private String errorMessage = "";
101:
102:            /** Creates a new instance of GardeDialog */
103:            public GardeDialog(GenDocDialog g) throws Exception {
104:                super (g, true);
105:                this .g = g;
106:                logoLabel = new JLabel(Language.getInstance()
107:                        .getText("Logo_:_"));
108:                logoTextField = new JTextField(30);
109:                logoButton = new JButton(Language.getInstance().getText(
110:                        "Choisir..."));
111:                logoButton.addActionListener(this );
112:
113:                entrepriseLabel = new JLabel(Language.getInstance().getText(
114:                        "Entreprise_:_"));
115:                entrepriseArea = new JTextArea(3, 30);
116:                JScrollPane entreprisePane = new JScrollPane(entrepriseArea);
117:
118:                auteurLabel = new JLabel(Language.getInstance().getText(
119:                        "Auteur_:_"));
120:                auteurTextField = new JTextField(30);
121:                auteurTextField.setText(DataModel.getCurrentUser()
122:                        .getFirstNameFromModel()
123:                        + " "
124:                        + DataModel.getCurrentUser().getLastNameFromModel());
125:
126:                emailLabel = new JLabel(Language.getInstance().getText(
127:                        "Email_:_"));
128:                emailTextField = new JTextField(30);
129:                emailTextField.setText(DataModel.getCurrentUser()
130:                        .getEmailFromModel());
131:
132:                titreLabel = new JLabel(Language.getInstance().getText(
133:                        "Titre_du_document_(*)_:_"));
134:                titreTextField = new JTextField(30);
135:                titreTextField.setText(DataModel.getCurrentProject()
136:                        .getNameFromModel());
137:
138:                versionLabel = new JLabel(Language.getInstance().getText(
139:                        "Version_du_document_:_"));
140:                versionTextField = new JTextField(30);
141:
142:                infosLabel = new JLabel(Language.getInstance().getText(
143:                        "Informations_complémentaires_:_"));
144:                infosArea = new JTextArea(2, 30);
145:                JScrollPane infosPane = new JScrollPane(infosArea);
146:
147:                annuler = new JButton(Language.getInstance().getText("Annuler"));
148:                annuler.addActionListener(this );
149:
150:                valider = new JButton(Language.getInstance().getText("Valider"));
151:                valider.addActionListener(this );
152:
153:                champ = new JLabel(Language.getInstance().getText(
154:                        "*_:_champ_obligatoire"));
155:                champ.setFont(new Font(null, Font.ITALIC, 12));
156:
157:                JPanel logoChois = new JPanel(new FlowLayout(FlowLayout.LEFT));
158:                logoChois.add(logoButton);
159:
160:                JPanel logo1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
161:                logo1.add(logoTextField);
162:
163:                JPanel logo2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
164:                logo2.add(logoLabel);
165:
166:                JPanel pan1 = new JPanel(new BorderLayout());
167:                pan1.setBorder(BorderFactory.createTitledBorder(""));
168:                pan1.add(logo2, BorderLayout.NORTH);
169:                pan1.add(logo1, BorderLayout.CENTER);
170:                pan1.add(logoChois, BorderLayout.SOUTH);
171:
172:                JPanel entreprise = new JPanel(new FlowLayout(FlowLayout.LEFT));
173:                entreprise.add(entrepriseLabel);
174:
175:                JPanel entreprise1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
176:                entreprise1.add(entreprisePane);
177:
178:                JPanel ent1 = new JPanel(new BorderLayout());
179:                ent1.setBorder(BorderFactory.createTitledBorder(""));
180:                ent1.add(entreprise, BorderLayout.NORTH);
181:                ent1.add(entreprise1, BorderLayout.CENTER);
182:
183:                JPanel infosSte = new JPanel();
184:                infosSte.setLayout(new GridLayout(1, 2));
185:                infosSte.add(pan1);
186:                infosSte.add(ent1);
187:
188:                JPanel auteur = new JPanel(new FlowLayout(FlowLayout.LEFT));
189:                auteur.add(auteurLabel);
190:
191:                JPanel auteur1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
192:                auteur1.add(auteurTextField);
193:
194:                JPanel email = new JPanel(new FlowLayout(FlowLayout.LEFT));
195:                email.add(emailLabel);
196:
197:                JPanel email1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
198:                email1.add(emailTextField);
199:
200:                JPanel aut1 = new JPanel(new BorderLayout());
201:                aut1.setBorder(BorderFactory.createTitledBorder(""));
202:                aut1.add(auteur, BorderLayout.NORTH);
203:                aut1.add(auteur1, BorderLayout.CENTER);
204:
205:                JPanel mail1 = new JPanel(new BorderLayout());
206:                mail1.setBorder(BorderFactory.createTitledBorder(""));
207:                mail1.add(email, BorderLayout.NORTH);
208:                mail1.add(email1, BorderLayout.CENTER);
209:
210:                JPanel infosAuteur = new JPanel();
211:                infosAuteur.setLayout(new GridLayout(1, 2));
212:                infosAuteur.add(aut1);
213:                infosAuteur.add(mail1);
214:
215:                JPanel titre = new JPanel(new FlowLayout(FlowLayout.LEFT));
216:                titre.add(titreLabel);
217:
218:                JPanel titre1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
219:                titre1.add(titreTextField);
220:
221:                JPanel tit1 = new JPanel(new BorderLayout());
222:                tit1.setBorder(BorderFactory.createTitledBorder(""));
223:                tit1.add(titre, BorderLayout.NORTH);
224:                tit1.add(titre1, BorderLayout.CENTER);
225:
226:                JPanel version = new JPanel(new FlowLayout(FlowLayout.LEFT));
227:                version.add(versionLabel);
228:
229:                JPanel version1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
230:                version1.add(versionTextField);
231:
232:                JPanel vers1 = new JPanel(new BorderLayout());
233:                vers1.setBorder(BorderFactory.createTitledBorder(""));
234:                vers1.add(version, BorderLayout.NORTH);
235:                vers1.add(version1, BorderLayout.CENTER);
236:
237:                JPanel infosTitre = new JPanel();
238:                infosTitre.setLayout(new GridLayout(1, 2));
239:                infosTitre.add(tit1);
240:                infosTitre.add(vers1);
241:
242:                JLabel dateLabel = new JLabel(Language.getInstance().getText(
243:                        "Date_:"));
244:                JPanel dateLabelPanel = new JPanel(new FlowLayout(
245:                        FlowLayout.LEFT));
246:                dateLabelPanel.add(dateLabel);
247:                date = new JDateChooser("d MMMMM yyyy", false);
248:                JPanel datePanel = new JPanel();
249:                datePanel.setLayout(new BoxLayout(datePanel, BoxLayout.Y_AXIS));
250:                datePanel.setBorder(BorderFactory.createTitledBorder(""));
251:                datePanel.add(dateLabelPanel);
252:                datePanel.add(Box.createRigidArea(new Dimension(1, 10)));
253:                datePanel.add(date);
254:
255:                JPanel infos = new JPanel(new FlowLayout(FlowLayout.LEFT));
256:                infos.add(infosLabel);
257:
258:                JPanel infos1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
259:                infos1.add(infosPane);
260:
261:                JPanel inf1 = new JPanel(new BorderLayout());
262:                inf1.setBorder(BorderFactory.createTitledBorder(""));
263:                inf1.add(infos, BorderLayout.NORTH);
264:                inf1.add(infos1, BorderLayout.CENTER);
265:
266:                JPanel dateInfos = new JPanel();
267:                dateInfos.setLayout(new GridLayout(1, 2));
268:                dateInfos.add(datePanel);
269:                dateInfos.add(inf1);
270:
271:                /* JPanel endPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
272:                 endPanel.add(valider);
273:                 endPanel.add(annuler);*/
274:                JPanel endPanel = new JPanel();
275:                endPanel.setLayout(new BoxLayout(endPanel, BoxLayout.X_AXIS));
276:                endPanel.add(Box.createHorizontalStrut(230));
277:                endPanel.add(valider);
278:                endPanel.add(annuler);
279:                endPanel.add(Box.createHorizontalStrut(100));
280:                endPanel.add(champ);
281:
282:                JPanel page = new JPanel();
283:                page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
284:                page.add(infosSte);
285:                page.add(Box.createRigidArea(new Dimension(1, 10)));
286:                page.add(infosAuteur);
287:                page.add(Box.createRigidArea(new Dimension(1, 10)));
288:                page.add(infosTitre);
289:                page.add(Box.createRigidArea(new Dimension(1, 10)));
290:                page.add(dateInfos);
291:                page.add(Box.createRigidArea(new Dimension(1, 10)));
292:                page.add(endPanel);
293:
294:                JPanel vide, vide1, vide2, vide3;
295:                vide = new JPanel();
296:                vide1 = new JPanel();
297:                vide2 = new JPanel();
298:                vide3 = new JPanel();
299:
300:                if (g.getSave() != null) {
301:                    restore(g.getSave());
302:                }
303:
304:                Container contentPaneFrame = this .getContentPane();
305:                contentPaneFrame.add(page, BorderLayout.CENTER);
306:                contentPaneFrame.add(vide, BorderLayout.NORTH);
307:                contentPaneFrame.add(vide1, BorderLayout.EAST);
308:                contentPaneFrame.add(vide2, BorderLayout.SOUTH);
309:                contentPaneFrame.add(vide3, BorderLayout.WEST);
310:
311:                this .setTitle(Language.getInstance().getText("Page_de_garde"));
312:                //this.setLocation(300,100);
313:                centerScreen();
314:            }
315:
316:            void centerScreen() {
317:                Dimension dim = getToolkit().getScreenSize();
318:                this .pack();
319:                Rectangle abounds = getBounds();
320:                setLocation((dim.width - abounds.width) / 2,
321:                        (dim.height - abounds.height) / 2);
322:                this .setVisible(true);
323:                requestFocus();
324:            }
325:
326:            /***************************************************************************************************** 
327:             * Action Listener
328:             ****************************************************************************************************/
329:
330:            public void actionPerformed(ActionEvent evt) {
331:                if (evt.getSource().equals(logoButton)) {
332:                    try {
333:                        logoButtonPerformed();
334:                    } catch (Exception ex) {
335:                        Tools.ihmExceptionView(ex);
336:                    }
337:                } else if (evt.getSource().equals(annuler)) {
338:                    try {
339:                        annulerPerformed();
340:                    } catch (Exception ex) {
341:                        Tools.ihmExceptionView(ex);
342:                    }
343:                } else if (evt.getSource().equals(valider)) {
344:                    try {
345:                        validerPerformed();
346:                    } catch (Exception ex) {
347:                        Tools.ihmExceptionView(ex);
348:                    }
349:                }
350:            }
351:
352:            void logoButtonPerformed() throws Exception {
353:                JFileChooser fileChooser = new JFileChooser();
354:                String[] tab = { ".jpeg", ".jpg", ".png", ".gif" };
355:                fileChooser
356:                        .addChoosableFileFilter(new ScriptFileFilter(
357:                                Language
358:                                        .getInstance()
359:                                        .getText(
360:                                                "Fichiers_[*.jpeg;_*.jpg;_*.png;_*.gif]"),
361:                                tab));
362:                int returnVal = fileChooser.showDialog(GardeDialog.this ,
363:                        Language.getInstance().getText("Sélectionner"));
364:                if (returnVal == JFileChooser.APPROVE_OPTION) {
365:                    try {
366:                        logoFile = fileChooser.getSelectedFile()
367:                                .getAbsolutePath();
368:                        urlLogo = fileChooser.getSelectedFile().toURL();
369:                        logoTextField.setText(logoFile);
370:                    } catch (Exception ex) {
371:                        Tools.ihmExceptionView(ex);
372:                    }
373:                }
374:            }
375:
376:            void annulerPerformed() throws Exception {
377:                GardeDialog.this .dispose();
378:            }
379:
380:            void validerPerformed() throws Exception {
381:                GardePage save = new GardePage(logoTextField.getText(),
382:                        entrepriseArea.getText(), auteurTextField.getText(),
383:                        emailTextField.getText(), titreTextField.getText(),
384:                        versionTextField.getText(), date.getDate(), infosArea
385:                                .getText());
386:                GardeDialog.this .g.setSave(save);
387:                if (titreTextField.getText().equals("")) {
388:                    JOptionPane
389:                            .showMessageDialog(
390:                                    GardeDialog.this ,
391:                                    Language
392:                                            .getInstance()
393:                                            .getText(
394:                                                    "Vous_devez_entrez_un_titre_pour_le_document"),
395:                                    Language.getInstance().getText("Erreur_!"),
396:                                    JOptionPane.ERROR_MESSAGE);
397:                } else {
398:                    //vérif que le fichier donné pour le logo existe
399:                    if (!logoTextField.getText().equals("")) {
400:                        File fic = new File(logoTextField.getText());
401:                        boolean estFichier = fic.exists();
402:                        if (!estFichier) {
403:                            JOptionPane
404:                                    .showMessageDialog(
405:                                            GardeDialog.this ,
406:                                            Language
407:                                                    .getInstance()
408:                                                    .getText(
409:                                                            "Vous_devez_entrez_un_nom_de_fichier_existant"),
410:                                            Language.getInstance().getText(
411:                                                    "Erreur_!"),
412:                                            JOptionPane.ERROR_MESSAGE);
413:                        } else {
414:                            createPage(GardeDialog.this .g);
415:                        }
416:                    } else {
417:                        createPage(GardeDialog.this .g);
418:                    }
419:                }
420:            }
421:
422:            /**
423:             * Méthode quirestaure les éléments sauvegardés
424:             * @param save objet qui sauvegarde les différentes valeurs des champs du formulaire
425:             */
426:            public void restore(GardePage save) throws Exception {
427:                logoTextField.setText(save.getLogo());
428:                entrepriseArea.setText(save.getEntreprise());
429:                auteurTextField.setText(save.getAuteur());
430:                emailTextField.setText(save.getEmail());
431:                titreTextField.setText(save.getTitre());
432:                versionTextField.setText(save.getVersion());
433:                date.setDate(save.getDate());
434:                infosArea.setText(save.getInfos());
435:            }
436:
437:            /**
438:             * Méthode qui créé l'élément à insérer dans le document Html
439:             * afin d'obtenir une page de garde
440:             */
441:            public void createPage(GenDocDialog g) throws Exception {
442:                String urlLogoForTitlePage = null;
443:                String company = null;
444:                String version = null;
445:                String author = null;
446:                String email = null;
447:                if (!logoTextField.getText().equals(""))
448:                    urlLogoForTitlePage = logoTextField.getText();
449:                if (!entrepriseArea.getText().equals(""))
450:                    company = entrepriseArea.getText();
451:                if (!versionTextField.getText().equals(""))
452:                    version = versionTextField.getText();
453:                if (!auteurTextField.getText().equals(""))
454:                    author = auteurTextField.getText();
455:                if (!emailTextField.getText().equals(""))
456:                    email = emailTextField.getText();
457:                g.createTitlePage(urlLogoForTitlePage, company, titreTextField
458:                        .getText(), version, infosArea.getText(), date
459:                        .getDate(), author, email);
460:                GardeDialog.this .dispose();
461:            }
462:
463:            /**
464:             * Méthode qui affiche les messages d'erreur
465:             * @return
466:             */
467:            public void showErrorMessage() {
468:                JOptionPane.showMessageDialog(GardeDialog.this , errorMessage,
469:                        Language.getInstance().getText("Erreur_!"),
470:                        JOptionPane.ERROR_MESSAGE);
471:                GardeDialog.this .dispose();
472:            }
473:        }//Fin de la classe GardeDialog
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.