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