001: package salomeTMF_plug.mantis;
002:
003: import java.awt.Container;
004: import java.awt.Dialog;
005: import java.awt.Dimension;
006: import java.awt.Frame;
007: import java.awt.GraphicsConfiguration;
008: import java.awt.GraphicsDevice;
009: import java.awt.GraphicsEnvironment;
010: import java.awt.Rectangle;
011: import java.util.Hashtable;
012: import java.util.Vector;
013:
014: import javax.swing.BoxLayout;
015: import javax.swing.JDialog;
016: import javax.swing.JTabbedPane;
017:
018: import org.objectweb.salome_tmf.data.Attachment;
019: import org.objectweb.salome_tmf.data.ExecutionResult;
020: import org.objectweb.salome_tmf.data.ExecutionTestResult;
021: import org.objectweb.salome_tmf.ihm.main.IBugJDialog;
022:
023: import salomeTMF_plug.mantis.sqlWrapper.DefectWrapper;
024:
025: public class DefectView extends JDialog implements IBugJDialog {
026:
027: boolean haveDoModification = false;
028: boolean viewLink = false;
029:
030: DefectViewPanel pDefectViewPanel;
031: DefectPanel pLinkDefectPanel;
032: HistoryPanel pHistoryPanel;
033: ViewLinkPanel pViewLinkExecPanel;
034:
035: JTabbedPane mainPane;
036:
037: /**
038: * Add Defect with information about test execution
039: * @param owner
040: * @param execResult
041: * @param executionTestResult
042: * @param actionName
043: * @param actionDesc
044: * @param actionAwatedRes
045: * @param actionEffectiveRes
046: * @param pMantisPlugin
047: */
048: public DefectView(Dialog owner, ExecutionResult execResult,
049: ExecutionTestResult executionTestResult, String actionName,
050: String actionDesc, String actionAwatedRes,
051: String actionEffectiveRes, MantisPlugin pMantisPlugin) {
052: super (owner, true);
053: pDefectViewPanel = new DefectViewPanel(this , execResult,
054: executionTestResult, actionName, actionDesc,
055: actionAwatedRes, actionEffectiveRes, pMantisPlugin);
056: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language
057: .getInstance().getText("Ajouter_un_bug_dans")
058: + " Mantis");
059: }
060:
061: public DefectView(Frame owner, ExecutionResult execResult,
062: ExecutionTestResult executionTestResult, String actionName,
063: String actionDesc, String actionAwatedRes,
064: String actionEffectiveRes, MantisPlugin pMantisPlugin) {
065: super (owner, true);
066: pDefectViewPanel = new DefectViewPanel(this , execResult,
067: executionTestResult, actionName, actionDesc,
068: actionAwatedRes, actionEffectiveRes, pMantisPlugin);
069: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language
070: .getInstance().getText("Ajouter_un_bug_dans")
071: + " Mantis");
072: }
073:
074: /**
075: * Add defect from empty description
076: * @param owner
077: * @param pMantisPlugin
078: */
079: public DefectView(Dialog owner, MantisPlugin pMantisPlugin) {
080: super (owner, true);
081: setModal(true);
082: pDefectViewPanel = new DefectViewPanel(this , pMantisPlugin);
083: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language
084: .getInstance().getText("Ajouter_un_bug_dans")
085: + " Mantis");
086: }
087:
088: public DefectView(Frame owner, MantisPlugin pMantisPlugin) {
089: super (owner, true);
090: setModal(true);
091: pDefectViewPanel = new DefectViewPanel(this , pMantisPlugin);
092: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language
093: .getInstance().getText("Ajouter_un_bug_dans")
094: + " Mantis");
095: }
096:
097: /**
098: * Add defect with environement restriction
099: * @param owner
100: * @param pMantisPlugin
101: * @param envRestriction
102: */
103: public DefectView(Dialog owner, MantisPlugin pMantisPlugin,
104: String envRestriction) {
105: super (owner, true);
106: setModal(true);
107: pDefectViewPanel = new DefectViewPanel(this , pMantisPlugin,
108: envRestriction);
109: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language
110: .getInstance().getText("Ajouter_un_bug_dans")
111: + " Mantis");
112: }
113:
114: public DefectView(Frame owner, MantisPlugin pMantisPlugin,
115: String envRestriction) {
116: super (owner, true);
117: setModal(true);
118: pDefectViewPanel = new DefectViewPanel(this , pMantisPlugin,
119: envRestriction);
120: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language
121: .getInstance().getText("Ajouter_un_bug_dans")
122: + " Mantis");
123: }
124:
125: /**
126: * Edit existing defect
127: * @param owner
128: * @param pDefectWrapper
129: * @param pMantisPlugin
130: */
131: /*public DefectView(Dialog owner, DefectWrapper pDefectWrapper, MantisPlugin pMantisPlugin){
132: super(owner,true);
133: pDefectViewPanel = new DefectViewPanel(this, pDefectWrapper, pMantisPlugin);
134: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language.getInstance().getText("Ajouter_un_bug_dans")+ " Mantis");
135:
136: }
137: public DefectView(Frame owner, DefectWrapper pDefectWrapper, MantisPlugin pMantisPlugin){
138: super(owner,true);
139: pDefectViewPanel = new DefectViewPanel(this, pDefectWrapper, pMantisPlugin);
140: makeDialog(org.objectweb.salome_tmf.ihm.languages.Language.getInstance().getText("Ajouter_un_bug_dans")+ " Mantis");
141:
142: }*/
143: /**
144: * Edit existing defect
145: * @param owner
146: * @param pDefectWrapper
147: * @param pMantisPlugin
148: */
149: public DefectView(Dialog owner, DefectWrapper pDefectWrapper,
150: MantisPlugin pMantisPlugin, boolean viewLink) {
151: super (owner, true);
152: this .viewLink = viewLink;
153: if (viewLink) {
154: makeViewLinkPanel(pDefectWrapper, pMantisPlugin);
155: makeHistoryPanel(pDefectWrapper, pMantisPlugin);
156: makeViewLinkExecPanel(pDefectWrapper, pMantisPlugin);
157: }
158: pDefectViewPanel = new DefectViewPanel(this , pDefectWrapper,
159: pMantisPlugin);
160: //makeDialog(org.objectweb.salome_tmf.ihm.languages.Language.getInstance().getText("Ajouter_un_bug_dans")+ " Mantis");
161: if (pDefectWrapper != null) {
162: makeDialog(salomeTMF_plug.mantis.languages.Language
163: .getInstance().getText("Visualiser_bugs")
164: + " id : " + pDefectWrapper.getId());
165: } else {
166: makeDialog(salomeTMF_plug.mantis.languages.Language
167: .getInstance().getText("Visualiser_bugs"));
168: }
169: }
170:
171: public DefectView(Frame owner, DefectWrapper pDefectWrapper,
172: MantisPlugin pMantisPlugin, boolean viewLink) {
173: super (owner, true);
174: this .viewLink = viewLink;
175: if (viewLink) {
176: makeViewLinkPanel(pDefectWrapper, pMantisPlugin);
177: makeHistoryPanel(pDefectWrapper, pMantisPlugin);
178: makeViewLinkExecPanel(pDefectWrapper, pMantisPlugin);
179: }
180: pDefectViewPanel = new DefectViewPanel(this , pDefectWrapper,
181: pMantisPlugin);
182: if (pDefectWrapper != null) {
183: makeDialog(salomeTMF_plug.mantis.languages.Language
184: .getInstance().getText("Visualiser_bugs")
185: + " id : " + pDefectWrapper.getId());
186: } else {
187: makeDialog(salomeTMF_plug.mantis.languages.Language
188: .getInstance().getText("Visualiser_bugs"));
189: }
190: }
191:
192: void makeViewLinkPanel(DefectWrapper pDefectWrapper,
193: MantisPlugin pMantisPlugin) {
194: Hashtable defectsLinked;
195: try {
196: defectsLinked = pMantisPlugin.getDefectLink(pDefectWrapper);
197: LinkWithDefectsPanel pLinkWithDefectsPanel = new LinkWithDefectsPanel(
198: this , pDefectWrapper, pMantisPlugin);
199: pLinkDefectPanel = new DefectPanel(true, pMantisPlugin,
200: pLinkWithDefectsPanel, null);
201: pLinkWithDefectsPanel.setDefectPanel(pLinkDefectPanel);
202: pLinkDefectPanel.loadData(defectsLinked);
203: } catch (Exception e) {
204: e.printStackTrace();
205: pLinkDefectPanel = null;
206: }
207: }
208:
209: void makeHistoryPanel(DefectWrapper pDefectWrapper,
210: MantisPlugin pMantisPlugin) {
211: Vector bugHistories = null;
212: try {
213: bugHistories = pMantisPlugin.getBugHistory(pDefectWrapper);
214: } catch (Exception e) {
215: e.printStackTrace();
216: }
217:
218: pHistoryPanel = new HistoryPanel(pMantisPlugin, bugHistories);
219:
220: }
221:
222: void makeViewLinkExecPanel(DefectWrapper pDefectWrapper,
223: MantisPlugin pMantisPlugin) {
224: pViewLinkExecPanel = new ViewLinkPanel(this , pDefectWrapper,
225: pMantisPlugin);
226: }
227:
228: void makeDialog(String title) {
229: int t_x = 1024 - 100;
230: int t_y = 768 / 3 * 2 - 50;
231: try {
232: GraphicsEnvironment ge = GraphicsEnvironment
233: .getLocalGraphicsEnvironment();
234: GraphicsDevice[] gs = ge.getScreenDevices();
235: GraphicsDevice gd = gs[0];
236: GraphicsConfiguration[] gc = gd.getConfigurations();
237: Rectangle r = gc[0].getBounds();
238: t_x = r.width - 100;
239: t_y = r.height / 3 * 2 - 50;
240: } catch (Exception E) {
241:
242: }
243:
244: Container contentPane = this .getContentPane();
245: contentPane.setLayout(new BoxLayout(contentPane,
246: BoxLayout.Y_AXIS));
247: if (viewLink && pLinkDefectPanel != null) {
248: mainPane = new JTabbedPane();
249: mainPane.add(
250: org.objectweb.salome_tmf.ihm.languages.Language
251: .getInstance().getText("Anomalie"),
252: pDefectViewPanel);
253: mainPane.add(salomeTMF_plug.mantis.languages.Language
254: .getInstance().getText("lien_anomalie"),
255: pLinkDefectPanel);
256: mainPane.add(salomeTMF_plug.mantis.languages.Language
257: .getInstance().getText("Liason"),
258: pViewLinkExecPanel);
259: mainPane.add(salomeTMF_plug.mantis.languages.Language
260: .getInstance().getText("Issue_History"),
261: pHistoryPanel);
262: contentPane.add(mainPane);
263: } else {
264: contentPane.add(pDefectViewPanel);
265: }
266: this .setTitle(title);
267: setSize(t_x, t_y);
268: /* this.pack();
269: this.setLocationRelativeTo(this.getParent());
270: this.setVisible(true);
271: */
272: centerScreen();
273: }
274:
275: void centerScreen() {
276: Dimension dim = getToolkit().getScreenSize();
277: this .pack();
278: Rectangle abounds = getBounds();
279: setLocation((dim.width - abounds.width) / 2,
280: (dim.height - abounds.height) / 2);
281: this .setVisible(true);
282: requestFocus();
283: }
284:
285: boolean isDoingModification() {
286: return pDefectViewPanel.isDoingModification();
287: }
288:
289: DefectWrapper getDefectWrapper() {
290: return pDefectViewPanel.pDefectWrapper;
291: }
292:
293: public void onViewPerformed() {
294: dispose();
295: }
296:
297: public void onModifyPerformed() {
298: dispose();
299: }
300:
301: public void onCancelPerformed() {
302: dispose();
303: }
304:
305: public void onCommitPerformed(Attachment bugURL) {
306: dispose();
307: }
308: }
|