Source Code Cross Referenced for AskNameAndDescription.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » 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 » org.objectweb.salome_tmf.ihm 
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 Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package org.objectweb.salome_tmf.ihm;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Color;
028:        import java.awt.Container;
029:        import java.awt.Dimension;
030:        import java.awt.Frame;
031:        import java.awt.event.ActionEvent;
032:        import java.awt.event.ActionListener;
033:        import java.awt.event.WindowEvent;
034:        import java.awt.event.WindowListener;
035:
036:        import javax.swing.BorderFactory;
037:        import javax.swing.Box;
038:        import javax.swing.BoxLayout;
039:        import javax.swing.JButton;
040:        import javax.swing.JDialog;
041:        import javax.swing.JLabel;
042:        import javax.swing.JOptionPane;
043:        import javax.swing.JPanel;
044:        import javax.swing.JScrollPane;
045:        import javax.swing.JTextArea;
046:        import javax.swing.JTextField;
047:
048:        import org.objectweb.salome_tmf.data.AdminProjectData;
049:        import org.objectweb.salome_tmf.data.DataConstants;
050:        import org.objectweb.salome_tmf.data.Element;
051:        import org.objectweb.salome_tmf.data.Family;
052:        import org.objectweb.salome_tmf.data.Group;
053:        import org.objectweb.salome_tmf.data.Parameter;
054:        import org.objectweb.salome_tmf.ihm.languages.Language;
055:
056:        /**
057:         * Classe qui permet d'afficher une fenêtre demandant d'entrer les
058:         * informations pour un nouveau paramètre, un nouveau groupe ou une nouvelle
059:         * famille.
060:         * @author teaml039
061:         * @version 0.1
062:         */
063:        public class AskNameAndDescription extends JDialog implements 
064:                DataConstants {
065:
066:            /**
067:             * le champ pour entrer le nom du paramètre
068:             */
069:            JTextField textFirst;
070:
071:            /**
072:             * le champ description
073:             */
074:            JTextArea descriptionArea;
075:
076:            /**
077:             * Un paramètre
078:             */
079:            Parameter parameter;
080:
081:            /**
082:             * Le type de donnée à récupérer
083:             */
084:            int givenType;
085:
086:            /**
087:             * Un groupe
088:             */
089:            Group group;
090:
091:            /**
092:             * Une famille
093:             */
094:            Family family;
095:
096:            /******************************************************************************/
097:            /** 							CONSTRUCTEUR								***/
098:            /******************************************************************************/
099:
100:            /**
101:             * Constructeur de la fenêtre permettant de demander deux informations.
102:             * @param type le type de donnée à récupérer
103:             * @param title le titre de la fenêtre
104:             * @param question le label proposant le texte à entrer
105:             * @param name le nom à placer dans le texteField
106:             * @param descr texte à placer dans la description
107:             */
108:            public AskNameAndDescription(int type, String title,
109:                    String question, Element elem, Frame owner) {
110:                super (owner, true);
111:                textFirst = new JTextField(15);
112:                descriptionArea = new JTextArea(10, 20);
113:                JPanel page = new JPanel();
114:
115:                JLabel promptFirst = new JLabel(question);
116:
117:                JPanel onlyTextPanel = new JPanel();
118:                onlyTextPanel.setLayout(new BoxLayout(onlyTextPanel,
119:                        BoxLayout.X_AXIS));
120:                onlyTextPanel.add(Box.createRigidArea(new Dimension(0, 10)));
121:                onlyTextPanel.add(promptFirst);
122:                onlyTextPanel.add(textFirst);
123:
124:                JScrollPane descriptionScrollPane = new JScrollPane(
125:                        descriptionArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
126:                        JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
127:                descriptionScrollPane.setBorder(BorderFactory
128:                        .createTitledBorder(BorderFactory
129:                                .createLineBorder(Color.BLACK), Language
130:                                .getInstance().getText("Description")));
131:
132:                JPanel textPanel = new JPanel();
133:                textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
134:                textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
135:                textPanel.add(onlyTextPanel);
136:                textPanel.add(Box.createRigidArea(new Dimension(10, 10)));
137:                textPanel.add(descriptionScrollPane);
138:
139:                JButton okButton = new JButton(Language.getInstance().getText(
140:                        "Valider"));
141:                okButton.setToolTipText(Language.getInstance().getText(
142:                        "Valider"));
143:                okButton.addActionListener(new ActionListener() {
144:                    public void actionPerformed(ActionEvent e) {
145:                        if (!textFirst.getText().trim().equals("")) {
146:                            if (givenType == GROUP) {
147:                                if (AdminProjectData.getCurrentProject()
148:                                        .getGroup(textFirst.getText().trim()) == null) {
149:                                    group.setName(textFirst.getText().trim());
150:                                    group.setDescription(descriptionArea
151:                                            .getText());
152:                                    AskNameAndDescription.this .dispose();
153:                                } else if (AdminProjectData.getCurrentProject()
154:                                        .getGroup(textFirst.getText().trim())
155:                                        .equals(group)) {
156:                                    group.setName(textFirst.getText().trim());
157:                                    group.setDescription(descriptionArea
158:                                            .getText());
159:                                    AskNameAndDescription.this .dispose();
160:                                } else {
161:                                    JOptionPane
162:                                            .showMessageDialog(
163:                                                    AskNameAndDescription.this ,
164:                                                    Language
165:                                                            .getInstance()
166:                                                            .getText(
167:                                                                    "Ce_nom_de_groupe_existe_déjà_!"),
168:                                                    Language
169:                                                            .getInstance()
170:                                                            .getText("Erreur_!"),
171:                                                    JOptionPane.ERROR_MESSAGE);
172:                                }
173:                            } else if (givenType == FAMILY) {
174:                                family.setName(textFirst.getText().trim());
175:                                family
176:                                        .setDescription(descriptionArea
177:                                                .getText());
178:                                AskNameAndDescription.this .dispose();
179:                            } else {
180:                                parameter.setName(textFirst.getText().trim());
181:                                parameter.setDescription(descriptionArea
182:                                        .getText());
183:                                AskNameAndDescription.this .dispose();
184:                            }
185:                        } else {
186:                            JOptionPane
187:                                    .showMessageDialog(
188:                                            AskNameAndDescription.this ,
189:                                            Language
190:                                                    .getInstance()
191:                                                    .getText(
192:                                                            "Il_faut_obligatoirement_donner_un_nom_!"),
193:                                            Language.getInstance().getText(
194:                                                    "Attention_!"),
195:                                            JOptionPane.WARNING_MESSAGE);
196:                        }
197:                    }
198:                });
199:
200:                JButton cancelButton = new JButton(Language.getInstance()
201:                        .getText("Annuler"));
202:                cancelButton.setToolTipText(Language.getInstance().getText(
203:                        "Annuler"));
204:                cancelButton.addActionListener(new ActionListener() {
205:                    public void actionPerformed(ActionEvent e) {
206:                        parameter = null;
207:                        family = null;
208:                        group = null;
209:                        AskNameAndDescription.this .dispose();
210:                    }
211:                });
212:
213:                JPanel buttonPanel = new JPanel();
214:                buttonPanel.setLayout(new BorderLayout());
215:                buttonPanel.add(okButton, BorderLayout.NORTH);
216:                buttonPanel.add(cancelButton, BorderLayout.SOUTH);
217:
218:                page.add(textPanel, BorderLayout.WEST);
219:                page.add(Box.createRigidArea(new Dimension(40, 10)),
220:                        BorderLayout.CENTER);
221:                page.add(buttonPanel, BorderLayout.EAST);
222:
223:                initData(elem, type);
224:
225:                this .addWindowListener(new WindowListener() {
226:                    public void windowClosing(WindowEvent e) {
227:                        parameter = null;
228:                        family = null;
229:                        group = null;
230:                    }
231:
232:                    public void windowDeiconified(WindowEvent e) {
233:                    }
234:
235:                    public void windowOpened(WindowEvent e) {
236:                    }
237:
238:                    public void windowActivated(WindowEvent e) {
239:                    }
240:
241:                    public void windowDeactivated(WindowEvent e) {
242:                    }
243:
244:                    public void windowClosed(WindowEvent e) {
245:                    }
246:
247:                    public void windowIconified(WindowEvent e) {
248:                    }
249:                });
250:
251:                Container contentPaneFrame = this .getContentPane();
252:                contentPaneFrame.add(page, BorderLayout.CENTER);
253:                this .setTitle(title);
254:                this .setLocation(400, 300);
255:                this .pack();
256:                this .setVisible(true);
257:            } // Fin du constructeur AskNewParameter/5
258:
259:            /**
260:             * Le nom et la description sont vides.
261:             * @param type le type de donnée à récupérer
262:             * @param title le titre de la fenêtre
263:             * @param question le label proposant le texte à entrer
264:             */
265:            public AskNameAndDescription(int type, String title,
266:                    String question, Frame owner) {
267:                this (type, title, question, null, owner);
268:            } // Fin du constructeur AskNewParameter/3
269:
270:            /******************************************************************************/
271:            /** 							METHODES PUBLIQUES							***/
272:            /******************************************************************************/
273:
274:            /**
275:             * Retourne le paramètre créé
276:             * @return le paramètre créé
277:             */
278:            public Parameter getNewParameter() {
279:                return parameter;
280:            } // Fin de la méthode getNewParameter/0
281:
282:            /**
283:             * Retourne le groupe créé
284:             * @return le groupe créé
285:             */
286:            public Group getGroup() {
287:                return group;
288:            } // Fin de la méthode getGroup/0
289:
290:            /**
291:             * Retourne la famille créée
292:             * @return la famille créée
293:             */
294:            public Family getFamily() {
295:                return family;
296:            } // Fin de la méthode getFamily/0
297:
298:            private void initData(Element elem, int type) {
299:                givenType = type;
300:                if (elem != null) {
301:                    textFirst.setText(elem.getName());
302:                    descriptionArea.setText(elem.getDescription());
303:                    if (elem instanceof  Group) {
304:                        group = (Group) elem;
305:                    } else if (elem instanceof  Parameter) {
306:                        parameter = (Parameter) elem;
307:                    } else if (elem instanceof  Family) {
308:                        family = (Family) elem;
309:                    }
310:                    if (givenType == PARAMETER) {
311:                        textFirst.setEnabled(false);
312:                    }
313:                } else {
314:                    if (givenType == GROUP) {
315:                        group = new Group();
316:                    } else if (givenType == PARAMETER) {
317:                        parameter = new Parameter();
318:                    } else if (givenType == FAMILY) {
319:                        family = new Family();
320:                    }
321:                }
322:            }
323:        } // Fin de la classe AskNewParameter
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.