001: package salomeTMF_plug.mantis;
002:
003: import java.awt.BorderLayout;
004: import java.awt.Color;
005: import java.awt.Container;
006: import java.awt.Dimension;
007: import java.awt.FlowLayout;
008: import java.awt.Font;
009: import java.awt.GraphicsConfiguration;
010: import java.awt.GraphicsDevice;
011: import java.awt.GraphicsEnvironment;
012: import java.awt.GridLayout;
013: import java.awt.Rectangle;
014: import java.awt.event.ActionEvent;
015: import java.awt.event.ActionListener;
016: import java.sql.Date;
017: import java.text.SimpleDateFormat;
018: import java.util.ArrayList;
019: import java.util.HashMap;
020: import java.util.Hashtable;
021: import java.util.Iterator;
022: import java.util.Set;
023:
024: import javax.swing.BorderFactory;
025: import javax.swing.BoxLayout;
026: import javax.swing.ImageIcon;
027: import javax.swing.JButton;
028: import javax.swing.JDialog;
029: import javax.swing.JLabel;
030: import javax.swing.JPanel;
031: import javax.swing.JScrollPane;
032: import javax.swing.JSplitPane;
033: import javax.swing.JTabbedPane;
034: import javax.swing.JTable;
035: import javax.swing.JTextArea;
036: import javax.swing.JTree;
037: import javax.swing.ListSelectionModel;
038: import javax.swing.event.ListSelectionEvent;
039: import javax.swing.event.ListSelectionListener;
040: import javax.swing.event.TreeSelectionEvent;
041: import javax.swing.event.TreeSelectionListener;
042: import javax.swing.tree.DefaultMutableTreeNode;
043: import javax.swing.tree.TreePath;
044: import javax.swing.tree.TreeSelectionModel;
045:
046: import org.objectweb.salome_tmf.data.Attachment;
047: import org.objectweb.salome_tmf.data.Campaign;
048: import org.objectweb.salome_tmf.data.DataConstants;
049: import org.objectweb.salome_tmf.data.Execution;
050: import org.objectweb.salome_tmf.data.ExecutionResult;
051: import org.objectweb.salome_tmf.data.ExecutionTestResult;
052: import org.objectweb.salome_tmf.data.Test;
053: import org.objectweb.salome_tmf.ihm.IHMConstants;
054: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
055: import org.objectweb.salome_tmf.ihm.main.SalomeTMFPanels;
056: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
057: import org.objectweb.salome_tmf.ihm.models.ActionDetailsResultMouseListener;
058: import org.objectweb.salome_tmf.ihm.models.AutomaticTestResultMouseListener;
059: import org.objectweb.salome_tmf.ihm.models.MyTableModel;
060: import org.objectweb.salome_tmf.ihm.models.TableSorter;
061: import org.objectweb.salome_tmf.ihm.models.TestTreeModel;
062: import org.objectweb.salome_tmf.ihm.models.TreeRenderer;
063: import org.objectweb.salome_tmf.ihm.tools.Tools;
064:
065: import salomeTMF_plug.mantis.languages.Language;
066: import salomeTMF_plug.mantis.sqlWrapper.DefectWrapper;
067:
068: public class AddLinkDialog extends JDialog implements DataConstants,
069: ActionListener, TreeSelectionListener {
070:
071: protected TestTreeModel campTreeModel;
072: JTree testTree;
073: DefaultMutableTreeNode testSelectedNode;
074: DefaultMutableTreeNode temporaryChosenRootNode;
075:
076: JTabbedPane detailPanel;
077: JPanel buttonPanel;
078: //JButton cancelButton;
079: JButton validateButton;
080:
081: JPanel emptyPanel;
082:
083: JTextArea descriptionArea;
084: JScrollPane campaignPanel;
085:
086: JPanel executionPanel;
087: JLabel envLabel;
088: JLabel dateLabel;
089: JLabel datelastExec;
090:
091: JPanel resExexPanel;
092:
093: ExecutionResult currentExecResult;
094: MyTableModel testResultTableModel;
095: JTable testResultTable;
096: TableSorter sorter;
097: ListSelectionModel rowSM;
098: JButton linkDefectButton;
099: JButton removelinkDefectButton;
100: JButton editDefectButton;
101: JButton addDefectButton;
102: JLabel executionName;
103: DefectPanel pDefectPanel;
104:
105: JPanel infoDefect;
106: JLabel idDefect;
107: JLabel resumeDefect;
108: JLabel priorityDefect;
109: JLabel stateDefect;
110: JButton editDefect;
111:
112: DefectWrapper defectToLink;
113: MantisPlugin pMantisPlugin;
114: Hashtable defectsWrapperCache;
115:
116: boolean doModification = false;
117:
118: public AddLinkDialog(DefectWrapper pDefectWrapper,
119: MantisPlugin pMantisPlugin) {
120:
121: super (SalomeTMFContext.getInstance().getSalomeFrame(), true);
122: defectToLink = pDefectWrapper;
123: this .pMantisPlugin = pMantisPlugin;
124: int t_x = 1024 - 100;
125: int t_y = 768 - 50;
126: try {
127: GraphicsEnvironment ge = GraphicsEnvironment
128: .getLocalGraphicsEnvironment();
129: GraphicsDevice[] gs = ge.getScreenDevices();
130: GraphicsDevice gd = gs[0];
131: GraphicsConfiguration[] gc = gd.getConfigurations();
132: Rectangle r = gc[0].getBounds();
133: t_x = r.width - 100;
134: t_y = r.height - 50;
135: } catch (Exception E) {
136:
137: }
138:
139: TreeRenderer testRenderer = new TreeRenderer();
140: DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode(
141: "Sélection");
142: temporaryChosenRootNode = new DefaultMutableTreeNode(treeRoot
143: .getUserObject());
144: DefaultMutableTreeNode testRoot = SalomeTMFPanels
145: .getCampaignDynamicTree().getRoot();
146: DefaultMutableTreeNode testRootClone = (DefaultMutableTreeNode) testRoot
147: .clone();
148:
149: testTree = new JTree();
150: campTreeModel = new TestTreeModel(testRootClone, testTree, null);
151: testTree.setModel(campTreeModel);
152: testTree.getSelectionModel().setSelectionMode(
153: TreeSelectionModel.SINGLE_TREE_SELECTION);
154:
155: for (int j = 0; j < testRoot.getChildCount(); j++) {
156: DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) testRoot
157: .getChildAt(j);
158: Campaign campaign = (Campaign) childNode.getUserObject();
159: if (campaign.containsExecutionResultInModel()) {
160: addObject(testRootClone, campaign, true);
161: }
162: }
163:
164: testTree.setCellRenderer(testRenderer);
165: testTree.addTreeSelectionListener(this );
166:
167: // Exécutions de chaque campagne
168: DefaultMutableTreeNode root = (DefaultMutableTreeNode) campTreeModel
169: .getRoot();
170: for (int j = 0; j < root.getChildCount(); j++) {
171: DefaultMutableTreeNode campNode = (DefaultMutableTreeNode) root
172: .getChildAt(j);
173: if (campNode.getUserObject() instanceof Campaign) {
174: campNode.removeAllChildren();
175: Campaign camp = (Campaign) campNode.getUserObject();
176: ArrayList execList = camp.getExecutionListFromModel();
177: if (!execList.isEmpty()) {
178: Iterator it = execList.iterator();
179: while (it.hasNext()) {
180: Execution exec = (Execution) it.next();
181: ArrayList execResList = exec
182: .getExecutionResultListFromModel();
183: if (execResList.size() > 0) {
184: DefaultMutableTreeNode execNode = addObject(
185: campNode, exec, true);
186: Iterator it2 = execResList.iterator();
187: while (it2.hasNext()) {
188: ExecutionResult resExec = (ExecutionResult) it2
189: .next();
190: addObject(execNode, resExec, true);
191: }
192: }
193: }
194: }
195: }
196: }
197:
198: detailPanel = new JTabbedPane();
199: detailPanel.setSize(new Dimension(t_x * 3 / 2, t_y / 10 * 8));
200:
201: emptyPanel = new JPanel();
202: //emptyPanel.setSize(new Dimension(t_x/2, t_y/10*8));
203: detailPanel.add(emptyPanel, "Details");
204:
205: descriptionArea = new JTextArea();
206: campaignPanel = new JScrollPane(descriptionArea);
207: descriptionArea.setEditable(false);
208: campaignPanel.setPreferredSize(new Dimension(t_x * 3 / 2,
209: t_y / 10 * 8));
210:
211: /* Execution */
212: executionPanel = new JPanel();
213: executionPanel.setLayout(new BoxLayout(executionPanel,
214: BoxLayout.Y_AXIS));
215: envLabel = new JLabel();
216: dateLabel = new JLabel();
217: datelastExec = new JLabel();
218: executionPanel.add(envLabel);
219: executionPanel.add(dateLabel);
220: executionPanel.add(datelastExec);
221:
222: /* Resultat d'exécution */
223: testResultTableModel = new MyTableModel();
224: testResultTable = new JTable();
225: executionName = new JLabel();
226: executionName.setFont(new Font(null, Font.BOLD, 18));
227:
228: testResultTableModel
229: .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
230: .getInstance().getText("Famille"));
231: testResultTableModel
232: .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
233: .getInstance().getText("Suite"));
234: testResultTableModel
235: .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
236: .getInstance().getText("Test"));
237: testResultTableModel
238: .addColumnNameAndColumn(org.objectweb.salome_tmf.ihm.languages.Language
239: .getInstance().getText("Résultats"));
240: sorter = new TableSorter(testResultTableModel);
241: testResultTable.setModel(sorter);
242: sorter.setTableHeader(testResultTable.getTableHeader());
243: //testResultTable.setPreferredScrollableViewportSize(new Dimension(600, 200));
244: testResultTable
245: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
246: JScrollPane tablePane = new JScrollPane(testResultTable);
247: tablePane.setBorder(BorderFactory.createRaisedBevelBorder());
248:
249: rowSM = testResultTable.getSelectionModel();
250: rowSM.addListSelectionListener(new ListSelectionListener() {
251: public void valueChanged(ListSelectionEvent e) {
252: if (e.getValueIsAdjusting())
253: return;
254:
255: int selectedRowIndex = testResultTable.getSelectedRow();
256: if (selectedRowIndex != -1
257: && testResultTableModel.getRowCount() > 0) {
258: Test test = DataModel.getCurrentProject()
259: .getTestFromModel(
260: (String) sorter.getValueAt(
261: selectedRowIndex, 0),
262: (String) sorter.getValueAt(
263: selectedRowIndex, 1),
264: (String) sorter.getValueAt(
265: selectedRowIndex, 2));
266: DataModel.setTestObservedInExecution(test);
267: DataModel
268: .setCurrentExecutionTestResult(currentExecResult
269: .getExecutionTestResultFromModel(test));
270: if (defectToLink != null) {
271: linkDefectButton.setEnabled(true);
272: removelinkDefectButton.setEnabled(true);
273: editDefectButton.setEnabled(true);
274: addDefectButton.setEnabled(true);
275: } else {
276: removelinkDefectButton.setEnabled(true);
277: editDefectButton.setEnabled(true);
278: addDefectButton.setEnabled(true);
279: }
280: updateDefectPanel(true);
281: } else {
282: linkDefectButton.setEnabled(false);
283: removelinkDefectButton.setEnabled(false);
284: editDefectButton.setEnabled(false);
285: addDefectButton.setEnabled(false);
286: updateDefectPanel(false);
287: }
288: }
289: });
290: // Gestion de la souris
291: testResultTable
292: .addMouseListener(new ActionDetailsResultMouseListener());
293: testResultTable
294: .addMouseListener(new AutomaticTestResultMouseListener());
295:
296: linkDefectButton = new JButton(
297: salomeTMF_plug.mantis.languages.Language.getInstance()
298: .getText("Lier_a_lannomalie"));
299: linkDefectButton.setEnabled(false);
300: linkDefectButton.addActionListener(this );
301:
302: removelinkDefectButton = new JButton(
303: salomeTMF_plug.mantis.languages.Language.getInstance()
304: .getText("Supprimer_lien"));
305: removelinkDefectButton.setEnabled(false);
306: removelinkDefectButton.addActionListener(this );
307:
308: editDefectButton = new JButton(
309: salomeTMF_plug.mantis.languages.Language.getInstance()
310: .getText("Editer"));
311: editDefectButton.setEnabled(false);
312: editDefectButton.addActionListener(this );
313:
314: addDefectButton = new JButton(
315: salomeTMF_plug.mantis.languages.Language.getInstance()
316: .getText("Ajouter"));
317: addDefectButton.setEnabled(false);
318: addDefectButton.addActionListener(this );
319:
320: JPanel upPart = new JPanel(new BorderLayout());
321: upPart.add(executionName, BorderLayout.NORTH);
322:
323: JPanel allView = new JPanel(new BorderLayout());
324:
325: allView.add(upPart, BorderLayout.NORTH);
326: allView.add(tablePane, BorderLayout.CENTER);
327:
328: JPanel buttonPanel = new JPanel(new FlowLayout(
329: FlowLayout.CENTER));
330: buttonPanel.add(linkDefectButton);
331: buttonPanel.add(removelinkDefectButton);
332: buttonPanel.add(addDefectButton);
333: buttonPanel.add(editDefectButton);
334:
335: pDefectPanel = new DefectPanel(true, pMantisPlugin,
336: buttonPanel, null);
337:
338: resExexPanel = new JPanel();
339: resExexPanel.setLayout(new BoxLayout(resExexPanel,
340: BoxLayout.Y_AXIS));
341: resExexPanel.add(allView);
342: //Ici les annomalies
343: resExexPanel.add(pDefectPanel);
344: //resExexPanel.add(buttonPanel);
345:
346: JScrollPane testScrollPane = new JScrollPane(testTree);
347: testScrollPane.setBorder(BorderFactory
348: .createTitledBorder("Exécutions"));
349: testScrollPane.setPreferredSize(new Dimension(t_x / 3,
350: t_y / 10 * 8));
351:
352: /*JPanel windowPanel = new JPanel();
353: windowPanel.setLayout(new BoxLayout(windowPanel, BoxLayout.X_AXIS));
354: windowPanel.add(testScrollPane);
355: windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
356: windowPanel.add(detailPanel);
357: windowPanel.setPreferredSize(new Dimension(t_x, t_y/10*8));
358: */
359:
360: JSplitPane windowPanel = new JSplitPane(
361: JSplitPane.HORIZONTAL_SPLIT, testScrollPane,
362: detailPanel);
363: windowPanel.setPreferredSize(new Dimension(t_x, t_y / 10 * 8));
364: //windowPanel.setDividerLocation(t_x/3);
365: /*if (Api.isIDE_DEV()){
366: windowPanel.setDividerLocation(3);
367: } else {
368: windowPanel.setDividerLocation(t_x*3/2);
369: }*/
370: //add(splitPane);
371: buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
372:
373: /*cancelButton = new JButton(org.objectweb.salome_tmf.ihm.languages.Language.getInstance().getText("Annuler"));
374: cancelButton.addActionListener(this);*/
375: validateButton = new JButton(
376: org.objectweb.salome_tmf.ihm.languages.Language
377: .getInstance().getText("Valider"));
378: validateButton.addActionListener(this );
379: //buttonPanel.add(cancelButton);
380: buttonPanel.add(validateButton);
381:
382: if (defectToLink != null) {
383: infoDefect = new JPanel(new GridLayout(1, 5));
384: infoDefect.setBorder(BorderFactory.createTitledBorder(
385: BorderFactory.createLineBorder(Color.BLACK),
386: salomeTMF_plug.mantis.languages.Language
387: .getInstance().getText(
388: "Anomalie_selectione")));
389: idDefect = new JLabel("id : " + defectToLink.getId());
390: resumeDefect = new JLabel(
391: org.objectweb.salome_tmf.ihm.languages.Language
392: .getInstance().getText("Résumé_:______")
393: + " " + defectToLink.getResume());
394: String str_value = (String) pMantisPlugin.priorityByID
395: .get(Integer.valueOf(""
396: + defectToLink.getPriority()));
397: priorityDefect = new JLabel(
398: org.objectweb.salome_tmf.ihm.languages.Language
399: .getInstance().getText("Priority")
400: + " : " + str_value);
401: str_value = (String) pMantisPlugin.statusByID.get(Integer
402: .valueOf("" + defectToLink.getStatus()));
403: stateDefect = new JLabel(
404: org.objectweb.salome_tmf.ihm.languages.Language
405: .getInstance().getText("Etat")
406: + " : " + str_value);
407: editDefect = new JButton(
408: salomeTMF_plug.mantis.languages.Language
409: .getInstance().getText("Editer"));
410: editDefect.addActionListener(this );
411:
412: infoDefect.add(idDefect);
413: infoDefect.add(resumeDefect);
414: infoDefect.add(priorityDefect);
415: infoDefect.add(stateDefect);
416: infoDefect.add(editDefect);
417:
418: }
419:
420: Container contentPaneFrame = this .getContentPane();
421: if (defectToLink != null) {
422: contentPaneFrame.add(infoDefect, BorderLayout.NORTH);
423: }
424: contentPaneFrame.add(windowPanel, BorderLayout.CENTER);
425: contentPaneFrame.add(buttonPanel, BorderLayout.SOUTH);
426:
427: this .setTitle(salomeTMF_plug.mantis.languages.Language
428: .getInstance().getText("Lier"));
429: this .setSize(new Dimension(t_x, t_y));
430: /*this.pack();
431: this.setLocationRelativeTo(this.getParent());
432: this.setVisible(true);
433: */
434: centerScreen();
435: } // Fin du constructeur ExecChooser
436:
437: void centerScreen() {
438: Dimension dim = getToolkit().getScreenSize();
439: this .pack();
440: Rectangle abounds = getBounds();
441: setLocation((dim.width - abounds.width) / 2,
442: (dim.height - abounds.height) / 2);
443: this .setVisible(true);
444: requestFocus();
445: }
446:
447: /**
448: * Méthode d'ajout d'un noeud dans l'arbre sous le parent.
449: * @param parent le parent
450: * @param child le noeud à ajouter
451: * @param shouldBeVisible visible ou non
452: * @return le nouveau noeud de l'arbre
453: */
454: public DefaultMutableTreeNode addObject(
455: DefaultMutableTreeNode parent, Object child,
456: boolean shouldBeVisible) {
457:
458: DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(
459: child);
460: if (parent == null) {
461: parent = temporaryChosenRootNode;
462: }
463: // Insertion du noeud
464: campTreeModel.insertNodeInto(childNode, parent, parent
465: .getChildCount());
466: // on s'assure que le noeud est visible
467: if (shouldBeVisible) {
468: testTree.scrollPathToVisible(new TreePath(childNode
469: .getPath()));
470: }
471: return childNode;
472: } // Fin de la classe addObject/3
473:
474: void setEmptyPanel() {
475: detailPanel.removeAll();
476: detailPanel.add(emptyPanel, "Details");
477: //detailPanel.repaint();
478: }
479:
480: void setCampaignPanel(Campaign pCamp) {
481: descriptionArea.setText(pCamp.getDescriptionFromModel());
482: detailPanel.removeAll();
483: detailPanel.add(campaignPanel,
484: org.objectweb.salome_tmf.ihm.languages.Language
485: .getInstance().getText("Campagne"));
486: }
487:
488: void setExecutionPanel(Execution pExec) {
489: detailPanel.removeAll();
490: SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy");
491: envLabel
492: .setText(org.objectweb.salome_tmf.ihm.languages.Language
493: .getInstance().getText("Environnement")
494: + " : "
495: + pExec.getEnvironmentFromModel()
496: .getNameFromModel());
497: dateLabel
498: .setText(org.objectweb.salome_tmf.ihm.languages.Language
499: .getInstance().getText("Date_de_création")
500: + " : "
501: + formater.format(
502: pExec.getCreationDateFromModel())
503: .toString());
504: Date pDate = pExec.getLastDateFromModel();
505: datelastExec
506: .setText(org.objectweb.salome_tmf.ihm.languages.Language
507: .getInstance().getText("Dernière_Exécution")
508: + " : " + formater.format(pDate).toString());
509: detailPanel.add(executionPanel,
510: org.objectweb.salome_tmf.ihm.languages.Language
511: .getInstance().getText("Exécution"));
512: }
513:
514: void setResExecutionPanel(ExecutionResult pExecutionResult) {
515: executionName.setText(pExecutionResult.getNameFromModel());
516: detailPanel.removeAll();
517: currentExecResult = pExecutionResult;
518: DataModel.setObervedExecutionResult(pExecutionResult);
519: DataModel.setObservedExecution(pExecutionResult.getExecution());
520: initTestResults(pExecutionResult);
521: detailPanel.add(resExexPanel,
522: org.objectweb.salome_tmf.ihm.languages.Language
523: .getInstance().getText("Exécution"));
524: }
525:
526: public void initTestResults(ExecutionResult executionResult) {
527: testResultTableModel.clearTable();
528: Test[] pTabTest = executionResult.getTestOrderedFromModel();
529: for (int j = 0; j < pTabTest.length; j++) {
530: Test test = pTabTest[j];
531: ArrayList data = new ArrayList();
532: data.add(test.getTestListFromModel().getFamilyFromModel()
533: .toString());
534: data.add(test.getTestListFromModel().toString());
535: data.add(test.toString());
536: ImageIcon image = Tools.getActionStatusIcon(executionResult
537: .getTestResultStatusFromModel(test));
538: if (image == null) {
539: data.add(Tools.createAppletImageIcon(
540: IHMConstants.PATH_TO_GOON_ICON, ""));
541: } else {
542: data.add(Tools.getActionStatusIcon(executionResult
543: .getTestResultStatusFromModel(test)));
544: }
545: currentExecResult = executionResult;
546: testResultTableModel.addRow(data);
547:
548: }
549: } // Fin de la m?thode initTestResults/1
550:
551: /*************************** Listener ***********************************/
552:
553: public void actionPerformed(ActionEvent e) {
554: if (e.getSource().equals(linkDefectButton)) {
555: LinkDefectPerformed();
556: } else if (editDefect != null
557: && e.getSource().equals(editDefect)) {
558: editDefectPermed(defectToLink);
559: } else if (e.getSource().equals(validateButton)) {
560: dispose();
561: } else if (e.getSource().equals(editDefectButton)) {
562: DefectWrapper pDefectWrapper = pDefectPanel
563: .getSelectedDefect();
564: editDefectPermed(pDefectWrapper);
565: } else if (e.getSource().equals(removelinkDefectButton)) {
566: removelinkDefectPerformed();
567: } else if (e.getSource().equals(addDefectButton)) {
568: addDefectPerformed();
569: }
570: }
571:
572: void addDefectPerformed() {
573: Execution pExecution = null;
574: ExecutionTestResult pExecutionTestResult = null;
575: try {
576: pExecutionTestResult = DataModel
577: .getCurrentExecutionTestResult();
578: pExecution = DataModel.getObservedExecutionResult()
579: .getExecution();
580: } catch (Exception e1) {
581: e1.printStackTrace();
582: }
583: DefectView pDefectView = null;
584: if (pExecution != null) {
585: pDefectView = new DefectView(this , pMantisPlugin,
586: pExecution.getEnvironmentFromModel()
587: .getNameFromModel());
588: } else {
589: pDefectView = new DefectView(this , pMantisPlugin);
590: }
591: try {
592: if (pDefectView.isDoingModification()) {
593: DefectWrapper pDefectWrapper = pDefectView
594: .getDefectWrapper();
595: if (pDefectWrapper != null) {
596: Attachment pAttch = pMantisPlugin
597: .makeAttachement(pDefectWrapper.getId());
598: pExecutionTestResult
599: .addAttachementInDBAndModel(pAttch);
600: doModification = true;
601: defectsWrapperCache.put(new Integer(pDefectWrapper
602: .getId()), pDefectWrapper);
603: pDefectPanel.loadData(defectsWrapperCache);
604: }
605: }
606: } catch (Exception e) {
607: e.printStackTrace();
608: }
609: }
610:
611: void removelinkDefectPerformed() {
612: DefectWrapper pDefectWrapper = pDefectPanel.getSelectedDefect();
613: if (pDefectWrapper != null) {
614: if (pMantisPlugin.deleteConfirme(Language.getInstance()
615: .getText("Le_lien"))) {
616: try {
617: int defectID = pDefectWrapper.getId();
618: ExecutionTestResult pExecutionTestResult = DataModel
619: .getCurrentExecutionTestResult();
620: HashMap attacMap = pExecutionTestResult
621: .getAttachmentMapFromModel();
622: Set keysSet = attacMap.keySet();
623: boolean trouve = false;
624: Iterator iter = keysSet.iterator();
625: while (!trouve && iter.hasNext()) {
626: Object attachName = iter.next();
627: Attachment pAttach = (Attachment) attacMap
628: .get(attachName);
629: int bugid = pMantisPlugin.getIDofBug(pAttach);
630: if (bugid == defectID) {
631: pExecutionTestResult
632: .deleteAttachementInDBAndModel(pAttach);
633: defectsWrapperCache.remove(new Integer(
634: bugid));
635: pDefectPanel.loadData(defectsWrapperCache);
636: trouve = true;
637: }
638: }
639: } catch (Exception ex) {
640: ex.printStackTrace();
641: }
642: }
643: }
644: }
645:
646: void updateDefectPanel(boolean load) {
647: if (defectsWrapperCache == null) {
648: defectsWrapperCache = new Hashtable();
649: }
650: defectsWrapperCache.clear();
651: if (!load) {
652: pDefectPanel.loadData(defectsWrapperCache);
653: return;
654:
655: }
656: ExecutionTestResult pExecutionTestResult = DataModel
657: .getCurrentExecutionTestResult();
658:
659: //Hashtable defectsWrapper = new Hashtable();
660: if (pExecutionTestResult != null) {
661: HashMap attacMap = pExecutionTestResult
662: .getAttachmentMapFromModel();
663: Set keysSet = attacMap.keySet();
664: for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
665: try {
666: Object attachName = iter.next();
667: Attachment pAttach = (Attachment) attacMap
668: .get(attachName);
669: int bugid = pMantisPlugin.getIDofBug(pAttach);
670: DefectWrapper pDefectWrapper = null;
671: if (bugid != -1) {
672: pDefectWrapper = pMantisPlugin.getDefectInfo(
673: bugid, false);
674: }
675: if (pDefectWrapper != null) {
676: defectsWrapperCache.put(new Integer(bugid),
677: pDefectWrapper);
678: }
679: } catch (Exception ex) {
680: ex.printStackTrace();
681: }
682: }
683: }
684: pDefectPanel.loadData(defectsWrapperCache);
685:
686: /*try {
687: Hashtable allDefects = pMantisPlugin.getDefectsOfProject(false);
688: Enumeration enumLikeddefect = linkedDefects.keys();
689: while (enumLikeddefect.hasMoreElements()){
690: Integer key = (Integer) enumLikeddefect.nextElement();
691: allDefects.remove(key);
692: }
693: pDefectPanel.loadData(allDefects);
694: } catch(Exception e){
695: e.printStackTrace();
696: }*/
697: }
698:
699: void editDefectPermed(DefectWrapper pDefectWrapper) {
700: //DefectWrapper pDefectWrapper = getSelectedDefect();
701: if (pDefectWrapper != null) {
702: DefectView pDefectView = new DefectView(this ,
703: pDefectWrapper, pMantisPlugin, true);
704:
705: if (pDefectView.isDoingModification()) {
706: doModification = true;
707: if (defectToLink != null
708: && defectToLink.getId() == pDefectWrapper
709: .getId()) {
710: idDefect.setText("id : " + defectToLink.getId());
711: resumeDefect
712: .setText(org.objectweb.salome_tmf.ihm.languages.Language
713: .getInstance().getText(
714: "Résumé_:______")
715: + " " + defectToLink.getResume());
716: String str_value = (String) pMantisPlugin.priorityByID
717: .get(Integer.valueOf(""
718: + defectToLink.getPriority()));
719: priorityDefect
720: .setText(org.objectweb.salome_tmf.ihm.languages.Language
721: .getInstance().getText("Priority")
722: + " : " + str_value);
723: str_value = (String) pMantisPlugin.statusByID
724: .get(Integer.valueOf(""
725: + defectToLink.getStatus()));
726: stateDefect
727: .setText(org.objectweb.salome_tmf.ihm.languages.Language
728: .getInstance().getText("Etat")
729: + " : " + str_value);
730: }
731: pDefectPanel.loadData(defectsWrapperCache);
732: }
733: }
734: }
735:
736: void LinkDefectPerformed() {
737: if (defectToLink != null) {
738: int bug_id = defectToLink.getId();
739: if (bug_id >= 0) {
740: Integer id = new Integer(bug_id);
741: DefectWrapper pDefectwrapper = (DefectWrapper) defectsWrapperCache
742: .get(id);
743: if (pDefectwrapper == null) { /* If the link is not present */
744: try {
745: Attachment pAttch = pMantisPlugin
746: .makeAttachement(bug_id);
747: ExecutionTestResult pExecutionTestResult = DataModel
748: .getCurrentExecutionTestResult();
749: pExecutionTestResult
750: .addAttachementInDBAndModel(pAttch);
751: defectsWrapperCache.put(id, defectToLink);
752: pDefectPanel.reloadData();
753: } catch (Exception e) {
754: e.printStackTrace();
755: }
756: }
757: }
758: }
759:
760: }
761:
762: boolean isDoingModification() {
763: return doModification;
764: }
765:
766: public void valueChanged(TreeSelectionEvent e) {
767: DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode) testTree
768: .getSelectionPath().getLastPathComponent();
769: if (selectNode != null) {
770: Object selectObject = selectNode.getUserObject();
771: if (selectObject instanceof Campaign) {
772: setCampaignPanel((Campaign) selectObject);
773: } else if (selectObject instanceof Execution) {
774: setExecutionPanel((Execution) selectObject);
775: } else if (selectObject instanceof ExecutionResult) {
776: System.out.println("ExecutionResult" + selectObject);
777: setResExecutionPanel((ExecutionResult) selectObject);
778: } else {
779: setEmptyPanel();
780: }
781: }
782: }
783: }
|