Source Code Cross Referenced for ParameterJTableScrollPane.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » models » 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.models 
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 Mikael MARCHE, Fayçal SOUGRATI, Vincent PAUTRET
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package org.objectweb.salome_tmf.ihm.models;
025:
026:        import java.awt.Frame;
027:        import java.awt.event.KeyEvent;
028:        import java.awt.event.KeyListener;
029:        import java.util.ArrayList;
030:
031:        import javax.swing.JOptionPane;
032:        import javax.swing.JScrollPane;
033:        import javax.swing.JTable;
034:        import javax.swing.ListSelectionModel;
035:        import javax.swing.event.ListSelectionEvent;
036:        import javax.swing.event.ListSelectionListener;
037:        import javax.swing.event.TableModelEvent;
038:        import javax.swing.event.TableModelListener;
039:
040:        import org.objectweb.salome_tmf.ihm.languages.Language;
041:
042:        /**
043:         * @author teaml039
044:         * @version : 0.1
045:         */
046:        public class ParameterJTableScrollPane extends JScrollPane {
047:
048:            /**
049:             * Le mod?le de liste d'ex?cutions
050:             */
051:            ParameterTableModel parametersTableModel;
052:
053:            JTable parametersTable;
054:
055:            ListSelectionModel rowSelectionModel;
056:
057:            ListSelectionModel colSelectionModel;
058:
059:            boolean addNewLine = false;
060:
061:            boolean addNewParam = false;
062:
063:            boolean wrongName = false;
064:
065:            boolean otherKey = false;
066:
067:            /**
068:             *
069:             * @param table
070:             */
071:            public ParameterJTableScrollPane(JTable table) {
072:                super (table);
073:                parametersTableModel = new ParameterTableModel();
074:                parametersTable = table;
075:                parametersTableModel.addColumnNameAndColumn(Language
076:                        .getInstance().getText("Nom"));
077:                parametersTableModel.addColumnNameAndColumn(Language
078:                        .getInstance().getText("Valeur"));
079:                parametersTableModel.addColumnNameAndColumn(Language
080:                        .getInstance().getText("Description"));
081:
082:                parametersTable.setModel(parametersTableModel);
083:                parametersTable
084:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
085:
086:                parametersTable.setCellSelectionEnabled(true);
087:                parametersTable.setColumnSelectionAllowed(true);
088:                parametersTable.setRowSelectionAllowed(true);
089:
090:                rowSelectionModel = parametersTable.getSelectionModel();
091:                rowSelectionModel
092:                        .addListSelectionListener(new ListSelectionListener() {
093:                            public void valueChanged(ListSelectionEvent e) {
094:                                int rowIndex = e.getLastIndex();
095:
096:                                if (addNewParam) {
097:                                    rowSelectionModel.setSelectionInterval(
098:                                            rowIndex, rowIndex);
099:                                    addNewParam = false;
100:                                }
101:                                if (wrongName) {
102:                                    rowSelectionModel.setSelectionInterval(
103:                                            rowIndex, rowIndex);
104:                                    colSelectionModel
105:                                            .setSelectionInterval(0, 0);
106:                                    wrongName = false;
107:                                }
108:
109:                            }
110:                        });
111:
112:                colSelectionModel = parametersTable.getColumnModel()
113:                        .getSelectionModel();
114:                colSelectionModel
115:                        .addListSelectionListener(new ListSelectionListener() {
116:                            public void valueChanged(ListSelectionEvent e) {
117:                                if (addNewLine) {
118:                                    colSelectionModel
119:                                            .setSelectionInterval(0, 0);
120:                                    addNewLine = false;
121:                                }
122:                            }
123:                        });
124:                parametersTable.addKeyListener(new KeyListener() {
125:                    public void keyTyped(KeyEvent e) {
126:
127:                    }
128:
129:                    public void keyPressed(KeyEvent e) {
130:
131:                        if (e.getKeyCode() == KeyEvent.VK_ENTER
132:                                || e.getKeyCode() == KeyEvent.VK_TAB) {
133:                            if (parametersTable.getSelectedColumn() == 0
134:                                    && parametersTableModel
135:                                            .getValueAt(
136:                                                    parametersTable
137:                                                            .getSelectedRow(),
138:                                                    parametersTable
139:                                                            .getSelectedColumn()) == null
140:                                    && !otherKey) {
141:                                wrongName = true;
142:                                otherKey = false;
143:                            }
144:
145:                            if (parametersTable.getSelectedColumn() == 1
146:                                    && parametersTableModel
147:                                            .getValueAt(
148:                                                    parametersTable
149:                                                            .getSelectedRow(),
150:                                                    parametersTable
151:                                                            .getSelectedColumn()) == null
152:                                    && !otherKey
153:                                    && parametersTableModel
154:                                            .getValueAt(parametersTable
155:                                                    .getSelectedRow(), 0) != null
156:                                    && !parametersTableModel
157:                                            .getValueAt(
158:                                                    parametersTable
159:                                                            .getSelectedRow(),
160:                                                    0).equals("")) {
161:                                parametersTableModel.setValueAt("",
162:                                        parametersTable.getSelectedRow(),
163:                                        parametersTable.getSelectedColumn());
164:                                otherKey = false;
165:                            }
166:                            if (parametersTable.getSelectedColumn() == 2
167:                                    && parametersTableModel
168:                                            .getValueAt(
169:                                                    parametersTable
170:                                                            .getSelectedRow(),
171:                                                    parametersTable
172:                                                            .getSelectedColumn()) == null
173:                                    && !otherKey
174:                                    && parametersTableModel
175:                                            .getValueAt(parametersTable
176:                                                    .getSelectedRow(), 0) != null
177:                                    && !parametersTableModel
178:                                            .getValueAt(
179:                                                    parametersTable
180:                                                            .getSelectedRow(),
181:                                                    0).equals("")) {
182:                                parametersTableModel.setValueAt("",
183:                                        parametersTable.getSelectedRow(),
184:                                        parametersTable.getSelectedColumn());
185:                                otherKey = false;
186:                            }
187:                        } else {
188:                            otherKey = true;
189:                        }
190:                    }
191:
192:                    public void keyReleased(KeyEvent e) {
193:                    }
194:
195:                });
196:
197:                parametersTableModel
198:                        .addTableModelListener(new TableModelListener() {
199:                            public void tableChanged(TableModelEvent e) {
200:
201:                                int row = e.getFirstRow();
202:                                int column = e.getColumn();
203:                                if (row != -1 && column != -1) {
204:
205:                                    Object data = parametersTableModel
206:                                            .getValueAt(row, column);
207:                                    if (column == 0
208:                                            && data instanceof  String
209:                                            && containsParamName((String) data,
210:                                                    row)) {
211:                                        JOptionPane
212:                                                .showMessageDialog(
213:                                                        new Frame(),
214:                                                        Language
215:                                                                .getInstance()
216:                                                                .getText(
217:                                                                        "Ce_nom_de_paramètre_existe_déjà_!"),
218:                                                        Language
219:                                                                .getInstance()
220:                                                                .getText(
221:                                                                        "Erreur_!"),
222:                                                        JOptionPane.ERROR_MESSAGE);
223:                                        parametersTableModel.setValueAt(null,
224:                                                row, column);
225:                                        wrongName = true;
226:                                    } else if (parametersTableModel.getValueAt(
227:                                            row, 0) != null
228:                                            && !parametersTableModel
229:                                                    .getValueAt(row, 0).equals(
230:                                                            "")) {
231:                                        addNewParam = true;
232:                                        otherKey = false;
233:
234:                                    }
235:
236:                                    if (column == 2
237:                                            && parametersTableModel.getValueAt(
238:                                                    row, 0) != null
239:                                            && !parametersTableModel
240:                                                    .getValueAt(row, 0).equals(
241:                                                            "")
242:                                            && row == parametersTableModel
243:                                                    .getRowCount() - 1) {
244:                                        newEntry();
245:                                        addNewLine = true;
246:                                    }
247:                                }
248:                            }
249:                        });
250:            }
251:
252:            /**
253:             *
254:             * @param paramName
255:             * @param selectedRow
256:             * @return
257:             */
258:            private boolean containsParamName(String paramName, int selectedRow) {
259:                for (int i = 0; i < parametersTableModel.getRowCount(); i++) {
260:                    if (i != selectedRow
261:                            && parametersTableModel.getValueAt(i, 0) != null
262:                            && parametersTableModel.getValueAt(i, 0).equals(
263:                                    paramName)) {
264:                        return true;
265:                    }
266:                }
267:                return false;
268:            } // Fin de la m?thode containsParamName/2
269:
270:            /**
271:             *
272:             *
273:             */
274:            public void newEntry() {
275:                ArrayList dataList = new ArrayList();
276:                dataList.add(null);
277:                dataList.add(null);
278:                dataList.add(null);
279:                parametersTableModel.addRow(dataList);
280:            } // Fin de la m?thode newEntry/0
281:
282:        } // Fin de la classe ParameterJTable
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.