Source Code Cross Referenced for DefectPanel.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » mantis » 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.mantis 
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:         * 			faycal.sougrati@francetelecom.com
023:         */
024:
025:        package salomeTMF_plug.mantis;
026:
027:        import java.awt.BorderLayout;
028:        import java.awt.Color;
029:        import java.awt.Component;
030:        import java.awt.Dialog;
031:        import java.awt.FlowLayout;
032:        import java.awt.FontMetrics;
033:        import java.awt.GridLayout;
034:        import java.awt.event.ActionEvent;
035:        import java.awt.event.ActionListener;
036:        import java.awt.event.ItemEvent;
037:        import java.awt.event.ItemListener;
038:        import java.awt.event.KeyEvent;
039:        import java.awt.event.KeyListener;
040:        import java.awt.event.MouseAdapter;
041:        import java.awt.event.MouseEvent;
042:        import java.util.ArrayList;
043:        import java.util.Enumeration;
044:        import java.util.Hashtable;
045:        import java.util.Vector;
046:
047:        import javax.swing.BorderFactory;
048:        import javax.swing.JButton;
049:        import javax.swing.JCheckBox;
050:        import javax.swing.JComboBox;
051:        import javax.swing.JLabel;
052:        import javax.swing.JOptionPane;
053:        import javax.swing.JPanel;
054:        import javax.swing.JScrollPane;
055:        import javax.swing.JTable;
056:        import javax.swing.JTextField;
057:        import javax.swing.ListSelectionModel;
058:        import javax.swing.table.DefaultTableCellRenderer;
059:
060:        import org.objectweb.salome_tmf.data.Environment;
061:        import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
062:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
063:        import org.objectweb.salome_tmf.ihm.models.MyTableModel;
064:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
065:
066:        import salomeTMF_plug.mantis.languages.Language;
067:        import salomeTMF_plug.mantis.sqlWrapper.DefectWrapper;
068:
069:        public class DefectPanel extends JPanel implements  ActionListener {
070:
071:            /** Fitre **/
072:            JPanel panelFiltre;
073:            JLabel labelRapporter; //Rapporteur
074:            JComboBox comboRapporter; //On Maxi
075:
076:            JLabel labelOwner; //Assigné à
077:            JComboBox comboOwner; //On Maxi
078:
079:            JLabel labelProduit; //Produit (environnement)
080:            JComboBox comboProduit; //On Maxi-Mini
081:
082:            JLabel labelSeverite; //Sévérité
083:            //Hashtable severityByID;
084:            JComboBox comboSeverite; //On Maxi-Mini
085:
086:            JLabel labelPriorite; //Priorité
087:            //Hashtable prioriteByID;
088:            JComboBox comboPriorite; //On Maxi-Mini
089:
090:            JLabel labelDiagnostic; //Diagnostic
091:            //Hashtable diagnosticByID;
092:            JComboBox comboDiagnostic; //On Maxi
093:
094:            JLabel labelState; //Etat
095:            //Hashtable stateByID;
096:            Vector choiceState;
097:            JComboBox comboState; //On Maxi
098:
099:            JLabel labelHideSate; // Cacher le statut:
100:            JComboBox comboHideSate;
101:
102:            JLabel labelResume;
103:            JTextField filtreResume;
104:            JCheckBox checkStartWith;
105:            JCheckBox checkContyent;
106:            //JButton applyFiltreButton;
107:
108:            //Date : TODO
109:
110:            /** Table **/
111:            JPanel defectsPanel;
112:            MyTableModel defectsTableModel;
113:            TableSorter sorter;
114:            JTable defectsTable;
115:            Vector ligneTbable;
116:            Hashtable colorState;
117:
118:            /** Action **/
119:            JPanel actionPanel;
120:            JPanel pPanelActionDefects;
121:            JButton newDefectButton;
122:            JButton editDefectButton;
123:            JButton viewLinkButton;
124:            JButton addLinkButton;
125:            JButton deleteButton;
126:
127:            boolean isMiniSize = false;
128:            MantisPlugin pMantisPlugin;
129:
130:            Hashtable defectsWrapper;
131:            boolean canReload = false;
132:            boolean isIndependant = false;
133:
134:            public DefectPanel(boolean miniSize, MantisPlugin pMantisPlugin,
135:                    JPanel _pPanelActionDefects, String envRestrictionName) {
136:                super ();
137:                setLayout(new BorderLayout());
138:                isMiniSize = miniSize;
139:                this .pMantisPlugin = pMantisPlugin;
140:                if (_pPanelActionDefects == null) {
141:                    pPanelActionDefects = this ;
142:                    initActionPanel();
143:                } else {
144:                    try {
145:                        pPanelActionDefects = _pPanelActionDefects;
146:                        actionPanel = _pPanelActionDefects;
147:                    } catch (Exception e) {
148:                        e.printStackTrace();
149:                        pPanelActionDefects = this ;
150:                        initActionPanel();
151:                    }
152:                }
153:                initFiltrePanel();
154:                if (envRestrictionName != null) {
155:                    applyEnvRestriction(envRestrictionName);
156:                }
157:                initTablePanel();
158:
159:                add(panelFiltre, BorderLayout.NORTH);
160:                add(defectsPanel, BorderLayout.CENTER);
161:                add(actionPanel, BorderLayout.SOUTH);
162:                canReload = true;
163:
164:            }
165:
166:            void initFiltrePanel() {
167:                //PASSER pas last ID et test null
168:                panelFiltre = new JPanel();
169:                /* On Maxi-Mini */
170:                labelProduit = new JLabel(
171:                        org.objectweb.salome_tmf.ihm.languages.Language
172:                                .getInstance().getText("Environnement")
173:                                + " :"); //Produit (environnement)
174:                ArrayList listOfEnv = DataModel.getCurrentProject()
175:                        .getEnvironmentListFromModel();
176:                Vector choiceEnv = new Vector();
177:                choiceEnv.add(org.objectweb.salome_tmf.ihm.languages.Language
178:                        .getInstance().getText("Tout"));
179:                choiceEnv.add(org.objectweb.salome_tmf.ihm.languages.Language
180:                        .getInstance().getText("Aucun"));
181:                int size = listOfEnv.size();
182:                for (int i = 0; i < size; i++) {
183:                    choiceEnv.add(((Environment) listOfEnv.get(i))
184:                            .getNameFromModel());
185:                }
186:                comboProduit = new JComboBox(choiceEnv);
187:                comboProduit.addActionListener(this );
188:                comboProduit.setEditable(false);
189:
190:                /* comboSeverite; On Maxi-Mini */
191:                labelSeverite = new JLabel(Language.getInstance().getText(
192:                        "Severite")
193:                        + " :");
194:                Vector choiceSeverite = new Vector();
195:                choiceSeverite
196:                        .add(org.objectweb.salome_tmf.ihm.languages.Language
197:                                .getInstance().getText("Tout"));
198:                size = pMantisPlugin.severity_values.size();
199:                for (int i = 0; i < size; i++) {
200:                    choiceSeverite.add(pMantisPlugin.severity_values
201:                            .elementAt(i));
202:                }
203:                comboSeverite = new JComboBox(choiceSeverite);
204:                comboSeverite.addActionListener(this );
205:                comboSeverite.setEditable(false);
206:
207:                /*comboPriorite; On Maxi-Mini*/
208:                labelPriorite = new JLabel(
209:                        org.objectweb.salome_tmf.ihm.languages.Language
210:                                .getInstance().getText("Priority")
211:                                + " :"); //Priorité
212:                Vector choicePriorite = new Vector();
213:                choicePriorite
214:                        .add(org.objectweb.salome_tmf.ihm.languages.Language
215:                                .getInstance().getText("Tout"));
216:                size = pMantisPlugin.priority_values.size();
217:                for (int i = 0; i < size; i++) {
218:                    choicePriorite.add(pMantisPlugin.priority_values
219:                            .elementAt(i));
220:                }
221:                comboPriorite = new JComboBox(choicePriorite);
222:                comboPriorite.addActionListener(this );
223:                comboPriorite.setEditable(false);
224:
225:                choiceState = new Vector();
226:                choiceState.add(org.objectweb.salome_tmf.ihm.languages.Language
227:                        .getInstance().getText("Tout"));
228:                size = pMantisPlugin.status_values.size();
229:                int incColor = 0;
230:                int incColor2 = 0;
231:                if (size > 2) {
232:                    incColor = 255 / (size - 2);
233:                    incColor2 = 150 / (size - 2);
234:                }
235:                int indexColor = 0;
236:                int indexColor2 = 0;
237:                Color pColor = new Color(255, 0, 0);
238:                colorState = new Hashtable();
239:                for (int i = 0; i < size; i++) {
240:                    String values = (String) pMantisPlugin.status_values
241:                            .elementAt(i);
242:                    Integer id = (Integer) pMantisPlugin.statusByValues
243:                            .get(values);
244:                    choiceState.add(pMantisPlugin.status_values.elementAt(i));
245:                    if (i == 0) {
246:                        colorState.put(id, new Color(0, 150, 255));
247:                    } else if (i < size - 1) {
248:                        indexColor = indexColor + incColor;
249:                        indexColor2 = indexColor2 + incColor2;
250:                        pColor = new Color(255, indexColor, indexColor2);
251:                        colorState.put(id, pColor);
252:                    } else {
253:                        colorState.put(id, Color.GREEN);
254:                    }
255:                }
256:
257:                if (isMiniSize) {
258:                    panelFiltre.setLayout(new GridLayout(2, 3));
259:                    panelFiltre.add(labelProduit);
260:                    panelFiltre.add(labelSeverite);
261:                    panelFiltre.add(labelPriorite);
262:                    panelFiltre.add(comboProduit);
263:                    panelFiltre.add(comboSeverite);
264:                    panelFiltre.add(comboPriorite);
265:                } else {
266:                    labelRapporter = new JLabel(Language.getInstance().getText(
267:                            "Rapporteur")
268:                            + " :"); //Rapporteur
269:                    //comboRapporter; //On Maxi
270:                    Vector choiceRapporter = pMantisPlugin
271:                            .getBugTrackerAllUsers();
272:                    choiceRapporter.add(0,
273:                            org.objectweb.salome_tmf.ihm.languages.Language
274:                                    .getInstance().getText("Tout"));
275:                    comboRapporter = new JComboBox(choiceRapporter);
276:                    comboRapporter.addActionListener(this );
277:                    comboRapporter.setEditable(false);
278:
279:                    labelOwner = new JLabel(Language.getInstance().getText(
280:                            "Destinataire")
281:                            + " :"); //Assigné à
282:                    //comboOwner; //On Maxi
283:                    Vector choiceOwner = pMantisPlugin.getBugTrackerAllUsers();
284:                    choiceOwner.add(0,
285:                            org.objectweb.salome_tmf.ihm.languages.Language
286:                                    .getInstance().getText("Tout"));
287:                    comboOwner = new JComboBox(choiceOwner);
288:                    comboOwner.addActionListener(this );
289:                    comboOwner.setEditable(false);
290:
291:                    labelDiagnostic = new JLabel(Language.getInstance()
292:                            .getText("Diagnostic")
293:                            + " :"); //Diagnostic
294:                    //comboDiagnostic; //On Maxi
295:
296:                    Vector choiceDiagnostic = new Vector();
297:                    choiceDiagnostic
298:                            .add(org.objectweb.salome_tmf.ihm.languages.Language
299:                                    .getInstance().getText("Tout"));
300:                    size = pMantisPlugin.resolution_values.size();
301:                    for (int i = 0; i < size; i++) {
302:                        choiceDiagnostic.add(pMantisPlugin.resolution_values
303:                                .elementAt(i));
304:                    }
305:                    comboDiagnostic = new JComboBox(choiceDiagnostic);
306:                    comboDiagnostic.addActionListener(this );
307:                    comboDiagnostic.setEditable(false);
308:
309:                    labelState = new JLabel(
310:                            org.objectweb.salome_tmf.ihm.languages.Language
311:                                    .getInstance().getText("Etat")
312:                                    + " :"); //Etat
313:                    //JComboBox comboState; //On Maxi
314:                    /*choiceState = new Vector();
315:                    choiceState.add(org.objectweb.salome_tmf.ihm.languages.Language.getInstance().getText("Tout"));
316:                    size = pMantisPlugin.status_values.size();
317:                    int incColor = 0;
318:                    int incColor2 = 0;
319:                    if (size > 2){
320:                    	incColor = 255 / (size -2);
321:                    	incColor2 = 150 / (size -2);
322:                    }
323:                    int indexColor = 0;
324:                    int indexColor2 = 0;
325:                    Color pColor = new Color(255,0,0);
326:                    colorState = new Hashtable();
327:                    for (int i = 0; i < size ; i++){
328:                    	String values = (String) pMantisPlugin.status_values.elementAt(i);
329:                    	Integer id = (Integer) pMantisPlugin.statusByValues.get(values);
330:                    	choiceState.add( pMantisPlugin.status_values.elementAt(i));
331:                    	if (i == 0){
332:                    		colorState.put(id, new Color(0,150,255));
333:                    	}else if (i < size-1 ){
334:                    		indexColor = indexColor + incColor;
335:                    		indexColor2 = indexColor2 + incColor2;
336:                    		pColor = new Color( 255, indexColor, indexColor2);
337:                    		colorState.put(id, pColor);
338:                    	} else {
339:                    		colorState.put(id, Color.GREEN);
340:                    	}
341:                    }*/
342:                    comboState = new JComboBox(choiceState);
343:                    comboState.addActionListener(this );
344:                    comboState.setEditable(false);
345:
346:                    labelHideSate = new JLabel(Language.getInstance().getText(
347:                            "Cacher_le_statut")
348:                            + " :");
349:                    Vector choiceHideSate = new Vector();
350:                    size = choiceState.size();
351:                    choiceHideSate
352:                            .add(org.objectweb.salome_tmf.ihm.languages.Language
353:                                    .getInstance().getText("Aucun"));
354:                    String str2add = Language.getInstance().getText("et_supp");
355:                    for (int i = 1; i < size; i++) {
356:                        choiceHideSate.add(choiceState.elementAt(i) + " "
357:                                + str2add);
358:                    }
359:                    comboHideSate = new JComboBox(choiceHideSate);
360:                    comboHideSate.addActionListener(this );
361:                    comboHideSate.setEditable(false);
362:
363:                    labelResume = new JLabel(
364:                            org.objectweb.salome_tmf.ihm.languages.Language
365:                                    .getInstance().getText("Résumé_:______"));
366:                    filtreResume = new JTextField(150);
367:                    checkStartWith = new JCheckBox(Language.getInstance()
368:                            .getText("Start_With"));
369:                    checkStartWith.setSelected(true);
370:                    checkContyent = new JCheckBox(Language.getInstance()
371:                            .getText("Content"));
372:
373:                    checkStartWith.addItemListener(new ItemListener() {
374:                        public void itemStateChanged(ItemEvent e) {
375:                            if (checkStartWith.isSelected()) {
376:                                checkContyent.setSelected(false);
377:                            } else {
378:                                checkContyent.setSelected(true);
379:                            }
380:                        }
381:                    });
382:                    checkContyent.addItemListener(new ItemListener() {
383:                        public void itemStateChanged(ItemEvent e) {
384:                            if (checkContyent.isSelected()) {
385:                                checkStartWith.setSelected(false);
386:                            } else {
387:                                checkStartWith.setSelected(true);
388:                            }
389:                        }
390:                    });
391:                    filtreResume.addKeyListener(new KeyListener() {
392:                        public void keyTyped(KeyEvent keyEvent) {
393:                            reloadData();
394:                        }
395:
396:                        public void keyPressed(KeyEvent keyEvent) {
397:                        }
398:
399:                        public void keyReleased(KeyEvent keyEvent) {
400:                        }
401:
402:                    });
403:
404:                    panelFiltre.setLayout(new GridLayout(5, 4));
405:                    panelFiltre.add(labelProduit);
406:                    panelFiltre.add(labelSeverite);
407:                    panelFiltre.add(labelPriorite);
408:                    panelFiltre.add(labelState);
409:
410:                    panelFiltre.add(comboProduit);
411:                    panelFiltre.add(comboSeverite);
412:                    panelFiltre.add(comboPriorite);
413:                    panelFiltre.add(comboState);
414:
415:                    panelFiltre.add(labelDiagnostic);
416:                    panelFiltre.add(labelRapporter);
417:                    panelFiltre.add(labelOwner);
418:                    panelFiltre.add(labelHideSate);
419:
420:                    panelFiltre.add(comboDiagnostic);
421:                    panelFiltre.add(comboRapporter);
422:                    panelFiltre.add(comboOwner);
423:                    panelFiltre.add(comboHideSate);
424:
425:                    JPanel resumePanel = new JPanel(new FlowLayout(
426:                            FlowLayout.LEFT));
427:                    resumePanel.add(labelResume);
428:                    resumePanel.add(filtreResume);
429:
430:                    JPanel checkPanel = new JPanel(new FlowLayout(
431:                            FlowLayout.CENTER));
432:                    checkPanel.add(checkStartWith);
433:                    checkPanel.add(checkContyent);
434:                    //checkPanel.add(applyFiltreButton);
435:                    panelFiltre.add(filtreResume);
436:                    panelFiltre.add(checkPanel);
437:
438:                    panelFiltre.setBorder(BorderFactory.createTitledBorder(
439:                            BorderFactory.createLineBorder(Color.BLACK),
440:                            "Filtre"));
441:
442:                }
443:
444:            }
445:
446:            void initTablePanel() {
447:                defectsTable = new JTable();
448:                defectsTableModel = new MyTableModel();
449:                if (isMiniSize) {
450:                    defectsTableModel.addColumnNameAndColumn("id");
451:                    defectsTableModel
452:                            .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
453:                                    .getInstance().getText("Environnement")); //Produit
454:                    defectsTableModel.addColumnNameAndColumn(Language
455:                            .getInstance().getText("Resume")); //Produit
456:                    defectsTableModel.addColumnNameAndColumn(Language
457:                            .getInstance().getText("Severite")); //Etat
458:                } else {
459:                    defectsTableModel.addColumnNameAndColumn("id");
460:                    defectsTableModel
461:                            .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
462:                                    .getInstance().getText("Environnement")); //Produit
463:                    //defectsTableModel.addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language.getInstance().getText("Etat")); //Etat
464:                    defectsTableModel
465:                            .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
466:                                    .getInstance().getText("Priority")); //Etat
467:                    defectsTableModel.addColumnNameAndColumn(Language
468:                            .getInstance().getText("Resume")); //Produit
469:                    defectsTableModel.addColumnNameAndColumn(Language
470:                            .getInstance().getText("Severite")); //Etat
471:                    defectsTableModel
472:                            .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
473:                                    .getInstance().getText("resolution"));
474:                    defectsTableModel.addColumnNameAndColumn(Language
475:                            .getInstance().getText("Rapporteur"));
476:                    defectsTableModel.addColumnNameAndColumn(Language
477:                            .getInstance().getText("Destinataire"));
478:
479:                }
480:
481:                sorter = new TableSorter(defectsTableModel);
482:                defectsTable.setModel(sorter);
483:                sorter.setTableHeader(defectsTable.getTableHeader());
484:                defectsTable
485:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
486:                JScrollPane defectsTableScrollPane = new JScrollPane(
487:                        defectsTable);
488:                defectsTable.getColumnModel().getColumn(0).setWidth(20);
489:                try {
490:                    //reqTable.setDefaultRenderer(Class.forName( "java.lang.Object" ), new PriorityTableCellRenderer(reqCovered));
491:                    defectsTable.setDefaultRenderer(Class
492:                            .forName("java.lang.Object"),
493:                            new StateTableCellRenderer());
494:                } catch (Exception e) {
495:                    e.printStackTrace();
496:                }
497:
498:                defectsTable.addMouseListener(new MouseAdapter() {
499:                    public void mouseClicked(MouseEvent e) {
500:                        if (e.getClickCount() > 1) {
501:                            if (isIndependant) {
502:                                editDefectPerformed();
503:                            }
504:                        }
505:                    }
506:                });
507:
508:                int size = choiceState.size();
509:                JPanel statePanel = new JPanel();
510:                statePanel.setLayout(new GridLayout(1, size - 1));
511:                for (int i = 1; i < size; i++) {
512:                    String state = (String) choiceState.elementAt(i);
513:                    JLabel pLabel = new JLabel(state);
514:                    Integer id = (Integer) pMantisPlugin.statusByValues
515:                            .get(state);
516:                    Color pColor = (Color) colorState.get(id);
517:
518:                    pLabel.setBorder(BorderFactory
519:                            .createLineBorder(Color.BLACK));
520:                    pLabel.setBackground(pColor);
521:                    //pLabel.setForeground(pColor);
522:                    pLabel.setOpaque(true);
523:                    statePanel.add(pLabel);
524:                }
525:                defectsPanel = new JPanel();
526:                defectsPanel.setLayout(new BorderLayout());
527:                defectsPanel.add(defectsTableScrollPane, BorderLayout.CENTER);
528:                defectsPanel.add(statePanel, BorderLayout.SOUTH);
529:
530:            }
531:
532:            void initActionPanel() {
533:                isIndependant = true;
534:                actionPanel = new JPanel(new GridLayout(1, 5));
535:                newDefectButton = new JButton(Language.getInstance().getText(
536:                        "Ajouter"));
537:                newDefectButton.addActionListener(this );
538:                editDefectButton = new JButton(Language.getInstance().getText(
539:                        "Editer"));
540:                editDefectButton.addActionListener(this );
541:                viewLinkButton = new JButton(Language.getInstance().getText(
542:                        "Liason"));
543:                viewLinkButton.addActionListener(this );
544:                addLinkButton = new JButton(Language.getInstance().getText(
545:                        "Lier"));
546:                addLinkButton.addActionListener(this );
547:
548:                deleteButton = new JButton(
549:                        org.objectweb.salome_tmf.ihm.languages.Language
550:                                .getInstance().getText("Supprimer"));
551:                deleteButton.addActionListener(this );
552:                /*if (pMantisPlugin.access_level < 70){
553:                	deleteButton.setEnabled(false);
554:                }*/
555:                actionPanel.add(newDefectButton);
556:                actionPanel.add(editDefectButton);
557:                actionPanel.add(viewLinkButton);
558:                actionPanel.add(addLinkButton);
559:                actionPanel.add(deleteButton);
560:            }
561:
562:            void applyEnvRestriction(String envName) {
563:                int size = comboProduit.getItemCount();
564:                int i = 0;
565:                boolean trouve = false;
566:                if (envName != null) {
567:                    while (i < size && !trouve) {
568:                        String value = ((String) comboProduit.getItemAt(i))
569:                                .trim();
570:                        if (value.equals(envName)) {
571:                            trouve = true;
572:                            comboProduit.setSelectedIndex(i);
573:                            /*if (!(value.equals("___NO_ENV___") || value.equals("")  )){
574:                            	comboProduit.setEnabled(false);
575:                            }*/
576:                        }
577:                        i++;
578:                    }
579:                }
580:            }
581:
582:            void loadData(Hashtable hashDefectsWrapper) {
583:                if (hashDefectsWrapper == null) {
584:                    return;
585:                }
586:                /* HASH : ID - > DefectWrapper */
587:                defectsWrapper = hashDefectsWrapper;
588:                reloadData();
589:            }
590:
591:            void reloadData() {
592:                if (defectsWrapper == null || canReload == false) {
593:                    return;
594:                }
595:                Enumeration listKey = defectsWrapper.keys();
596:                defectsTableModel.clearTable();
597:                while (listKey.hasMoreElements()) {
598:                    Integer ID = (Integer) listKey.nextElement();
599:                    DefectWrapper pDefectWrapper = (DefectWrapper) defectsWrapper
600:                            .get(ID);
601:                    if (isFiltred(pDefectWrapper)) {
602:                        ArrayList data = new ArrayList();
603:                        if (isMiniSize) {
604:                            data.add("" + pDefectWrapper.getId());
605:                            data.add(pDefectWrapper.getEnvironement());
606:                            data.add(pDefectWrapper.getResume());
607:                            int severity = pDefectWrapper.getSeverity();
608:                            String str_severity = (String) pMantisPlugin.severityByID
609:                                    .get(Integer.valueOf("" + severity));
610:                            data.add(str_severity);
611:                        } else {
612:                            data.add("" + pDefectWrapper.getId());
613:                            data.add(pDefectWrapper.getEnvironement());
614:
615:                            /*int state = pDefectWrapper.getStatus();
616:                            String str_state = (String) pMantisPlugin.statusByID.get(Integer.valueOf(state));
617:                            data.add(str_state);
618:                             */
619:                            int priority = pDefectWrapper.getPriority();
620:                            String str_priority = (String) pMantisPlugin.priorityByID
621:                                    .get(Integer.valueOf("" + priority));
622:                            data.add(str_priority);
623:                            //
624:                            data.add(pDefectWrapper.getResume());
625:                            int severity = pDefectWrapper.getSeverity();
626:                            String str_severity = (String) pMantisPlugin.severityByID
627:                                    .get(Integer.valueOf("" + severity));
628:                            data.add(str_severity);
629:                            int resolution = pDefectWrapper.getResolution();
630:                            String str_resolution = (String) pMantisPlugin.resolutionByID
631:                                    .get(Integer.valueOf("" + resolution));
632:                            data.add(str_resolution);
633:                            data.add(pDefectWrapper.getUser());
634:                            data.add(pDefectWrapper.getRecipient());
635:                            //"id","Environnement", "priorite", "Resume", "Severite", "resolution", "Rapporteur", "Destinataire";
636:                        }
637:                        defectsTableModel.addRow(data);
638:                    }
639:                }
640:                setColumnSize(defectsTable);
641:            }
642:
643:            private boolean isFiltred(DefectWrapper pDefectWrapper) {
644:                int envSelected = comboProduit.getSelectedIndex();
645:                if (envSelected > 0) {
646:                    String filtredEnv = (String) comboProduit.getSelectedItem();
647:                    String env = pDefectWrapper.getEnvironement().trim();
648:                    if (envSelected > 1) {
649:                        if (!env.equals(filtredEnv)) {
650:                            return false;
651:                        }
652:                    } else {
653:                        //No env or vide
654:                        if (!((env.equals("")) || (env.equals("___NO_ENV___")))) {
655:                            return false;
656:                        }
657:                    }
658:                }
659:
660:                int severityselected = comboSeverite.getSelectedIndex();
661:                if (severityselected > 0) {
662:                    String filtredSeverity = (String) comboSeverite
663:                            .getSelectedItem();
664:                    int severity = pDefectWrapper.getSeverity();
665:                    String str_seveiry = (String) pMantisPlugin.severityByID
666:                            .get(Integer.valueOf("" + severity));
667:                    if (!filtredSeverity.equals(str_seveiry)) {
668:                        return false;
669:                    }
670:                }
671:
672:                int priorityselected = comboPriorite.getSelectedIndex();
673:                if (priorityselected > 0) {
674:                    String filtredPriority = (String) comboPriorite
675:                            .getSelectedItem();
676:                    int priority = pDefectWrapper.getPriority();
677:                    String str_priority = (String) pMantisPlugin.priorityByID
678:                            .get(Integer.valueOf("" + priority));
679:                    if (!filtredPriority.equals(str_priority)) {
680:                        return false;
681:                    }
682:                }
683:
684:                if (!isMiniSize) {
685:                    int stateselected = comboState.getSelectedIndex();
686:                    if (stateselected > 0) {
687:                        String filtredState = (String) comboState
688:                                .getSelectedItem();
689:                        int state = pDefectWrapper.getStatus();
690:                        String str_state = (String) pMantisPlugin.statusByID
691:                                .get(Integer.valueOf("" + state));
692:                        if (!filtredState.equals(str_state)) {
693:                            return false;
694:                        }
695:                    }
696:
697:                    int diagnosticselected = comboDiagnostic.getSelectedIndex();
698:                    if (diagnosticselected > 0) {
699:                        String filtredState = (String) comboDiagnostic
700:                                .getSelectedItem();
701:                        int res = pDefectWrapper.getResolution();
702:                        String str_res = (String) pMantisPlugin.resolutionByID
703:                                .get(Integer.valueOf("" + res));
704:                        if (!filtredState.equals(str_res)) {
705:                            return false;
706:                        }
707:                    }
708:
709:                    int rapporter_selected = comboRapporter.getSelectedIndex();
710:                    if (rapporter_selected > 0) {
711:                        String filtredRapporter = (String) comboRapporter
712:                                .getSelectedItem();
713:                        String str_rapporter = (String) pDefectWrapper
714:                                .getUser();
715:                        if (!filtredRapporter.equals(str_rapporter)) {
716:                            return false;
717:                        }
718:                    }
719:
720:                    int owner_selected = comboOwner.getSelectedIndex();
721:                    if (owner_selected > 0) {
722:                        String filtredOwner = (String) comboOwner
723:                                .getSelectedItem();
724:                        String str_owner = (String) pDefectWrapper
725:                                .getRecipient();
726:                        System.out.println("Owner is " + str_owner);
727:                        if (!filtredOwner.equals(str_owner)) {
728:                            return false;
729:                        }
730:                    }
731:
732:                    int hidesate_selected = comboHideSate.getSelectedIndex();
733:                    if (hidesate_selected > 0) {
734:                        String filtredState = (String) comboState
735:                                .getItemAt(hidesate_selected);
736:                        int state = pDefectWrapper.getStatus();
737:                        int stateFiltre = ((Integer) pMantisPlugin.statusByValues
738:                                .get(filtredState)).intValue();
739:                        if (!(state <= stateFiltre)) {
740:                            return false;
741:                        }
742:                    }
743:                    String filtre = filtreResume.getText().trim();
744:                    if (!filtre.equals("")) {
745:                        String sumary = pDefectWrapper.getResume().trim();
746:                        if (checkStartWith.isSelected()) {
747:                            if (!sumary.startsWith(filtre)) {
748:                                return false;
749:                            }
750:                        }
751:
752:                        if (checkContyent.isSelected()) {
753:                            filtre = ".*" + filtre + ".*";
754:                            if (!sumary.matches(filtre)) {
755:                                return false;
756:                            }
757:                        }
758:                    }
759:                }
760:                return true;
761:            }
762:
763:            public void updateDefects(Hashtable defects) {
764:
765:            }
766:
767:            /**************************** Listener ***********************************/
768:            public void actionPerformed(ActionEvent e) {
769:                if (e.getSource().equals(newDefectButton)) {
770:                    newDefectPerformed();
771:                } else if (e.getSource().equals(editDefectButton)) {
772:                    editDefectPerformed();
773:                } else if (e.getSource().equals(deleteButton)) {
774:                    deletePerformed();
775:                } else if (e.getSource().equals(viewLinkButton)) {
776:                    viewLinkPerformed();
777:                } else if (e.getSource().equals(addLinkButton)) {
778:                    addLinkPerformed();
779:                } else if (e.getSource().equals(comboProduit)) {
780:                    reloadData();
781:                } else if (e.getSource().equals(comboSeverite)) {
782:                    reloadData();
783:                } else if (e.getSource().equals(comboPriorite)) {
784:                    reloadData();
785:                } else if (e.getSource().equals(comboState)) {
786:                    reloadData();
787:                } else if (e.getSource().equals(comboDiagnostic)) {
788:                    reloadData();
789:                } else if (e.getSource().equals(comboOwner)) {
790:                    reloadData();
791:                } else if (e.getSource().equals(comboRapporter)) {
792:                    reloadData();
793:                } else if (e.getSource().equals(comboHideSate)) {
794:                    reloadData();
795:                }
796:            }
797:
798:            void addLinkPerformed() {
799:                DefectWrapper pDefectWrapper = getSelectedDefect();
800:                AddLinkDialog pAddLinkDialog = new AddLinkDialog(
801:                        pDefectWrapper, pMantisPlugin);
802:                if (pAddLinkDialog.isDoingModification()) {
803:                    try {
804:                        loadData(pMantisPlugin.getDefectsOfProject(true));
805:                    } catch (Exception e) {
806:                        e.printStackTrace();
807:                    }
808:                } else {
809:                    reloadData();
810:                }
811:            }
812:
813:            void viewLinkPerformed() {
814:                DefectWrapper pDefectWrapper = getSelectedDefect();
815:                if (pDefectWrapper != null) {
816:                    new ViewLinkDialog(pDefectWrapper, pMantisPlugin);
817:                }
818:            }
819:
820:            void deletePerformed() {
821:                DefectWrapper pDefectWrapper = getSelectedDefect();
822:                if (pDefectWrapper != null) {
823:                    if (pMantisPlugin.access_level < 70) {
824:                        JOptionPane.showMessageDialog(SalomeTMFContext
825:                                .getInstance().getSalomeFrame(), Language
826:                                .getInstance().getText(
827:                                        "Access_level_insuffisant2"), "Error!",
828:                                JOptionPane.ERROR_MESSAGE);
829:                        return;
830:                    }
831:                    if (pMantisPlugin.deleteConfirme(Language.getInstance()
832:                            .getText("Anomalie_selectione"))) {
833:                        try {
834:                            pMantisPlugin.deleteDefect(pDefectWrapper);
835:                            //deleteref
836:                            defectsWrapper.remove(new Integer(pDefectWrapper
837:                                    .getId()));
838:                            reloadData();
839:                        } catch (Exception e) {
840:                            e.printStackTrace();
841:                        }
842:                    }
843:                }
844:            }
845:
846:            /*void applyFiltrePerformed() {
847:            	String filtre = filtreResume.getText().trim();
848:            	if (filtre.equals("")){
849:            		return;
850:            	}
851:            }*/
852:
853:            void newDefectPerformed() {
854:                //new AskNewBug(pMantisPlugin, false,  "", "", "", "");
855:                DefectView pDefectView = new DefectView(SalomeTMFContext
856:                        .getInstance().getSalomeFrame(), pMantisPlugin);
857:                try {
858:                    if (pDefectView.isDoingModification()) {
859:                        loadData(pMantisPlugin.getDefectsOfProject(true));
860:                    }
861:                } catch (Exception e) {
862:                    e.printStackTrace();
863:                }
864:            }
865:
866:            void editDefectPerformed() {
867:                DefectWrapper pDefectWrapper = getSelectedDefect();
868:                if (pDefectWrapper != null) {
869:                    DefectView pDefectView = new DefectView(SalomeTMFContext
870:                            .getInstance().getSalomeFrame(), pDefectWrapper,
871:                            pMantisPlugin, true);
872:
873:                    try {
874:                        if (pDefectView.isDoingModification()) {
875:                            //loadData(pMantisPlugin.getDefectsOfProject(true));
876:                            reloadData();
877:                        }
878:                    } catch (Exception e) {
879:                        e.printStackTrace();
880:                    }
881:                }
882:            }
883:
884:            DefectWrapper getSelectedDefect() {
885:                DefectWrapper pDefectWrapper = null;
886:                if (defectsWrapper == null) {
887:                    return null;
888:                }
889:                int selectedRowIndex = defectsTable.getSelectedRow();
890:                if (selectedRowIndex != -1) {
891:                    String str_id = (String) sorter.getValueAt(
892:                            selectedRowIndex, 0);
893:                    str_id = str_id.trim();
894:                    Integer id = Integer.valueOf(str_id);
895:                    pDefectWrapper = (DefectWrapper) defectsWrapper.get(id);
896:                    /* System.out.println(id);*/
897:                }
898:                return pDefectWrapper;
899:
900:            }
901:
902:            /********************* Render ******************/
903:            /**
904:             * redefine size of table columns
905:             */
906:            public void setColumnSize(JTable table) {
907:                FontMetrics fm = table.getFontMetrics(table.getFont());
908:                for (int i = 0; i < table.getColumnCount(); i++) {
909:                    int max = 0;
910:                    for (int j = 0; j < table.getRowCount(); j++) {
911:                        int taille = fm.stringWidth((String) table.getValueAt(
912:                                j, i));
913:                        if (taille > max)
914:                            max = taille;
915:                    }
916:                    String nom = (String) table.getColumnModel().getColumn(i)
917:                            .getIdentifier();
918:                    int taille = fm.stringWidth(nom);
919:                    if (taille > max)
920:                        max = taille;
921:                    table.getColumnModel().getColumn(i).setPreferredWidth(
922:                            max + 10);
923:                }
924:            }
925:
926:            public class StateTableCellRenderer extends
927:                    DefaultTableCellRenderer {
928:                Color colorToUse = null;
929:
930:                public Component getTableCellRendererComponent(JTable table,
931:                        Object value, boolean isSelected, boolean hasFocus,
932:                        int row, int column) {
933:
934:                    //super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
935:                    super .getTableCellRendererComponent(table, value,
936:                            isSelected, hasFocus, row, column);
937:
938:                    try {
939:                        if (column == 0) {
940:                            Integer ID = Integer.valueOf((String) value);
941:                            DefectWrapper pDefectWrapper = (DefectWrapper) defectsWrapper
942:                                    .get(ID);
943:                            int state = pDefectWrapper.getStatus();
944:                            colorToUse = (Color) colorState.get(Integer
945:                                    .valueOf("" + state));
946:                        }
947:                        if (colorToUse != null) {
948:                            if (isSelected) {
949:                                setBorder(BorderFactory
950:                                        .createLineBorder(Color.BLACK));
951:                            }
952:                            setBackground(colorToUse);
953:                            setForeground(Color.BLACK);
954:                            //setOpaque(false);
955:                            setText((String) value);
956:                        }
957:
958:                        //super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
959:
960:                    } catch (Exception e) {
961:                        e.printStackTrace();
962:                    }
963:                    return this;
964:                }
965:            }
966:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.