001: package salomeTMF_plug.mantis;
002:
003: import java.awt.Dialog;
004: import java.awt.GridLayout;
005: import java.awt.event.ActionEvent;
006: import java.awt.event.ActionListener;
007:
008: import javax.swing.JButton;
009: import javax.swing.JPanel;
010:
011: import salomeTMF_plug.mantis.sqlWrapper.DefectWrapper;
012:
013: public class LinkWithDefectsPanel extends JPanel implements
014: ActionListener {
015:
016: JButton linkDefectButton;
017: JButton editDefectButton;
018: JButton deleteLinkButton;
019:
020: DefectPanel pDefectPanel;
021: MantisPlugin pMantisPlugin;
022:
023: Dialog jDialog;
024: DefectWrapper sourceDefectWrapper;
025:
026: LinkWithDefectsPanel(Dialog jDialog, DefectWrapper pDefectWrapper,
027: MantisPlugin pMantisPlugin) {
028: super (new GridLayout(1, 3));
029: this .pMantisPlugin = pMantisPlugin;
030: sourceDefectWrapper = pDefectWrapper;
031: this .jDialog = jDialog;
032: initActionPanel();
033: }
034:
035: void setDefectPanel(DefectPanel pDefectPanel) {
036: this .pDefectPanel = pDefectPanel;
037: }
038:
039: void initActionPanel() {
040: linkDefectButton = new JButton(
041: salomeTMF_plug.mantis.languages.Language.getInstance()
042: .getText("Lier_a_annomalie"));
043: linkDefectButton.addActionListener(this );
044: editDefectButton = new JButton(
045: salomeTMF_plug.mantis.languages.Language.getInstance()
046: .getText("Editer"));
047: editDefectButton.addActionListener(this );
048: deleteLinkButton = new JButton(
049: salomeTMF_plug.mantis.languages.Language.getInstance()
050: .getText("Supprimer_lien"));
051: deleteLinkButton.addActionListener(this );
052:
053: add(editDefectButton);
054: add(deleteLinkButton);
055: add(linkDefectButton);
056: }
057:
058: public void actionPerformed(ActionEvent e) {
059: if (e.getSource().equals(editDefectButton)) {
060: editDefectPerformed();
061: } else if (e.getSource().equals(deleteLinkButton)) {
062: deleteDefectPerformed();
063: } else if (e.getSource().equals(linkDefectButton)) {
064: linkPerformed();
065: }
066: }
067:
068: void linkPerformed() {
069: pDefectPanel.defectsWrapper.put(new Integer(sourceDefectWrapper
070: .getId()), sourceDefectWrapper);
071: LinkDefectDialog pLinkDefectDialog = new LinkDefectDialog(
072: jDialog, pMantisPlugin, pDefectPanel.defectsWrapper,
073: null);
074: pDefectPanel.defectsWrapper.remove(new Integer(
075: sourceDefectWrapper.getId()));
076: DefectWrapper pDefectWrapper = pLinkDefectDialog
077: .getSelectedDefectWrapper();
078: if (pDefectWrapper != null) {
079: try {
080: pMantisPlugin.addDefectLink(sourceDefectWrapper,
081: pDefectWrapper);
082: pDefectPanel.defectsWrapper.put(new Integer(
083: pDefectWrapper.getId()), pDefectWrapper);
084: pDefectPanel.reloadData();
085: } catch (Exception e) {
086: e.printStackTrace();
087: }
088: }
089:
090: }
091:
092: void editDefectPerformed() {
093: //PAS DE LINK
094: DefectWrapper pDefectWrapper = pDefectPanel.getSelectedDefect();
095: if (pDefectWrapper != null) {
096: new DefectView(jDialog, pDefectWrapper, pMantisPlugin,
097: false);
098: pDefectPanel.reloadData();
099: }
100:
101: }
102:
103: void deleteDefectPerformed() {
104: DefectWrapper pDefectWrapper = pDefectPanel.getSelectedDefect();
105: if (pDefectWrapper != null) {
106: try {
107: if (pMantisPlugin
108: .deleteConfirme(salomeTMF_plug.mantis.languages.Language
109: .getInstance().getText("Le_lien"))) {
110: pMantisPlugin.deleteDefectLink(sourceDefectWrapper,
111: pDefectWrapper);
112: pDefectPanel.defectsWrapper.remove(new Integer(
113: pDefectWrapper.getId()));
114: pDefectPanel.reloadData();
115: }
116: } catch (Exception e) {
117: e.printStackTrace();
118: }
119: }
120: }
121: }
|