01: package salomeTMF_plug.mantis;
02:
03: import java.awt.FlowLayout;
04: import java.awt.GridLayout;
05: import java.awt.event.ActionEvent;
06: import java.awt.event.ActionListener;
07:
08: import javax.swing.JButton;
09: import javax.swing.JPanel;
10:
11: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
12: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
13:
14: import salomeTMF_plug.mantis.languages.Language;
15: import salomeTMF_plug.mantis.sqlWrapper.DefectWrapper;
16:
17: public class TestDefectActionPanel extends JPanel implements
18: ActionListener {
19: JButton editDefectButton;
20: JButton viewLinkButton;
21:
22: DefectPanel pDefectPanel;
23: MantisPlugin pMantisPlugin;
24:
25: TestDefectActionPanel(MantisPlugin pMantisPlugin) {
26: super (new FlowLayout());
27: this .pMantisPlugin = pMantisPlugin;
28: initActionPanel();
29: }
30:
31: void setDefectPanel(DefectPanel pDefectPanel) {
32: this .pDefectPanel = pDefectPanel;
33: }
34:
35: void initActionPanel() {
36: editDefectButton = new JButton(
37: salomeTMF_plug.mantis.languages.Language.getInstance()
38: .getText("Editer"));
39: editDefectButton.addActionListener(this );
40:
41: viewLinkButton = new JButton(Language.getInstance().getText(
42: "Liason"));
43: viewLinkButton.addActionListener(this );
44:
45: add(editDefectButton);
46: add(viewLinkButton);
47:
48: }
49:
50: public void actionPerformed(ActionEvent e) {
51: if (e.getSource().equals(editDefectButton)) {
52: editDefectPerformed();
53: } else if (e.getSource().equals(viewLinkButton)) {
54: viewLinkPerformed();
55: }
56: }
57:
58: void editDefectPerformed() {
59: DefectWrapper pDefectWrapper = pDefectPanel.getSelectedDefect();
60: if (pDefectWrapper != null) {
61: DefectView pDefectView = new DefectView(SalomeTMFContext
62: .getInstance().getSalomeFrame(), pDefectWrapper,
63: pMantisPlugin, true);
64: try {
65: if (pDefectView.isDoingModification()) {
66: pDefectPanel.reloadData();
67: }
68: } catch (Exception e) {
69: e.printStackTrace();
70: }
71: }
72: }
73:
74: void viewLinkPerformed() {
75: DefectWrapper pDefectWrapper = pDefectPanel.getSelectedDefect();
76: if (pDefectWrapper != null) {
77: new ViewLinkDialog(pDefectWrapper, pMantisPlugin, DataModel
78: .getCurrentTest());
79: }
80: }
81: }
|