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 Jordan BRUNIER, Gregory CALONNIER
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package salomeTMF_plug.clif;
025:
026: import java.awt.event.ActionEvent;
027: import java.io.BufferedReader;
028: import java.io.File;
029: import java.io.FileInputStream;
030: import java.io.FileWriter;
031: import java.io.IOException;
032: import java.io.InputStreamReader;
033: import java.net.MalformedURLException;
034: import java.net.URL;
035: import java.util.ArrayList;
036: import java.util.Hashtable;
037: import java.util.Vector;
038:
039: import javax.swing.AbstractAction;
040: import javax.swing.JMenu;
041: import javax.swing.JMenuBar;
042: import javax.swing.JPanel;
043: import javax.swing.JTabbedPane;
044: import javax.swing.JButton;
045: import javax.swing.JTree;
046: import javax.swing.event.TreeSelectionEvent;
047: import javax.swing.event.TreeSelectionListener;
048: import javax.swing.tree.DefaultMutableTreeNode;
049:
050: import org.dom4j.Document;
051: import org.dom4j.Element;
052:
053: import org.java.plugin.ExtensionPoint;
054: import org.java.plugin.Plugin;
055: import org.java.plugin.PluginDescriptor;
056: import org.java.plugin.PluginManager;
057:
058: import org.objectweb.salome_tmf.api.Util;
059: import org.objectweb.salome_tmf.data.Action;
060: import org.objectweb.salome_tmf.data.AutomaticTest;
061: import org.objectweb.salome_tmf.data.Campaign;
062: import org.objectweb.salome_tmf.data.DataSet;
063: import org.objectweb.salome_tmf.data.Environment;
064: import org.objectweb.salome_tmf.data.Execution;
065: import org.objectweb.salome_tmf.data.ExecutionResult;
066: import org.objectweb.salome_tmf.data.ExecutionTestResult;
067: import org.objectweb.salome_tmf.data.Family;
068: import org.objectweb.salome_tmf.data.Parameter;
069: import org.objectweb.salome_tmf.data.Project;
070: import org.objectweb.salome_tmf.data.Test;
071: import org.objectweb.salome_tmf.data.TestList;
072: import org.objectweb.salome_tmf.data.UrlAttachment;
073: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
074: import org.objectweb.salome_tmf.ihm.models.DynamicTree;
075: import org.objectweb.salome_tmf.plugins.core.Common;
076: import org.objectweb.salome_tmf.plugins.core.TestDriver;
077: import org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin;
078: import org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin;
079: import org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin;
080: import org.objectweb.salome_tmf.plugins.UICompCst;
081:
082: import salomeTMF_plug.clif.languages.Language;
083: import salomeTMF_plug.clif.ui.ClifTestPlanEditor;
084: import salomeTMF_plug.clif.ui.GuiTestPlanChoice;
085: import salomeTMF_plug.clif.ui.LaunchTestUI;
086:
087: public class ClifPlugin extends Plugin implements Common, TestDriver,
088: XMLPrinterPlugin {
089:
090: public static final boolean AUTOMATIC_ADD_URL = true;
091:
092: private String tmpLog = null;
093:
094: public ClifPlugin(PluginManager manager, PluginDescriptor descr) {
095: super (manager, descr);
096: }
097:
098: //********************* extends Plugin**********************************//
099:
100: /**
101: * @see org.java.plugin.Plugin()
102: */
103: protected void doStart() throws Exception {
104: Util.log("[ClifPlugin:doStart] chargement du plugin");
105: }
106:
107: /**
108: * @see org.java.plugin.Plugin()
109: */
110: protected void doStop() throws Exception {
111: // no-op
112: }
113:
114: //********************* interface common *******************************//
115:
116: /* (non-Javadoc)
117: * @see org.objectweb.salome_tmf.plugins.core.Common#activatePluginInCampToolsMenu(javax.swing.JMenu)
118: */
119: public void activatePluginInCampToolsMenu(JMenu campToolsMenu) {
120:
121: }
122:
123: /* (non-Javadoc)
124: * @see org.objectweb.salome_tmf.plugins.core.Common#activatePluginInDataToolsMenu(javax.swing.JMenu)
125: */
126: public void activatePluginInDataToolsMenu(JMenu dataToolsMenu) {
127:
128: }
129:
130: /* (non-Javadoc)
131: * @see org.objectweb.salome_tmf.plugins.core.Common#activatePluginInDynamicComponent(java.lang.Integer)
132: */
133: public void activatePluginInDynamicComponent(Integer uiCompCst) {
134:
135: }
136:
137: /* (non-Javadoc)
138: * @see org.objectweb.salome_tmf.plugins.core.Common#activatePluginInStaticComponent(java.lang.Integer)
139: */
140: public void activatePluginInStaticComponent(Integer uiCompCst) {
141: if (uiCompCst
142: .equals(UICompCst.AUTOMATED_TEST_WORKSPACE_PANEL_FOR_TABS)) {
143: autTestTabs = (JTabbedPane) SalomeTMFContext.getInstance()
144: .getUIComponent(uiCompCst);
145: } else if (uiCompCst
146: .equals(UICompCst.AUTOMATED_TEST_SCRIPT_BUTTONS_PANEL)) {
147: // Change add button text and tool tip text
148: JPanel butPanel = (JPanel) SalomeTMFContext.getInstance()
149: .getUIComponent(uiCompCst);
150: butAdd = (JButton) butPanel.getComponent(0);
151:
152: // Change delete button tool tip text
153: butDel = (JButton) butPanel.getComponent(1);
154:
155: //Change Menu text
156: JMenuBar menuBar = (JMenuBar) butPanel.getComponent(2);
157: menu = menuBar.getMenu(0);
158:
159: } else if (uiCompCst.equals(UICompCst.TEST_DYNAMIC_TREE)) {
160: DynamicTree panTree = (DynamicTree) SalomeTMFContext
161: .getInstance().getUIComponent(uiCompCst);
162: tree = panTree.getTree();
163: tree.addTreeSelectionListener(new UpdateAction());
164: }
165: }
166:
167: /*User Interface components*/
168: private JTabbedPane autTestTabs = null;
169: private JButton butAdd = null;
170: private JButton butDel = null;
171: private JMenu menu = null;
172: private JTree tree = null;
173:
174: /**
175: * An action for inserting new nodes.
176: */
177: protected class UpdateAction extends AbstractAction implements
178: TreeSelectionListener {
179: UpdateAction() {
180: }
181:
182: public void actionPerformed(ActionEvent e) {
183: }
184:
185: public void valueChanged(TreeSelectionEvent e) {
186: DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
187: .getLastSelectedPathComponent();
188:
189: if (node != null) {
190: if (node.getUserObject() instanceof AutomaticTest) {
191: if (((Test) node.getUserObject())
192: .getExtensionFromModel().equals(
193: "clif.TestDriver")) {
194: //Change title tab
195: autTestTabs
196: .setTitleAt(1, Language.getInstance()
197: .getText("TestPlanTitle"));
198:
199: //Change add button text and tool tip text
200: butAdd.setText(Language.getInstance().getText(
201: "AddButtonText"));
202: butAdd.setToolTipText(Language.getInstance()
203: .getText("AddButtonToolTipText"));
204:
205: //Change delete button tool tip text
206: butDel.setToolTipText(Language.getInstance()
207: .getText("DeleteButtonToolTipText"));
208:
209: //Change Menu text
210: menu.setText(Language.getInstance().getText(
211: "TestPlanMenuTitle"));
212: menu.getItem(0).setText(
213: Language.getInstance().getText(
214: "TestPlanMenuModify"));
215: menu.getItem(1).setText(
216: Language.getInstance().getText(
217: "TestPlanMenuUpdate"));
218: } else {
219: //Change title tab
220: autTestTabs
221: .setTitleAt(
222: 1,
223: org.objectweb.salome_tmf.ihm.languages.Language
224: .getInstance().getText(
225: "Script"));
226:
227: //Change add button text and tool tip text
228: butAdd
229: .setText(org.objectweb.salome_tmf.ihm.languages.Language
230: .getInstance().getText(
231: "Ajouter"));
232: butAdd
233: .setToolTipText(org.objectweb.salome_tmf.ihm.languages.Language
234: .getInstance().getText(
235: "Ajouter_un_fichier"));
236:
237: //Change delete button tool tip text
238: butDel
239: .setToolTipText(org.objectweb.salome_tmf.ihm.languages.Language
240: .getInstance()
241: .getText(
242: "Supprimer_le_fichier_de_script"));
243:
244: //Change Menu text
245: menu
246: .setText(org.objectweb.salome_tmf.ihm.languages.Language
247: .getInstance()
248: .getText("Script"));
249: menu
250: .getItem(0)
251: .setText(
252: org.objectweb.salome_tmf.ihm.languages.Language
253: .getInstance()
254: .getText(
255: "Modifier_le_Script"));
256: menu
257: .getItem(1)
258: .setText(
259: org.objectweb.salome_tmf.ihm.languages.Language
260: .getInstance()
261: .getText(
262: "Actualiser_le_Script"));
263: }
264: }
265:
266: }
267: }
268: }
269:
270: /* (non-Javadoc)
271: * @see org.objectweb.salome_tmf.plugins.core.Common#activatePluginInTestToolsMenu(javax.swing.JMenu)
272: */
273: public void activatePluginInTestToolsMenu(JMenu testToolsMenu) {
274:
275: }
276:
277: /* (non-Javadoc)
278: * @see org.objectweb.salome_tmf.plugins.core.Common#allPluginActived(org.java.plugin.ExtensionPoint, org.java.plugin.ExtensionPoint, org.java.plugin.ExtensionPoint, org.java.plugin.ExtensionPoint)
279: */
280: public void allPluginActived(ExtensionPoint commonExtensions,
281: ExtensionPoint testDriverExtensions,
282: ExtensionPoint scriptEngineExtensions,
283: ExtensionPoint bugTrackerExtensions) {
284:
285: }
286:
287: /* (non-Javadoc)
288: * @see org.objectweb.salome_tmf.plugins.core.Common#freeze()
289: */
290: public void freeze() {
291:
292: }
293:
294: /* (non-Javadoc)
295: * @see org.objectweb.salome_tmf.plugins.core.Common#getUsedUIComponents()
296: */
297: public Vector getUsedUIComponents() {
298: Vector<Integer> uiComponents = new Vector<Integer>();
299: uiComponents
300: .add(UICompCst.AUTOMATED_TEST_WORKSPACE_PANEL_FOR_TABS);
301: uiComponents.add(UICompCst.AUTOMATED_TEST_SCRIPT_BUTTONS_PANEL);
302: uiComponents.add(UICompCst.TEST_DYNAMIC_TREE);
303: return uiComponents;
304: }
305:
306: /* (non-Javadoc)
307: * @see org.objectweb.salome_tmf.plugins.core.Common#init(java.lang.Object)
308: */
309: public void init(Object ihm) {
310:
311: }
312:
313: /* (non-Javadoc)
314: * @see org.objectweb.salome_tmf.plugins.core.Common#isActivableInCampToolsMenu()
315: */
316: public boolean isActivableInCampToolsMenu() {
317: return false;
318: }
319:
320: /* (non-Javadoc)
321: * @see org.objectweb.salome_tmf.plugins.core.Common#isActivableInDataToolsMenu()
322: */
323: public boolean isActivableInDataToolsMenu() {
324: return false;
325: }
326:
327: /* (non-Javadoc)
328: * @see org.objectweb.salome_tmf.plugins.core.Common#isActivableInTestToolsMenu()
329: */
330: public boolean isActivableInTestToolsMenu() {
331: return false;
332: }
333:
334: /* (non-Javadoc)
335: * @see org.objectweb.salome_tmf.plugins.core.Common#isFreezable()
336: */
337: public boolean isFreezable() {
338: return false;
339: }
340:
341: /* (non-Javadoc)
342: * @see org.objectweb.salome_tmf.plugins.core.Common#isFreezed()
343: */
344: public boolean isFreezed() {
345: return false;
346: }
347:
348: /* (non-Javadoc)
349: * @see org.objectweb.salome_tmf.plugins.core.Common#unFreeze()
350: */
351: public void unFreeze() {
352:
353: }
354:
355: /* (non-Javadoc)
356: * @see org.objectweb.salome_tmf.plugins.core.Common#usesOtherUIComponents()
357: */
358: public boolean usesOtherUIComponents() {
359: return true;
360: }
361:
362: //*********************** Interface TestDriver ****************************//
363:
364: /* (non-Javadoc)
365: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#choiceTest(org.objectweb.salome_tmf.data.AutomaticTest)
366: */
367: public File choiceTest(AutomaticTest pTest) {
368: GuiTestPlanChoice tpc = new GuiTestPlanChoice(SalomeTMFContext
369: .getInstance().getSalomeFrame());
370: return tpc.getSelectedFile();
371: }
372:
373: /* (non-Javadoc)
374: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#editTest(java.lang.String, org.objectweb.salome_tmf.data.AutomaticTest, java.util.Hashtable, java.lang.String)
375: */
376: public void editTest(String testScript, AutomaticTest pTest,
377: Hashtable arg, String plugParam) throws Exception {
378: new ClifTestPlanEditor(testScript);
379: }
380:
381: /* (non-Javadoc)
382: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#getDefaultTestDiverAgument()
383: */
384: public String getDefaultTestDiverAgument() {
385: return null;
386: }
387:
388: /* (non-Javadoc)
389: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#getHelp()
390: */
391: public void getHelp() {
392:
393: }
394:
395: /* (non-Javadoc)
396: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#getTestLog()
397: */
398: public String getTestLog() {
399: return tmpLog;
400: }
401:
402: /* (non-Javadoc)
403: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#initTestDriver(java.net.URL)
404: */
405: public void initTestDriver(URL urlSalome) {
406: Util.log("Init Test Driver");
407: }
408:
409: /* (non-Javadoc)
410: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#modifyTestDiverAgument(java.lang.String)
411: */
412: public String modifyTestDiverAgument(String oldArg) {
413: return null;
414: }
415:
416: /* (non-Javadoc)
417: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#onDeleteTestScript(org.objectweb.salome_tmf.data.AutomaticTest)
418: */
419: public void onDeleteTestScript(AutomaticTest pTest) {
420:
421: }
422:
423: /* (non-Javadoc)
424: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#runTest(java.lang.String, org.objectweb.salome_tmf.data.AutomaticTest, java.util.Hashtable, java.lang.String)
425: */
426: public int runTest(String testScript, AutomaticTest pTest,
427: Hashtable argTest, String plugArg) throws Exception {
428:
429: ArrayList paramList = pTest.getParameterListFromModel();
430: BufferedReader br;
431: String paramName;
432: String paramValue;
433: String line;
434: String newFile = "";
435: String reportUrl = null;
436:
437: for (int i = 0; i < paramList.size(); i++) {
438: //Take a parameter and his value
439: paramName = paramList.get(i).toString();
440: paramValue = (String) argTest.get(paramName);
441: br = new BufferedReader(new InputStreamReader(
442: new FileInputStream(testScript)));
443:
444: //Replace the parameter by his value in the test plan
445: line = br.readLine();
446: newFile = "";
447: while (line != null) {
448: newFile += line.replaceAll("[$]" + paramName + "[$]",
449: paramValue)
450: + "\n";
451: line = br.readLine();
452: }
453: FileWriter writer = null;
454: try {
455: writer = new FileWriter(testScript);
456: writer.write(newFile, 0, newFile.length());
457: } catch (IOException ex) {
458: ex.printStackTrace();
459: } finally {
460: if (writer != null) {
461: writer.close();
462: }
463: }
464: }
465:
466: LaunchTestUI test = new LaunchTestUI();
467: int result = test.launchtest(testScript, pTest);
468: tmpLog = test.getTestLog();
469:
470: if (ClifPlugin.AUTOMATIC_ADD_URL) {
471: // Add report url in attachment
472: reportUrl = test.getReportUrl();
473: if (reportUrl != null && !reportUrl.trim().equals("")) {
474: ExecutionTestResult execTestResult = ((ExecutionTestResult) argTest
475: .get("salome_ExecTestResultObject"));
476: ExecutionResult execResult = ((ExecutionResult) argTest
477: .get("salome_ExecResultObject"));
478:
479: try {
480: execTestResult
481: .addAttachementInModel(new UrlAttachment(
482: fileToURL(reportUrl
483: + argTest
484: .get(
485: "salome_CampagneName")
486: .toString()
487: + "."
488: + execResult
489: .getNameFromModel()
490: + "."
491: + pTest.getNameFromModel()),
492: Language.getInstance().getText(
493: "ReportURLDesc")));
494:
495: } catch (MalformedURLException mue) {
496: System.err.println("CliPlugin error: "
497: + mue.getMessage());
498: }
499: }
500: }
501:
502: return result;
503: }
504:
505: /* (non-Javadoc)
506: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#stopTest()
507: */
508: public void stopTest() throws Exception {
509:
510: }
511:
512: /* (non-Javadoc)
513: * @see org.objectweb.salome_tmf.plugins.core.TestDriver#updateTestScriptFromImport(java.lang.String, org.objectweb.salome_tmf.data.AutomaticTest)
514: */
515: public void updateTestScriptFromImport(String testScript,
516: AutomaticTest pTest) {
517:
518: }
519:
520: //********************* interface XMLPrinterPlugin ********************//
521:
522: /************** EXPORT *****************/
523: /* (non-Javadoc)
524: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Action(org.dom4j.Element, org.objectweb.salome_tmf.data.Action, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
525: */
526: public void addXMLElement2Action(Element testElement,
527: Action pAction, XMLWriterPlugin pXMLWriter,
528: String pathAttach) {
529:
530: }
531:
532: /* (non-Javadoc)
533: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Campaign(org.dom4j.Element, org.objectweb.salome_tmf.data.Campaign, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
534: */
535: public void addXMLElement2Campaign(Element campaignElement,
536: Campaign pcampaign, XMLWriterPlugin pXMLWriter,
537: String pathAttach) {
538:
539: }
540:
541: /* (non-Javadoc)
542: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2DataSet(org.dom4j.Element, org.objectweb.salome_tmf.data.DataSet, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
543: */
544: public void addXMLElement2DataSet(Element dataSetElement,
545: DataSet pDataSet, XMLWriterPlugin pXMLWriter,
546: String pathAttach) {
547:
548: }
549:
550: /* (non-Javadoc)
551: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Environment(org.dom4j.Element, org.objectweb.salome_tmf.data.Environment, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
552: */
553: public void addXMLElement2Environment(Element envElement,
554: Environment pEnv, XMLWriterPlugin pXMLWriter,
555: String pathAttach) {
556:
557: }
558:
559: /* (non-Javadoc)
560: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Execution(org.dom4j.Element, org.objectweb.salome_tmf.data.Execution, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
561: */
562: public void addXMLElement2Execution(Element execElement,
563: Execution pExecution, XMLWriterPlugin pXMLWriter,
564: String pathAttach) {
565:
566: }
567:
568: /* (non-Javadoc)
569: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Family(org.dom4j.Element, org.objectweb.salome_tmf.data.Family, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
570: */
571: public void addXMLElement2Family(Element familyElement,
572: Family pFamily, XMLWriterPlugin pXMLWriter,
573: String pathAttach) {
574:
575: }
576:
577: /* (non-Javadoc)
578: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Parameter(org.dom4j.Element, org.objectweb.salome_tmf.data.Parameter, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
579: */
580: public void addXMLElement2Parameter(Element paramElement,
581: Parameter pParam, XMLWriterPlugin pXMLWriter,
582: String pathAttach) {
583:
584: }
585:
586: /* (non-Javadoc)
587: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Project(org.dom4j.Element, org.objectweb.salome_tmf.data.Project, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
588: */
589: public void addXMLElement2Project(Element projectElement,
590: Project pProject, XMLWriterPlugin pXMLWriter,
591: String pathAttach) {
592:
593: }
594:
595: /* (non-Javadoc)
596: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2ResExecution(org.dom4j.Element, org.objectweb.salome_tmf.data.ExecutionResult, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
597: */
598: public void addXMLElement2ResExecution(Element resExecElement,
599: ExecutionResult pExecRes, XMLWriterPlugin pXMLWriter,
600: String pathAttach) {
601:
602: }
603:
604: /* (non-Javadoc)
605: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2ResTestExecution(org.dom4j.Element, org.objectweb.salome_tmf.data.ExecutionTestResult, org.objectweb.salome_tmf.data.Test, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
606: */
607: public void addXMLElement2ResTestExecution(Element resTestElem,
608: ExecutionTestResult pExecTestRes, Test pTest,
609: XMLWriterPlugin pXMLWriter, String pathAttach) {
610:
611: }
612:
613: /* (non-Javadoc)
614: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Root(org.dom4j.Element, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
615: */
616: public void addXMLElement2Root(Element rootElement,
617: XMLWriterPlugin pXMLWriter, String pathAttach) {
618:
619: }
620:
621: /* (non-Javadoc)
622: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Suite(org.dom4j.Element, org.objectweb.salome_tmf.data.TestList, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
623: */
624: public void addXMLElement2Suite(Element suiteElement,
625: TestList ptestList, XMLWriterPlugin pXMLWriter,
626: String pathAttach) {
627:
628: }
629:
630: /* (non-Javadoc)
631: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#addXMLElement2Test(org.dom4j.Element, org.objectweb.salome_tmf.data.Test, org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin, java.lang.String)
632: */
633: public void addXMLElement2Test(Element testElement, Test pTest,
634: XMLWriterPlugin pXMLWriter, String pathAttach) {
635:
636: }
637:
638: /************** Option Panel *************/
639: /* (non-Javadoc)
640: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#getExportOptionPanel()
641: */
642: public JPanel getExportOptionPanel() {
643: return null;
644: }
645:
646: /* (non-Javadoc)
647: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#getImportOptionPanel()
648: */
649: public JPanel getImportOptionPanel() {
650: return null;
651: }
652:
653: /**************** XSLT ******************/
654: /* (non-Javadoc)
655: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#getTranslationFile()
656: */
657: public File getTranslationFile() {
658: // String _urlBase = SalomeTMFContext.getInstance().getUrlBase().toString();
659: // String url_txt = _urlBase.substring(0, _urlBase.lastIndexOf("/"));
660: // String translate = "/plugins/clif/xsl/translate.xml";
661: // String temporaryFilePath = System.getProperties().getProperty("java.io.tmpdir") + File.separator + "clifTranslate.xml";
662: // try {
663: // URL translateURL = new URL(url_txt + translate);
664: // Tools.writeFile(translateURL.openStream(), temporaryFilePath);
665: // } catch (Exception e) {
666: // Tools.writeFile(ReqPlugin.class.getResourceAsStream("/salome/" + translate), temporaryFilePath);
667: // }
668: // File translateFile = new File(temporaryFilePath);
669: // return translateFile;
670: return null;
671: }
672:
673: /* (non-Javadoc)
674: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#getXSLToImport(boolean, boolean)
675: */
676: public File getXSLToImport(boolean dynamicMode, boolean multiFrame) {
677: // String _urlBase = SalomeTMFContext.getInstance().getUrlBase().toString();
678: // String url_txt = _urlBase.substring(0, _urlBase.lastIndexOf("/"));
679: // String xsl = "";
680: // if (dynamicMode) {
681: // if (multiFrame) {
682: // xsl = "/plugins/clif/xsl/frameDynaClif.xsl";
683: // } else {
684: // xsl = "/plugins/clif/xsl/dynaClif.xsl";
685: // }
686: // } else {//staticMode
687: // if (multiFrame) {
688: // xsl = "/plugins/requirements/xsl/frameClif.xsl";
689: // } else {
690: // xsl = "/plugins/requirements/xsl/clif.xsl";
691: // }
692: // }
693: // String temporaryFilePath = System.getProperties().getProperty("java.io.tmpdir") + File.separator + "clifXSLT.xsl";
694: // try {
695: // URL xsltURL = new URL(url_txt + xsl);
696: // Tools.writeFile(xsltURL.openStream(), temporaryFilePath);
697: // } catch (Exception e) {
698: // Tools.writeFile(ReqPlugin.class.getResourceAsStream("/salome/" + xsl), temporaryFilePath);
699: // }
700: // File xsltFile = new File(temporaryFilePath);
701: // return xsltFile;
702: return null;
703: }
704:
705: /**************** IMPORT *****************/
706: /* (non-Javadoc)
707: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#manageDelete(org.dom4j.Document, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
708: */
709: public void manageDelete(Document doc, XMLLoaderPlugin pXMLLoader)
710: throws Exception {
711:
712: }
713:
714: /* (non-Javadoc)
715: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#refreshNewData()
716: */
717: public void refreshNewData() {
718:
719: }
720:
721: /* (non-Javadoc)
722: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateActionFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.Action, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
723: */
724: public void updateActionFromXML(Element actionElement,
725: Action pAction, boolean isSupOption,
726: XMLLoaderPlugin pXMLLoader) throws Exception {
727:
728: }
729:
730: /* (non-Javadoc)
731: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateCampaignFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.Campaign, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
732: */
733: public void updateCampaignFromXML(Element campaignElement,
734: Campaign pcampaign, boolean isSupOption,
735: XMLLoaderPlugin pXMLLoader) throws Exception {
736:
737: }
738:
739: /* (non-Javadoc)
740: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateDataSetFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.DataSet, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
741: */
742: public void updateDataSetFromXML(Element dataSetElement,
743: DataSet pDataSet, boolean isSupOption,
744: XMLLoaderPlugin pXMLLoader) throws Exception {
745:
746: }
747:
748: /* (non-Javadoc)
749: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateEnvironmentFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.Environment, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
750: */
751: public void updateEnvironmentFromXML(Element envElement,
752: Environment pEnv, boolean isSupOption,
753: XMLLoaderPlugin pXMLLoader) throws Exception {
754:
755: }
756:
757: /* (non-Javadoc)
758: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateExecutionFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.Execution, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
759: */
760: public void updateExecutionFromXML(Element execElement,
761: Execution pExecution, boolean isSupOption,
762: XMLLoaderPlugin pXMLLoader) throws Exception {
763:
764: }
765:
766: /* (non-Javadoc)
767: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateFamilyFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.Family, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
768: */
769: public void updateFamilyFromXML(Element familyElement,
770: Family pFamily, boolean isSupOption,
771: XMLLoaderPlugin pXMLLoader) throws Exception {
772:
773: }
774:
775: /* (non-Javadoc)
776: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateParameterFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.Parameter, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
777: */
778: public void updateParameterFromXML(Element paramElement,
779: Parameter pParam, boolean isSupOption,
780: XMLLoaderPlugin pXMLLoader) throws Exception {
781:
782: }
783:
784: /* (non-Javadoc)
785: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateProjectFromXML(org.dom4j.Document, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
786: */
787: public void updateProjectFromXML(Document doc, boolean isSupOption,
788: XMLLoaderPlugin pXMLLoader) throws Exception {
789:
790: }
791:
792: /* (non-Javadoc)
793: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateResExecutionFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.ExecutionResult, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
794: */
795: public void updateResExecutionFromXML(Element resExecElement,
796: ExecutionResult pExecRes, boolean isSupOption,
797: XMLLoaderPlugin pXMLLoader) throws Exception {
798:
799: }
800:
801: /* (non-Javadoc)
802: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateSuiteFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.TestList, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
803: */
804: public void updateSuiteFromXML(Element suiteElement,
805: TestList pSuite, boolean isSupOption,
806: XMLLoaderPlugin pXMLLoader) throws Exception {
807:
808: }
809:
810: /* (non-Javadoc)
811: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateTestFromXML(org.dom4j.Element, org.objectweb.salome_tmf.data.Test, boolean, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
812: */
813: public void updateTestFromXML(Element testElement, Test pTest,
814: boolean isSupOption, XMLLoaderPlugin pXMLLoader)
815: throws Exception {
816:
817: }
818:
819: /* (non-Javadoc)
820: * @see org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin#updateProjectFromXML(org.dom4j.Document, boolean, org.objectweb.salome_tmf.data.Project, org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin)
821: */
822: public void updateProjectFromXML(Document doc, boolean isSupOption,
823: Project project, XMLLoaderPlugin pXMLLoader)
824: throws Exception {
825:
826: }
827:
828: public String getChapterTitleInReport() {
829: return null;
830: }
831:
832: public String getParameterName(String chapterName) {
833: return null;
834: }
835:
836: public void setExport(boolean b) {
837:
838: }
839:
840: public void setImport(boolean b) {
841:
842: }
843:
844: //********************* ClifPlugin methods ********************//
845: /**
846: * Convert a file name into a string
847: * that represents a well-formed
848: * URL.
849: *
850: * d:\path\to\logfile
851: * file://d:/path/to/logfile
852: */
853: private String fileToURL(String filename)
854: throws MalformedURLException {
855: File file = new File(filename);
856: String path = file.getAbsolutePath();
857: String fSep = System.getProperty("file.separator");
858:
859: if (fSep != null && fSep.length() == 1) {
860: path = "file://" + path.replace(fSep.charAt(0), '/');
861: }
862:
863: return path;
864: }
865: }
|