001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.ihm.main;
025:
026: import java.awt.Cursor;
027: import java.awt.GraphicsConfiguration;
028: import java.awt.GraphicsDevice;
029: import java.awt.GraphicsEnvironment;
030: import java.awt.Rectangle;
031: import java.util.Iterator;
032: import java.util.Vector;
033:
034: import javax.swing.JButton;
035: import javax.swing.JMenu;
036: import javax.swing.JTabbedPane;
037: import javax.swing.event.ChangeEvent;
038: import javax.swing.event.ChangeListener;
039:
040: import org.java.plugin.Extension;
041: import org.objectweb.salome_tmf.api.Api;
042: import org.objectweb.salome_tmf.data.DataConstants;
043: import org.objectweb.salome_tmf.data.Family;
044: import org.objectweb.salome_tmf.data.SimpleData;
045: import org.objectweb.salome_tmf.data.Test;
046: import org.objectweb.salome_tmf.data.TestList;
047: import org.objectweb.salome_tmf.ihm.languages.Language;
048: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
049: import org.objectweb.salome_tmf.ihm.models.DynamicTree;
050: import org.objectweb.salome_tmf.plugins.UICompCst;
051: import org.objectweb.salome_tmf.plugins.core.BugTracker;
052: import org.objectweb.salome_tmf.plugins.core.ReqManager;
053:
054: public class SalomeTMFPanels {
055:
056: /**
057: * Les onglets principaux
058: */
059: JTabbedPane tabs;
060:
061: // LES 4 ECRANS
062:
063: /**
064: * Le panel des tests
065: */
066: static TestPanel pTestPanel;
067:
068: /**
069: * Le panel des campagnes
070: */
071: static CampainPanel pCampainPanel;
072:
073: /**
074: * Le panel des données
075: */
076: static DataPanel pDataPanel;
077:
078: PluginsView pluginsView;
079:
080: /**
081: * Le panel des indicateurs
082: */
083: static IndicatorsPanel pIndicatorsPanel;
084:
085: SalomeTMFContext pSalomeTMFContext;
086: BaseIHM pBaseIHM;
087:
088: int t_x = 1024;
089: int t_y = 768;
090:
091: BugTracker indicatorTracker;
092: ReqManager reqPlug;
093:
094: public SalomeTMFPanels(SalomeTMFContext _pSalomeTMFContext,
095: BaseIHM _BaseIHM) {
096: pSalomeTMFContext = _pSalomeTMFContext;
097: pBaseIHM = _BaseIHM;
098: }
099:
100: public void initComponentPanel() {
101:
102: try {
103: GraphicsEnvironment ge = GraphicsEnvironment
104: .getLocalGraphicsEnvironment();
105: GraphicsDevice[] gs = ge.getScreenDevices();
106: GraphicsDevice gd = gs[0];
107: GraphicsConfiguration[] gc = gd.getConfigurations();
108: Rectangle r = gc[0].getBounds();
109: t_x = r.width;
110: t_y = r.height;
111:
112: } catch (Exception E) {
113:
114: }
115:
116: /**
117: * Les onglets principaux
118: */
119: tabs = new JTabbedPane();
120:
121: pTestPanel = new TestPanel(pSalomeTMFContext, pBaseIHM, tabs,
122: t_x, t_y);
123: pCampainPanel = new CampainPanel(pSalomeTMFContext, pBaseIHM,
124: tabs, t_x, t_y);
125: pDataPanel = new DataPanel(pSalomeTMFContext, pBaseIHM, tabs,
126: t_x, t_y);
127:
128: tabs.addTab(Language.getInstance().getText("Plan_de_tests"),
129: pTestPanel);
130: tabs.addTab(Language.getInstance().getText(
131: "Gestion_des_campagnes"), pCampainPanel);
132: tabs.addTab(Language.getInstance().getText(
133: "Gestion_des_données"), pDataPanel);
134:
135: tabs.addChangeListener(new ChangeListener() {
136: public void stateChanged(ChangeEvent e) {
137: if (tabs.getSelectedIndex() == 2) {
138: DataModel.initAttachmentTable(DataModel
139: .getCurrentProject()
140: .getAttachmentMapFromModel().values());
141: }
142: }
143: });
144:
145: // Mapping entre objets graphiques et constantes
146: pSalomeTMFContext.UIComponentsMap.put(
147: UICompCst.MAIN_TABBED_PANE, tabs);
148: // Add this component as static component
149: UICompCst.staticUIComps.add(UICompCst.MAIN_TABBED_PANE);
150:
151: tabs.addChangeListener(new ChangeListener() {
152: public void stateChanged(ChangeEvent e) {
153: if (tabs.getModel().getSelectedIndex() == 0) {
154: // Onglet des tests
155: if (getTestDynamicTree().getSelectedNode() != null) {
156: if (getTestDynamicTree().getSelectedNode()
157: .getUserObject() instanceof Test) {
158: DataModel
159: .initAttachmentTable(((Test) getTestDynamicTree()
160: .getSelectedNode()
161: .getUserObject())
162: .getAttachmentMapFromModel()
163: .values());
164: DataModel
165: .setCurrentTest((Test) getTestDynamicTree()
166: .getSelectedNode()
167: .getUserObject());
168: } else if (getTestDynamicTree()
169: .getSelectedNode().getUserObject() instanceof TestList) {
170: DataModel
171: .initAttachmentTable(((TestList) getTestDynamicTree()
172: .getSelectedNode()
173: .getUserObject())
174: .getAttachmentMapFromModel()
175: .values());
176: DataModel
177: .setCurrentTestList((TestList) getTestDynamicTree()
178: .getSelectedNode()
179: .getUserObject());
180: } else if (getTestDynamicTree()
181: .getSelectedNode().getUserObject() instanceof Family) {
182: DataModel
183: .initAttachmentTable(((Family) getTestDynamicTree()
184: .getSelectedNode()
185: .getUserObject())
186: .getAttachmentMapFromModel()
187: .values());
188: DataModel
189: .setCurrentFamily((Family) getTestDynamicTree()
190: .getSelectedNode()
191: .getUserObject());
192: }
193: }
194: } else if (tabs.getModel().getSelectedIndex() == 1) {
195: // Onglet des campagnes
196: if (DataModel.getCurrentCampaign() != null) {
197: if (DataModel.getCurrentCampaign()
198: .getAttachmentMapFromModel() != null) {
199: DataModel.initAttachmentTable(DataModel
200: .getCurrentCampaign()
201: .getAttachmentMapFromModel()
202: .values());
203: }
204: }
205: if (getTestDynamicTree().getSelectedNode() != null
206: && getCampaignDynamicTree()
207: .getSelectedNode() != null
208: && getTestDynamicTree().getSelectedNode()
209: .getUserObject().equals(
210: getCampaignDynamicTree()
211: .getSelectedNode()
212: .getUserObject())) {
213: if (getTestDynamicTree().getSelectedNode()
214: .getUserObject() instanceof Family) {
215: setCampPanelDescription(
216: DataConstants.FAMILY,
217: ((SimpleData) getTestDynamicTree()
218: .getSelectedNode()
219: .getUserObject())
220: .getDescriptionFromModel());
221: DataModel
222: .setCurrentFamily((Family) getTestDynamicTree()
223: .getSelectedNode()
224: .getUserObject());
225: } else if (getTestDynamicTree()
226: .getSelectedNode().getUserObject() instanceof TestList) {
227: setCampPanelDescription(
228: DataConstants.TESTLIST,
229: ((SimpleData) getTestDynamicTree()
230: .getSelectedNode()
231: .getUserObject())
232: .getDescriptionFromModel());
233: DataModel
234: .setCurrentTestList((TestList) getTestDynamicTree()
235: .getSelectedNode()
236: .getUserObject());
237: } else if (getTestDynamicTree()
238: .getSelectedNode().getUserObject() instanceof Test) {
239: Test test = (Test) getTestDynamicTree()
240: .getSelectedNode().getUserObject();
241: setCampPanelDescription(DataConstants.TEST,
242: ((SimpleData) getTestDynamicTree()
243: .getSelectedNode()
244: .getUserObject())
245: .getDescriptionFromModel());
246: SalomeTMFPanels.setCampPanelDetailsForTest(
247: test.getNameFromModel(), test
248: .getConceptorFromModel(),
249: test.getCreationDateFromModel()
250: .toString(), DataModel
251: .getCurrentCampaign()
252: .getAssignedUserID(test));
253: DataModel
254: .setCurrentTest((Test) getTestDynamicTree()
255: .getSelectedNode()
256: .getUserObject());
257: }
258: }
259: } else if ((Api.isALLOW_PLUGINS())
260: && (tabs.getModel().getSelectedIndex() == tabs
261: .indexOfTab(Language.getInstance()
262: .getText("Plugins")))) {
263: pluginsView.refreshPluginsActivation();
264: }
265: }
266: });
267:
268: DataModel.initData();
269: pTestPanel.initCoponent();
270: pCampainPanel.initCoponent();
271: pDataPanel.initCoponent();
272: }
273:
274: /******************************************************************************/
275: /** METHODE ***/
276: /******************************************************************************/
277:
278: public static void reValidateTestPanel() {
279: pTestPanel.reValidate();
280: }
281:
282: public static void reValidateCampainPanel() {
283: pCampainPanel.reValidate();
284: }
285:
286: public static void setCursor(int tabsPanel, int cursor) {
287: if (tabsPanel == DataConstants.CAMPAIGN) {
288: pCampainPanel.setCursor(new Cursor(cursor));
289: } else if (tabsPanel == DataConstants.TEST) {
290: pTestPanel.setCursor(new Cursor(cursor));
291: } else if (tabsPanel == DataConstants.PROJECT) {
292: pDataPanel.setCursor(new Cursor(cursor));
293: }
294: }
295:
296: public static void setTestPanelWorkSpace(int type) {
297: pTestPanel.setWorkSpace(type);
298: }
299:
300: public static void setTestPanelDescription(int type, String text) {
301: pTestPanel.setDescription(type, text);
302: }
303:
304: public static void setTestPanelTestInfo(int type, String name,
305: String conceptor, String date) {
306: pTestPanel.setTestInfo(type, name, conceptor, date);
307: }
308:
309: public static void setTestPanelTestExecutedInfo(int type,
310: String execcuted) {
311: pTestPanel.TestExecutedInfo(type, execcuted);
312: }
313:
314: public static void setCampPanelWorkSpace(int type) {
315: pCampainPanel.setWorkSpace(type);
316: }
317:
318: public static void setCampPanelDescription(int type, String text) {
319: pCampainPanel.setDescription(type, text);
320: }
321:
322: public static void setCampPanelDetailsForTest(String name,
323: String conceptor, String date, int assigned_to_ID) {
324: pCampainPanel.setTestInfoForTestPanel(name, conceptor, date,
325: assigned_to_ID);
326: }
327:
328: public static void setCampPanelInfo(String name, String conceptor,
329: String date) {
330: pCampainPanel.setTestInfo(name, conceptor, date);
331: }
332:
333: /******************************************************************************/
334: /** ACCESSEURS ***/
335: /******************************************************************************/
336:
337: public static DynamicTree getTestDynamicTree() {
338: return pTestPanel.testDynamicTree;
339: }
340:
341: public static JMenu getTestToolsMenu() {
342: return pTestPanel.testToolsMenu;
343: }
344:
345: public static JButton getDelTestOrTestList() {
346: return pTestPanel.delTestOrTestList;
347: }
348:
349: public static JButton getAutomaticButtonCampaignDetails() {
350: return pTestPanel.automaticButtonCampaignDetails;
351: }
352:
353: public static JButton getManualTestButtonCampaignDetails() {
354: return pTestPanel.manualButtonCampaignDetails;
355: }
356:
357: public static JButton getRenameTestButton() {
358: return pTestPanel.renameTestButton;
359: }
360:
361: public static DynamicTree getCampaignDynamicTree() {
362: return pCampainPanel.campaignDynamicTree;
363: }
364:
365: public static JButton getRenameCampaignButton() {
366: return pCampainPanel.renameCampaignButton;
367: }
368:
369: public static JButton getOrderCampagne() {
370: return pCampainPanel.orderCampagne;
371: }
372:
373: public static JButton getDelCampagne() {
374: return pCampainPanel.delCampagne;
375: }
376:
377: public static JButton getAddTestInCampagne() {
378: return pCampainPanel.addTestInCampagne;
379: }
380:
381: public static JMenu getCampToolsMenu() {
382: return pCampainPanel.campToolsMenu;
383: }
384:
385: public static void clearTrees() {
386: getTestDynamicTree().clear();
387: getCampaignDynamicTree().clear();
388: }
389:
390: private void giveAccessToIhm() {
391: pTestPanel.giveAccessToIhm();
392: pCampainPanel.giveAccessToIhm();
393: }
394:
395: public static JMenu getDataToolsMenu() {
396: return pDataPanel.dataToolsMenu;
397: }
398:
399: public static EnvironmentView getEnvironnementView() {
400: return pDataPanel.pEnvView;
401: }
402:
403: /*********************************************** MODEL ****************************************************/
404: void loadModel(String strProject, String strLogin) {
405: ////Api.addWatchListener(this, DataModel.getCurrentProject().getNameFromModel());
406: giveAccessToIhm();
407: ManualActionView.giveAccessToIhmManualActionView();
408: EnvironmentView.giveAccessToIhmEnvironmentView();
409: DataSetView.giveAccessToIhmDataSetView();
410: ExecutionView.giveAccessToIhmExecutionView();
411: AutomaticTestScriptView.giveAccessToIhmScriptView();
412: pTestPanel.loadModel(strProject, strLogin);
413: pCampainPanel.loadModel(strProject, strLogin);
414: pDataPanel.loadModel(strProject, strLogin);
415: }
416:
417: void reloadModel() {
418: giveAccessToIhm();
419: ManualActionView.giveAccessToIhmManualActionView();
420: EnvironmentView.giveAccessToIhmEnvironmentView();
421: DataSetView.giveAccessToIhmDataSetView();
422: ExecutionView.giveAccessToIhmExecutionView();
423: AutomaticTestScriptView.giveAccessToIhmScriptView();
424: pTestPanel.reloadModel();
425: pCampainPanel.reloadModel();
426: pDataPanel.reloadModel();
427: }
428:
429: public static void resetTreeSelection() {
430: getTestDynamicTree().resetToRoot();
431: getCampaignDynamicTree().resetToRoot();
432: }
433:
434: /********************************** Observer Implementation **********************************************/
435:
436: /*public void update(Observable observable, Object obj) {
437: Util.log("[SalomeTMF] " + Language.getInstance().getText("On_entre_dans_update_observer"));
438:
439: if (obj instanceof Integer) {
440: int code = ((Integer)obj).intValue();
441: Util.log("Valeur de Integer : " + code);
442: if (code >= 100 && code < 105) {
443: testMultiUserChangeListenerPanel.addDelete();
444: } else if (code >= 105 && code < 110) {
445: campagneMultiUserChangeListenerPanel.addDelete();
446: } else if (code >= 110 && code < 112) {
447: dataMultiUserChangeListenerPanel.addDelete();
448: } else if (code >= 200 && code < 205) {
449: testMultiUserChangeListenerPanel.addUInsert();
450: } else if (code >= 205 && code < 211) {
451: campagneMultiUserChangeListenerPanel.addUInsert();
452: } else if (code >= 211 && code < 214) {
453: dataMultiUserChangeListenerPanel.addUInsert();
454: } else if ( code >= 300 && code < 304) {
455: testMultiUserChangeListenerPanel.addUpdate();
456: } else if ( code >= 304 && code < 307) {
457: campagneMultiUserChangeListenerPanel.addUpdate();
458: } else if (code >= 307 && code < 309) {
459: dataMultiUserChangeListenerPanel.addUpdate();
460: }
461: // DataModel.addModification(obj);
462: }
463: }*/
464:
465: private void createPluginsPlane() {
466:
467: Vector commonExtensions = new Vector();
468: Vector testDriverExtensions = new Vector();
469: Vector scriptEngineExtensions = new Vector();
470: Vector reqMgrExtensions = new Vector();
471:
472: // Extensions de type "TestDriver"
473: for (Iterator it = pSalomeTMFContext.testDriverExtPoint
474: .getConnectedExtensions().iterator(); it.hasNext();) {
475: Extension testDriverExt = (Extension) it.next();
476: testDriverExtensions.add(testDriverExt);
477: //associatedTestDriver(testDriverExt.getId(), testDriverExt);
478: }
479:
480: // Extensions de type "ScriptEngine"
481: for (Iterator it = pSalomeTMFContext.scriptEngineExtPoint
482: .getConnectedExtensions().iterator(); it.hasNext();) {
483: Extension scriptEngineExt = (Extension) it.next();
484: scriptEngineExtensions.add(scriptEngineExt);
485: //associatedScriptEngine(scriptEngineExt.getId(), scriptEngineExt);
486: }
487:
488: // Extensions "Common"
489: for (Iterator it = pSalomeTMFContext.CommonExtPoint
490: .getConnectedExtensions().iterator(); it.hasNext();) {
491: Extension commonExt = (Extension) it.next();
492: commonExtensions.add(commonExt);
493: pSalomeTMFContext.associatedExtension(commonExt.getId(),
494: commonExt);
495: }
496:
497: // "BugTracker" extensions
498: for (Iterator it = pSalomeTMFContext.bugTrackerExtPoint
499: .getConnectedExtensions().iterator(); it.hasNext();) {
500: Extension bTrackExt = (Extension) it.next();
501: pSalomeTMFContext.associatedBugTrackerExtension(bTrackExt
502: .getId(), bTrackExt);
503: }
504:
505: // "ReqManager" extensions
506: for (Iterator it = pSalomeTMFContext.reqManagerExtPoint
507: .getConnectedExtensions().iterator(); it.hasNext();) {
508: Extension reqMgrExt = (Extension) it.next();
509: reqMgrExtensions.add(reqMgrExt);
510: }
511:
512: pluginsView = new PluginsView(commonExtensions,
513: testDriverExtensions, scriptEngineExtensions,
514: pSalomeTMFContext.getAllTracker(), reqMgrExtensions,
515: pSalomeTMFContext.pluginManager);
516:
517: //plugins.add(pluginsView);
518: }
519:
520: void loadPlugin() {
521: if (Api.isALLOW_PLUGINS()) {
522: createPluginsPlane();
523: tabs.addTab(Language.getInstance().getText("Plugins"),
524: pluginsView);
525: addPluginsInStaticUIComps();
526:
527: createIndicatorsPlane();
528: }
529: }
530:
531: public void addPluginsInStaticUIComps() {
532: // Activate bugTrackers in environment view
533: getEnvironnementView().activateBugTrackersMenu();
534:
535: // ICAL calculation
536: /*if (Api.isWith_ICAL()) {
537: new ICAL(pSalomeTMFContext, pTestPanel.testToolsMenu);
538: }*/
539: }
540:
541: private void createIndicatorsPlane() {
542: Vector bugTrackers = SalomeTMFContext.getInstance()
543: .getBugTracker();
544: int i = 0;
545: boolean found = false;
546: if (bugTrackers != null && bugTrackers.size() != 0) {
547: while ((i < bugTrackers.size()) && (!found)) {
548: BugTracker bugTracker = (BugTracker) bugTrackers
549: .elementAt(i);
550: if (bugTracker.isSuportIndicators()) {
551: //if ((bugTracker.getBugTrackerName()).equals("Mantis")) {
552: indicatorTracker = bugTracker;
553: found = true;
554: }
555: i = i + 1;
556: }
557: }
558: if ((indicatorTracker != null) && (Api.isWith_ICAL())) {
559: Vector reqManagers = SalomeTMFContext.getInstance()
560: .getReqManagers();
561: int j = 0;
562: boolean trouve = false;
563: if (reqManagers != null && reqManagers.size() != 0) {
564: while ((j < reqManagers.size()) && (!trouve)) {
565: ReqManager req = (ReqManager) reqManagers
566: .elementAt(j);
567: if ((req.getReqManagerName())
568: .equals("SALOME_REQ_PLUG")) {
569: reqPlug = req;
570: trouve = true;
571: }
572: j = j + 1;
573: }
574: }
575: pIndicatorsPanel = new IndicatorsPanel(indicatorTracker,
576: reqPlug);
577: tabs.addTab(Language.getInstance().getText("Indicateurs"),
578: pIndicatorsPanel);
579: pIndicatorsPanel.initComponents();
580: }
581: }
582:
583: public JTabbedPane getTabs() {
584: return tabs;
585: }
586:
587: public void setTabs(JTabbedPane tabs) {
588: this.tabs = tabs;
589: }
590:
591: }
|