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

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


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.main;
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.awt.event.FocusEvent;
0033:        import java.awt.event.FocusListener;
0034:        import java.awt.event.WindowEvent;
0035:        import java.awt.event.WindowListener;
0036:        import java.io.File;
0037:        import java.io.IOException;
0038:        import java.net.MalformedURLException;
0039:        import java.net.URL;
0040:        import java.sql.Date;
0041:        import java.util.ArrayList;
0042:        import java.util.Collection;
0043:        import java.util.Hashtable;
0044:        import java.util.Iterator;
0045:        import java.util.Properties;
0046:        import java.util.Vector;
0047:
0048:        import javax.swing.BorderFactory;
0049:        import javax.swing.ImageIcon;
0050:        import javax.swing.JButton;
0051:        import javax.swing.JDialog;
0052:        import javax.swing.JFileChooser;
0053:        import javax.swing.JMenu;
0054:        import javax.swing.JMenuBar;
0055:        import javax.swing.JMenuItem;
0056:        import javax.swing.JOptionPane;
0057:        import javax.swing.JPanel;
0058:        import javax.swing.JScrollPane;
0059:        import javax.swing.JTable;
0060:        import javax.swing.JTextArea;
0061:        import javax.swing.JTextPane;
0062:        import javax.swing.ListSelectionModel;
0063:        import javax.swing.event.CaretEvent;
0064:        import javax.swing.event.CaretListener;
0065:        import javax.swing.event.ListSelectionEvent;
0066:        import javax.swing.event.ListSelectionListener;
0067:
0068:        import org.objectweb.salome_tmf.api.Api;
0069:        import org.objectweb.salome_tmf.api.ApiConstants;
0070:        import org.objectweb.salome_tmf.api.Permission;
0071:        import org.objectweb.salome_tmf.api.Util;
0072:        import org.objectweb.salome_tmf.data.Action;
0073:        import org.objectweb.salome_tmf.data.Attachment;
0074:        import org.objectweb.salome_tmf.data.DataConstants;
0075:        import org.objectweb.salome_tmf.data.FileAttachment;
0076:        import org.objectweb.salome_tmf.data.ManualTest;
0077:        import org.objectweb.salome_tmf.data.Test;
0078:        import org.objectweb.salome_tmf.data.UrlAttachment;
0079:        import org.objectweb.salome_tmf.data.WithAttachment;
0080:        import org.objectweb.salome_tmf.ihm.IHMConstants;
0081:        import org.objectweb.salome_tmf.ihm.admin.AskName;
0082:        import org.objectweb.salome_tmf.ihm.languages.Language;
0083:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
0084:        import org.objectweb.salome_tmf.ihm.main.plugins.PluginsTools;
0085:        import org.objectweb.salome_tmf.ihm.models.MyTableModel;
0086:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
0087:        import org.objectweb.salome_tmf.ihm.tools.Tools;
0088:        import org.objectweb.salome_tmf.plugins.UICompCst;
0089:        import org.objectweb.salome_tmf.plugins.core.BugTracker;
0090:
0091:        public class AttachmentView extends JPanel implements  DataConstants,
0092:                ActionListener, IHMConstants, ListSelectionListener,
0093:                FocusListener {
0094:
0095:            boolean readOnly = false;
0096:
0097:            JButton openAttach;
0098:
0099:            JButton delAttach;
0100:
0101:            JButton modifyButton;
0102:
0103:            JButton addFileAttach;
0104:
0105:            JButton addUrlAttach;
0106:
0107:            JButton saveAttachButton;
0108:
0109:            JButton screeshootButton;
0110:
0111:            JTable attachmentTable;
0112:
0113:            /**
0114:             *
0115:             */
0116:            int sourceType;
0117:
0118:            /**
0119:             * Table des attachements
0120:             */
0121:            //static HashMap attachmentMap;
0122:            /**
0123:             * Description de l'attachement
0124:             */
0125:            JTextArea descriptionArea;
0126:
0127:            /**
0128:             * Applet
0129:             */
0130:            BaseIHM applet;
0131:
0132:            //WithAttachment actionOrExecutionForModification;
0133:
0134:            WithAttachment withAttachment = null;
0135:
0136:            String typeName = "";
0137:            Attachment previousAtt;
0138:
0139:            //Execution exec;
0140:
0141:            //ExecutionResult execResult;
0142:
0143:            //Test observedTest;
0144:
0145:            TableSorter sorter;
0146:
0147:            JPanel attachmentsPanel;
0148:
0149:            static Hashtable extPrg = new Hashtable();
0150:
0151:            JDialog parent;
0152:
0153:            /******************************************************************************/
0154:            /** 							CONSTRUCTEUR								***/
0155:            /******************************************************************************/
0156:            public AttachmentView(BaseIHM app, int realtype, int type,
0157:                    WithAttachment pWithAttachment, int size, JDialog _parent) {
0158:                //public AttachmentView(JApplet app, int realtype, int type, WithAttachment actionOrExecution, int size, Execution execution, ExecutionResult executionResult, Test testInObservation){
0159:                previousAtt = null;
0160:                parent = _parent;
0161:                attachmentsPanel = new JPanel();
0162:                attachmentTable = new JTable();
0163:
0164:                descriptionArea = new JTextArea();
0165:                modifyButton = new JButton(Language.getInstance().getText(
0166:                        "Actualiser"));
0167:                delAttach = new JButton(Language.getInstance().getText(
0168:                        "Supprimer"));
0169:                openAttach = new JButton(Language.getInstance().getText(
0170:                        "Visualiser"));
0171:
0172:                openAttach.setToolTipText(Language.getInstance().getText(
0173:                        "Récupérer_et_visualiser_un_attachement"));
0174:                //openAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_VIEW_ATTACH_ICON,""));
0175:                openAttach.setEnabled(false);
0176:                openAttach.addActionListener(this );
0177:
0178:                addFileAttach = new JButton(Language.getInstance().getText(
0179:                        "Ajouter_fichier"));
0180:                //addFileAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_FILE_ATTACH_ICON,""));
0181:                addFileAttach.setToolTipText(Language.getInstance().getText(
0182:                        "Ajouter_un_fichier_en_attachement"));
0183:                addFileAttach.addActionListener(this );
0184:
0185:                addUrlAttach = new JButton(Language.getInstance().getText(
0186:                        "Ajouter_url"));
0187:                //addUrlAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_URL_ATTACH_ICON,""));
0188:                addUrlAttach.setToolTipText(Language.getInstance().getText(
0189:                        "Ajouter_une_URL_en_attachement"));
0190:                addUrlAttach.addActionListener(this );
0191:
0192:                modifyButton.setToolTipText(Language.getInstance().getText(
0193:                        "Enregistre_les_modifications_du_fichier"));
0194:                modifyButton.setEnabled(false);
0195:                //modifyButton.setIcon(Tools.createAppletImageIcon(PATH_TO_BDD_ATTACH_ICON,""));
0196:                modifyButton.addActionListener(this );
0197:
0198:                delAttach.setToolTipText(Language.getInstance().getText(
0199:                        "Supprimer_un_attachement"));
0200:                //delAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_FAIL2_ICON,""));
0201:                delAttach.setEnabled(false);
0202:                delAttach.addActionListener(this );
0203:
0204:                saveAttachButton = new JButton(Language.getInstance().getText(
0205:                        "Enregistrer_sous"));
0206:                //delAttach.setIcon(Tools.createAppletImageIcon(PATH_TO_FAIL2_ICON,""));
0207:                saveAttachButton.setEnabled(false);
0208:                saveAttachButton.addActionListener(this );
0209:
0210:                screeshootButton = new JButton();
0211:                screeshootButton.setIcon(Tools.createAppletImageIcon(
0212:                        PATH_TO_SCREENSHOT_ICON, ""));
0213:                screeshootButton.addActionListener(this );
0214:                if (type == EXECUTION_RESULT_TEST) {
0215:                    screeshootButton.setEnabled(false);
0216:                }
0217:
0218:                JPanel allButtons = new JPanel(new GridLayout(1, 7));
0219:                allButtons.add(addFileAttach);
0220:                allButtons.add(addUrlAttach);
0221:                allButtons.add(screeshootButton);
0222:                allButtons.add(openAttach);
0223:                allButtons.add(saveAttachButton);
0224:                allButtons.add(modifyButton);
0225:                allButtons.add(delAttach);
0226:
0227:                if (type == EXECUTION_RESULT_TEST) {
0228:                    // Menu for bugtrackers
0229:                    //Vector bugTrackers = SalomeTMFContext.getInstance().bugTrackerExtensions; 
0230:                    Vector bugTrackers = SalomeTMFContext.getInstance()
0231:                            .getBugTracker();
0232:                    if (bugTrackers.size() != 0) {
0233:                        JMenu bugTrackMenu = new JMenu(Language.getInstance()
0234:                                .getText("add_bug"));
0235:                        for (int i = 0; i < bugTrackers.size(); i++) {
0236:                            //final BugTracker bugTracker = (BugTracker)SalomeTMFContext.getInstance().bugTrackers.elementAt(i);
0237:                            final BugTracker bugTracker = (BugTracker) bugTrackers
0238:                                    .elementAt(i);
0239:                            JMenuItem bugTrackerItem = new JMenuItem(bugTracker
0240:                                    .getBugTrackerName());
0241:                            bugTrackerItem
0242:                                    .addActionListener(new ActionListener() {
0243:                                        public void actionPerformed(
0244:                                                ActionEvent e) {
0245:                                            Test testInExec = PluginsTools
0246:                                                    .getTestForCurrentTestExecResult();
0247:                                            if (testInExec instanceof  ManualTest) {
0248:                                                JTextPane description = (JTextPane) SalomeTMFContext
0249:                                                        .getInstance()
0250:                                                        .getUIComponent(
0251:                                                                UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_DESC);
0252:                                                JTextPane awaitedResult = (JTextPane) SalomeTMFContext
0253:                                                        .getInstance()
0254:                                                        .getUIComponent(
0255:                                                                UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_WAITED_RES);
0256:                                                JTextPane effectiveResult = (JTextPane) SalomeTMFContext
0257:                                                        .getInstance()
0258:                                                        .getUIComponent(
0259:                                                                UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_EFF_RES);
0260:                                                JTable actionsTable = (JTable) SalomeTMFContext
0261:                                                        .getInstance()
0262:                                                        .getUIComponent(
0263:                                                                UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTIONS_TABLE);
0264:                                                if ((description != null)
0265:                                                        && (awaitedResult != null)
0266:                                                        && (effectiveResult != null)
0267:                                                        && (actionsTable != null)) {
0268:                                                    int selectedRowIndex = actionsTable
0269:                                                            .getSelectedRow();
0270:                                                    ArrayList dataList = ((MyTableModel) actionsTable
0271:                                                            .getModel())
0272:                                                            .getData(selectedRowIndex);
0273:                                                    ManualTest pTest = (ManualTest) testInExec;
0274:                                                    Action action = pTest
0275:                                                            .getActionFromModel((String) dataList
0276:                                                                    .get(0));
0277:                                                    if (action != null) {
0278:                                                        new AskNewBug(
0279:                                                                SalomeTMFContext
0280:                                                                        .getInstance()
0281:                                                                        .getSalomeFrame(),
0282:                                                                bugTracker,
0283:                                                                true,
0284:                                                                action
0285:                                                                        .getNameFromModel(),
0286:                                                                description
0287:                                                                        .getText(),
0288:                                                                awaitedResult
0289:                                                                        .getText(),
0290:                                                                effectiveResult
0291:                                                                        .getText());
0292:                                                    } else {
0293:                                                        new AskNewBug(
0294:                                                                SalomeTMFContext
0295:                                                                        .getInstance()
0296:                                                                        .getSalomeFrame(),
0297:                                                                bugTracker,
0298:                                                                true, null,
0299:                                                                null, null,
0300:                                                                null);
0301:                                                    }
0302:                                                } else {
0303:                                                    new AskNewBug(
0304:                                                            SalomeTMFContext
0305:                                                                    .getInstance()
0306:                                                                    .getSalomeFrame(),
0307:                                                            bugTracker, true,
0308:                                                            null, null, null,
0309:                                                            null);
0310:                                                }
0311:                                            } else {
0312:                                                new AskNewBug(SalomeTMFContext
0313:                                                        .getInstance()
0314:                                                        .getSalomeFrame(),
0315:                                                        bugTracker, true, null,
0316:                                                        null, null, null);
0317:                                            }
0318:                                        }
0319:                                    });
0320:
0321:                            if (!bugTracker.isUserExistsInBugDB()) {
0322:                                bugTrackerItem.setEnabled(false);
0323:                            }
0324:                            bugTrackMenu.add(bugTrackerItem);
0325:                        }
0326:                        JMenuBar menuBar = new JMenuBar();
0327:                        menuBar.add(bugTrackMenu);
0328:                        allButtons.add(menuBar);
0329:                    }
0330:                }
0331:
0332:                allButtons.setBorder(BorderFactory.createRaisedBevelBorder());
0333:
0334:                //  La liste des attachements 
0335:                sorter = new TableSorter(DataModel.getAttachmentTableModel());
0336:                attachmentTable.setModel(sorter);
0337:                sorter.setTableHeader(attachmentTable.getTableHeader());
0338:
0339:                attachmentTable
0340:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0341:
0342:                JScrollPane tablePane = new JScrollPane(attachmentTable);
0343:                tablePane.setPreferredSize(new Dimension(500, size));
0344:
0345:                ListSelectionModel rowSM = attachmentTable.getSelectionModel();
0346:                rowSM.addListSelectionListener(this );
0347:
0348:                descriptionArea.setEditable(false);
0349:                descriptionArea
0350:                        .addCaretListener(new AttachmentDescriptionListener());
0351:                descriptionArea.addFocusListener(this );
0352:                JScrollPane descriptionScrollPane = new JScrollPane(
0353:                        descriptionArea);
0354:                descriptionScrollPane.setBorder(BorderFactory
0355:                        .createTitledBorder(BorderFactory
0356:                                .createLineBorder(Color.BLACK), Language
0357:                                .getInstance().getText("Description")));
0358:                descriptionScrollPane.setPreferredSize(new Dimension(500, 75));
0359:
0360:                //initData(type, app, actionOrExecution, execution, executionResult, testInObservation);
0361:                initData(type, app, pWithAttachment);
0362:
0363:                giveAccessToIhmScriptView();
0364:                attachmentsPanel.setLayout(new BorderLayout());
0365:                attachmentsPanel.add(allButtons, BorderLayout.NORTH);
0366:                attachmentsPanel.add(tablePane, BorderLayout.CENTER);
0367:                attachmentsPanel.add(descriptionScrollPane, BorderLayout.SOUTH);
0368:
0369:                this .setLayout(new BorderLayout());
0370:                this .add(attachmentsPanel, BorderLayout.CENTER);
0371:
0372:                // Mapping GUI Object for plugins//
0373:                mapUIComponents(attachmentsPanel, attachmentTable, allButtons,
0374:                        realtype);
0375:
0376:            }
0377:
0378:            void mapUIComponents(JPanel attachmentsPanel,
0379:                    JTable attachmentTable, JPanel allButtons, int type) {
0380:                switch (type) {
0381:                case MANUAL_TEST: {
0382:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0383:                            UICompCst.MANUAL_TEST_ATTACHMENTS_PANEL,
0384:                            attachmentsPanel);
0385:                    UICompCst.staticUIComps
0386:                            .add(UICompCst.MANUAL_TEST_ATTACHMENTS_PANEL);
0387:                    //PluginsTools.activateAssociatedPlgs(UICompCst.MANUAL_TEST_ATTACHMENTS_PANEL);
0388:
0389:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0390:                            UICompCst.MANUAL_TEST_ATTACHMENTS_TABLE,
0391:                            attachmentTable);
0392:                    UICompCst.staticUIComps
0393:                            .add(UICompCst.MANUAL_TEST_ATTACHMENTS_TABLE);
0394:                    //PluginsTools.activateAssociatedPlgs(UICompCst.MANUAL_TEST_ATTACHMENTS_TABLE);
0395:
0396:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0397:                            UICompCst.MANUAL_TEST_ATTACHMENTS_BUTTONS_PANEL,
0398:                            allButtons);
0399:                    UICompCst.staticUIComps
0400:                            .add(UICompCst.MANUAL_TEST_ATTACHMENTS_BUTTONS_PANEL);
0401:                    //PluginsTools.activateAssociatedPlgs(UICompCst.MANUAL_TEST_ATTACHMENTS_BUTTONS_PANEL);
0402:
0403:                    break;
0404:                }
0405:                case AUTOMATIC_TEST: {
0406:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0407:                            UICompCst.AUTOMATED_TEST_ATTACHMENTS_PANEL,
0408:                            attachmentsPanel);
0409:                    UICompCst.staticUIComps
0410:                            .add(UICompCst.AUTOMATED_TEST_ATTACHMENTS_PANEL);
0411:                    //PluginsTools.activateAssociatedPlgs(UICompCst.AUTOMATED_TEST_ATTACHMENTS_PANEL);
0412:
0413:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0414:                            UICompCst.AUTOMATED_TEST_ATTACHMENTS_TABLE,
0415:                            attachmentTable);
0416:                    UICompCst.staticUIComps
0417:                            .add(UICompCst.AUTOMATED_TEST_ATTACHMENTS_TABLE);
0418:                    //PluginsTools.activateAssociatedPlgs(UICompCst.AUTOMATED_TEST_ATTACHMENTS_TABLE);
0419:
0420:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0421:                            UICompCst.AUTOMATED_TEST_ATTACHMENTS_BUTTONS_PANEL,
0422:                            allButtons);
0423:                    UICompCst.staticUIComps
0424:                            .add(UICompCst.AUTOMATED_TEST_ATTACHMENTS_BUTTONS_PANEL);
0425:                    //PluginsTools.activateAssociatedPlgs(UICompCst.AUTOMATED_TEST_ATTACHMENTS_BUTTONS_PANEL);
0426:                    break;
0427:                }
0428:                case TESTLIST: {
0429:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0430:                            UICompCst.TESTLIST_ATTACHMENTS_PANEL,
0431:                            attachmentsPanel);
0432:                    UICompCst.staticUIComps
0433:                            .add(UICompCst.TESTLIST_ATTACHMENTS_PANEL);
0434:                    //PluginsTools.activateAssociatedPlgs(UICompCst.TESTLIST_ATTACHMENTS_PANEL);
0435:
0436:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0437:                            UICompCst.TESTLIST_ATTACHMENTS_TABLE,
0438:                            attachmentTable);
0439:                    UICompCst.staticUIComps
0440:                            .add(UICompCst.TESTLIST_ATTACHMENTS_TABLE);
0441:                    //PluginsTools.activateAssociatedPlgs(UICompCst.TESTLIST_ATTACHMENTS_TABLE);
0442:
0443:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0444:                            UICompCst.TESTLIST_ATTACHMENTS_BUTTONS_PANEL,
0445:                            allButtons);
0446:                    UICompCst.staticUIComps
0447:                            .add(UICompCst.TESTLIST_ATTACHMENTS_BUTTONS_PANEL);
0448:                    //PluginsTools.activateAssociatedPlgs(UICompCst.TESTLIST_ATTACHMENTS_BUTTONS_PANEL);
0449:                    break;
0450:                }
0451:                case CAMPAIGN: {
0452:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0453:                            UICompCst.CAMP_ATTACHMENTS_PANEL, attachmentsPanel);
0454:                    UICompCst.staticUIComps
0455:                            .add(UICompCst.CAMP_ATTACHMENTS_PANEL);
0456:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_PANEL);
0457:
0458:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0459:                            UICompCst.CAMP_ATTACHMENTS_TABLE, attachmentTable);
0460:                    UICompCst.staticUIComps
0461:                            .add(UICompCst.CAMP_ATTACHMENTS_TABLE);
0462:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_TABLE);
0463:
0464:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0465:                            UICompCst.CAMP_ATTACHMENTS_BUTTONS_PANEL,
0466:                            allButtons);
0467:                    UICompCst.staticUIComps
0468:                            .add(UICompCst.CAMP_ATTACHMENTS_BUTTONS_PANEL);
0469:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_BUTTONS_PANEL);
0470:                    break;
0471:                }
0472:                case FAMILY: {
0473:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0474:                            UICompCst.FAMILY_ATTACHMENTS_PANEL,
0475:                            attachmentsPanel);
0476:                    UICompCst.staticUIComps
0477:                            .add(UICompCst.FAMILY_ATTACHMENTS_PANEL);
0478:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_PANEL);
0479:
0480:                    SalomeTMFContext.getInstance()
0481:                            .addToUIComponentsMap(
0482:                                    UICompCst.FAMILY_ATTACHMENTS_TABLE,
0483:                                    attachmentTable);
0484:                    UICompCst.staticUIComps
0485:                            .add(UICompCst.FAMILY_ATTACHMENTS_TABLE);
0486:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_TABLE);
0487:
0488:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0489:                            UICompCst.FAMILY_ATTACHMENTS_BUTTONS_PANEL,
0490:                            allButtons);
0491:                    UICompCst.staticUIComps
0492:                            .add(UICompCst.FAMILY_ATTACHMENTS_BUTTONS_PANEL);
0493:                    break;
0494:                }
0495:                case PROJECT: {
0496:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0497:                            UICompCst.PROJECT_ATTACHMENTS_PANEL,
0498:                            attachmentsPanel);
0499:                    UICompCst.staticUIComps
0500:                            .add(UICompCst.PROJECT_ATTACHMENTS_PANEL);
0501:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_PANEL);
0502:
0503:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0504:                            UICompCst.PROJECT_ATTACHMENTS_TABLE,
0505:                            attachmentTable);
0506:                    UICompCst.staticUIComps
0507:                            .add(UICompCst.PROJECT_ATTACHMENTS_TABLE);
0508:                    //PluginsTools.activateAssociatedPlgs(UICompCst.CAMP_ATTACHMENTS_TABLE);
0509:
0510:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0511:                            UICompCst.PROJECT_ATTACHMENTS_BUTTONS_PANEL,
0512:                            allButtons);
0513:                    UICompCst.staticUIComps
0514:                            .add(UICompCst.PROJECT_ATTACHMENTS_BUTTONS_PANEL);
0515:                    break;
0516:                }
0517:                default: {
0518:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0519:                            UICompCst.ATTACHMENTS_PANEL, attachmentsPanel);
0520:                    PluginsTools
0521:                            .activateAssociatedPlgs(UICompCst.ATTACHMENTS_PANEL);
0522:
0523:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0524:                            UICompCst.ATTACHMENTS_TABLE, attachmentTable);
0525:                    PluginsTools
0526:                            .activateAssociatedPlgs(UICompCst.ATTACHMENTS_TABLE);
0527:
0528:                    SalomeTMFContext.getInstance().addToUIComponentsMap(
0529:                            UICompCst.ATTACHMENTS_BUTTONS_PANEL, allButtons);
0530:                    PluginsTools
0531:                            .activateAssociatedPlgs(UICompCst.ATTACHMENTS_BUTTONS_PANEL);
0532:                }
0533:                }
0534:            }
0535:
0536:            /**
0537:             *
0538:             * @param type
0539:             * @param app
0540:             * @param actionOrExecution
0541:             */
0542:            //public void initData(int type, JApplet app, WithAttachment actionOrExecution, Execution execution, ExecutionResult executionResult, Test testInObservation) {
0543:            public void initData(int type, BaseIHM app,
0544:                    WithAttachment pWithAttachment) {
0545:
0546:                sourceType = type;
0547:
0548:                if (app != null) {
0549:                    applet = app;
0550:                } else {
0551:                    applet = DataModel.getApplet();
0552:                }
0553:
0554:                DataModel.getAttachmentTableModel().clearTable();
0555:                initAttachmentObject(type);
0556:                loadAttachment();
0557:
0558:            }
0559:
0560:            public void setAttachmentObject(WithAttachment _withAttachment) {
0561:                withAttachment = _withAttachment;
0562:                loadAttachment();
0563:            }
0564:
0565:            void loadAttachment() {
0566:                if (withAttachment != null) {
0567:                    DataModel.getAttachmentTableModel().clearTable();
0568:                    Collection keysSet = withAttachment
0569:                            .getAttachmentMapFromModel().values();
0570:                    boolean isSorting = sorter.isSorting();
0571:                    int statusSort_col0 = -1;
0572:                    int statusSort_col1 = -1;
0573:                    int statusSort_col2 = -1;
0574:                    if (isSorting) {
0575:                        statusSort_col0 = sorter.getSortingStatus(0);
0576:                        statusSort_col1 = sorter.getSortingStatus(1);
0577:                        statusSort_col2 = sorter.getSortingStatus(2);
0578:                    }
0579:                    int i = 0;
0580:                    for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
0581:                        Attachment attach = (Attachment) iter.next();
0582:                        if (attach instanceof  FileAttachment) {
0583:                            DataModel.getAttachmentTableModel().addValueAt(
0584:                                    ((FileAttachment) attach)
0585:                                            .getNameFromModel(), i, 0);
0586:                            DataModel.getAttachmentTableModel().addValueAt(
0587:                                    ((FileAttachment) attach).getSize()
0588:                                            .toString(), i, 1);
0589:                            DataModel.getAttachmentTableModel().addValueAt(
0590:                                    ((FileAttachment) attach).getDate()
0591:                                            .toString(), i, 2);
0592:                        } else {
0593:                            DataModel.getAttachmentTableModel()
0594:                                    .addValueAt(
0595:                                            ((UrlAttachment) attach)
0596:                                                    .getNameFromModel(), i, 0);
0597:                            DataModel.getAttachmentTableModel().addValueAt("",
0598:                                    i, 1);
0599:                            DataModel.getAttachmentTableModel().addValueAt("",
0600:                                    i, 2);
0601:                        }
0602:                        i++;
0603:                    }
0604:                    if (isSorting) {
0605:                        sorter.setSortingStatus(0, statusSort_col0);
0606:                        sorter.setSortingStatus(1, statusSort_col1);
0607:                        sorter.setSortingStatus(2, statusSort_col2);
0608:                    }
0609:
0610:                }
0611:            }
0612:
0613:            void initAttachmentObject(int type) {
0614:                if (type == CAMPAIGN) {
0615:                    withAttachment = DataModel.getCurrentCampaign();
0616:                    typeName = Language.getInstance().getText("cette_campagne");
0617:                } else if (type == TESTLIST) {
0618:                    withAttachment = DataModel.getCurrentTestList();
0619:                    typeName = Language.getInstance().getText(
0620:                            "cette_suite_de_tests");
0621:                } else if (type == TEST) {
0622:                    withAttachment = DataModel.getCurrentTest();
0623:                    typeName = Language.getInstance().getText("ce_test");
0624:                } else if (type == ACTION) {
0625:                    withAttachment = DataModel.getCurrentAction();
0626:                    typeName = Language.getInstance().getText("cette_action");
0627:                } else if (type == EXECUTION) {
0628:                    withAttachment = DataModel.getObservedExecution();
0629:                    typeName = Language.getInstance()
0630:                            .getText("cette_exécution");
0631:                } else if (type == EXECUTION_RESULT) {
0632:                    withAttachment = DataModel.getObservedExecutionResult();
0633:                    typeName = Language.getInstance().getText(
0634:                            "ce_résultat_d'exécution");
0635:                } else if (type == EXECUTION_RESULT_TEST) {
0636:                    withAttachment = DataModel.getCurrentExecutionTestResult();
0637:                    typeName = Language.getInstance().getText(
0638:                            "ce_résultat_d'exécution_de_test");
0639:                } else if (type == ENVIRONMENT) {
0640:                    withAttachment = DataModel.getCurrentEnvironment();
0641:                    typeName = Language.getInstance().getText(
0642:                            "cet_environnement_sous_test");
0643:                } else if (type == FAMILY) {
0644:                    withAttachment = DataModel.getCurrentFamily();
0645:                    typeName = Language.getInstance().getText("cette_famille");
0646:                } else if (type == PROJECT) {
0647:                    withAttachment = DataModel.getCurrentProject();
0648:                    typeName = Language.getInstance().getText("ce_projet");
0649:                }
0650:                Util.log("[AttachmentView->initAttachmentObject] for "
0651:                        + typeName + " = " + withAttachment);
0652:            }
0653:
0654:            /*public static HashMap getAttachmentMap() {
0655:            	return attachmentMap;
0656:            }*/
0657:
0658:            public class AttachmentDescriptionListener implements 
0659:                    CaretListener, IHMConstants {
0660:
0661:                /* (non-Javadoc)
0662:                 * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
0663:                 */
0664:                public void caretUpdate(CaretEvent e) {
0665:                    int[] selectedRows = attachmentTable.getSelectedRows();
0666:                    Attachment at = null;
0667:                    if (selectedRows.length == 1
0668:                            && ((JTextArea) e.getSource()).isEditable()) {
0669:
0670:                        int selectedRow = selectedRows[0];
0671:                        if (selectedRow != -1) {
0672:                            initAttachmentObject(sourceType);
0673:                            at = withAttachment
0674:                                    .getAttachmentFromModel((String) sorter
0675:                                            .getValueAt(selectedRow, 0));
0676:                            previousAtt = at;
0677:
0678:                            try {
0679:                                if (at != null) {
0680:                                    at.updateDescriptionInModel(((JTextArea) e
0681:                                            .getSource()).getText());
0682:                                } else {
0683:                                    getAttachByName(
0684:                                            (String) sorter.getValueAt(
0685:                                                    selectedRow, 0))
0686:                                            .updateDescriptionInModel(
0687:                                                    ((JTextArea) e.getSource())
0688:                                                            .getText());
0689:                                    //((Attachment)attachmentMap.get(sorter.getValueAt(selectedRow, 0))).updateDescriptionInModel(((JTextArea)e.getSource()).getText());
0690:                                }
0691:
0692:                            } catch (Exception exception) {
0693:                                Tools.ihmExceptionView(exception);
0694:                            }
0695:                        }
0696:                    }
0697:                }
0698:
0699:            }
0700:
0701:            /*private Attachment getAttachment(String attachName) {
0702:            	return (Attachment)attachmentMap.get(attachName);
0703:            }*/
0704:
0705:            public void giveAccessToIhmScriptView() {
0706:                if (sourceType == PROJECT || sourceType == FAMILY
0707:                        || sourceType == TESTLIST || sourceType == TEST
0708:                        || sourceType == ACTION) {
0709:                    allowTest();
0710:                } else if (sourceType == CAMPAIGN || sourceType == EXECUTION) {
0711:                    allowCampaign();
0712:                } else if (sourceType == EXECUTION_RESULT
0713:                        || sourceType == EXECUTION_RESULT_TEST) {
0714:                    allowCampaignExec();
0715:                }
0716:            }
0717:
0718:            private void allowTest() {
0719:                if (!Permission.canDeleteTest()) {
0720:                    delAttach.setEnabled(false);
0721:                }
0722:                if (!Permission.canCreateTest()) {
0723:                    addFileAttach.setEnabled(false);
0724:                    screeshootButton.setEnabled(false);
0725:                    addUrlAttach.setEnabled(false);
0726:                } else {
0727:                    addFileAttach.setEnabled(true);
0728:                    screeshootButton.setEnabled(true);
0729:                    addUrlAttach.setEnabled(true);
0730:                }
0731:                if (!Permission.canUpdateTest()) {
0732:                    modifyButton.setEnabled(false);
0733:                    descriptionArea.setEditable(false);
0734:                }
0735:            }
0736:
0737:            private void allowCampaign() {
0738:                if (!Permission.canDeleteCamp()) {
0739:                    delAttach.setEnabled(false);
0740:                }
0741:                if (!Permission.canCreateCamp()) {
0742:                    addFileAttach.setEnabled(false);
0743:                    screeshootButton.setEnabled(false);
0744:                    addUrlAttach.setEnabled(false);
0745:                } else {
0746:                    addFileAttach.setEnabled(true);
0747:                    screeshootButton.setEnabled(true);
0748:                    addUrlAttach.setEnabled(true);
0749:                }
0750:                if (!Permission.canUpdateCamp()) {
0751:                    modifyButton.setEnabled(false);
0752:                    descriptionArea.setEditable(false);
0753:                }
0754:
0755:            }
0756:
0757:            private void allowCampaignExec() {
0758:                if (!Permission.canExecutCamp()) {
0759:                    delAttach.setEnabled(false);
0760:                    addFileAttach.setEnabled(false);
0761:                    screeshootButton.setEnabled(false);
0762:                    addUrlAttach.setEnabled(false);
0763:                    modifyButton.setEnabled(false);
0764:                    descriptionArea.setEditable(false);
0765:                }
0766:
0767:            }
0768:
0769:            public void actionPerformed(java.awt.event.ActionEvent e) {
0770:                Object source = e.getSource();
0771:                if (source.equals(openAttach)) {
0772:                    openPerformed(e);
0773:                } else if (source.equals(addFileAttach)) {
0774:                    addFileAttachPerformed(e);
0775:                } else if (source.equals(addUrlAttach)) {
0776:                    addUrlAttachPerformed(e);
0777:                } else if (source.equals(modifyButton)) {
0778:                    modifyButtonPerformed(e);
0779:                } else if (source.equals(delAttach)) {
0780:                    delAttachPerformed(e);
0781:                } else if (source.equals(saveAttachButton)) {
0782:                    saveAttachPerformed(e);
0783:                } else if (source.equals(screeshootButton)) {
0784:                    //screeshootPerformed(e);
0785:                    screeshootFrame(e);
0786:                }
0787:
0788:            }
0789:
0790:            JDialog takeScreenShoot;
0791:            boolean screenShootValided = false;
0792:
0793:            public void screeshootFrame(java.awt.event.ActionEvent e) {
0794:                screenShootValided = false;
0795:                takeScreenShoot = new JDialog();
0796:                takeScreenShoot.setResizable(false);
0797:                takeScreenShoot.setTitle("Capture Screen");
0798:                JButton screeshootButton2 = new JButton();
0799:                ImageIcon icon = Tools.createAppletImageIcon(
0800:                        PATH_TO_SCREENSHOT_ICON, "");
0801:                screeshootButton2.setIcon(icon);
0802:                screeshootButton2.setMinimumSize(new Dimension(icon
0803:                        .getIconWidth(), icon.getIconHeight()));
0804:                //takeScreenShoot.setSize(new Dimension(icon.getIconWidth(),icon.getIconHeight()));
0805:                screeshootButton2.addActionListener(new ActionListener() {
0806:                    public void actionPerformed(java.awt.event.ActionEvent e) {
0807:                        screenShootValided = true;
0808:                        takeScreenShoot.dispose();
0809:                        screeshootPerformed(e);
0810:                        if (parent != null) {
0811:                            parent.setVisible(true);
0812:                        }
0813:                    }
0814:                });
0815:                takeScreenShoot.addWindowListener(new WindowListener() {
0816:                    public void windowActivated(WindowEvent e) {
0817:                    }
0818:
0819:                    public void windowClosed(WindowEvent e) {
0820:
0821:                    }
0822:
0823:                    public void windowClosing(WindowEvent e) {
0824:                        if (!screenShootValided) {
0825:                            screenShootValided = true;
0826:                            takeScreenShoot.dispose();
0827:                            if (parent != null) {
0828:                                parent.setVisible(true);
0829:                            }
0830:                        }
0831:                    }
0832:
0833:                    public void windowDeactivated(WindowEvent e) {
0834:                        takeScreenShoot.toFront();
0835:                    }
0836:
0837:                    public void windowDeiconified(WindowEvent e) {
0838:                    }
0839:
0840:                    public void windowIconified(WindowEvent e) {
0841:                        takeScreenShoot.toFront();
0842:                    }
0843:
0844:                    public void windowOpened(WindowEvent e) {
0845:                    }
0846:
0847:                });
0848:
0849:                if (parent != null) {
0850:                    parent.setVisible(false);
0851:                }
0852:                takeScreenShoot.getContentPane().add(screeshootButton2);
0853:                takeScreenShoot.pack();
0854:                takeScreenShoot.setVisible(true);
0855:
0856:            }
0857:
0858:            public void saveAttachPerformed(ActionEvent e) {
0859:                int selectedRow = attachmentTable.getSelectedRow();
0860:                if (selectedRow != -1) {
0861:                    FileAttachment at = null;
0862:                    initAttachmentObject(sourceType);
0863:                    File file = null;
0864:                    String name;
0865:                    Attachment pAttch = withAttachment
0866:                            .getAttachmentFromModel((String) sorter.getValueAt(
0867:                                    selectedRow, 0));
0868:                    if (pAttch != null) {
0869:                        if (pAttch instanceof  FileAttachment) {
0870:                            name = pAttch.getNameFromModel();
0871:                            JFileChooser chooser = new JFileChooser(Language
0872:                                    .getInstance().getText("Enregistrer_sous"));
0873:                            chooser.setSelectedFile(new File(name));
0874:                            int returnVal = chooser
0875:                                    .showSaveDialog(SalomeTMFContext
0876:                                            .getInstance().ptrFrame);
0877:                            if (returnVal == JFileChooser.APPROVE_OPTION) {
0878:                                try {
0879:                                    ((FileAttachment) pAttch)
0880:                                            .getFileFromDBIn(chooser
0881:                                                    .getSelectedFile());
0882:                                } catch (Exception ex) {
0883:                                    Tools.ihmExceptionView(ex);
0884:                                }
0885:                            }
0886:                        }
0887:                    }
0888:                }
0889:            }
0890:
0891:            public void openPerformed(ActionEvent e) {
0892:                int selectedRow = attachmentTable.getSelectedRow();
0893:                if (selectedRow != -1) {
0894:                    //URL recup = null;
0895:                    //File file = null;
0896:                    //FileAttachment at = null;
0897:                    //String fileName = null;
0898:                    initAttachmentObject(sourceType);
0899:                    Attachment pAttch = withAttachment
0900:                            .getAttachmentFromModel((String) sorter.getValueAt(
0901:                                    selectedRow, 0));
0902:                    if (pAttch != null) {
0903:                        BugTracker pBugTracker = SalomeTMFContext.getInstance()
0904:                                .getBugTrackerFromAttachment(pAttch);
0905:                        if (pBugTracker != null) {
0906:                            pBugTracker.showBug(pAttch);
0907:                        } else {
0908:                            viewAttachement(pAttch);
0909:                        }
0910:                    } else {
0911:                        JOptionPane
0912:                                .showMessageDialog(
0913:                                        AttachmentView.this ,
0914:                                        Language
0915:                                                .getInstance()
0916:                                                .getText(
0917:                                                        "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_visualiser!"),
0918:                                        Language.getInstance().getText(
0919:                                                "Erreur_!"),
0920:                                        JOptionPane.ERROR_MESSAGE);
0921:                    }
0922:                    /*if (pAttch != null){
0923:                    	BugTracker pBugTracker = SalomeTMFContext.getInstance().getBugTrackerFromAttachment(pAttch);
0924:                    	if (pBugTracker != null){
0925:                    		pBugTracker.showBug(pAttch);
0926:                    	}
0927:                    	try {
0928:                    		if (pAttch instanceof FileAttachment){
0929:                    			if (pAttch.isInBase()){
0930:                    				file = ((FileAttachment)pAttch).getFileFromDB();
0931:                    			} else {
0932:                    				file = ((FileAttachment)pAttch).getLocalFile();
0933:                    			}
0934:                    			fileName = file.getAbsolutePath();	
0935:                    		} else {
0936:                    			recup = new URL((String)sorter.getValueAt(selectedRow, 0));
0937:                    		}
0938:                    	}catch (Exception e1){
0939:                    		Tools.ihmExceptionView(e1);
0940:                    	}
0941:                    } else {
0942:                    	JOptionPane.showMessageDialog(AttachmentView.this,
0943:                    			Language.getInstance().getText("Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_visualiser!"),
0944:                    			Language.getInstance().getText("Erreur_!"),
0945:                    			JOptionPane.ERROR_MESSAGE);
0946:                    }
0947:                    
0948:                    
0949:                    Properties sys = System.getProperties();
0950:                    String fileSeparator = sys.getProperty("file.separator");
0951:                    Runtime r = Runtime.getRuntime();
0952:                    String executable = "cmd /c call \"";
0953:                    String ext = null;
0954:                    try	{
0955:                    	if (!fileSeparator.equals("\\") && DataModel.isBadDirectoryView() && recup == null) {
0956:                    		//new BadDirectoryView();
0957:                    		ext = fileName.substring(fileName.lastIndexOf("."), fileName.length());
0958:                    		//System.out.println("file extention : " + ext);
0959:                    		executable = (String) extPrg.get(ext);
0960:                    		if (executable == null){
0961:                    			int n = JOptionPane.showConfirmDialog(
0962:                    					SalomeTMFContext.getInstance().ptrFrame,
0963:                    					Language.getInstance().getText("choice_exec_file") +"?",
0964:                    					Language.getInstance().getText("Mime_type_not_detected"),
0965:                    					JOptionPane.YES_NO_OPTION);
0966:                    			if (n == JOptionPane.YES_OPTION){
0967:                    				JFileChooser chooser = new JFileChooser(Language.getInstance().getText("Ouvrir_avec"));
0968:                    				int returnVal = chooser.showOpenDialog(SalomeTMFContext.getInstance().ptrFrame);
0969:                    				if(returnVal == JFileChooser.APPROVE_OPTION) {
0970:                    					try {
0971:                    						executable = chooser.getSelectedFile().getAbsolutePath();
0972:                    					} catch(Exception ex){
0973:                    						Tools.ihmExceptionView(ex);
0974:                    					}
0975:                    				} else {
0976:                    					executable = null;
0977:                    				}
0978:                    			} else {
0979:                    				new BadDirectoryView();
0980:                    			}
0981:                    		} 
0982:                    	}
0983:                    	if (fileSeparator.equals("\\") && fileName != null) {
0984:                    		
0985:                    		//r.exec("cmd /c call " + "\"" + fileName + "\"");
0986:                    		r.exec(executable + fileName + "\"");
0987:                    	} else if (fileName != null){
0988:                    		// Affiche le document après avoir recupérer le contexte courant 
0989:                    		try {
0990:                    			if (executable != null){
0991:                    				r.exec(executable +  " " + fileName);
0992:                    				if (ext != null)  {
0993:                    					extPrg.put(ext, executable);
0994:                    				}
0995:                    			} else {
0996:                    				//applet.getAppletContext().showDocument(new URL("file://" + fileName), "_blank");
0997:                    				applet.showDocument(new URL("file:///" + fileName), "_blank");
0998:                    			}
0999:                    		} catch (Exception ex){
1000:                    			//applet.getAppletContext().showDocument(new URL("file://" + fileName), "_blank");
1001:                    			applet.showDocument(new URL("file:///" + fileName), "_blank");
1002:                    		}
1003:                    	} else if (recup != null) {
1004:                    		
1005:                    		//applet.getAppletContext().showDocument(recup, "_blank");
1006:                    		applet.showDocument(recup, "_blank");
1007:                    	}
1008:                    } catch (IOException ex) {
1009:                    	ex.printStackTrace();
1010:                    }*/
1011:                }
1012:            }
1013:
1014:            public static void viewAttachement(Attachment pAttch) {
1015:                URL recup = null;
1016:                File file = null;
1017:                String fileName = null;
1018:                if (pAttch != null) {
1019:                    try {
1020:                        if (pAttch instanceof  FileAttachment) {
1021:                            if (pAttch.isInBase()) {
1022:                                file = ((FileAttachment) pAttch)
1023:                                        .getFileFromDB();
1024:                            } else {
1025:                                file = ((FileAttachment) pAttch).getLocalFile();
1026:                            }
1027:                            fileName = file.getAbsolutePath();
1028:                        } else {
1029:                            recup = ((UrlAttachment) pAttch).getUrl();
1030:                        }
1031:                    } catch (Exception e1) {
1032:                        Tools.ihmExceptionView(e1);
1033:                    }
1034:                } else {
1035:                    return;
1036:                }
1037:
1038:                Properties sys = System.getProperties();
1039:                String fileSeparator = sys.getProperty("file.separator");
1040:                Runtime r = Runtime.getRuntime();
1041:                String executable = "cmd /c call \"";
1042:                String ext = null;
1043:                try {
1044:                    if (!fileSeparator.equals("\\")
1045:                            && DataModel.isBadDirectoryView() && recup == null
1046:                            && fileName != null) {
1047:                        //new BadDirectoryView();
1048:                        ext = fileName.substring(fileName.lastIndexOf("."),
1049:                                fileName.length());
1050:                        //System.out.println("file extention : " + ext);
1051:                        executable = (String) extPrg.get(ext);
1052:                        if (executable == null) {
1053:                            int n = JOptionPane.showConfirmDialog(
1054:                                    SalomeTMFContext.getInstance().ptrFrame,
1055:                                    Language.getInstance().getText(
1056:                                            "choice_exec_file")
1057:                                            + "?", Language.getInstance()
1058:                                            .getText("Mime_type_not_detected"),
1059:                                    JOptionPane.YES_NO_OPTION);
1060:                            if (n == JOptionPane.YES_OPTION) {
1061:                                JFileChooser chooser = new JFileChooser(
1062:                                        Language.getInstance().getText(
1063:                                                "Ouvrir_avec"));
1064:                                int returnVal = chooser
1065:                                        .showOpenDialog(SalomeTMFContext
1066:                                                .getInstance().ptrFrame);
1067:                                if (returnVal == JFileChooser.APPROVE_OPTION) {
1068:                                    try {
1069:                                        executable = chooser.getSelectedFile()
1070:                                                .getAbsolutePath();
1071:                                    } catch (Exception ex) {
1072:                                        Tools.ihmExceptionView(ex);
1073:                                    }
1074:                                } else {
1075:                                    executable = null;
1076:                                }
1077:                            } else {
1078:                                new BadDirectoryView();
1079:                            }
1080:                        }
1081:                    }
1082:                    if (fileSeparator.equals("\\") && fileName != null) {
1083:
1084:                        //r.exec("cmd /c call " + "\"" + fileName + "\"");
1085:                        r.exec(executable + fileName + "\"");
1086:                    } else if (fileName != null) {
1087:                        /* Affiche le document après avoir recupérer le contexte courant */
1088:                        try {
1089:                            if (executable != null) {
1090:                                r.exec(executable + " " + fileName);
1091:                                if (ext != null) {
1092:                                    extPrg.put(ext, executable);
1093:                                }
1094:                            } else {
1095:                                //applet.getAppletContext().showDocument(new URL("file://" + fileName), "_blank");
1096:                                //applet.showDocument(new URL("file:///" + fileName), "_blank");
1097:                                SalomeTMFContext.getBaseIHM().showDocument(
1098:                                        new URL("file:///" + fileName),
1099:                                        "_blank");
1100:                            }
1101:                        } catch (Exception ex) {
1102:                            //applet.getAppletContext().showDocument(new URL("file://" + fileName), "_blank");
1103:                            //applet.showDocument(new URL("file:///" + fileName), "_blank");
1104:                            SalomeTMFContext.getBaseIHM().showDocument(
1105:                                    new URL("file:///" + fileName), "_blank");
1106:                        }
1107:                    } else if (recup != null) {
1108:
1109:                        //applet.getAppletContext().showDocument(recup, "_blank");
1110:                        //applet.showDocument(recup, "_blank");
1111:                        SalomeTMFContext.getBaseIHM().showDocument(recup,
1112:                                "_blank");
1113:                    }
1114:                } catch (IOException ex) {
1115:                    ex.printStackTrace();
1116:                }
1117:            }
1118:
1119:            public void screeshootPerformed(ActionEvent e) {
1120:                boolean add = false;
1121:                initAttachmentObject(sourceType);
1122:                try {
1123:                    FileAttachment fileAttachment = withAttachment
1124:                            .takeScreenShot();
1125:                    if (sourceType == PROJECT || sourceType == FAMILY
1126:                            || sourceType == CAMPAIGN || sourceType == TESTLIST
1127:                            || sourceType == TEST || sourceType == -1) {
1128:                        withAttachment
1129:                                .addAttachementInDBAndModel(fileAttachment);
1130:                        add = true;
1131:
1132:                    } else {
1133:                        withAttachment.addAttachementInModel(fileAttachment);
1134:                        //attachmentMap.put(fileAttachment.getNameFromModel(), fileAttachment);
1135:                        add = true;
1136:                    }
1137:                    if (add) {
1138:                        ArrayList data = new ArrayList();
1139:                        data.add(fileAttachment.getNameFromModel());
1140:                        data.add(fileAttachment.getSize().toString());
1141:                        data.add(fileAttachment.getDate().toString());
1142:                        DataModel.getAttachmentTableModel().addRow(data);
1143:                    }
1144:                } catch (Exception ex1) {
1145:                    ex1.printStackTrace();
1146:                    JOptionPane.showMessageDialog(AttachmentView.this , Language
1147:                            .getInstance().getText("Le_fichier_")
1148:                            + " Screenshot "
1149:                            + Language.getInstance().getText(
1150:                                    "_est_déjà_attaché_à_") + typeName + " !",
1151:                            Language.getInstance().getText("Erreur_!"),
1152:                            JOptionPane.ERROR_MESSAGE);
1153:                }
1154:            }
1155:
1156:            public void addFileAttachPerformed(ActionEvent e) {
1157:                boolean exception = false;
1158:                boolean add = false;
1159:                JFileChooser fileChooser = new JFileChooser();
1160:                fileChooser.setApproveButtonText(Language.getInstance()
1161:                        .getText("Valider"));
1162:                int returnVal = fileChooser.showOpenDialog(AttachmentView.this );
1163:                if (returnVal == JFileChooser.APPROVE_OPTION) {
1164:                    File file = fileChooser.getSelectedFile();
1165:                    //Date dateOfFile = new Date(file.lastModified());
1166:                    FileAttachment fileAttachment = new FileAttachment(file, "");
1167:                    initAttachmentObject(sourceType);
1168:                    if (withAttachment.containsAttachmentInModel(fileAttachment
1169:                            .getNameFromModel())) {
1170:                        JOptionPane.showMessageDialog(AttachmentView.this ,
1171:                                Language.getInstance().getText("Le_fichier_")
1172:                                        + " "
1173:                                        + fileAttachment.getNameFromModel()
1174:                                        + " "
1175:                                        + Language.getInstance().getText(
1176:                                                "_est_déjà_attaché_à_")
1177:                                        + typeName + " !", Language
1178:                                        .getInstance().getText("Erreur_!"),
1179:                                JOptionPane.ERROR_MESSAGE);
1180:                        return;
1181:                    }
1182:                    if (sourceType == PROJECT || sourceType == FAMILY
1183:                            || sourceType == CAMPAIGN || sourceType == TESTLIST
1184:                            || sourceType == TEST || sourceType == -1) {
1185:                        try {
1186:                            withAttachment
1187:                                    .addAttachementInDBAndModel(fileAttachment);
1188:                            add = true;
1189:                        } catch (Exception ex1) {
1190:                            Tools.ihmExceptionView(ex1);
1191:                            exception = true;
1192:                        }
1193:                    } else {
1194:                        withAttachment.addAttachementInModel(fileAttachment);
1195:                        //attachmentMap.put(fileAttachment.getNameFromModel(), fileAttachment);
1196:                        add = true;
1197:                    }
1198:
1199:                    if (add) {
1200:                        ArrayList data = new ArrayList();
1201:                        data.add(file.getName());
1202:                        data.add(new Long(file.length()).toString());
1203:                        data.add(new Date(file.lastModified()).toString());
1204:                        DataModel.getAttachmentTableModel().addRow(data);
1205:
1206:                    } else if (!exception) {
1207:                        JOptionPane.showMessageDialog(AttachmentView.this ,
1208:                                Language.getInstance().getText("Le_fichier_")
1209:                                        + file.getAbsolutePath()
1210:                                        + Language.getInstance().getText(
1211:                                                "_est_déjà_attaché_à_")
1212:                                        + typeName + " !", Language
1213:                                        .getInstance().getText("Erreur_!"),
1214:                                JOptionPane.ERROR_MESSAGE);
1215:                    }
1216:                }
1217:            }
1218:
1219:            public void addUrlAttachPerformed(ActionEvent e) {
1220:
1221:                URL url = null;
1222:                int essai = 0;
1223:                String lastRes = null;
1224:                while (essai < 3) {
1225:                    try {
1226:                        AskName askName = new AskName(Language.getInstance()
1227:                                .getText("Entrez_une_URL_:"), Language
1228:                                .getInstance().getText("Attacher_une_URL"),
1229:                                Language.getInstance().getText("url"), lastRes,
1230:                                SalomeTMFContext.getInstance().ptrFrame);
1231:                        lastRes = askName.getResult();
1232:                        if (lastRes != null) {
1233:                            url = new URL(lastRes);
1234:                        }
1235:                        essai = 4;
1236:                    } catch (MalformedURLException mue) {
1237:                        JOptionPane.showMessageDialog(AttachmentView.this ,
1238:                                Language.getInstance().getText("L'url_")
1239:                                        + lastRes
1240:                                        + Language.getInstance().getText(
1241:                                                "_est_mal_formée_!"), Language
1242:                                        .getInstance().getText("Erreur_!"),
1243:                                JOptionPane.ERROR_MESSAGE);
1244:                        essai++;
1245:                    }
1246:                }
1247:                if (essai < 4 || lastRes == null) {
1248:                    return;
1249:                }
1250:                boolean add = false;
1251:                UrlAttachment urlAttachment = new UrlAttachment(lastRes, "");
1252:                initAttachmentObject(sourceType);
1253:                if (withAttachment.containsAttachmentInModel(urlAttachment
1254:                        .getNameFromModel())) {
1255:                    JOptionPane.showMessageDialog(AttachmentView.this , Language
1256:                            .getInstance().getText("L'url_")
1257:                            + " "
1258:                            + urlAttachment.getNameFromModel()
1259:                            + " "
1260:                            + Language.getInstance().getText(
1261:                                    "_est_déjà_attachée_à_") + typeName + " !",
1262:                            Language.getInstance().getText("Erreur_!"),
1263:                            JOptionPane.ERROR_MESSAGE);
1264:                    return;
1265:                }
1266:
1267:                urlAttachment.setUrl(url);
1268:                if (sourceType == PROJECT || sourceType == FAMILY
1269:                        || sourceType == CAMPAIGN || sourceType == TESTLIST
1270:                        || sourceType == TEST || sourceType == -1) {
1271:                    try {
1272:                        withAttachment
1273:                                .addAttachementInDBAndModel(urlAttachment);
1274:                        add = true;
1275:                    } catch (Exception ex1) {
1276:                        Tools.ihmExceptionView(ex1);
1277:                    }
1278:                } else {
1279:                    withAttachment.addAttachementInModel(urlAttachment);
1280:                    //attachmentMap.put(urlAttachment.getNameFromModel(), urlAttachment);
1281:                    add = true;
1282:                }
1283:
1284:                if (add) {
1285:                    ArrayList data = new ArrayList();
1286:                    data.add(urlAttachment.getNameFromModel());
1287:                    data.add("");
1288:                    data.add("");
1289:                    DataModel.getAttachmentTableModel().addRow(data);
1290:                } else {
1291:                    JOptionPane.showMessageDialog(AttachmentView.this , Language
1292:                            .getInstance().getText("L'url_")
1293:                            + urlAttachment.getNameFromModel()
1294:                            + Language.getInstance().getText(
1295:                                    "_est_déjà_attachée_à_") + typeName + " !",
1296:                            Language.getInstance().getText("Erreur_!"),
1297:                            JOptionPane.ERROR_MESSAGE);
1298:                }
1299:
1300:            }
1301:
1302:            public void modifyButtonPerformed(ActionEvent e) {
1303:
1304:                int selectedRow = attachmentTable.getSelectedRow();
1305:                Attachment at = null;
1306:                if (selectedRow != -1) {
1307:                    initAttachmentObject(sourceType);
1308:                    at = withAttachment.getAttachmentFromModel((String) sorter
1309:                            .getValueAt(selectedRow, 0));
1310:
1311:                    if (at == null) {
1312:                        JOptionPane
1313:                                .showMessageDialog(
1314:                                        AttachmentView.this ,
1315:                                        Language
1316:                                                .getInstance()
1317:                                                .getText(
1318:                                                        "Vous_devez_valider_l'ajout_des_attachements_avant_de_pouvoir_les_modifier!"),
1319:                                        Language.getInstance().getText(
1320:                                                "Erreur_!"),
1321:                                        JOptionPane.ERROR_MESSAGE);
1322:                        return;
1323:                    } else {
1324:                        FileAttachment fileAttach = (FileAttachment) at;
1325:                        File file = new File(fileAttach.getLocalisation());
1326:                        if (!file.exists()) {
1327:                            return;
1328:                        }
1329:                        int transNumber = -1;
1330:                        try {
1331:                            transNumber = Api.beginTransaction(0,
1332:                                    ApiConstants.UPDATE_ATTACHMENT);
1333:                            // On récupère le flux du fichier après modification
1334:                            file = new File(fileAttach.getLocalisation());
1335:                            fileAttach.updateInDBAndModel(file);
1336:
1337:                            Api.commitTrans(transNumber);
1338:                            transNumber = -1;
1339:
1340:                            // Mise à jour dans l'IHM
1341:                            sorter.setValueAt(new Long(file.length())
1342:                                    .toString(), selectedRow, 1);
1343:                            sorter.setValueAt(new Date(file.lastModified())
1344:                                    .toString(), selectedRow, 2);
1345:
1346:                            JOptionPane
1347:                                    .showMessageDialog(
1348:                                            AttachmentView.this ,
1349:                                            Language
1350:                                                    .getInstance()
1351:                                                    .getText(
1352:                                                            "Le_fichier_a_été_correctement_archivé."),
1353:                                            Language.getInstance().getText(
1354:                                                    "Info..."),
1355:                                            JOptionPane.INFORMATION_MESSAGE);
1356:
1357:                        } catch (Exception exception) {
1358:                            Api.forceRollBackTrans(transNumber);
1359:                            Tools.ihmExceptionView(exception);
1360:                        }
1361:                    }
1362:                }
1363:            }
1364:
1365:            public void delAttachPerformed(ActionEvent e) {
1366:                Object[] options = { Language.getInstance().getText("Oui"),
1367:                        Language.getInstance().getText("Non") };
1368:                int choice = -1;
1369:                int selectedRow = attachmentTable.getSelectedRow();
1370:                int[] selectedRows = attachmentTable.getSelectedRows();
1371:                if (selectedRows.length > 0) {
1372:                    initAttachmentObject(sourceType);
1373:                    choice = JOptionPane
1374:                            .showOptionDialog(
1375:                                    AttachmentView.this ,
1376:                                    //"Etes vous sûr de vouloir supprimer l'attachement <" + (String)DataModel.getAttachmentTableModel().getValueAt(selectedRow, 0) + "> ?",
1377:                                    Language
1378:                                            .getInstance()
1379:                                            .getText(
1380:                                                    "Etes_vous_sûr_de_vouloir_supprimer_l'attachement_<")
1381:                                            + (String) sorter.getValueAt(
1382:                                                    selectedRow, 0) + "> ?",
1383:                                    Language.getInstance().getText(
1384:                                            "Attention_!"),
1385:                                    JOptionPane.YES_NO_OPTION,
1386:                                    JOptionPane.QUESTION_MESSAGE, null,
1387:                                    options, options[1]);
1388:                    if (choice == JOptionPane.YES_OPTION) {
1389:                        for (int i = 0; i < selectedRows.length; i++) {
1390:
1391:                            Attachment attach = withAttachment
1392:                                    .getAttachmentFromModel((String) sorter
1393:                                            .getValueAt(selectedRows[i], 0));
1394:                            if (attach != null) {
1395:                                try {
1396:                                    if (sourceType == PROJECT
1397:                                            || sourceType == FAMILY
1398:                                            || sourceType == CAMPAIGN
1399:                                            || sourceType == TESTLIST
1400:                                            || sourceType == TEST
1401:                                            || sourceType == -1) {
1402:
1403:                                        withAttachment
1404:                                                .deleteAttachementInDBAndModel(attach);
1405:
1406:                                    } else {
1407:                                        withAttachment
1408:                                                .deleteAttachmentInModel(attach);
1409:
1410:                                    }
1411:                                    //DataModel.getAttachmentTableModel().removeData(sorter.modelIndex(selectedRow));
1412:                                } catch (Exception exception) {
1413:                                    Tools.ihmExceptionView(exception);
1414:                                }
1415:                            } else {
1416:
1417:                            }
1418:                        }
1419:                        DataModel.getAttachmentTableModel().clearTable();
1420:                        loadAttachment();
1421:                    }
1422:
1423:                }
1424:            }
1425:
1426:            public void valueChanged(ListSelectionEvent e) {
1427:                if (e.getSource().equals(attachmentTable.getSelectionModel())) {
1428:                    attachmentTableValueChanged(e);
1429:                }
1430:            }
1431:
1432:            Attachment getAttachByName(String name) {
1433:                Attachment pAttach = withAttachment
1434:                        .getAttachmentFromModel(name);
1435:                return pAttach;
1436:            }
1437:
1438:            public void attachmentTableValueChanged(ListSelectionEvent e) {
1439:
1440:                if (e.getValueIsAdjusting())
1441:                    return;
1442:
1443:                int nbOfSelectedRows = attachmentTable.getSelectedRowCount();
1444:                int selectedRow = attachmentTable.getSelectedRow();
1445:                if (selectedRow != -1) {
1446:                    if (nbOfSelectedRows == 1) {
1447:                        openAttach.setEnabled(true);
1448:                        initAttachmentObject(sourceType);
1449:                        if (sourceType == EXECUTION_RESULT
1450:                                || sourceType == EXECUTION_RESULT_TEST) {
1451:                            if (Permission.canExecutCamp()) {
1452:                                descriptionArea.setEditable(true);
1453:                            }
1454:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1455:                                    .equals("")) {
1456:                                if (Permission.canExecutCamp())
1457:                                    modifyButton.setEnabled(true);
1458:                                saveAttachButton.setEnabled(true);
1459:                            } else {
1460:                                modifyButton.setEnabled(false);
1461:                                saveAttachButton.setEnabled(false);
1462:                            }
1463:                            if (Permission.canExecutCamp()) {
1464:                                delAttach.setEnabled(true);
1465:                            }
1466:                            if (descriptionArea.isEditable()) {
1467:                                descriptionArea.setText(getAttachByName(
1468:                                        (String) sorter.getValueAt(selectedRow,
1469:                                                0)).getDescriptionFromModel());
1470:                                //descriptionArea.setText(((Attachment)attachmentMap.get(sorter.getValueAt(selectedRow, 0))).getDescriptionFromModel());
1471:
1472:                            }
1473:                        } else if (sourceType == ENVIRONMENT) {
1474:                            if (Permission.canUpdateCamp()) {
1475:                                descriptionArea.setEditable(true);
1476:                            }
1477:
1478:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1479:                                    .equals("")) {
1480:                                if (Permission.canUpdateCamp())
1481:                                    modifyButton.setEnabled(true);
1482:                                saveAttachButton.setEnabled(true);
1483:                            } else {
1484:                                modifyButton.setEnabled(false);
1485:                                saveAttachButton.setEnabled(false);
1486:                            }
1487:                            if (Permission.canDeleteCamp()) {
1488:                                delAttach.setEnabled(true);
1489:                            }
1490:
1491:                            if (descriptionArea.isEditable()) {
1492:                                descriptionArea.setText(getAttachByName(
1493:                                        (String) sorter.getValueAt(selectedRow,
1494:                                                0)).getDescriptionFromModel());
1495:                            }
1496:                        } else if (sourceType == EXECUTION) {
1497:                            if (Permission.canUpdateCamp()
1498:                                    || Permission.canExecutCamp()) {
1499:                                descriptionArea.setEditable(true);
1500:                            }
1501:                            // le bouton actualiser est valide suelement pour les fichiers
1502:
1503:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1504:                                    .equals("")) {
1505:                                if (Permission.canUpdateCamp()
1506:                                        || Permission.canExecutCamp())
1507:                                    modifyButton.setEnabled(true);
1508:                                saveAttachButton.setEnabled(true);
1509:                            } else {
1510:                                modifyButton.setEnabled(false);
1511:                                saveAttachButton.setEnabled(false);
1512:                            }
1513:                            if (Permission.canDeleteCamp()
1514:                                    || Permission.canExecutCamp()) {
1515:                                delAttach.setEnabled(true);
1516:                            }
1517:
1518:                            if (descriptionArea.isEditable()) {
1519:                                descriptionArea.setText(getAttachByName(
1520:                                        (String) sorter.getValueAt(selectedRow,
1521:                                                0)).getDescriptionFromModel());
1522:                                //descriptionArea.setText(((Attachment)attachmentMap.get(sorter.getValueAt(selectedRow, 0))).getDescriptionFromModel());
1523:                            }
1524:                        } else if (sourceType == PROJECT
1525:                                || sourceType == FAMILY
1526:                                || sourceType == TESTLIST || sourceType == TEST
1527:                                || sourceType == ACTION) {
1528:                            if (Permission.canUpdateTest()) {
1529:                                descriptionArea.setEditable(true);
1530:                            }
1531:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1532:                                    .equals("")) {
1533:                                if (Permission.canUpdateTest())
1534:                                    modifyButton.setEnabled(true);
1535:                                saveAttachButton.setEnabled(true);
1536:                            } else {
1537:                                modifyButton.setEnabled(false);
1538:                                saveAttachButton.setEnabled(false);
1539:                            }
1540:                            if (Permission.canDeleteTest()) {
1541:                                delAttach.setEnabled(true);
1542:                            }
1543:                            if (descriptionArea.isEditable()) {
1544:                                descriptionArea.setText(getAttachByName(
1545:                                        (String) sorter.getValueAt(selectedRow,
1546:                                                0)).getDescriptionFromModel());
1547:                                //descriptionArea.setText(DataModel.getCurrentTest().getAttachmentFromModel((String)sorter.getValueAt(selectedRow, 0)).getDescriptionFromModel());
1548:                            }
1549:                        } else if (sourceType == CAMPAIGN) {
1550:                            /*try{
1551:                            	previousAtt.updateDescriptionInDB(previousAtt.getDescriptionFromModel());
1552:                            } catch (Exception e1){
1553:                            	
1554:                            }*/
1555:                            if (Permission.canUpdateCamp())
1556:                                descriptionArea.setEditable(true);
1557:
1558:                            if (!((String) sorter.getValueAt(selectedRow, 1))
1559:                                    .equals("")) {
1560:                                if (Permission.canUpdateCamp())
1561:                                    modifyButton.setEnabled(true);
1562:                                saveAttachButton.setEnabled(true);
1563:                            } else {
1564:                                modifyButton.setEnabled(false);
1565:                                saveAttachButton.setEnabled(false);
1566:                            }
1567:                            if (Permission.canDeleteCamp()) {
1568:                                delAttach.setEnabled(true);
1569:                            }
1570:
1571:                            if (descriptionArea.isEditable()) {
1572:                                descriptionArea.setText(getAttachByName(
1573:                                        (String) sorter.getValueAt(selectedRow,
1574:                                                0)).getDescriptionFromModel());
1575:                                //descriptionArea.setText(DataModel.getCurrentCampaign().getAttachmentFromModel((String)sorter.getValueAt(selectedRow, 0)).getDescriptionFromModel());
1576:                            }
1577:
1578:                        } else {
1579:                            if (withAttachment != null) {
1580:                                openAttach.setEnabled(true);
1581:                                descriptionArea.setEditable(true);
1582:                                if (!((String) sorter
1583:                                        .getValueAt(selectedRow, 1)).equals("")) {
1584:                                    modifyButton.setEnabled(true);
1585:                                    saveAttachButton.setEnabled(true);
1586:                                } else {
1587:                                    modifyButton.setEnabled(false);
1588:                                    saveAttachButton.setEnabled(false);
1589:                                }
1590:                                delAttach.setEnabled(true);
1591:                                descriptionArea.setText(getAttachByName(
1592:                                        (String) sorter.getValueAt(selectedRow,
1593:                                                0)).getDescriptionFromModel());
1594:                            } else {
1595:                                openAttach.setEnabled(false);
1596:                                descriptionArea.setEditable(false);
1597:                                modifyButton.setEnabled(false);
1598:                                delAttach.setEnabled(false);
1599:                                descriptionArea.setText("");
1600:                            }
1601:                        }
1602:                    } else {
1603:                        openAttach.setEnabled(false);
1604:                        descriptionArea.setEditable(false);
1605:                        modifyButton.setEnabled(false);
1606:                        descriptionArea.setText("");
1607:                    }
1608:
1609:                } else {
1610:                    descriptionArea.setEditable(false);
1611:                    descriptionArea.setText("");
1612:                    openAttach.setEnabled(false);
1613:                    delAttach.setEnabled(false);
1614:                    modifyButton.setEnabled(false);
1615:                }
1616:
1617:                if (readOnly)
1618:                    setReadOnly();
1619:
1620:            }
1621:
1622:            /* Focus on description */
1623:            public void focusGained(FocusEvent e) {
1624:                //System.out.println("Focus gained" + e);
1625:            }
1626:
1627:            public void focusLost(FocusEvent e) {
1628:                if (sourceType == PROJECT || sourceType == FAMILY
1629:                        || sourceType == CAMPAIGN || sourceType == TESTLIST
1630:                        || sourceType == TEST || sourceType == -1) {
1631:                    try {
1632:                        previousAtt.updateDescriptionInDB(previousAtt
1633:                                .getDescriptionFromModel());
1634:                    } catch (Exception e1) {
1635:                    }
1636:                }
1637:            }
1638:
1639:            void setReadOnly() {
1640:                readOnly = true;
1641:                addFileAttach.setEnabled(false);
1642:                addUrlAttach.setEnabled(false);
1643:                screeshootButton.setEnabled(false);
1644:                modifyButton.setEnabled(false);
1645:                delAttach.setEnabled(false);
1646:                descriptionArea.setEditable(false);
1647:            }
1648:
1649:        } // 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.