001: package org.objectweb.salome_tmf.ihm.main;
002:
003: import java.awt.BorderLayout;
004: import java.awt.Container;
005: import java.awt.Dialog;
006: import java.awt.Dimension;
007: import java.awt.Frame;
008: import java.awt.Rectangle;
009: import java.util.ArrayList;
010:
011: import javax.swing.JDialog;
012: import javax.swing.JPanel;
013:
014: import org.objectweb.salome_tmf.data.Attachment;
015: import org.objectweb.salome_tmf.data.ExecutionResult;
016: import org.objectweb.salome_tmf.data.ExecutionTestResult;
017: import org.objectweb.salome_tmf.data.FileAttachment;
018: import org.objectweb.salome_tmf.ihm.languages.Language;
019: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
020: import org.objectweb.salome_tmf.ihm.tools.Tools;
021: import org.objectweb.salome_tmf.plugins.core.BugTracker;
022:
023: public class AskNewBug extends JDialog implements IBugJDialog {
024:
025: /**
026: * Constructeur de la fenêtre pour l'ajout d'un bug
027: */
028: public AskNewBug(Frame pFrame, BugTracker bugTrack,
029: boolean _autofill, String actionName, String actionDesc,
030: String actionAwatedRes, String actionEffectiveRes) {
031: // Init des composants de la fenêtre
032: super (pFrame, true);
033: JPanel mainPanel = bugTrack.getBugViewPanel(this , actionName,
034: actionDesc, actionAwatedRes, actionEffectiveRes);
035: if (mainPanel == null) {
036: mainPanel = new AskNewBugDefaultPanel(this , bugTrack,
037: _autofill, actionName, actionDesc, actionAwatedRes,
038: actionEffectiveRes);
039: }
040: Container contentPaneFrame = this .getContentPane();
041: contentPaneFrame.add(mainPanel, BorderLayout.CENTER);
042: this .setTitle(Language.getInstance().getText(
043: "Ajouter_un_bug_dans")
044: + " " + bugTrack.getBugTrackerName());
045: /*this.pack();
046: this.setLocationRelativeTo(this.getParent());
047: this.setVisible(true);*/
048: centerScreen();
049: } // Fin du constructeur
050:
051: /**
052: * Constructeur de la fenêtre pour l'ajout d'un bug
053: */
054: public AskNewBug(Dialog pDialog, BugTracker bugTrack,
055: boolean _autofill, String actionName, String actionDesc,
056: String actionAwatedRes, String actionEffectiveRes) {
057: // Init des composants de la fenêtre
058: super (pDialog, true);
059: JPanel mainPanel = bugTrack.getBugViewPanel(this , actionName,
060: actionDesc, actionAwatedRes, actionEffectiveRes);
061: if (mainPanel == null) {
062: mainPanel = new AskNewBugDefaultPanel(this , bugTrack,
063: _autofill, actionName, actionDesc, actionAwatedRes,
064: actionEffectiveRes);
065: }
066: Container contentPaneFrame = this .getContentPane();
067: contentPaneFrame.add(mainPanel, BorderLayout.CENTER);
068: this .setTitle(Language.getInstance().getText(
069: "Ajouter_un_bug_dans")
070: + " " + bugTrack.getBugTrackerName());
071:
072: /*this.pack();
073: this.setLocation(300,120);
074: this.setVisible(true);**/
075: centerScreen();
076: } // Fin du constructeur
077:
078: void centerScreen() {
079: Dimension dim = getToolkit().getScreenSize();
080: this .pack();
081: Rectangle abounds = getBounds();
082: setLocation((dim.width - abounds.width) / 2,
083: (dim.height - abounds.height) / 2);
084: this .setVisible(true);
085: requestFocus();
086: }
087:
088: /**
089: * Constructeur de la fenêtre pour montrer un bug
090: */
091: /*public AskNewBug(BugTracker bugTrack, boolean editable, Attachment _theBug, String environement, String user, String plateforme, String os,
092: String priority, String severity, String status,String reproducibility,String resolution, String recipient, String url, String resume, String description) {
093:
094:
095: // Init des composants de la fenêtre
096: super(SalomeTMFContext.getInstance().getSalomeFrame(), true);
097: JPanel mainPanel = new AskNewBugDefaultPanel(this, bugTrack, editable, _theBug, environement, user, plateforme, os,
098: priority, severity, status, reproducibility, resolution, recipient, url, resume, description);
099:
100: Container contentPaneFrame = this.getContentPane();
101: contentPaneFrame.add(mainPanel, BorderLayout.CENTER);
102:
103: this.setLocation(300,120);
104: this.setTitle(Language.getInstance().getText("Ajouter_un_bug_dans")+ " " + bugTrack.getBugTrackerName());
105: this.pack();
106: this.setVisible(true);
107:
108: } // Fin du constructeur
109: */
110:
111: public void onViewPerformed() {
112: AskNewBug.this .dispose();
113:
114: }
115:
116: public void onModifyPerformed() {
117: AskNewBug.this .dispose();
118: }
119:
120: public void onCancelPerformed() {
121: AskNewBug.this .dispose();
122: }
123:
124: public void onCommitPerformed(Attachment bugURL) {
125: if (!bugURL.getNameFromModel().equals("")) {
126: boolean isBugAdded = false;
127: try {
128: ExecutionResult execResult = DataModel
129: .getObservedExecutionResult();
130: ExecutionTestResult executionTestResult = DataModel
131: .getCurrentExecutionTestResult();
132: if (executionTestResult != null) {
133: executionTestResult.addAttachementInModel(bugURL);
134: } else {
135: execResult.addAttachementInModel(bugURL);
136: }
137: isBugAdded = true;
138: } catch (Exception E) {
139: Tools.ihmExceptionView(E);
140: E.printStackTrace();
141: }
142: if (isBugAdded) {
143: ArrayList data = new ArrayList();
144: data.add(bugURL.getNameFromModel());
145: if (bugURL instanceof FileAttachment) {
146: data.add(((FileAttachment) bugURL).getSize()
147: .toString());
148: data.add(((FileAttachment) bugURL).getDate()
149: .toString());
150: } else {
151: data.add("");
152: data.add("");
153: }
154: DataModel.getAttachmentTableModel().addRow(data);
155: } else {
156: Tools.ihmExceptionView(new Exception(Language
157: .getInstance().getText("URL_already_exists")));
158: }
159: this.dispose();
160: }
161: }
162: }
|