Source Code Cross Referenced for AskNewDataSet.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » main » 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.main 
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.main;
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.Rectangle;
032:        import java.awt.event.ActionEvent;
033:        import java.awt.event.ActionListener;
034:        import java.awt.event.WindowEvent;
035:        import java.awt.event.WindowListener;
036:        import java.util.Iterator;
037:        import java.util.Set;
038:
039:        import javax.swing.BorderFactory;
040:        import javax.swing.Box;
041:        import javax.swing.BoxLayout;
042:        import javax.swing.JButton;
043:        import javax.swing.JDialog;
044:        import javax.swing.JLabel;
045:        import javax.swing.JOptionPane;
046:        import javax.swing.JPanel;
047:        import javax.swing.JScrollPane;
048:        import javax.swing.JTable;
049:        import javax.swing.JTextArea;
050:        import javax.swing.JTextField;
051:        import javax.swing.table.TableColumn;
052:
053:        import org.objectweb.salome_tmf.api.Api;
054:        import org.objectweb.salome_tmf.data.DataConstants;
055:        import org.objectweb.salome_tmf.data.DataSet;
056:        import org.objectweb.salome_tmf.data.Parameter;
057:        import org.objectweb.salome_tmf.data.Test;
058:        import org.objectweb.salome_tmf.ihm.languages.Language;
059:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
060:        import org.objectweb.salome_tmf.ihm.models.DataSetCellEditor;
061:        import org.objectweb.salome_tmf.ihm.models.ParameterTableModel;
062:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
063:
064:        //import org.objectweb.salome_tmf.ihm.datawrapper.TestData;
065:
066:        public class AskNewDataSet extends JDialog implements  ActionListener,
067:                WindowListener {
068:
069:            /**
070:             * La zone texte pour saisir le nom du jeu de données
071:             */
072:            JTextField nameField;
073:
074:            /**
075:             * La zone texte pour saisir la description
076:             */
077:            JTextArea descriptionArea;
078:
079:            /**
080:             * Le nouvel jeu de données
081:             */
082:            DataSet dataSet;
083:
084:            ParameterTableModel parametersTableModel;
085:            TableSorter sorter;
086:
087:            /**
088:             * Table des paramètres
089:             */
090:            JTable parametersTable;
091:
092:            DataSetCellEditor dataCellEditor;
093:
094:            int row = 0;
095:
096:            /**
097:             * Button
098:             */
099:            JButton okButton;
100:            JButton cancelButton;
101:
102:            //JButton updateButton;
103:            /**************************************************************************/
104:            /**							CONSTRUCTEUR								***/
105:            /**************************************************************************/
106:
107:            public AskNewDataSet(DataSet oldDataSet) {
108:                super (SalomeTMFContext.getInstance().ptrFrame, true);
109:                nameField = new JTextField(10);
110:                descriptionArea = new JTextArea(15, 40);
111:                parametersTableModel = new ParameterTableModel();
112:                parametersTable = new JTable();
113:                JLabel testNameLabel = new JLabel(Language.getInstance()
114:                        .getText("Nom_du_jeu_de_données_:_"));
115:
116:                JPanel giveName = new JPanel();
117:                giveName.setLayout(new BoxLayout(giveName, BoxLayout.X_AXIS));
118:                giveName.setBorder(BorderFactory.createEmptyBorder(0, 10, 10,
119:                        10));
120:                giveName.add(Box.createHorizontalGlue());
121:                giveName.add(testNameLabel);
122:                giveName.add(Box.createRigidArea(new Dimension(10, 0)));
123:                giveName.add(nameField);
124:
125:                descriptionArea.setPreferredSize(new Dimension(100, 100));
126:
127:                JScrollPane descriptionScrollPane = new JScrollPane(
128:                        descriptionArea);
129:                descriptionScrollPane.setBorder(BorderFactory
130:                        .createTitledBorder(BorderFactory
131:                                .createLineBorder(Color.BLACK), Language
132:                                .getInstance().getText("Description")));
133:                descriptionScrollPane.setPreferredSize(new Dimension(100, 150));
134:
135:                parametersTableModel.addColumnNameAndColumn(Language
136:                        .getInstance().getText("Nom"));
137:                parametersTableModel.addColumnNameAndColumn(Language
138:                        .getInstance().getText("Valeur"));
139:                parametersTableModel.addColumnNameAndColumn(Language
140:                        .getInstance().getText("Description"));
141:
142:                sorter = new TableSorter(parametersTableModel);
143:                parametersTable.setModel(sorter);
144:                sorter.setTableHeader(parametersTable.getTableHeader());
145:
146:                TableColumn col = parametersTable.getColumnModel().getColumn(1);
147:                dataCellEditor = new DataSetCellEditor();
148:                col.setCellEditor(dataCellEditor);
149:
150:                JScrollPane parametersScrollPane = new JScrollPane(
151:                        parametersTable);
152:                parametersScrollPane.setPreferredSize(new Dimension(450, 150));
153:
154:                JPanel textPanel = new JPanel();
155:                textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
156:                textPanel.add(Box.createRigidArea(new Dimension(0, 10)));
157:                textPanel.add(giveName);
158:                textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
159:                textPanel.add(descriptionScrollPane);
160:                textPanel.add(Box.createRigidArea(new Dimension(1, 30)));
161:                textPanel.add(parametersScrollPane);
162:
163:                okButton = new JButton(Language.getInstance()
164:                        .getText("Valider"));
165:                okButton.setToolTipText(Language.getInstance().getText(
166:                        "Valider"));
167:                okButton.addActionListener(this );
168:
169:                cancelButton = new JButton(Language.getInstance().getText(
170:                        "Annuler"));
171:                cancelButton.setToolTipText(Language.getInstance().getText(
172:                        "Annuler"));
173:                cancelButton.addActionListener(this );
174:
175:                /*if (oldDataSet != null){
176:                	updateButton = new JButton("Update");
177:                	updateButton.addActionListener(this);
178:                }*/
179:                JPanel buttonPanel = new JPanel(new FlowLayout());
180:
181:                buttonPanel.add(cancelButton);
182:                /*if (oldDataSet != null){
183:                	 buttonPanel.add(updateButton);
184:                }*/
185:                buttonPanel.add(okButton);
186:                textPanel.add(buttonPanel);
187:
188:                //Initialisation des données de la fenêtre
189:                initData(oldDataSet);
190:
191:                Container contentPaneFrame = this .getContentPane();
192:                contentPaneFrame.add(textPanel, BorderLayout.CENTER);
193:
194:                parametersScrollPane.setPreferredSize(new Dimension(450, 150));
195:                this .addWindowListener(this );
196:
197:                //this.setLocation(350,200);
198:                this .setTitle(Language.getInstance().getText(
199:                        "Ajouter_un_jeu_de_données"));
200:                /*this.setLocationRelativeTo(this.getParent()); 
201:                this.pack();
202:                this.setVisible(true);*/
203:                centerScreen();
204:
205:            } // Fin du constructeur AskNewDataSet/1
206:
207:            void centerScreen() {
208:                Dimension dim = getToolkit().getScreenSize();
209:                this .pack();
210:                Rectangle abounds = getBounds();
211:                setLocation((dim.width - abounds.width) / 2,
212:                        (dim.height - abounds.height) / 2);
213:                this .setVisible(true);
214:                requestFocus();
215:            }
216:
217:            public AskNewDataSet() {
218:                this (null);
219:            } // Fin du constructeur AskNewDataSet/0
220:
221:            /**
222:             *
223:             * @return
224:             */
225:            public DataSet getDataSet() {
226:                return dataSet;
227:            } // Fin de la méthode getDataSet/0
228:
229:            /**
230:             *
231:             * @param oldDataSet
232:             */
233:            private void initData(DataSet oldDataSet) {
234:                if (oldDataSet != null) {
235:                    dataSet = oldDataSet;
236:                    nameField.setText(oldDataSet.getNameFromModel());
237:                    descriptionArea.setText(oldDataSet
238:                            .getDescriptionFromModel());
239:                    //int i = 0;
240:                    Set keysSet = oldDataSet.getParametersHashMapFromModel()
241:                            .keySet();
242:                    for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
243:                        String paramName = (String) iter.next();
244:                        Parameter param = DataModel.getCurrentProject()
245:                                .getParameterFromModel(paramName);
246:                        //parametersTableModel.addValueAt(param.getNameFromModel(), i, 0);
247:                        parametersTableModel.addValueAt(param
248:                                .getNameFromModel(), row, 0);
249:                        JTextField valueField = new JTextField();
250:                        valueField.setText(oldDataSet
251:                                .getParameterValueFromModel(param
252:                                        .getNameFromModel()));
253:                        //parametersTableModel.addValueAt(oldDataSet.getParameterValueFromModel(param.getNameFromModel()), i, 1);
254:                        //parametersTableModel.addValueAt(param.getDescriptionFromModel(), i, 2);
255:                        //i++;
256:                        parametersTableModel.addValueAt(oldDataSet
257:                                .getParameterValueFromModel(param
258:                                        .getNameFromModel()), row, 1);
259:                        parametersTableModel.addValueAt(param
260:                                .getDescriptionFromModel(), row, 2);
261:                        row++;
262:                    }
263:                } else {
264:                    dataSet = new DataSet("", "");
265:                    //int row  = 0;
266:                    for (int j = 0; j < DataModel.getCurrentCampaign()
267:                            .getTestListFromModel().size(); j++) {
268:                        Test test = (Test) DataModel.getCurrentCampaign()
269:                                .getTestListFromModel().get(j);
270:                        for (int i = 0; i < test.getParameterListFromModel()
271:                                .size(); i++) {
272:                            if (!dataSet
273:                                    .getParametersHashMapFromModel()
274:                                    .containsKey(
275:                                            ((Parameter) test
276:                                                    .getParameterListFromModel()
277:                                                    .get(i)).getNameFromModel())) {
278:                                parametersTableModel.addValueAt(
279:                                        ((Parameter) test
280:                                                .getParameterListFromModel()
281:                                                .get(i)).getNameFromModel(),
282:                                        row, 0);
283:
284:                                //parametersTableModel.addValueAt("", row, 1);
285:                                if (Api.isDYNAMIC_VALUE_DATASET()) {
286:                                    parametersTableModel.addValueAt(
287:                                            DataConstants.PARAM_VALUE_FROM_ENV,
288:                                            row, 1);
289:                                } else {
290:                                    parametersTableModel.addValueAt("", row, 1);
291:                                }
292:                                parametersTableModel.addValueAt(
293:                                        ((Parameter) test
294:                                                .getParameterListFromModel()
295:                                                .get(i))
296:                                                .getDescriptionFromModel(),
297:                                        row, 2);
298:                                row++;
299:                                //dataSet.addParameterValueInModel(((Parameter)test.getParameterListFromModel().get(i)).getNameFromModel(), "");
300:                                if (Api.isDYNAMIC_VALUE_DATASET()) {
301:                                    dataSet
302:                                            .addParameterValueInModel(
303:                                                    ((Parameter) test
304:                                                            .getParameterListFromModel()
305:                                                            .get(i))
306:                                                            .getNameFromModel(),
307:                                                    DataConstants.PARAM_VALUE_FROM_ENV);
308:                                } else {
309:                                    dataSet
310:                                            .addParameterValueInModel(
311:                                                    ((Parameter) test
312:                                                            .getParameterListFromModel()
313:                                                            .get(i))
314:                                                            .getNameFromModel(),
315:                                                    "");
316:                                }
317:                            }
318:                        }
319:                    }
320:
321:                }
322:            } // Fin de la méthode initData/1
323:
324:            private void createAndQuit() {
325:                dataSet.updateInModel(nameField.getText().trim(),
326:                        descriptionArea.getText());
327:
328:                dataSet.getParametersHashMapFromModel().clear();
329:
330:                for (int i = 0; i < parametersTableModel.getRowCount(); i++) {
331:
332:                    if (sorter.getValueAt(i, 0) != null
333:                            && !sorter.getValueAt(i, 0).equals("")
334:                            && !nameField.getText().trim().equals(
335:                                    DataModel.EMPTY_NAME)) {
336:                        if (!parametersTable.isCellSelected(i, 1)) {
337:                            dataSet.addParameterValueInModel(DataModel
338:                                    .getCurrentProject().getParameterFromModel(
339:                                            (String) sorter.getValueAt(i, 0))
340:                                    .getNameFromModel(), (String) sorter
341:                                    .getValueAt(i, 1));
342:                        } else {
343:                            dataSet.addParameterValueInModel(DataModel
344:                                    .getCurrentProject().getParameterFromModel(
345:                                            (String) sorter.getValueAt(i, 0))
346:                                    .getNameFromModel(),
347:                                    (String) dataCellEditor
348:                                            .getCellEditorValue());
349:                        }
350:
351:                    }
352:                }
353:                AskNewDataSet.this .dispose();
354:            }
355:
356:            // Event //
357:            public void actionPerformed(ActionEvent evt) {
358:                if (evt.getSource().equals(okButton)) {
359:                    okPerformed();
360:                } else if (evt.getSource().equals(cancelButton)) {
361:                    cancelPerformed();
362:                } /*else if (evt.getSource().equals(updateButton)){
363:                   		updatePerformed();
364:                   	}*/
365:            }
366:
367:            void okPerformed() {
368:                if (!nameField.getText().trim().equals("")) {
369:                    if (DataModel.getCurrentCampaign().getDataSetFromModel(
370:                            nameField.getText().trim()) == null
371:                            && !nameField.getText().trim().equals(
372:                                    DataModel.EMPTY_NAME)
373:                            && !DataSet.isInBase(
374:                                    DataModel.getCurrentCampaign(), nameField
375:                                            .getText().trim())) {
376:                        createAndQuit();
377:                    } else if (DataModel.getCurrentCampaign()
378:                            .getDataSetFromModel(nameField.getText().trim()) != null
379:                            && DataModel.getCurrentCampaign()
380:                                    .getDataSetFromModel(
381:                                            nameField.getText().trim()).equals(
382:                                            dataSet)) {
383:                        createAndQuit();
384:                    } else {
385:                        JOptionPane
386:                                .showMessageDialog(
387:                                        AskNewDataSet.this ,
388:                                        Language
389:                                                .getInstance()
390:                                                .getText(
391:                                                        "Ce_nom_d'environnement_existe_déjà_!"),
392:                                        Language.getInstance().getText(
393:                                                "Erreur_!"),
394:                                        JOptionPane.ERROR_MESSAGE);
395:                    }
396:
397:                } else {
398:                    JOptionPane
399:                            .showMessageDialog(
400:                                    AskNewDataSet.this ,
401:                                    Language
402:                                            .getInstance()
403:                                            .getText(
404:                                                    "Il_faut_obligatoirement_donner_un_nom_au_jeu_de_données_!"),
405:                                    Language.getInstance().getText(
406:                                            "Attention_!"),
407:                                    JOptionPane.WARNING_MESSAGE);
408:                }
409:            }
410:
411:            void cancelPerformed() {
412:                dataSet = null;
413:                AskNewDataSet.this .dispose();
414:            }
415:
416:            /*void updatePerformed(){
417:            	//int row  = 0;
418:                for (int j = 0; j < DataModel.getCurrentCampaign().getTestListFromModel().size(); j++) {
419:                    Test test = (Test)DataModel.getCurrentCampaign().getTestListFromModel().get(j);
420:                    for (int i = 0; i < test.getParameterListFromModel().size(); i++) {
421:                        if (!dataSet.getParametersHashMapFromModel().containsKey(((Parameter)test.getParameterListFromModel().get(i)).getNameFromModel())) {
422:                            parametersTableModel.addValueAt(((Parameter)test.getParameterListFromModel().get(i)).getNameFromModel(), row, 0);
423:                            
424:                            parametersTableModel.addValueAt("", row, 1);
425:                            
426:                            parametersTableModel.addValueAt(((Parameter)test.getParameterListFromModel().get(i)).getDescriptionFromModel(), row, 2);
427:                            row++;
428:                            //dataSet.addParameterValueInModel(((Parameter)test.getParameterListFromModel().get(i)).getNameFromModel(), "");
429:                        }
430:                    }
431:                }
432:            }*/
433:
434:            // Windows Listener
435:            public void windowClosing(WindowEvent e) {
436:                dataSet = null;
437:            }
438:
439:            public void windowDeiconified(WindowEvent e) {
440:            }
441:
442:            public void windowOpened(WindowEvent e) {
443:            }
444:
445:            public void windowActivated(WindowEvent e) {
446:            }
447:
448:            public void windowDeactivated(WindowEvent e) {
449:            }
450:
451:            public void windowClosed(WindowEvent e) {
452:            }
453:
454:            public void windowIconified(WindowEvent e) {
455:            }
456:        } // 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.