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 Aurore PENAULT
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package salomeTMF_plug.docXML;
025:
026: import java.awt.event.ActionEvent;
027: import java.awt.event.ActionListener;
028: import java.util.Map;
029: import java.util.Vector;
030:
031: import javax.swing.JButton;
032: import javax.swing.JMenu;
033: import javax.swing.JMenuItem;
034: import javax.swing.JPanel;
035:
036: import org.java.plugin.ExtensionPoint;
037: import org.java.plugin.Plugin;
038: import org.java.plugin.PluginDescriptor;
039: import org.java.plugin.PluginManager;
040: import org.objectweb.salome_tmf.data.DataConstants;
041: import org.objectweb.salome_tmf.data.Project;
042: import org.objectweb.salome_tmf.ihm.IHMConstants;
043: import org.objectweb.salome_tmf.ihm.tools.Tools;
044: import org.objectweb.salome_tmf.plugins.IPlugObject;
045: import org.objectweb.salome_tmf.plugins.UICompCst;
046: import org.objectweb.salome_tmf.plugins.core.Admin;
047: import org.objectweb.salome_tmf.plugins.core.Common;
048:
049: import salomeTMF_plug.docXML.common.CreateProjectDialog;
050: import salomeTMF_plug.docXML.common.ExportDialog;
051: import salomeTMF_plug.docXML.common.GenDocDialog;
052: import salomeTMF_plug.docXML.importxml.ImportDialog;
053: import salomeTMF_plug.docXML.importxml.ImportDialog2;
054: import salomeTMF_plug.docXML.languages.Language;
055:
056: /**
057: *
058: * @version $Id$
059: */
060: public class DocXMLPlugin extends Plugin implements Common, Admin,
061: DataConstants, IHMConstants {
062:
063: // SalomeTMF pIhm;
064: boolean isFreezed = false;
065: JMenu testGendocSubMenu = null;
066: JMenu campGendocSubMenu = null;
067: JMenu dataGendocSubMenu = null;
068: JMenu testEchangeDonneesSubMenu = null;
069: JMenu campEchangeDonneesSubMenu = null;
070: JMenu dataEchangeDonneesSubMenu = null;
071:
072: IPlugObject pIPlugObject;
073:
074: public static boolean importInV2 = true;
075:
076: /**
077: * @param manager
078: * @param descr
079: */
080: public DocXMLPlugin(PluginManager manager, PluginDescriptor descr) {
081: super (manager, descr);
082: }
083:
084: /**
085: * @see org.java.plugin.Plugin()
086: */
087: protected void doStart() throws Exception {
088: // no-op
089: }
090:
091: /**
092: * @see org.java.plugin.Plugin()
093: */
094: protected void doStop() throws Exception {
095: // no-op
096: }
097:
098: /**
099: * @see salome.plugins.core.Common
100: */
101: public void init(Object pIPlugObject) {
102: //pIhm = (SalomeTMF)pIPlugObject;
103: this .pIPlugObject = (IPlugObject) pIPlugObject;
104: }
105:
106: /**
107: * @see salome.plugins.core.Common
108: */
109: public boolean isActivableInTestToolsMenu() {
110: return true;
111: }
112:
113: /**
114: * @see salome.plugins.core.Common
115: */
116: public boolean isActivableInCampToolsMenu() {
117: return true;
118: }
119:
120: /**
121: * @see salome.plugins.core.Common
122: */
123: public boolean isActivableInDataToolsMenu() {
124: return true;
125: }
126:
127: /**
128: * @see salome.plugins.core.Common
129: */
130: public boolean usesOtherUIComponents() {
131: return false;
132: }
133:
134: /**
135: * @see salome.plugins.core.Common
136: */
137: public void activatePluginInTestToolsMenu(JMenu testToolsMenu) {
138: testGendocSubMenu = new JMenu(Language.getInstance().getText(
139: "Plugin_génération_de_documents"));
140: testEchangeDonneesSubMenu = new JMenu(Language.getInstance()
141: .getText("Echange_de_données_au_format_XML"));
142: activatePluginInToolsMenu(testToolsMenu, testGendocSubMenu,
143: testEchangeDonneesSubMenu);
144: }
145:
146: /**
147: * @see salome.plugins.core.Common
148: */
149: public void activatePluginInCampToolsMenu(JMenu campToolsMenu) {
150: campGendocSubMenu = new JMenu(Language.getInstance().getText(
151: "Plugin_génération_de_documents"));
152: campEchangeDonneesSubMenu = new JMenu(Language.getInstance()
153: .getText("Echange_de_données_au_format_XML"));
154: activatePluginInToolsMenu(campToolsMenu, campGendocSubMenu,
155: campEchangeDonneesSubMenu);
156: }
157:
158: /**
159: * @see salome.plugins.core.Common
160: */
161: public void activatePluginInDataToolsMenu(JMenu dataToolsMenu) {
162: dataGendocSubMenu = new JMenu(Language.getInstance().getText(
163: "Plugin_génération_de_documents"));
164: dataEchangeDonneesSubMenu = new JMenu(Language.getInstance()
165: .getText("Echange_de_données_au_format_XML"));
166: activatePluginInToolsMenu(dataToolsMenu, dataGendocSubMenu,
167: dataEchangeDonneesSubMenu);
168: }
169:
170: /**
171: * @see salome.plugins.core.Common
172: */
173: public void activatePluginInToolsMenu(JMenu toolsMenu,
174: JMenu subMenu, JMenu subMenu2) {
175:
176: JMenuItem importer = new JMenuItem(
177: Language
178: .getInstance()
179: .getText(
180: "Importer_des_données_à_partir_d\'un_fichier_XML"));
181: importer.addActionListener(new ActionListener() {
182: public void actionPerformed(ActionEvent e) {
183: try {
184: if (importInV2) {
185: new ImportDialog2(pIPlugObject);
186: } else {
187: new ImportDialog(pIPlugObject);
188: }
189: } catch (Exception ex) {
190: Tools.ihmExceptionView(ex);
191: }
192: }
193: });
194:
195: JMenuItem export = new JMenuItem(Language.getInstance()
196: .getText("Exporter_au_format_XML"));
197: export.addActionListener(new ActionListener() {
198: public void actionPerformed(ActionEvent e) {
199: try {
200: new ExportDialog(pIPlugObject);
201: } catch (Exception ex) {
202: Tools.ihmExceptionView(ex);
203: }
204: }
205: });
206:
207: JMenuItem createProject = new JMenuItem("Test: create project");
208: createProject.addActionListener(new ActionListener() {
209: public void actionPerformed(ActionEvent e) {
210: //new CreateProjectDialog(pIhm);
211: }
212: });
213:
214: JMenuItem testIhm = new JMenuItem(Language.getInstance()
215: .getText("Dossier_de_tests"));
216: testIhm.addActionListener(new ActionListener() {
217: public void actionPerformed(ActionEvent e) {
218: try {
219: new GenDocDialog(TEST, pIPlugObject);
220: } catch (Exception ex) {
221: Tools.ihmExceptionView(ex);
222: }
223: }
224: });
225:
226: JMenuItem testIhmCampaign = new JMenuItem(Language
227: .getInstance().getText("Resultat_des_tests"));
228: testIhmCampaign.addActionListener(new ActionListener() {
229: public void actionPerformed(ActionEvent e) {
230: try {
231: new GenDocDialog(CAMPAIGN, pIPlugObject);
232: } catch (Exception ex) {
233: Tools.ihmExceptionView(ex);
234: }
235: }
236: });
237:
238: subMenu2.add(importer);
239: subMenu2.add(export);
240: //subMenu2.add(createProject);
241: subMenu.add(testIhm);
242: subMenu.add(testIhmCampaign);
243:
244: toolsMenu.addSeparator();
245: toolsMenu.add(subMenu);
246: toolsMenu.add(subMenu2);
247: }
248:
249: /**
250: * @see salome.plugins.core.Common
251: */
252: public Vector getUsedUIComponents() {
253: return null;
254: }
255:
256: /**
257: * @see salome.plugins.core.Common
258: */
259: public void activatePluginInStaticComponent(Integer uiCompCst) {
260: }
261:
262: /**
263: * @see salome.plugins.core.Common
264: */
265: public void activatePluginInDynamicComponent(Integer uiCompCst) {
266: }
267:
268: /**
269: * @see salome.plugins.core.Common
270: */
271: public boolean isFreezable() {
272: return true;
273: }
274:
275: /**
276: * @see salome.plugins.core.Common
277: */
278: public void freeze() {
279: testGendocSubMenu.setEnabled(false);
280: campGendocSubMenu.setEnabled(false);
281: dataGendocSubMenu.setEnabled(false);
282: isFreezed = true;
283: }
284:
285: /**
286: * @see salome.plugins.core.Common
287: */
288: public void unFreeze() {
289: testGendocSubMenu.setEnabled(true);
290: campGendocSubMenu.setEnabled(true);
291: dataGendocSubMenu.setEnabled(true);
292: isFreezed = false;
293: }
294:
295: /**
296: * @see salome.plugins.core.Common
297: */
298: public boolean isFreezed() {
299: return isFreezed;
300: }
301:
302: public void allPluginActived(ExtensionPoint commonExtensions,
303: ExtensionPoint testDriverExtensions,
304: ExtensionPoint scriptEngineExtensions,
305: ExtensionPoint bugTrackerExtensions) {
306:
307: }
308:
309: //////////////////////////////// Admin interface ////////////////////////////////////
310:
311: /* (non-Javadoc)
312: * @see org.objectweb.salome_tmf.plugins.core.Admin#activateInSalomeAdmin(java.util.Map)
313: */
314: public void activateInSalomeAdmin(final Map adminUIComps,
315: IPlugObject iPlugObject) {
316: try {
317: this .pIPlugObject = iPlugObject;
318: Object projectViewButtonsObj = adminUIComps
319: .get(UICompCst.ADMIN_PROJECT_MANAGEMENT_BUTTONS_PANEL);
320: if (projectViewButtonsObj != null) {
321: JPanel projectViewButtonsPan = (JPanel) projectViewButtonsObj;
322: JButton bouton = new JButton(Language.getInstance()
323: .getText("Créer_à_partir_d'un_fichier_XML"));
324: bouton.addActionListener(new ActionListener() {
325: public void actionPerformed(ActionEvent e) {
326: try {
327: new CreateProjectDialog(pIPlugObject);
328: } catch (Exception ex2) {
329: Tools.ihmExceptionView(ex2);
330: }
331: }
332: });
333: projectViewButtonsPan.add(bouton);
334: }
335: } catch (Exception ex) {
336: Tools.ihmExceptionView(ex);
337: }
338: //!\\ Pour la frame parent de la fenetre secondaire -> Administarion.ptrFrame
339: }
340:
341: public void onDeleteProject(Project p) {
342:
343: }
344: }
|