Source Code Cross Referenced for AskNewDataSet.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.FlowLayout;
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:        import java.util.Iterator;
036:        import java.util.Set;
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.JLabel;
044:        import javax.swing.JOptionPane;
045:        import javax.swing.JPanel;
046:        import javax.swing.JScrollPane;
047:        import javax.swing.JTable;
048:        import javax.swing.JTextArea;
049:        import javax.swing.JTextField;
050:        import javax.swing.table.TableColumn;
051:
052:        import org.objectweb.salome_tmf.data.ConnectionData;
053:        import org.objectweb.salome_tmf.data.DataSet;
054:        import org.objectweb.salome_tmf.data.Parameter;
055:        import org.objectweb.salome_tmf.data.ProjectData;
056:        import org.objectweb.salome_tmf.data.Test;
057:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
058:        import org.objectweb.salome_tmf.ihm.languages.Language;
059:        import org.objectweb.salome_tmf.ihm.models.DataSetCellEditor;
060:        import org.objectweb.salome_tmf.ihm.models.ParameterTableModel;
061:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
062:
063:        //import org.objectweb.salome_tmf.ihm.datawrapper.TestData;
064:
065:        /**
066:         * @author teaml039
067:         * @version : 0.1
068:         */
069:        public class AskNewDataSet extends JDialog {
070:
071:            /**
072:             * La zone texte pour saisir le nom du jeu de données
073:             */
074:            JTextField nameField;
075:
076:            /**
077:             * La zone texte pour saisir la description
078:             */
079:            JTextArea descriptionArea;
080:
081:            /**
082:             * Le nouvel jeu de données
083:             */
084:            DataSet dataSet;
085:
086:            ParameterTableModel parametersTableModel;
087:            TableSorter sorter;
088:
089:            /**
090:             * Table des paramètres
091:             */
092:            JTable parametersTable;
093:
094:            DataSetCellEditor dataCellEditor;
095:
096:            /**************************************************************************/
097:            /**							CONSTRUCTEUR								***/
098:            /**************************************************************************/
099:
100:            public AskNewDataSet(DataSet oldDataSet) {
101:                super (SalomeTMF.ptrFrame, true);
102:                nameField = new JTextField(10);
103:                descriptionArea = new JTextArea(15, 40);
104:                parametersTableModel = new ParameterTableModel();
105:                parametersTable = new JTable();
106:                JLabel testNameLabel = new JLabel(Language.getInstance()
107:                        .getText("Nom_du_jeu_de_données_:_"));
108:
109:                JPanel giveName = new JPanel();
110:                giveName.setLayout(new BoxLayout(giveName, BoxLayout.X_AXIS));
111:                giveName.setBorder(BorderFactory.createEmptyBorder(0, 10, 10,
112:                        10));
113:                giveName.add(Box.createHorizontalGlue());
114:                giveName.add(testNameLabel);
115:                giveName.add(Box.createRigidArea(new Dimension(10, 0)));
116:                giveName.add(nameField);
117:
118:                descriptionArea.setPreferredSize(new Dimension(100, 100));
119:
120:                JScrollPane descriptionScrollPane = new JScrollPane(
121:                        descriptionArea);
122:                descriptionScrollPane.setBorder(BorderFactory
123:                        .createTitledBorder(BorderFactory
124:                                .createLineBorder(Color.BLACK), Language
125:                                .getInstance().getText("Description")));
126:                descriptionScrollPane.setPreferredSize(new Dimension(100, 150));
127:
128:                parametersTableModel.addColumnNameAndColumn(Language
129:                        .getInstance().getText("Nom"));
130:                parametersTableModel.addColumnNameAndColumn(Language
131:                        .getInstance().getText("Valeur"));
132:                parametersTableModel.addColumnNameAndColumn(Language
133:                        .getInstance().getText("Description"));
134:
135:                sorter = new TableSorter(parametersTableModel);
136:                parametersTable.setModel(sorter);
137:                sorter.setTableHeader(parametersTable.getTableHeader());
138:
139:                TableColumn col = parametersTable.getColumnModel().getColumn(1);
140:                dataCellEditor = new DataSetCellEditor();
141:                col.setCellEditor(dataCellEditor);
142:
143:                JScrollPane parametersScrollPane = new JScrollPane(
144:                        parametersTable);
145:                parametersScrollPane.setPreferredSize(new Dimension(450, 150));
146:
147:                JPanel textPanel = new JPanel();
148:                textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
149:                textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
150:                textPanel.add(giveName);
151:                textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
152:                textPanel.add(descriptionScrollPane);
153:                textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
154:                textPanel.add(parametersScrollPane);
155:
156:                JButton okButton = new JButton(Language.getInstance().getText(
157:                        "Valider"));
158:                okButton.setToolTipText(Language.getInstance().getText(
159:                        "Valider"));
160:                okButton.addActionListener(new ActionListener() {
161:                    public void actionPerformed(ActionEvent e) {
162:                        if (!nameField.getText().trim().equals("")) {
163:                            if (DataModel.getCurrentCampaign().getDataSet(
164:                                    nameField.getText().trim()) == null
165:                                    && !nameField.getText().trim().equals(
166:                                            DataModel.EMPTY_NAME)
167:                                    && !ConnectionData.isInBaseDataSet(
168:                                            nameField.getText().trim(),
169:                                            DataModel.getCurrentCampaign()
170:                                                    .getName())) {
171:                                createAndQuit();
172:                            } else if (DataModel.getCurrentCampaign()
173:                                    .getDataSet(nameField.getText().trim()) != null
174:                                    && DataModel.getCurrentCampaign()
175:                                            .getDataSet(
176:                                                    nameField.getText().trim())
177:                                            .equals(dataSet)) {
178:                                createAndQuit();
179:                            } else {
180:                                JOptionPane
181:                                        .showMessageDialog(
182:                                                AskNewDataSet.this ,
183:                                                Language
184:                                                        .getInstance()
185:                                                        .getText(
186:                                                                "Ce_nom_d'environnement_existe_déjà_!"),
187:                                                Language.getInstance().getText(
188:                                                        "Erreur_!"),
189:                                                JOptionPane.ERROR_MESSAGE);
190:                            }
191:
192:                        } else {
193:                            JOptionPane
194:                                    .showMessageDialog(
195:                                            AskNewDataSet.this ,
196:                                            Language
197:                                                    .getInstance()
198:                                                    .getText(
199:                                                            "Il_faut_obligatoirement_donner_un_nom_au_jeu_de_données_!"),
200:                                            Language.getInstance().getText(
201:                                                    "Attention_!"),
202:                                            JOptionPane.WARNING_MESSAGE);
203:                        }
204:
205:                    }
206:                });
207:
208:                JButton cancelButton = new JButton(Language.getInstance()
209:                        .getText("Annuler"));
210:                cancelButton.setToolTipText(Language.getInstance().getText(
211:                        "Annuler"));
212:                cancelButton.addActionListener(new ActionListener() {
213:                    public void actionPerformed(ActionEvent e) {
214:                        dataSet = null;
215:                        AskNewDataSet.this .dispose();
216:                    }
217:                });
218:
219:                JPanel buttonPanel = new JPanel(new FlowLayout());
220:
221:                buttonPanel.add(okButton);
222:                buttonPanel.add(cancelButton);
223:
224:                textPanel.add(buttonPanel);
225:
226:                //Initialisation des données de la fenêtre
227:                initData(oldDataSet);
228:
229:                Container contentPaneFrame = this .getContentPane();
230:                contentPaneFrame.add(textPanel, BorderLayout.CENTER);
231:
232:                parametersScrollPane.setPreferredSize(new Dimension(450, 150));
233:
234:                this .addWindowListener(new WindowListener() {
235:                    public void windowClosing(WindowEvent e) {
236:                        dataSet = null;
237:                    }
238:
239:                    public void windowDeiconified(WindowEvent e) {
240:                    }
241:
242:                    public void windowOpened(WindowEvent e) {
243:                    }
244:
245:                    public void windowActivated(WindowEvent e) {
246:                    }
247:
248:                    public void windowDeactivated(WindowEvent e) {
249:                    }
250:
251:                    public void windowClosed(WindowEvent e) {
252:                    }
253:
254:                    public void windowIconified(WindowEvent e) {
255:                    }
256:                });
257:
258:                this .setLocation(350, 200);
259:                this .setTitle(Language.getInstance().getText(
260:                        "Ajouter_un_jeu_de_données"));
261:                this .pack();
262:                this .setVisible(true);
263:
264:            } // Fin du constructeur AskNewDataSet/1
265:
266:            public AskNewDataSet() {
267:                this (null);
268:            } // Fin du constructeur AskNewDataSet/0
269:
270:            /**
271:             *
272:             * @return
273:             */
274:            public DataSet getDataSet() {
275:                return dataSet;
276:            } // Fin de la méthode getDataSet/0
277:
278:            /**
279:             *
280:             * @param oldDataSet
281:             */
282:            private void initData(DataSet oldDataSet) {
283:                if (oldDataSet != null) {
284:                    dataSet = oldDataSet;
285:                    nameField.setText(oldDataSet.getName());
286:                    descriptionArea.setText(oldDataSet.getDescription());
287:                    int i = 0;
288:                    Set keysSet = oldDataSet.getParametersHashMap().keySet();
289:                    for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
290:                        String paramName = (String) iter.next();
291:                        Parameter param = ProjectData.getCurrentProject()
292:                                .getParameter(paramName);
293:                        parametersTableModel.addValueAt(param.getName(), i, 0);
294:                        JTextField valueField = new JTextField();
295:                        valueField
296:                                .setText(oldDataSet.getValue(param.getName()));
297:                        parametersTableModel.addValueAt(oldDataSet
298:                                .getValue(param.getName()), i, 1);
299:
300:                        parametersTableModel.addValueAt(param.getDescription(),
301:                                i, 2);
302:                        i++;
303:                    }
304:                } else {
305:                    dataSet = new DataSet();
306:                    int row = 0;
307:                    for (int j = 0; j < DataModel.getCurrentCampaign()
308:                            .getTestList().size(); j++) {
309:                        Test test = (Test) DataModel.getCurrentCampaign()
310:                                .getTestList().get(j);
311:                        for (int i = 0; i < test.getParameterList().size(); i++) {
312:                            if (!dataSet.getParametersHashMap()
313:                                    .containsKey(
314:                                            ((Parameter) test
315:                                                    .getParameterList().get(i))
316:                                                    .getName())) {
317:                                parametersTableModel.addValueAt(
318:                                        ((Parameter) test.getParameterList()
319:                                                .get(i)).getName(), row, 0);
320:
321:                                parametersTableModel.addValueAt("", row, 1);
322:
323:                                parametersTableModel.addValueAt(
324:                                        ((Parameter) test.getParameterList()
325:                                                .get(i)).getDescription(), row,
326:                                        2);
327:                                row++;
328:                                dataSet.addParameter(((Parameter) test
329:                                        .getParameterList().get(i)).getName(),
330:                                        "");
331:                            }
332:                        }
333:                    }
334:
335:                }
336:            } // Fin de la méthode initData/1
337:
338:            private void createAndQuit() {
339:                dataSet.setName(nameField.getText().trim());
340:                dataSet.setDescription(descriptionArea.getText());
341:
342:                dataSet.getParametersHashMap().clear();
343:
344:                for (int i = 0; i < parametersTableModel.getRowCount(); i++) {
345:
346:                    if (sorter.getValueAt(i, 0) != null
347:                            && !sorter.getValueAt(i, 0).equals("")
348:                            && !nameField.getText().trim().equals(
349:                                    DataModel.EMPTY_NAME)) {
350:                        if (!parametersTable.isCellSelected(i, 1)) {
351:                            dataSet.addParameter(ProjectData
352:                                    .getCurrentProject().getParameter(
353:                                            (String) sorter.getValueAt(i, 0))
354:                                    .getName(), (String) sorter
355:                                    .getValueAt(i, 1));
356:                        } else {
357:                            dataSet.addParameter(ProjectData
358:                                    .getCurrentProject().getParameter(
359:                                            (String) sorter.getValueAt(i, 0))
360:                                    .getName(), (String) dataCellEditor
361:                                    .getCellEditorValue());
362:                        }
363:
364:                    }
365:                }
366:                AskNewDataSet.this .dispose();
367:            }
368:        } // Fin de la classe AskNewDataSet
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.