Source Code Cross Referenced for AttachmentView.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » org.objectweb.salome_tmf.ihm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * SalomeTMF is a Test Management Framework
0003:         * Copyright (C) 2005 France Telecom R&D
0004:         *
0005:         * This library is free software; you can redistribute it and/or
0006:         * modify it under the terms of the GNU Lesser General Public
0007:         * License as published by the Free Software Foundation; either
0008:         * version 2 of the License, or (at your option) any later version.
0009:         *
0010:         * This library is distributed in the hope that it will be useful,
0011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013:         * Lesser General Public License for more details.
0014:         *
0015:         * You should have received a copy of the GNU Lesser General Public
0016:         * License along with this library; if not, write to the Free Software
0017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018:         *
0019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
0020:         *
0021:         * Contact: mikael.marche@rd.francetelecom.com
0022:         */
0023:
0024:        package org.objectweb.salome_tmf.ihm;
0025:
0026:        import java.awt.BorderLayout;
0027:        import java.awt.Color;
0028:        import java.awt.Dimension;
0029:        import java.awt.GridLayout;
0030:        import java.awt.event.ActionEvent;
0031:        import java.awt.event.ActionListener;
0032:        import java.io.BufferedInputStream;
0033:        import java.io.File;
0034:        import java.io.FileInputStream;
0035:        import java.io.IOException;
0036:        import java.net.MalformedURLException;
0037:        import java.net.URL;
0038:        import java.sql.Date;
0039:        import java.util.ArrayList;
0040:        import java.util.Collection;
0041:        import java.util.HashMap;
0042:        import java.util.Iterator;
0043:        import java.util.Properties;
0044:        import java.util.Set;
0045:
0046:        import javax.swing.BorderFactory;
0047:        import javax.swing.JApplet;
0048:        import javax.swing.JButton;
0049:        import javax.swing.JFileChooser;
0050:        import javax.swing.JOptionPane;
0051:        import javax.swing.JPanel;
0052:        import javax.swing.JScrollPane;
0053:        import javax.swing.JTable;
0054:        import javax.swing.JTextArea;
0055:        import javax.swing.ListSelectionModel;
0056:        import javax.swing.event.CaretEvent;
0057:        import javax.swing.event.CaretListener;
0058:        import javax.swing.event.ListSelectionEvent;
0059:        import javax.swing.event.ListSelectionListener;
0060:
0061:        import org.objectweb.salome_tmf.api.Api;
0062:        import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
0063:        import org.objectweb.salome_tmf.data.Action;
0064:        import org.objectweb.salome_tmf.data.Attachment;
0065:        import org.objectweb.salome_tmf.data.Campaign;
0066:        import org.objectweb.salome_tmf.data.ConnectionData;
0067:        import org.objectweb.salome_tmf.data.DataConstants;
0068:        import org.objectweb.salome_tmf.data.Environment;
0069:        import org.objectweb.salome_tmf.data.Execution;
0070:        import org.objectweb.salome_tmf.data.ExecutionResult;
0071:        import org.objectweb.salome_tmf.data.ExecutionTestResult;
0072:        import org.objectweb.salome_tmf.data.FileAttachment;
0073:        import org.objectweb.salome_tmf.data.Test;
0074:        import org.objectweb.salome_tmf.data.TestList;
0075:        import org.objectweb.salome_tmf.data.UrlAttachment;
0076:        import org.objectweb.salome_tmf.data.WithAttachment;
0077:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
0078:        import org.objectweb.salome_tmf.ihm.languages.Language;
0079:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
0080:        import org.objectweb.salome_tmf.ihm.plugins.PluginsTools;
0081:        import org.objectweb.salome_tmf.ihm.tools.Tools;
0082:
0083:        public class AttachmentView extends JPanel implements  DataConstants,
0084:                ActionListener, IHMConstants, ListSelectionListener {
0085:
0086:            JButton openAttach;
0087:
0088:            JButton delAttach;
0089:
0090:            JButton modifyButton;
0091:
0092:            JButton addFileAttach;
0093:
0094:            JButton addUrlAttach;
0095:
0096:            JTable attachmentTable;
0097:
0098:            /**
0099:             *
0100:             */
0101:            int sourceType;
0102:
0103:            /**
0104:             * Table des attachements
0105:             */
0106:            static HashMap attachmentMap;
0107:
0108:            /**
0109:             * Description de l'attachement
0110:             */
0111:            JTextArea descriptionArea;
0112:
0113:            /**
0114:             * Applet
0115:             */
0116:            JApplet applet;
0117:
0118:            WithAttachment actionOrExecutionForModification;
0119:
0120:            Execution exec;
0121:
0122:            ExecutionResult execResult;
0123:
0124:            Test observedTest;
0125:
0126:            TableSorter sorter;
0127:
0128:            JPanel attachmentsPanel;
0129:
0130:            /******************************************************************************/
0131:            /** 							CONSTRUCTEUR								***/
0132:            /******************************************************************************/
0133:
0134:            public AttachmentView(JApplet app, int realtype, int type,
0135:                    WithAttachment actionOrExecution, int size,
0136:                    Execution execution, ExecutionResult executionResult,
0137:                    Test testInObservation) {
0138:
0139:                attachmentsPanel = new JPanel();
0140:                attachmentTable = new JTable();
0141:
0142:                descriptionArea = new JTextArea();
0143:                modifyButton = new JButton(Language.getInstance().getText(
0144:                        "Actualiser"));
0145:                delAttach = new JButton(Language.getInstance().getText(
0146:                        "Supprimer"));
0147:                openAttach = new JButton(Language.getInstance().getText(
0148:                        "Visualiser"));
0149:
0150:                openAttach.setToolTipText(Language.getInstance().getText(
0151:                        "Récupérer_et_visualiser_un_attachement"));
0152:                //openAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_VIEW_ATTACH_ICON,""));
0153:                openAttach.setEnabled(false);
0154:                openAttach.addActionListener(this );
0155:
0156:                addFileAttach = new JButton(Language.getInstance().getText(
0157:                        "Ajouter_fichier"));
0158:                //addFileAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_FILE_ATTACH_ICON,""));
0159:                addFileAttach.setToolTipText(Language.getInstance().getText(
0160:                        "Ajouter_un_fichier_en_attachement"));
0161:                addFileAttach.addActionListener(this );
0162:
0163:                addUrlAttach = new JButton(Language.getInstance().getText(
0164:                        "Ajouter_url"));
0165:                //addUrlAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_URL_ATTACH_ICON,""));
0166:                addUrlAttach.setToolTipText(Language.getInstance().getText(
0167:                        "Ajouter_une_URL_en_attachement"));
0168:                addUrlAttach.addActionListener(this );
0169:
0170:                modifyButton.setToolTipText(Language.getInstance().getText(
0171:                        "Enregistre_les_modifications_du_fichier"));
0172:                modifyButton.setEnabled(false);
0173:                //modifyButton.setIcon(Tools.createAppletImageIcon(PATH_TO_BDD_ATTACH_ICON,""));
0174:                modifyButton.addActionListener(this );
0175:
0176:                delAttach.setToolTipText(Language.getInstance().getText(
0177:                        "Supprimer_un_attachement"));
0178:                //delAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_FAIL2_ICON,""));
0179:                delAttach.setEnabled(false);
0180:                delAttach.addActionListener(this );
0181:
0182:                JPanel allButtons = new JPanel(new GridLayout(1, 5));
0183:                allButtons.add(addFileAttach);
0184:                allButtons.add(addUrlAttach);
0185:                allButtons.add(openAttach);
0186:                allButtons.add(modifyButton);
0187:                allButtons.add(delAttach);
0188:
0189:                allButtons.setBorder(BorderFactory.createRaisedBevelBorder());
0190:
0191:                //  La liste des attachements 
0192:                sorter = new TableSorter(DataModel.getAttachmentTableModel());
0193:                attachmentTable.setModel(sorter);
0194:                sorter.setTableHeader(attachmentTable.getTableHeader());
0195:
0196:                attachmentTable
0197:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0198:
0199:                JScrollPane tablePane = new JScrollPane(attachmentTable);
0200:                tablePane.setPreferredSize(new Dimension(500, size));
0201:
0202:                ListSelectionModel rowSM = attachmentTable.getSelectionModel();
0203:                rowSM.addListSelectionListener(this );
0204:
0205:                descriptionArea.setEditable(false);
0206:                descriptionArea
0207:                        .addCaretListener(new AttachmentDescriptionListener());
0208:                JScrollPane descriptionScrollPane = new JScrollPane(
0209:                        descriptionArea);
0210:                descriptionScrollPane.setBorder(BorderFactory
0211:                        .createTitledBorder(BorderFactory
0212:                                .createLineBorder(Color.BLACK), Language
0213:                                .getInstance().getText("Description")));
0214:                descriptionScrollPane.setPreferredSize(new Dimension(500, 75));
0215:
0216:                initData(type, app, actionOrExecution, execution,
0217:                        executionResult, testInObservation);
0218:                giveAccessToIhmScriptView();
0219:                attachmentsPanel.setLayout(new BorderLayout());
0220:                attachmentsPanel.add(allButtons, BorderLayout.NORTH);
0221:                attachmentsPanel.add(tablePane, BorderLayout.CENTER);
0222:                attachmentsPanel.add(descriptionScrollPane, BorderLayout.SOUTH);
0223:
0224:                this .setLayout(new BorderLayout());
0225:                this .add(attachmentsPanel, BorderLayout.CENTER);
0226:
0227:                // Mapping GUI Object for plugins//
0228:                mapUIComponents(attachmentsPanel, attachmentTable, allButtons,
0229:                        realtype);
0230:
0231:            }
0232:
0233:            void mapUIComponents(JPanel attachmentsPanel,
0234:                    JTable attachmentTable, JPanel allButtons, int type) {
0235:                switch (type) {
0236:                case MANUAL_TEST: {
0237:                    SalomeTMF.addToUIComponentsMap(
0238:                            UICompCst.MANUAL_TEST_ATTACHMENTS_PANEL,
0239:                            attachmentsPanel);
0240:                    UICompCst.staticUIComps
0241:                            .add(UICompCst.MANUAL_TEST_ATTACHMENTS_PANEL);
0242:                    //PluginsTools.activateAssociatedPlgs(UICompCst.MANUAL_TEST_ATTACHMENTS_PANEL);
0243:
0244:                    SalomeTMF.addToUIComponentsMap(
0245:                            UICompCst.MANUAL_TEST_ATTACHMENTS_TABLE,
0246:                            attachmentTable);
0247:                    UICompCst.staticUIComps
0248:                            .add(UICompCst.MANUAL_TEST_ATTACHMENTS_TABLE);
0249:                    //PluginsTools.activateAssociatedPlgs(UICompCst.MANUAL_TEST_ATTACHMENTS_TABLE);
0250:
0251:                    SalomeTMF.addToUIComponentsMap(
0252:                            UICompCst.MANUAL_TEST_ATTACHMENTS_BUTTONS_PANEL,
0253:                            allButtons);
0254:                    UICompCst.staticUIComps
0255:                            .add(UICompCst.MANUAL_TEST_ATTACHMENTS_BUTTONS_PANEL);
0256:                    //PluginsTools.activateAssociatedPlgs(UICompCst.MANUAL_TEST_ATTACHMENTS_BUTTONS_PANEL);
0257:
0258:                    break;
0259:                }
0260:                case AUTOMATIC_TEST: {
0261:                    SalomeTMF.addToUIComponentsMap(
0262:                            UICompCst.AUTOMATED_TEST_ATTACHMENTS_PANEL,
0263:                            attachmentsPanel);
0264:                    UICompCst.staticUIComps
0265:                            .add(UICompCst.AUTOMATED_TEST_ATTACHMENTS_PANEL);
0266:                    //PluginsTools.activateAssociatedPlgs(UICompCst.AUTOMATED_TEST_ATTACHMENTS_PANEL);
0267:
0268:                    SalomeTMF.addToUIComponentsMap(
0269:                            UICompCst.AUTOMATED_TEST_ATTACHMENTS_TABLE,
0270:                            attachmentTable);
0271:                    UICompCst.staticUIComps
0272:                            .add(UICompCst.AUTOMATED_TEST_ATTACHMENTS_TABLE);
0273:                    //PluginsTools.activateAssociatedPlgs(UICompCst.AUTOMATED_TEST_ATTACHMENTS_TABLE);
0274:
0275:                    SalomeTMF.addToUIComponentsMap(
0276:                            UICompCst.AUTOMATED_TEST_ATTACHMENTS_BUTTONS_PANEL,
0277:                            allButtons);
0278:                    UICompCst.staticUIComps
0279:                            .add(UICompCst.AUTOMATED_TEST_ATTACHMENTS_BUTTONS_PANEL);
0280:                    //PluginsTools.activateAssociatedPlgs(UICompCst.AUTOMATED_TEST_ATTACHMENTS_BUTTONS_PANEL);
0281:                    break;
0282:                }
0283:                case TESTLIST: {
0284:                    SalomeTMF.addToUIComponentsMap(
0285:                            UICompCst.TESTLIST_ATTACHMENTS_PANEL,
0286:                            attachmentsPanel);
0287:                    UICompCst.staticUIComps
0288:                            .add(UICompCst.TESTLIST_ATTACHMENTS_PANEL);
0289:                    //PluginsTools.activateAssociatedPlgs(UICompCst.TESTLIST_ATTACHMENTS_PANEL);
0290:
0291:                    SalomeTMF.addToUIComponentsMap(
0292:                            UICompCst.TESTLIST_ATTACHMENTS_TABLE,
0293:                            attachmentTable);
0294:                    UICompCst.staticUIComps
0295:                            .add(UICompCst.TESTLIST_ATTACHMENTS_TABLE);
0296:                    //PluginsTools.activateAssociatedPlgs(UICompCst.TESTLIST_ATTACHMENTS_TABLE);
0297:
0298:                    SalomeTMF.addToUIComponentsMap(
0299:                            UICompCst.TESTLIST_ATTACHMENTS_BUTTONS_PANEL,
0300:                            allButtons);
0301:                    UICompCst.staticUIComps
0302:                            .add(UICompCst.TESTLIST_ATTACHMENTS_BUTTONS_PANEL);
0303:                    //PluginsTools.activateAssociatedPlgs(UICompCst.TESTLIST_ATTACHMENTS_BUTTONS_PANEL);
0304:                    break;
0305:                }
0306:                case CAMPAIGN: {
0307:                    SalomeTMF.addToUIComponentsMap(
0308:                            UICompCst.CAMP_ATTACHMENTS_PANEL, attachmentsPanel);
0309:                    UICompCst.staticUIComps
0310:                            .add(UICompCst.CAMP_ATTACHMENTS_PANEL);
0311:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_PANEL);
0312:
0313:                    SalomeTMF.addToUIComponentsMap(
0314:                            UICompCst.CAMP_ATTACHMENTS_TABLE, attachmentTable);
0315:                    UICompCst.staticUIComps
0316:                            .add(UICompCst.CAMP_ATTACHMENTS_TABLE);
0317:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_TABLE);
0318:
0319:                    SalomeTMF.addToUIComponentsMap(
0320:                            UICompCst.CAMP_ATTACHMENTS_BUTTONS_PANEL,
0321:                            allButtons);
0322:                    UICompCst.staticUIComps
0323:                            .add(UICompCst.CAMP_ATTACHMENTS_BUTTONS_PANEL);
0324:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_BUTTONS_PANEL);
0325:                    break;
0326:                }
0327:                default: {
0328:                    SalomeTMF.addToUIComponentsMap(UICompCst.ATTACHMENTS_PANEL,
0329:                            attachmentsPanel);
0330:                    PluginsTools
0331:                            .activateAssociatedPlgs(UICompCst.ATTACHMENTS_PANEL);
0332:
0333:                    SalomeTMF.addToUIComponentsMap(UICompCst.ATTACHMENTS_TABLE,
0334:                            attachmentTable);
0335:                    PluginsTools
0336:                            .activateAssociatedPlgs(UICompCst.ATTACHMENTS_TABLE);
0337:
0338:                    SalomeTMF.addToUIComponentsMap(
0339:                            UICompCst.ATTACHMENTS_BUTTONS_PANEL, allButtons);
0340:                    PluginsTools
0341:                            .activateAssociatedPlgs(UICompCst.ATTACHMENTS_BUTTONS_PANEL);
0342:                }
0343:                }
0344:            }
0345:
0346:            /**
0347:             *
0348:             * @param type
0349:             * @param app
0350:             * @param actionOrExecution
0351:             */
0352:            public void initData(int type, JApplet app,
0353:                    WithAttachment actionOrExecution, Execution execution,
0354:                    ExecutionResult executionResult, Test testInObservation) {
0355:                sourceType = type;
0356:
0357:                if (app != null) {
0358:                    applet = app;
0359:                } else {
0360:                    applet = DataModel.getApplet();
0361:                }
0362:
0363:                actionOrExecutionForModification = actionOrExecution;
0364:
0365:                DataModel.getAttachmentTableModel().clearTable();
0366:                WithAttachment withAttachment = null;
0367:                if (type == CAMPAIGN) {
0368:                    withAttachment = DataModel.getCurrentCampaign();
0369:                } else if (type == TESTLIST) {
0370:                    withAttachment = DataModel.getCurrentTestList();
0371:                } else if (type == TEST) {
0372:                    withAttachment = DataModel.getCurrentTest();
0373:                } else if (type == ACTION) {
0374:                    withAttachment = DataModel.getCurrentAction();
0375:                } else if (type == EXECUTION) {
0376:                    withAttachment = DataModel.getObservedExecution();
0377:                } else if (type == EXECUTION_RESULT) {
0378:                    withAttachment = DataModel.getObservedExecutionResult();
0379:                } else if (type == EXECUTION_RESULT_TEST) {
0380:                    withAttachment = DataModel.getCurrentExecutionTestResult();
0381:                } else if (type == ENVIRONMENT) {
0382:                    withAttachment = DataModel.getCurrentEnvironment();
0383:                }
0384:
0385:                if ((type == ACTION || type == EXECUTION
0386:                        || type == EXECUTION_RESULT
0387:                        || type == EXECUTION_RESULT_TEST
0388:                        || type == EXECUTION_RESULT_TEST || type == ENVIRONMENT)
0389:                        && actionOrExecution == null) {
0390:                    attachmentMap = new HashMap();
0391:                } else if (type == ACTION || type == EXECUTION
0392:                        || type == EXECUTION_RESULT
0393:                        || type == EXECUTION_RESULT_TEST || type == ENVIRONMENT) {
0394:                    Set keysSet = actionOrExecution.getAttachmentMap().keySet();
0395:                    attachmentMap = new HashMap();
0396:                    for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
0397:                        Object elem = iter.next();
0398:                        attachmentMap.put(elem, actionOrExecution
0399:                                .getAttachmentMap().get(elem));
0400:                    }
0401:                }
0402:                if (withAttachment != null) {
0403:                    Collection keysSet = withAttachment.getAttachmentMap()
0404:                            .values();
0405:                    int i = 0;
0406:                    for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
0407:                        Attachment attach = (Attachment) iter.next();
0408:                        if (attach instanceof  FileAttachment) {
0409:                            DataModel.getAttachmentTableModel().addValueAt(
0410:                                    ((FileAttachment) attach).getName(), i, 0);
0411:                            DataModel.getAttachmentTableModel().addValueAt(
0412:                                    ((FileAttachment) attach).getSize()
0413:                                            .toString(), i, 1);
0414:                            DataModel.getAttachmentTableModel().addValueAt(
0415:                                    ((FileAttachment) attach).getDate()
0416:                                            .toString(), i, 2);
0417:                        } else {
0418:                            DataModel.getAttachmentTableModel().addValueAt(
0419:                                    ((UrlAttachment) attach).getName(), i, 0);
0420:                            DataModel.getAttachmentTableModel().addValueAt("",
0421:                                    i, 1);
0422:                            DataModel.getAttachmentTableModel().addValueAt("",
0423:                                    i, 2);
0424:                        }
0425:                        i++;
0426:                    }
0427:                }
0428:                exec = execution;
0429:                observedTest = testInObservation;
0430:                execResult = executionResult;
0431:            }
0432:
0433:            public static HashMap getAttachmentMap() {
0434:                return attachmentMap;
0435:            }
0436:
0437:            public class AttachmentDescriptionListener implements 
0438:                    CaretListener, IHMConstants {
0439:
0440:                /* (non-Javadoc)
0441:                 * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
0442:                 */
0443:                public void caretUpdate(CaretEvent e) {
0444:                    int[] selectedRows = attachmentTable.getSelectedRows();
0445:                    Attachment at = null;
0446:                    if (selectedRows.length == 1
0447:                            && ((JTextArea) e.getSource()).isEditable()) {
0448:
0449:                        int selectedRow = selectedRows[0];
0450:                        if (selectedRow != -1) {
0451:                            switch (sourceType) {
0452:                            case CAMPAIGN: {
0453:                                at = DataModel.getCurrentCampaign()
0454:                                        .getAttachment(
0455:                                                (String) sorter.getValueAt(
0456:                                                        selectedRow, 0));
0457:
0458:                                break;
0459:                            }
0460:                            case TESTLIST: {
0461:                                at = DataModel.getCurrentTestList()
0462:                                        .getAttachment(
0463:                                                (String) sorter.getValueAt(
0464:                                                        selectedRow, 0));
0465:
0466:                                break;
0467:                            }
0468:                            case TEST: {
0469:                                at = DataModel.getCurrentTest().getAttachment(
0470:                                        (String) sorter.getValueAt(selectedRow,
0471:                                                0));
0472:
0473:                                break;
0474:                            }
0475:                            case ACTION: {
0476:                                at = DataModel.getCurrentAction()
0477:                                        .getAttachment(
0478:                                                (String) sorter.getValueAt(
0479:                                                        selectedRow, 0));
0480:
0481:                                break;
0482:                            }
0483:                            case EXECUTION: {
0484:                                if (DataModel.getObservedExecution() != null)
0485:                                    at = DataModel.getObservedExecution()
0486:                                            .getAttachment(
0487:                                                    (String) sorter.getValueAt(
0488:                                                            selectedRow, 0));
0489:
0490:                                break;
0491:                            }
0492:                            case EXECUTION_RESULT: {
0493:                                at = DataModel.getObservedExecutionResult()
0494:                                        .getAttachment(
0495:                                                (String) sorter.getValueAt(
0496:                                                        selectedRow, 0));
0497:
0498:                                break;
0499:                            }
0500:
0501:                            case EXECUTION_RESULT_TEST: {
0502:                                at = DataModel.getCurrentExecutionTestResult()
0503:                                        .getAttachment(
0504:                                                (String) sorter.getValueAt(
0505:                                                        selectedRow, 0));
0506:
0507:                                break;
0508:                            }
0509:                            case ENVIRONMENT: {
0510:                                at = DataModel.getCurrentEnvironment()
0511:                                        .getAttachment(
0512:                                                (String) sorter.getValueAt(
0513:                                                        selectedRow, 0));
0514:
0515:                                break;
0516:                            }
0517:                            }
0518:
0519:                            try {
0520:                                if (at != null) {
0521:                                    at
0522:                                            .updateAttachDescriptionInDB(((JTextArea) e
0523:                                                    .getSource()).getText());
0524:                                    at.setDescription(((JTextArea) e
0525:                                            .getSource()).getText());
0526:                                } else {
0527:                                    ((Attachment) attachmentMap.get(sorter
0528:                                            .getValueAt(selectedRow, 0)))
0529:                                            .setDescription(((JTextArea) e
0530:                                                    .getSource()).getText());
0531:                                }
0532:
0533:                            } catch (Exception exception) {
0534:                                Tools.ihmExceptionView(exception.toString());
0535:                            }
0536:                        }
0537:                    }
0538:                }
0539:
0540:            }
0541:
0542:            private Attachment getAttachment(String attachName) {
0543:                return (Attachment) attachmentMap.get(attachName);
0544:            }
0545:
0546:            public void giveAccessToIhmScriptView() {
0547:                switch (sourceType) {
0548:                case CAMPAIGN: {
0549:                    allowCampaign();
0550:                    break;
0551:                }
0552:                case TESTLIST: {
0553:                    allowTest();
0554:                    break;
0555:                }
0556:                case TEST: {
0557:                    allowTest();
0558:                    break;
0559:                }
0560:                case ACTION: {
0561:                    allowTest();
0562:                    break;
0563:                }
0564:                case EXECUTION: {
0565:                    allowCampaign();
0566:                    break;
0567:                }
0568:                case EXECUTION_RESULT: {
0569:                    allowCampaignExec();
0570:                    break;
0571:                }
0572:                case EXECUTION_RESULT_TEST: {
0573:                    allowCampaignExec();
0574:                    break;
0575:                }
0576:                }
0577:
0578:            }
0579:
0580:            private void allowTest() {
0581:                if (!AdminProject.canDeleteTest()) {
0582:                    delAttach.setEnabled(false);
0583:                }
0584:                if (!AdminProject.canCreateTest()) {
0585:                    addFileAttach.setEnabled(false);
0586:
0587:                    addUrlAttach.setEnabled(false);
0588:                } else {
0589:                    addFileAttach.setEnabled(true);
0590:
0591:                    addUrlAttach.setEnabled(true);
0592:                }
0593:                if (!AdminProject.canUpdateTest()) {
0594:                    modifyButton.setEnabled(false);
0595:                    descriptionArea.setEditable(false);
0596:                }
0597:            }
0598:
0599:            private void allowCampaign() {
0600:                if (!AdminProject.canDeleteCamp()) {
0601:                    delAttach.setEnabled(false);
0602:                }
0603:                if (!AdminProject.canCreateCamp()) {
0604:                    addFileAttach.setEnabled(false);
0605:
0606:                    addUrlAttach.setEnabled(false);
0607:                } else {
0608:                    addFileAttach.setEnabled(true);
0609:
0610:                    addUrlAttach.setEnabled(true);
0611:                }
0612:                if (!AdminProject.canUpdateCamp()) {
0613:                    modifyButton.setEnabled(false);
0614:                    descriptionArea.setEditable(false);
0615:                }
0616:
0617:            }
0618:
0619:            private void allowCampaignExec() {
0620:                if (!AdminProject.canExecutCamp()) {
0621:                    delAttach.setEnabled(false);
0622:                    addFileAttach.setEnabled(false);
0623:                    addUrlAttach.setEnabled(false);
0624:                    modifyButton.setEnabled(false);
0625:                    descriptionArea.setEditable(false);
0626:                }
0627:
0628:            }
0629:
0630:            public void actionPerformed(java.awt.event.ActionEvent e) {
0631:                Object source = e.getSource();
0632:                if (source.equals(openAttach)) {
0633:                    openPerformed(e);
0634:                } else if (source.equals(addFileAttach)) {
0635:                    addFileAttachPerformed(e);
0636:                } else if (source.equals(addUrlAttach)) {
0637:                    addUrlAttachPerformed(e);
0638:                } else if (source.equals(modifyButton)) {
0639:                    modifyButtonPerformed(e);
0640:                } else if (source.equals(delAttach)) {
0641:                    delAttachPerformed(e);
0642:                }
0643:
0644:            }
0645:
0646:            public void openPerformed(ActionEvent e) {
0647:                int selectedRow = attachmentTable.getSelectedRow();
0648:                if (selectedRow != -1) {
0649:                    URL recup = null;
0650:                    File file = null;
0651:                    FileAttachment at = null;
0652:                    String fileName = null;
0653:
0654:                    switch (sourceType) {
0655:                    case CAMPAIGN: {
0656:
0657:                        if (DataModel.getCurrentCampaign().getAttachment(
0658:                                (String) sorter.getValueAt(selectedRow, 0)) instanceof  FileAttachment) {
0659:                            if (ConnectionData.isConnected()) {
0660:
0661:                                try {
0662:                                    file = ((FileAttachment) DataModel
0663:                                            .getCurrentCampaign()
0664:                                            .getAttachment(
0665:                                                    (String) sorter.getValueAt(
0666:                                                            selectedRow, 0)))
0667:                                            .getFileFromDB();
0668:                                } catch (Exception exception) {
0669:                                    Tools
0670:                                            .ihmExceptionView(exception
0671:                                                    .toString());
0672:                                }
0673:                                fileName = file.getAbsolutePath();
0674:
0675:                                DataModel.getCurrentCampaign().getAttachment(
0676:                                        (String) sorter.getValueAt(selectedRow,
0677:                                                0)).setLocalisation(
0678:                                        file.getAbsolutePath());
0679:                            } else {
0680:
0681:                                fileName = ((FileAttachment) DataModel
0682:                                        .getCurrentCampaign().getAttachment(
0683:                                                (String) sorter.getValueAt(
0684:                                                        selectedRow, 0)))
0685:                                        .getLocalisation();
0686:                            }
0687:                        } else {
0688:                            try {
0689:
0690:                                recup = new URL((String) sorter.getValueAt(
0691:                                        selectedRow, 0));
0692:                            } catch (MalformedURLException me) {
0693:                                me.printStackTrace();
0694:                            }
0695:                        }
0696:                        break;
0697:                    }
0698:
0699:                    case TESTLIST: {
0700:
0701:                        if (DataModel.getCurrentTestList().getAttachment(
0702:                                (String) sorter.getValueAt(selectedRow, 0)) instanceof  FileAttachment) {
0703:                            if (ConnectionData.isConnected()) {
0704:                                try {
0705:                                    file = ((FileAttachment) DataModel
0706:                                            .getCurrentTestList()
0707:                                            .getAttachment(
0708:                                                    (String) sorter.getValueAt(
0709:                                                            selectedRow, 0)))
0710:                                            .getFileFromDB();
0711:                                } catch (Exception exception) {
0712:                                    Tools
0713:                                            .ihmExceptionView(exception
0714:                                                    .toString());
0715:                                }
0716:                                fileName = file.getAbsolutePath();
0717:
0718:                                DataModel.getCurrentTestList().getAttachment(
0719:                                        (String) sorter.getValueAt(selectedRow,
0720:                                                0)).setLocalisation(
0721:                                        file.getAbsolutePath());
0722:                            } else {
0723:
0724:                                fileName = ((FileAttachment) DataModel
0725:                                        .getCurrentTestList().getAttachment(
0726:                                                (String) sorter.getValueAt(
0727:                                                        selectedRow, 0)))
0728:                                        .getLocalisation();
0729:                            }
0730:                        } else {
0731:                            try {
0732:
0733:                                recup = new URL((String) sorter.getValueAt(
0734:                                        selectedRow, 0));
0735:                            } catch (MalformedURLException me) {
0736:                                me.printStackTrace();
0737:                            }
0738:                        }
0739:                        break;
0740:                    }
0741:                    case TEST: {
0742:
0743:                        if (DataModel.getCurrentTest().getAttachment(
0744:                                (String) sorter.getValueAt(selectedRow, 0)) instanceof  FileAttachment) {
0745:                            if (ConnectionData.isConnected()) {
0746:                                try {
0747:                                    file = ((FileAttachment) DataModel
0748:                                            .getCurrentTest().getAttachment(
0749:                                                    (String) sorter.getValueAt(
0750:                                                            selectedRow, 0)))
0751:                                            .getFileFromDB();
0752:                                } catch (Exception exception) {
0753:                                    Tools
0754:                                            .ihmExceptionView(exception
0755:                                                    .toString());
0756:                                }
0757:                                fileName = file.getAbsolutePath();
0758:
0759:                                DataModel.getCurrentTest().getAttachment(
0760:                                        (String) sorter.getValueAt(selectedRow,
0761:                                                0)).setLocalisation(
0762:                                        file.getAbsolutePath());
0763:                            } else {
0764:
0765:                                fileName = ((FileAttachment) DataModel
0766:                                        .getCurrentTest().getAttachment(
0767:                                                (String) sorter.getValueAt(
0768:                                                        selectedRow, 0)))
0769:                                        .getLocalisation();
0770:                            }
0771:                        } else {
0772:                            try {
0773:
0774:                                recup = new URL((String) sorter.getValueAt(
0775:                                        selectedRow, 0));
0776:                            } catch (MalformedURLException me) {
0777:                                me.printStackTrace();
0778:                            }
0779:                        }
0780:                        break;
0781:                    }
0782:
0783:                    case ACTION: {
0784:
0785:                        if (getAttachment((String) sorter.getValueAt(
0786:                                selectedRow, 0)) instanceof  FileAttachment) {
0787:                            if (ConnectionData.isConnected()
0788:                                    && actionOrExecutionForModification != null) {
0789:                                at = (FileAttachment) DataModel
0790:                                        .getCurrentAction().getAttachment(
0791:                                                (String) sorter.getValueAt(
0792:                                                        selectedRow, 0));
0793:                                if (at == null) {
0794:                                    JOptionPane
0795:                                            .showMessageDialog(
0796:                                                    AttachmentView.this ,
0797:                                                    Language
0798:                                                            .getInstance()
0799:                                                            .getText(
0800:                                                                    "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_visualiser!"),
0801:                                                    Language
0802:                                                            .getInstance()
0803:                                                            .getText("Erreur_!"),
0804:                                                    JOptionPane.ERROR_MESSAGE);
0805:                                } else {
0806:                                    try {
0807:                                        file = at.getFileFromDB();
0808:                                    } catch (Exception exception) {
0809:                                        Tools.ihmExceptionView(exception
0810:                                                .toString());
0811:                                    }
0812:                                    fileName = file.getAbsolutePath();
0813:                                    getAttachment(
0814:                                            (String) sorter.getValueAt(
0815:                                                    selectedRow, 0))
0816:                                            .setLocalisation(
0817:                                                    file.getAbsolutePath());
0818:                                }
0819:                            } else {
0820:                                fileName = ((FileAttachment) getAttachment((String) sorter
0821:                                        .getValueAt(selectedRow, 0)))
0822:                                        .getLocalisation();
0823:                            }
0824:                        } else {
0825:                            try {
0826:                                recup = new URL((String) sorter.getValueAt(
0827:                                        selectedRow, 0));
0828:                            } catch (MalformedURLException me) {
0829:                                me.printStackTrace();
0830:                            }
0831:                        }
0832:                        break;
0833:                    }
0834:
0835:                    case EXECUTION: {
0836:                        if (getAttachment((String) sorter.getValueAt(
0837:                                selectedRow, 0)) instanceof  FileAttachment) {
0838:                            if (ConnectionData.isConnected()
0839:                                    && actionOrExecutionForModification != null) {
0840:                                at = (FileAttachment) DataModel
0841:                                        .getObservedExecution().getAttachment(
0842:                                                (String) sorter.getValueAt(
0843:                                                        selectedRow, 0));
0844:                                if (at == null) {
0845:                                    JOptionPane
0846:                                            .showMessageDialog(
0847:                                                    AttachmentView.this ,
0848:                                                    Language
0849:                                                            .getInstance()
0850:                                                            .getText(
0851:                                                                    "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_visualiser!"),
0852:                                                    Language
0853:                                                            .getInstance()
0854:                                                            .getText("Erreur_!"),
0855:                                                    JOptionPane.ERROR_MESSAGE);
0856:                                } else {
0857:                                    try {
0858:                                        file = at.getFileFromDB();
0859:                                    } catch (Exception exception) {
0860:                                        Tools.ihmExceptionView(exception
0861:                                                .toString());
0862:                                    }
0863:                                    fileName = file.getAbsolutePath();
0864:                                    getAttachment(
0865:                                            (String) sorter.getValueAt(
0866:                                                    selectedRow, 0))
0867:                                            .setLocalisation(
0868:                                                    file.getAbsolutePath());
0869:                                }
0870:                            } else {
0871:                                fileName = ((FileAttachment) getAttachment((String) sorter
0872:                                        .getValueAt(selectedRow, 0)))
0873:                                        .getLocalisation();
0874:                            }
0875:                        } else {
0876:                            try {
0877:                                recup = new URL((String) sorter.getValueAt(
0878:                                        selectedRow, 0));
0879:                            } catch (MalformedURLException me) {
0880:                                me.printStackTrace();
0881:                            }
0882:                        }
0883:                        break;
0884:                    }
0885:
0886:                    case EXECUTION_RESULT: {
0887:                        if (getAttachment((String) sorter.getValueAt(
0888:                                selectedRow, 0)) instanceof  FileAttachment) {
0889:                            if (ConnectionData.isConnected()
0890:                                    && actionOrExecutionForModification != null) {
0891:                                at = (FileAttachment) DataModel
0892:                                        .getObservedExecutionResult()
0893:                                        .getAttachment(
0894:                                                (String) sorter.getValueAt(
0895:                                                        selectedRow, 0));
0896:                                if (at == null) {
0897:                                    JOptionPane
0898:                                            .showMessageDialog(
0899:                                                    AttachmentView.this ,
0900:                                                    Language
0901:                                                            .getInstance()
0902:                                                            .getText(
0903:                                                                    "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_visualiser!"),
0904:                                                    Language
0905:                                                            .getInstance()
0906:                                                            .getText("Erreur_!"),
0907:                                                    JOptionPane.ERROR_MESSAGE);
0908:                                } else {
0909:                                    try {
0910:                                        file = at.getFileFromDB();
0911:                                    } catch (Exception exception) {
0912:                                        Tools.ihmExceptionView(exception
0913:                                                .toString());
0914:                                    }
0915:                                    fileName = file.getAbsolutePath();
0916:                                    getAttachment(
0917:                                            (String) sorter.getValueAt(
0918:                                                    selectedRow, 0))
0919:                                            .setLocalisation(
0920:                                                    file.getAbsolutePath());
0921:                                }
0922:                            } else {
0923:                                fileName = ((FileAttachment) getAttachment((String) sorter
0924:                                        .getValueAt(selectedRow, 0)))
0925:                                        .getLocalisation();
0926:                            }
0927:                        } else {
0928:                            try {
0929:                                recup = new URL((String) sorter.getValueAt(
0930:                                        selectedRow, 0));
0931:                            } catch (MalformedURLException me) {
0932:                                me.printStackTrace();
0933:                            }
0934:                        }
0935:                        break;
0936:                    }
0937:
0938:                    case EXECUTION_RESULT_TEST: {
0939:                        if (getAttachment((String) sorter.getValueAt(
0940:                                selectedRow, 0)) instanceof  FileAttachment) {
0941:                            if (ConnectionData.isConnected()
0942:                                    && actionOrExecutionForModification != null) {
0943:                                at = (FileAttachment) DataModel
0944:                                        .getCurrentExecutionTestResult()
0945:                                        .getAttachment(
0946:                                                (String) sorter.getValueAt(
0947:                                                        selectedRow, 0));
0948:                                if (at == null) {
0949:                                    JOptionPane
0950:                                            .showMessageDialog(
0951:                                                    AttachmentView.this ,
0952:                                                    Language
0953:                                                            .getInstance()
0954:                                                            .getText(
0955:                                                                    "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_visualiser!"),
0956:                                                    Language
0957:                                                            .getInstance()
0958:                                                            .getText("Erreur_!"),
0959:                                                    JOptionPane.ERROR_MESSAGE);
0960:                                } else {
0961:                                    try {
0962:                                        file = at.getFileFromDB();
0963:                                    } catch (Exception exception) {
0964:                                        Tools.ihmExceptionView(exception
0965:                                                .toString());
0966:                                    }
0967:                                    fileName = file.getAbsolutePath();
0968:                                    getAttachment(
0969:                                            (String) sorter.getValueAt(
0970:                                                    selectedRow, 0))
0971:                                            .setLocalisation(
0972:                                                    file.getAbsolutePath());
0973:                                }
0974:                            } else {
0975:                                fileName = ((FileAttachment) getAttachment((String) sorter
0976:                                        .getValueAt(selectedRow, 0)))
0977:                                        .getLocalisation();
0978:                            }
0979:                        } else {
0980:                            try {
0981:                                recup = new URL((String) sorter.getValueAt(
0982:                                        selectedRow, 0));
0983:                            } catch (MalformedURLException me) {
0984:                                me.printStackTrace();
0985:                            }
0986:                        }
0987:                        break;
0988:                    }
0989:                    case ENVIRONMENT: {
0990:                        if (getAttachment((String) sorter.getValueAt(
0991:                                selectedRow, 0)) instanceof  FileAttachment) {
0992:                            if (ConnectionData.isConnected()) {
0993:                                at = (FileAttachment) DataModel
0994:                                        .getCurrentEnvironment().getAttachment(
0995:                                                (String) sorter.getValueAt(
0996:                                                        selectedRow, 0));
0997:                                if (at == null) {
0998:                                    JOptionPane
0999:                                            .showMessageDialog(
1000:                                                    AttachmentView.this ,
1001:                                                    Language
1002:                                                            .getInstance()
1003:                                                            .getText(
1004:                                                                    "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_visualiser!"),
1005:                                                    Language
1006:                                                            .getInstance()
1007:                                                            .getText("Erreur_!"),
1008:                                                    JOptionPane.ERROR_MESSAGE);
1009:                                } else {
1010:                                    try {
1011:                                        file = at.getFileFromDB();
1012:                                    } catch (Exception exception) {
1013:                                        Tools.ihmExceptionView(exception
1014:                                                .toString());
1015:                                    }
1016:                                    fileName = file.getAbsolutePath();
1017:                                    getAttachment(
1018:                                            (String) sorter.getValueAt(
1019:                                                    selectedRow, 0))
1020:                                            .setLocalisation(
1021:                                                    file.getAbsolutePath());
1022:                                }
1023:                            } else {
1024:                                fileName = ((FileAttachment) getAttachment((String) sorter
1025:                                        .getValueAt(selectedRow, 0)))
1026:                                        .getLocalisation();
1027:                            }
1028:                        } else {
1029:                            try {
1030:                                recup = new URL((String) sorter.getValueAt(
1031:                                        selectedRow, 0));
1032:                            } catch (MalformedURLException me) {
1033:                                me.printStackTrace();
1034:                            }
1035:                        }
1036:                        break;
1037:                    }
1038:
1039:                    }
1040:                    Properties sys = System.getProperties();
1041:                    String fileSeparator = sys.getProperty("file.separator");
1042:                    Runtime r = Runtime.getRuntime();
1043:                    try {
1044:                        if (!fileSeparator.equals("\\")
1045:                                && DataModel.isBadDirectoryView()) {
1046:                            new BadDirectoryView();
1047:                        }
1048:                        if (fileSeparator.equals("\\") && fileName != null) {
1049:
1050:                            r.exec("cmd /c call " + "\"" + fileName + "\"");
1051:
1052:                        } else if (fileName != null) {
1053:
1054:                            /* Affiche le document après avoir recupérer le contexte courant */
1055:
1056:                            applet.getAppletContext().showDocument(
1057:                                    new URL("file://" + fileName), "_blank");
1058:                        } else if (recup != null) {
1059:
1060:                            applet.getAppletContext().showDocument(recup,
1061:                                    "_blank");
1062:                        }
1063:                    } catch (IOException ex) {
1064:                        ex.printStackTrace();
1065:                    }
1066:                }
1067:            }
1068:
1069:            public void addFileAttachPerformed(ActionEvent e) {
1070:                boolean add = false;
1071:                JFileChooser fileChooser = new JFileChooser();
1072:                fileChooser.setApproveButtonText(Language.getInstance()
1073:                        .getText("Valider"));
1074:                int returnVal = fileChooser.showOpenDialog(AttachmentView.this );
1075:                if (returnVal == JFileChooser.APPROVE_OPTION) {
1076:                    File file = fileChooser.getSelectedFile();
1077:                    //Date dateOfFile = new Date(file.lastModified());
1078:                    FileAttachment fileAttachment = new FileAttachment();
1079:                    fileAttachment.setName(file.getName());
1080:                    fileAttachment.setLocalisation(file.getAbsolutePath());
1081:                    fileAttachment.setSize(new Long(file.length()));
1082:                    fileAttachment.setDate(new Date(file.lastModified()));
1083:                    //TODO
1084:                    String typeName = "";
1085:                    switch (sourceType) {
1086:                    case CAMPAIGN: {
1087:                        if (!DataModel.getCurrentCampaign().containsAttachment(
1088:                                fileAttachment.getName())) {
1089:
1090:                            try {
1091:                                // BdD
1092:                                DataModel.getCurrentCampaign()
1093:                                        .addAttachFile2DB(fileAttachment);
1094:
1095:                                // IHM
1096:                                DataModel.getCurrentCampaign().addAttachment(
1097:                                        fileAttachment);
1098:                                add = true;
1099:
1100:                            } catch (Exception exception) {
1101:                                Tools.ihmExceptionView(exception.toString());
1102:                            }
1103:                        }
1104:                        typeName = Language.getInstance().getText(
1105:                                "cette_campagne");
1106:                        break;
1107:                    }
1108:                    case TESTLIST: {
1109:                        if (!DataModel.getCurrentTestList().containsAttachment(
1110:                                fileAttachment.getName())) {
1111:
1112:                            try {
1113:                                DataModel.getCurrentTestList()
1114:                                        .addAttachFile2DB(fileAttachment);
1115:                                DataModel.getCurrentTestList().addAttachment(
1116:                                        fileAttachment);
1117:                                add = true;
1118:                            } catch (Exception exception) {
1119:                                Tools.ihmExceptionView(exception.toString());
1120:                            }
1121:                        }
1122:                        typeName = Language.getInstance().getText(
1123:                                "cette_suite_de_tests");
1124:                        break;
1125:                    }
1126:                    case TEST: {
1127:                        if (!DataModel.getCurrentTest().containsAttachment(
1128:                                fileAttachment.getName())) {
1129:
1130:                            try {
1131:                                //DataModel.getCurrentTest().addAttachFile2DB(fileAttachment);
1132:                                //DataModel.getCurrentTest().addAttachment(fileAttachment);
1133:                                DataModel.getCurrentTest()
1134:                                        .addAttachInBddAndModel(fileAttachment);
1135:                                add = true;
1136:                            } catch (Exception exception) {
1137:                                Tools.ihmExceptionView(exception.toString());
1138:                            }
1139:                        }
1140:                        typeName = Language.getInstance().getText("ce_test");
1141:                        break;
1142:                    }
1143:                    case ACTION: {
1144:                        attachmentMap.put(fileAttachment.getName(),
1145:                                fileAttachment);
1146:                        add = true;
1147:                        typeName = Language.getInstance().getText(
1148:                                "cette_action");
1149:                        break;
1150:                    }
1151:                    case EXECUTION: {
1152:                        attachmentMap.put(fileAttachment.getName(),
1153:                                fileAttachment);
1154:                        add = true;
1155:                        typeName = Language.getInstance().getText(
1156:                                "cette_exécution");
1157:                        break;
1158:                    }
1159:                    case EXECUTION_RESULT: {
1160:                        attachmentMap.put(fileAttachment.getName(),
1161:                                fileAttachment);
1162:                        add = true;
1163:                        typeName = Language.getInstance().getText(
1164:                                "ce_résultat_d'exécution");
1165:                        break;
1166:                    }
1167:                    case EXECUTION_RESULT_TEST: {
1168:                        attachmentMap.put(fileAttachment.getName(),
1169:                                fileAttachment);
1170:                        add = true;
1171:                        typeName = Language.getInstance().getText(
1172:                                "ce_résultat_d'exécution_de_test");
1173:                        break;
1174:                    }
1175:                    case ENVIRONMENT: {
1176:                        attachmentMap.put(fileAttachment.getName(),
1177:                                fileAttachment);
1178:                        add = true;
1179:                        typeName = Language.getInstance().getText(
1180:                                "cet_environnement_sous_test");
1181:                        break;
1182:                    }
1183:
1184:                    }
1185:                    if (add) {
1186:                        ArrayList data = new ArrayList();
1187:                        data.add(file.getName());
1188:                        data.add(new Long(file.length()).toString());
1189:                        data.add(new Date(file.lastModified()).toString());
1190:                        DataModel.getAttachmentTableModel().addRow(data);
1191:
1192:                    } else {
1193:                        JOptionPane.showMessageDialog(AttachmentView.this ,
1194:                                Language.getInstance().getText("Le_fichier_")
1195:                                        + file.getAbsolutePath()
1196:                                        + Language.getInstance().getText(
1197:                                                "_est_déjà_attaché_à_")
1198:                                        + typeName + " !", Language
1199:                                        .getInstance().getText("Erreur_!"),
1200:                                JOptionPane.ERROR_MESSAGE);
1201:                    }
1202:                }
1203:            }
1204:
1205:            public void addUrlAttachPerformed(ActionEvent e) {
1206:
1207:                AskName askName = new AskName(Language.getInstance().getText(
1208:                        "Entrez_une_URL_:"), Language.getInstance().getText(
1209:                        "Attacher_une_URL"), Language.getInstance().getText(
1210:                        "url"), null, SalomeTMF.ptrFrame);
1211:                if (askName.getResult() != null) {
1212:                    boolean add = false;
1213:                    UrlAttachment urlAttachment = new UrlAttachment();
1214:                    try {
1215:                        URL url = new URL(askName.getResult());
1216:                        urlAttachment.setName(askName.getResult());
1217:                        urlAttachment.setUrl(url);
1218:                        String typeName = "";
1219:                        switch (sourceType) {
1220:                        case CAMPAIGN: {
1221:                            if (!DataModel
1222:                                    .getCurrentCampaign()
1223:                                    .containsAttachment(urlAttachment.getName())) {
1224:
1225:                                try {
1226:                                    // BdD
1227:                                    DataModel.getCurrentCampaign()
1228:                                            .addAttachUrl2DB(urlAttachment);
1229:                                    // IHM
1230:                                    DataModel.getCurrentCampaign()
1231:                                            .addAttachment(urlAttachment);
1232:                                    add = true;
1233:                                } catch (Exception exception) {
1234:                                    Tools
1235:                                            .ihmExceptionView(exception
1236:                                                    .toString());
1237:                                }
1238:                            }
1239:                            typeName = Language.getInstance().getText(
1240:                                    "cette_campagne");
1241:                            break;
1242:                        }
1243:                        case TESTLIST: {
1244:                            if (!DataModel
1245:                                    .getCurrentTestList()
1246:                                    .containsAttachment(urlAttachment.getName())) {
1247:
1248:                                try {
1249:                                    DataModel.getCurrentTestList()
1250:                                            .addAttachUrl2DB(urlAttachment);
1251:                                    DataModel.getCurrentTestList()
1252:                                            .addAttachment(urlAttachment);
1253:                                    add = true;
1254:                                } catch (Exception exception) {
1255:                                    Tools
1256:                                            .ihmExceptionView(exception
1257:                                                    .toString());
1258:                                }
1259:                            }
1260:                            typeName = Language.getInstance().getText(
1261:                                    "cette_suite_de_tests");
1262:                            break;
1263:                        }
1264:                        case TEST: {
1265:                            if (!DataModel.getCurrentTest().containsAttachment(
1266:                                    urlAttachment.getName())) {
1267:
1268:                                try {
1269:                                    //DataModel.getCurrentTest().addAttachUrl2DB(urlAttachment);
1270:                                    //DataModel.getCurrentTest().addAttachment(urlAttachment);
1271:                                    DataModel.getCurrentTest()
1272:                                            .addAttachInBddAndModel(
1273:                                                    urlAttachment);
1274:                                    add = true;
1275:                                } catch (Exception exception) {
1276:                                    Tools
1277:                                            .ihmExceptionView(exception
1278:                                                    .toString());
1279:                                }
1280:                            }
1281:
1282:                            typeName = Language.getInstance()
1283:                                    .getText("ce_test");
1284:                            break;
1285:                        }
1286:                        case ACTION: {
1287:                            attachmentMap.put(urlAttachment.getName(),
1288:                                    urlAttachment);
1289:                            add = true;
1290:                            typeName = Language.getInstance().getText(
1291:                                    "cette_action");
1292:                            break;
1293:                        }
1294:                        case EXECUTION: {
1295:                            attachmentMap.put(urlAttachment.getName(),
1296:                                    urlAttachment);
1297:                            add = true;
1298:                            typeName = Language.getInstance().getText(
1299:                                    "cette_exécution");
1300:                            break;
1301:                        }
1302:                        case EXECUTION_RESULT: {
1303:                            attachmentMap.put(urlAttachment.getName(),
1304:                                    urlAttachment);
1305:                            add = true;
1306:                            typeName = Language.getInstance().getText(
1307:                                    "ce_résultat_d'exécution");
1308:                            break;
1309:                        }
1310:                        case EXECUTION_RESULT_TEST: {
1311:                            attachmentMap.put(urlAttachment.getName(),
1312:                                    urlAttachment);
1313:                            add = true;
1314:                            typeName = Language.getInstance().getText(
1315:                                    "ce_résultat_d'exécution_de_test");
1316:                            break;
1317:                        }
1318:                        case ENVIRONMENT: {
1319:                            attachmentMap.put(urlAttachment.getName(),
1320:                                    urlAttachment);
1321:                            add = true;
1322:                            typeName = Language.getInstance().getText(
1323:                                    "cet_environnement_sous_test");
1324:                            break;
1325:                        }
1326:
1327:                        }
1328:                        if (add) {
1329:                            ArrayList data = new ArrayList();
1330:                            data.add(urlAttachment.getName());
1331:                            data.add("");
1332:                            data.add("");
1333:                            DataModel.getAttachmentTableModel().addRow(data);
1334:                        } else {
1335:                            JOptionPane.showMessageDialog(AttachmentView.this ,
1336:                                    Language.getInstance().getText("L'url_")
1337:                                            + urlAttachment.getName()
1338:                                            + Language.getInstance().getText(
1339:                                                    "_est_déjà_attachée_à_")
1340:                                            + typeName + " !", Language
1341:                                            .getInstance().getText("Erreur_!"),
1342:                                    JOptionPane.ERROR_MESSAGE);
1343:                        }
1344:                    } catch (MalformedURLException mue) {
1345:                        JOptionPane.showMessageDialog(AttachmentView.this ,
1346:                                Language.getInstance().getText("L'url_")
1347:                                        + urlAttachment.getName()
1348:                                        + Language.getInstance().getText(
1349:                                                "_est_mal_formée_!"), Language
1350:                                        .getInstance().getText("Erreur_!"),
1351:                                JOptionPane.ERROR_MESSAGE);
1352:                    }
1353:
1354:                }
1355:            }
1356:
1357:            public void modifyButtonPerformed(ActionEvent e) {
1358:
1359:                int selectedRow = attachmentTable.getSelectedRow();
1360:                Attachment at = null;
1361:                if (selectedRow != -1) {
1362:                    switch (sourceType) {
1363:                    case CAMPAIGN: {
1364:                        at = DataModel.getCurrentCampaign().getAttachment(
1365:                                (String) sorter.getValueAt(selectedRow, 0));
1366:
1367:                        break;
1368:                    }
1369:                    case TESTLIST: {
1370:                        at = DataModel.getCurrentTestList().getAttachment(
1371:                                (String) sorter.getValueAt(selectedRow, 0));
1372:
1373:                        break;
1374:                    }
1375:                    case TEST: {
1376:                        at = DataModel.getCurrentTest().getAttachment(
1377:                                (String) sorter.getValueAt(selectedRow, 0));
1378:
1379:                        break;
1380:                    }
1381:                    case ACTION: {
1382:                        at = DataModel.getCurrentAction().getAttachment(
1383:                                (String) sorter.getValueAt(selectedRow, 0));
1384:
1385:                        break;
1386:                    }
1387:                    case EXECUTION: {
1388:                        at = DataModel.getObservedExecution().getAttachment(
1389:                                (String) sorter.getValueAt(selectedRow, 0));
1390:
1391:                        break;
1392:                    }
1393:                    case EXECUTION_RESULT: {
1394:                        at = DataModel.getObservedExecutionResult()
1395:                                .getAttachment(
1396:                                        (String) sorter.getValueAt(selectedRow,
1397:                                                0));
1398:
1399:                        break;
1400:                    }
1401:
1402:                    case EXECUTION_RESULT_TEST: {
1403:                        at = DataModel.getCurrentExecutionTestResult()
1404:                                .getAttachment(
1405:                                        (String) sorter.getValueAt(selectedRow,
1406:                                                0));
1407:
1408:                        break;
1409:                    }
1410:                    case ENVIRONMENT: {
1411:                        at = DataModel.getCurrentEnvironment().getAttachment(
1412:                                (String) sorter.getValueAt(selectedRow, 0));
1413:
1414:                        break;
1415:                    }
1416:                    }
1417:
1418:                    if (at == null) {
1419:                        JOptionPane
1420:                                .showMessageDialog(
1421:                                        AttachmentView.this ,
1422:                                        Language
1423:                                                .getInstance()
1424:                                                .getText(
1425:                                                        "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_modifier!"),
1426:                                        Language.getInstance().getText(
1427:                                                "Erreur_!"),
1428:                                        JOptionPane.ERROR_MESSAGE);
1429:                        return;
1430:                    } else {
1431:                        FileAttachment fileAttach = (FileAttachment) at;
1432:                        int transNumber = -1;
1433:                        try {
1434:                            transNumber = Api
1435:                                    .beginTransaction(Api.UPDATE_ATTACHMENT);
1436:                            // On récupère le flux du fichier après modification
1437:                            File file = new File(fileAttach.getLocalisation());
1438:                            if (!file.exists())
1439:                                return;
1440:                            FileInputStream fis = new FileInputStream(file);
1441:                            BufferedInputStream bis = new BufferedInputStream(
1442:                                    fis);
1443:                            // Mise à jour dans la BdD
1444:                            fileAttach.updateFileContentInDB(bis);
1445:                            fileAttach.updateFileDateInDB(fileAttach.getDate());
1446:                            fileAttach.updateFileLengthInDB(fileAttach
1447:                                    .getSize().longValue());
1448:                            bis.close();
1449:                            Api.commitTrans(transNumber);
1450:
1451:                            // Mise à jour dans l'IHM
1452:                            sorter.setValueAt(new Long(file.length())
1453:                                    .toString(), selectedRow, 1);
1454:                            sorter.setValueAt(new Date(file.lastModified())
1455:                                    .toString(), selectedRow, 2);
1456:                            file.delete();
1457:                            JOptionPane
1458:                                    .showMessageDialog(
1459:                                            AttachmentView.this ,
1460:                                            Language
1461:                                                    .getInstance()
1462:                                                    .getText(
1463:                                                            "Le_fichier_a_été_correctement_archivé."),
1464:                                            Language.getInstance().getText(
1465:                                                    "Info..."),
1466:                                            JOptionPane.INFORMATION_MESSAGE);
1467:
1468:                        } catch (Exception exception) {
1469:                            Api.forceRollBackTrans(transNumber);
1470:                            Tools.ihmExceptionView(exception.toString());
1471:                        }
1472:                    }
1473:                }
1474:            }
1475:
1476:            public void delAttachPerformed(ActionEvent e) {
1477:                Object[] options = { Language.getInstance().getText("Oui"),
1478:                        Language.getInstance().getText("Non") };
1479:                int choice = -1;
1480:                int selectedRow = attachmentTable.getSelectedRow();
1481:                if (selectedRow != -1) {
1482:                    choice = JOptionPane
1483:                            .showOptionDialog(
1484:                                    AttachmentView.this ,
1485:                                    //"Etes vous sûr de vouloir supprimer l'attachement <" + (String)DataModel.getAttachmentTableModel().getValueAt(selectedRow, 0) + "> ?",
1486:                                    Language
1487:                                            .getInstance()
1488:                                            .getText(
1489:                                                    "Etes_vous_sûr_de_vouloir_supprimer_l'attachement_<")
1490:                                            + (String) sorter.getValueAt(
1491:                                                    selectedRow, 0) + "> ?",
1492:                                    Language.getInstance().getText(
1493:                                            "Attention_!"),
1494:                                    JOptionPane.YES_NO_OPTION,
1495:                                    JOptionPane.QUESTION_MESSAGE, null,
1496:                                    options, options[1]);
1497:                    if (choice == JOptionPane.YES_OPTION) {
1498:
1499:                        switch (sourceType) {
1500:                        case CAMPAIGN: {
1501:
1502:                            try {
1503:                                // BdD
1504:                                Campaign camp = DataModel.getCurrentCampaign();
1505:                                Attachment attach = camp
1506:                                        .getAttachment((String) sorter
1507:                                                .getValueAt(selectedRow, 0));
1508:                                camp
1509:                                        .deleteAttachFromCampInDB(attach
1510:                                                .getIdBdd());
1511:
1512:                                // IHM
1513:                                DataModel.getCurrentCampaign()
1514:                                        .removeAttachment(
1515:                                                (String) sorter.getValueAt(
1516:                                                        selectedRow, 0));
1517:
1518:                            } catch (Exception exception) {
1519:                                Tools.ihmExceptionView(exception.toString());
1520:                            }
1521:                            break;
1522:                        }
1523:                        case TESTLIST: {
1524:
1525:                            try {
1526:                                // BdD
1527:                                TestList suite = DataModel.getCurrentTestList();
1528:                                Attachment attach = suite
1529:                                        .getAttachment((String) sorter
1530:                                                .getValueAt(selectedRow, 0));
1531:                                suite.deleteAttachInBddAndModel(attach);
1532:                                //suite.deleteAttachFromDB(attach.getIdBdd());
1533:
1534:                                // IHM
1535:                                //suite.removeAttachment((String)sorter.getValueAt(selectedRow, 0));
1536:                            } catch (Exception exception) {
1537:                                Tools.ihmExceptionView(exception.toString());
1538:                            }
1539:                            break;
1540:
1541:                        }
1542:                        case TEST: {
1543:
1544:                            try {
1545:                                // BdD
1546:                                Test test = DataModel.getCurrentTest();
1547:                                Attachment attach = test
1548:                                        .getAttachment((String) sorter
1549:                                                .getValueAt(selectedRow, 0));
1550:                                //test.deleteAttachFromDB(attach.getIdBdd());
1551:                                test.deleteAttachInBddAndModel(attach);
1552:                                // IHM
1553:                                //test.removeAttachment((String)sorter.getValueAt(selectedRow, 0));
1554:                            } catch (Exception exception) {
1555:                                Tools.ihmExceptionView(exception.toString());
1556:                            }
1557:                            break;
1558:
1559:                        }
1560:                        case ACTION: {
1561:
1562:                            try {
1563:                                // BdD
1564:                                Action action = DataModel.getCurrentAction();
1565:                                Attachment attach = action
1566:                                        .getAttachment((String) sorter
1567:                                                .getValueAt(selectedRow, 0));
1568:                                if (attach != null) {
1569:                                    action.deleteAttachToBddAndModel(attach);
1570:                                    //action.deleteAttachFromDB(attach.getIdBdd());
1571:                                }
1572:
1573:                                // IHM
1574:                                attachmentMap.remove(sorter.getValueAt(
1575:                                        selectedRow, 0));
1576:                                if (actionOrExecutionForModification != null) {
1577:                                    actionOrExecutionForModification
1578:                                            .removeAttachment((String) sorter
1579:                                                    .getValueAt(selectedRow, 0));
1580:                                }
1581:                            } catch (Exception exception) {
1582:                                Tools.ihmExceptionView(exception.toString());
1583:                            }
1584:                            break;
1585:
1586:                        }
1587:                        case EXECUTION: {
1588:
1589:                            try {
1590:                                // BdD
1591:                                Execution exec = DataModel
1592:                                        .getObservedExecution();
1593:                                Attachment attach = exec
1594:                                        .getAttachment((String) sorter
1595:                                                .getValueAt(selectedRow, 0));
1596:                                if (attach != null) {
1597:                                    exec
1598:                                            .deleteAttachFromExecInBddAndModel(attach);
1599:                                    //exec.deleteAttachFromExecInDB(attach.getIdBdd());
1600:                                }
1601:                                // IHM
1602:                                attachmentMap.remove(sorter.getValueAt(
1603:                                        selectedRow, 0));
1604:                                if (actionOrExecutionForModification != null) {
1605:                                    actionOrExecutionForModification
1606:                                            .removeAttachment((String) sorter
1607:                                                    .getValueAt(selectedRow, 0));
1608:                                }
1609:
1610:                            } catch (Exception exception) {
1611:                                Tools.ihmExceptionView(exception.toString());
1612:                            }
1613:
1614:                            break;
1615:                        }
1616:                        case EXECUTION_RESULT: {
1617:
1618:                            try {
1619:                                // BdD
1620:                                ExecutionResult execRes = DataModel
1621:                                        .getObservedExecutionResult();
1622:                                Attachment attach = execRes
1623:                                        .getAttachment((String) sorter
1624:                                                .getValueAt(selectedRow, 0));
1625:                                if (attach != null)
1626:                                    execRes
1627:                                            .deleteAttachFromExecResultInDB(attach
1628:                                                    .getIdBdd());
1629:
1630:                                // IHM
1631:                                attachmentMap.remove(sorter.getValueAt(
1632:                                        selectedRow, 0));
1633:                                if (actionOrExecutionForModification != null) {
1634:                                    actionOrExecutionForModification
1635:                                            .removeAttachment((String) sorter
1636:                                                    .getValueAt(selectedRow, 0));
1637:                                }
1638:                            } catch (Exception exception) {
1639:                                Tools.ihmExceptionView(exception.toString());
1640:                            }
1641:                            break;
1642:                        }
1643:
1644:                        case EXECUTION_RESULT_TEST: {
1645:
1646:                            /*if (Api.getException() == null || Api.getException().size() == 0) {
1647:                                attachmentMap.remove(sorter.getValueAt(selectedRow, 0));
1648:                                
1649:                                if (actionOrExecutionForModification !=null) {
1650:                                    actionOrExecutionForModification.removeAttachment((String)sorter.getValueAt(selectedRow, 0));
1651:                                }
1652:                                
1653:                            }*/
1654:                            try {
1655:                                // BdD
1656:                                ExecutionResult execRes = DataModel
1657:                                        .getObservedExecutionResult();
1658:                                ExecutionTestResult execTestRes = DataModel
1659:                                        .getCurrentExecutionTestResult();
1660:                                Attachment attach = execTestRes
1661:                                        .getAttachment((String) sorter
1662:                                                .getValueAt(selectedRow, 0));
1663:                                if (attach != null)
1664:                                    execRes.deleteAttachFromExecTestResultInDB(
1665:                                            execTestRes.getTest().getIdBDD(),
1666:                                            attach.getIdBdd());
1667:
1668:                                // IHM
1669:                                attachmentMap.remove(sorter.getValueAt(
1670:                                        selectedRow, 0));
1671:                                if (actionOrExecutionForModification != null) {
1672:                                    actionOrExecutionForModification
1673:                                            .removeAttachment((String) sorter
1674:                                                    .getValueAt(selectedRow, 0));
1675:                                }
1676:                            } catch (Exception exception) {
1677:                                Tools.ihmExceptionView(exception.toString());
1678:                            }
1679:                            break;
1680:                        }
1681:
1682:                        case ENVIRONMENT: {
1683:
1684:                            try {
1685:                                // BdD
1686:                                Environment env = DataModel
1687:                                        .getCurrentEnvironment();
1688:                                Attachment attach = env
1689:                                        .getAttachment((String) sorter
1690:                                                .getValueAt(selectedRow, 0));
1691:                                if (attach != null)
1692:                                    env.deleteAttachFromEnvInDB(attach
1693:                                            .getIdBdd());
1694:
1695:                                // IHM
1696:                                attachmentMap.remove(sorter.getValueAt(
1697:                                        selectedRow, 0));
1698:                                if (actionOrExecutionForModification != null) {
1699:                                    actionOrExecutionForModification
1700:                                            .removeAttachment((String) sorter
1701:                                                    .getValueAt(selectedRow, 0));
1702:                                }
1703:
1704:                            } catch (Exception exception) {
1705:                                Tools.ihmExceptionView(exception.toString());
1706:                            }
1707:                            break;
1708:                        }
1709:
1710:                        }
1711:                    }
1712:                    if (Api.getException() == null
1713:                            || Api.getException().size() == 0)
1714:                        DataModel.getAttachmentTableModel().removeData(
1715:                                sorter.modelIndex(selectedRow));
1716:                }
1717:            }
1718:
1719:            public void valueChanged(ListSelectionEvent e) {
1720:                if (e.getSource().equals(attachmentTable.getSelectionModel())) {
1721:                    attachmentTableValueChanged(e);
1722:                }
1723:            }
1724:
1725:            public void attachmentTableValueChanged(ListSelectionEvent e) {
1726:
1727:                if (e.getValueIsAdjusting())
1728:                    return;
1729:
1730:                int nbOfSelectedRows = attachmentTable.getSelectedRowCount();
1731:                int selectedRow = attachmentTable.getSelectedRow();
1732:                if (selectedRow != -1) {
1733:                    if (nbOfSelectedRows == 1) {
1734:                        openAttach.setEnabled(true);
1735:                        switch (sourceType) {
1736:                        case CAMPAIGN: {
1737:                            if (AdminProject.canUpdateCamp())
1738:                                descriptionArea.setEditable(true);
1739:                            // le bouton actualiser est valide suelement pour les fichiers
1740:
1741:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1742:                                    .equals("")) {
1743:                                if (AdminProject.canUpdateCamp())
1744:                                    modifyButton.setEnabled(true);
1745:                            } else {
1746:                                modifyButton.setEnabled(false);
1747:                            }
1748:                            if (AdminProject.canDeleteCamp())
1749:                                delAttach.setEnabled(true);
1750:
1751:                            if (descriptionArea.isEditable())
1752:                                descriptionArea.setText(DataModel
1753:                                        .getCurrentCampaign().getAttachment(
1754:                                                (String) sorter.getValueAt(
1755:                                                        selectedRow, 0))
1756:                                        .getDescription());
1757:                            break;
1758:                        }
1759:                        case TESTLIST: {
1760:                            if (AdminProject.canUpdateTest())
1761:                                descriptionArea.setEditable(true);
1762:                            // le bouton actualiser est valide suelement pour les fichiers
1763:
1764:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1765:                                    .equals("")) {
1766:                                if (AdminProject.canUpdateTest())
1767:                                    modifyButton.setEnabled(true);
1768:                            } else {
1769:                                modifyButton.setEnabled(false);
1770:                            }
1771:                            if (AdminProject.canDeleteTest())
1772:                                delAttach.setEnabled(true);
1773:
1774:                            if (descriptionArea.isEditable())
1775:                                descriptionArea.setText(DataModel
1776:                                        .getCurrentTestList().getAttachment(
1777:                                                (String) sorter.getValueAt(
1778:                                                        selectedRow, 0))
1779:                                        .getDescription());
1780:                            break;
1781:                        }
1782:                        case TEST: {
1783:                            if (AdminProject.canUpdateTest())
1784:                                descriptionArea.setEditable(true);
1785:                            // le bouton actualiser est valide suelement pour les fichiers
1786:
1787:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1788:                                    .equals("")) {
1789:                                if (AdminProject.canUpdateTest())
1790:                                    modifyButton.setEnabled(true);
1791:                            } else {
1792:                                modifyButton.setEnabled(false);
1793:                            }
1794:                            if (AdminProject.canDeleteTest())
1795:                                delAttach.setEnabled(true);
1796:
1797:                            if (descriptionArea.isEditable())
1798:                                descriptionArea.setText(DataModel
1799:                                        .getCurrentTest().getAttachment(
1800:                                                (String) sorter.getValueAt(
1801:                                                        selectedRow, 0))
1802:                                        .getDescription());
1803:                            break;
1804:                        }
1805:                        case ACTION: {
1806:                            if (AdminProject.canUpdateTest())
1807:                                descriptionArea.setEditable(true);
1808:                            // le bouton actualiser est valide suelement pour les fichiers
1809:
1810:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1811:                                    .equals("")) {
1812:                                if (AdminProject.canUpdateTest())
1813:                                    modifyButton.setEnabled(true);
1814:                            } else {
1815:                                modifyButton.setEnabled(false);
1816:                            }
1817:                            if (AdminProject.canDeleteTest())
1818:                                delAttach.setEnabled(true);
1819:
1820:                            if (descriptionArea.isEditable())
1821:                                descriptionArea
1822:                                        .setText(((Attachment) attachmentMap
1823:                                                .get(sorter.getValueAt(
1824:                                                        selectedRow, 0)))
1825:                                                .getDescription());
1826:                            break;
1827:                        }
1828:                        case EXECUTION: {
1829:                            if (AdminProject.canUpdateCamp()
1830:                                    || AdminProject.canExecutCamp())
1831:                                descriptionArea.setEditable(true);
1832:                            // le bouton actualiser est valide suelement pour les fichiers
1833:
1834:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1835:                                    .equals("")) {
1836:                                if (AdminProject.canUpdateCamp()
1837:                                        || AdminProject.canExecutCamp())
1838:                                    modifyButton.setEnabled(true);
1839:                            } else {
1840:                                modifyButton.setEnabled(false);
1841:                            }
1842:                            if (AdminProject.canDeleteCamp()
1843:                                    || AdminProject.canExecutCamp())
1844:                                delAttach.setEnabled(true);
1845:
1846:                            if (descriptionArea.isEditable())
1847:                                descriptionArea
1848:                                        .setText(((Attachment) attachmentMap
1849:                                                .get(sorter.getValueAt(
1850:                                                        selectedRow, 0)))
1851:                                                .getDescription());
1852:                            break;
1853:                        }
1854:                        case EXECUTION_RESULT: {
1855:                            if (AdminProject.canExecutCamp())
1856:                                descriptionArea.setEditable(true);
1857:                            // le bouton actualiser est valide suelement pour les fichiers
1858:
1859:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1860:                                    .equals("")) {
1861:                                if (AdminProject.canExecutCamp())
1862:                                    modifyButton.setEnabled(true);
1863:                            } else {
1864:                                modifyButton.setEnabled(false);
1865:                            }
1866:                            if (AdminProject.canExecutCamp())
1867:                                delAttach.setEnabled(true);
1868:
1869:                            if (descriptionArea.isEditable())
1870:                                descriptionArea
1871:                                        .setText(((Attachment) attachmentMap
1872:                                                .get(sorter.getValueAt(
1873:                                                        selectedRow, 0)))
1874:                                                .getDescription());
1875:                            break;
1876:                        }
1877:                        case EXECUTION_RESULT_TEST: {
1878:                            if (AdminProject.canExecutCamp())
1879:                                descriptionArea.setEditable(true);
1880:                            // le bouton actualiser est valide suelement pour les fichiers
1881:
1882:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1883:                                    .equals("")) {
1884:                                if (AdminProject.canExecutCamp())
1885:                                    modifyButton.setEnabled(true);
1886:                            } else {
1887:                                modifyButton.setEnabled(false);
1888:                            }
1889:                            if (AdminProject.canExecutCamp())
1890:                                delAttach.setEnabled(true);
1891:
1892:                            if (descriptionArea.isEditable())
1893:                                descriptionArea
1894:                                        .setText(((Attachment) attachmentMap
1895:                                                .get(sorter.getValueAt(
1896:                                                        selectedRow, 0)))
1897:                                                .getDescription());
1898:                            break;
1899:                        }
1900:                        case ENVIRONMENT: {
1901:                            if (AdminProject.canUpdateCamp())
1902:                                descriptionArea.setEditable(true);
1903:                            // le bouton actualiser est valide suelement pour les fichiers
1904:
1905:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1906:                                    .equals("")) {
1907:                                if (AdminProject.canUpdateCamp())
1908:                                    modifyButton.setEnabled(true);
1909:                            } else {
1910:                                modifyButton.setEnabled(false);
1911:                            }
1912:                            if (AdminProject.canDeleteCamp())
1913:                                delAttach.setEnabled(true);
1914:
1915:                            if (descriptionArea.isEditable())
1916:                                descriptionArea
1917:                                        .setText(((Attachment) attachmentMap
1918:                                                .get(sorter.getValueAt(
1919:                                                        selectedRow, 0)))
1920:                                                .getDescription());
1921:                            break;
1922:                        }
1923:                        }
1924:                    } else {
1925:                        openAttach.setEnabled(false);
1926:                        descriptionArea.setEditable(false);
1927:                        modifyButton.setEnabled(false);
1928:                        descriptionArea.setText("");
1929:                    }
1930:
1931:                } else {
1932:                    descriptionArea.setEditable(false);
1933:                    descriptionArea.setText("");
1934:                    openAttach.setEnabled(false);
1935:                    delAttach.setEnabled(false);
1936:                    modifyButton.setEnabled(false);
1937:                }
1938:
1939:            }
1940:
1941:        } // Fin de la classe AttachmentView
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.