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.plugins;
025:
026: import java.awt.event.ActionEvent;
027: import java.awt.event.ActionListener;
028: import java.util.LinkedList;
029:
030: import javax.swing.JMenu;
031: import javax.swing.JMenuItem;
032:
033: import org.objectweb.salome_tmf.data.Campaign;
034: import org.objectweb.salome_tmf.data.Environment;
035: import org.objectweb.salome_tmf.data.Execution;
036: import org.objectweb.salome_tmf.data.ExecutionResult;
037: import org.objectweb.salome_tmf.data.ExecutionTestResult;
038: import org.objectweb.salome_tmf.data.Family;
039: import org.objectweb.salome_tmf.data.Project;
040: import org.objectweb.salome_tmf.data.Test;
041: import org.objectweb.salome_tmf.data.TestList;
042: import org.objectweb.salome_tmf.data.User;
043: import org.objectweb.salome_tmf.ihm.languages.Language;
044: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
045: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
046: import org.objectweb.salome_tmf.plugins.core.BugTracker;
047: import org.objectweb.salome_tmf.plugins.core.Common;
048:
049: /**
050: * Methods and tools for plugins management
051: * @author capg2710
052: */
053: public class PluginsTools {
054:
055: /** Creates a new instance of PluginsTools */
056: public PluginsTools() {
057: }
058:
059: /**
060: * Activates associated plugins to dynamic UI components
061: * @param uiConst
062: */
063: public static void activateAssociatedPlgs(Integer uiConst) {
064: LinkedList list = SalomeTMFContext.getInstance()
065: .getAssociatedPluginsToUIComp(uiConst);
066: if (list != null) {
067: for (int i = 0; i < list.size(); i++) {
068: ((Common) list.get(i))
069: .activatePluginInDynamicComponent(uiConst);
070: }
071: }
072: }
073:
074: /**
075: * Returns the current project in Salomé
076: * @return Current project in Salomé
077: */
078: public static Project getCurrentProject() {
079: return DataModel.getCurrentProject();
080: }
081:
082: /**
083: * Returns the current user in Salomé
084: * @return Current user in Salomé
085: */
086: public static User getCurrentUser() {
087: return DataModel.getCurrentUser();
088: }
089:
090: /**
091: * Returns current campaign execution
092: * @return current campaign execution
093: */
094: public static Execution getCurrentCampExecution() {
095: return DataModel.getObservedExecution();
096: }
097:
098: /**
099: * Returns current campaign execution's environement
100: * @return current campaign execution's environement
101: */
102: public static Environment getCurrentCampExecutionEnvironment() {
103: Environment result;
104: if (DataModel.getObservedExecution() == null) {
105: result = null;
106: } else {
107: result = DataModel.getObservedExecution()
108: .getEnvironmentFromModel();
109: }
110: return result;
111: }
112:
113: /**
114: * Returns current campaign execution result
115: * @return current campaign execution result
116: */
117: public static ExecutionResult getCurrentCampExecResult() {
118: return DataModel.getObservedExecutionResult();
119: }
120:
121: /**
122: * Returns current test execution result
123: * @return current test execution result
124: */
125: public static ExecutionTestResult getCurrentTestExecutionResult() {
126: return DataModel.getCurrentExecutionTestResult();
127: }
128:
129: /**
130: * Returns current campaign
131: * @return current campaign
132: */
133: public static Campaign getCurrentCampaign() {
134: return DataModel.getCurrentCampaign();
135: }
136:
137: /**
138: * Returns current test
139: * @return current test
140: */
141: public static Test getCurrentTest() {
142: return DataModel.getCurrentTest();
143: }
144:
145: /**
146: * Returns current test list
147: * @return current test list
148: */
149: public static TestList getCurrentTestList() {
150: return DataModel.getCurrentTestList();
151: }
152:
153: /**
154: * Returns current family
155: * @return current family
156: */
157: public static Family getCurrentFamily() {
158: return DataModel.getCurrentFamily();
159: }
160:
161: /**
162: * Returns the associated test to the current test execution result
163: * @return the associated test to the current test execution result
164: */
165: public static Test getTestForCurrentTestExecResult() {
166: Test result;
167: if (DataModel.getCurrentExecutionTestResult() == null) {
168: result = null;
169: } else {
170: result = DataModel.getCurrentExecutionTestResult()
171: .getTestFromModel();
172: }
173: return result;
174: }
175:
176: public static void activateBugTrackingPlgsInToolsMenu(
177: JMenu toolsMenu, final BugTracker bTrack) {
178:
179: JMenu bTrackSubMenu = new JMenu(bTrack.getBugTrackerName());
180:
181: //Adding the current user in Salomé TMF to bug tracking database
182: JMenuItem addCurrentUserItem = new JMenuItem(Language
183: .getInstance().getText("add_current_usr_to_bug_db"));
184: addCurrentUserItem.addActionListener(new ActionListener() {
185: public void actionPerformed(ActionEvent e) {
186: try {
187: bTrack.addUser(DataModel.getCurrentUser());
188: } catch (Exception E) {
189: E.printStackTrace();
190: }
191: }
192: });
193:
194: bTrackSubMenu.add(addCurrentUserItem);
195:
196: // Adding the current project in Salomé TMF to bug tracking database
197: JMenuItem addCurrentProjectItem = new JMenuItem(Language
198: .getInstance().getText("add_current_prj_to_bug_db"));
199: addCurrentProjectItem.addActionListener(new ActionListener() {
200: public void actionPerformed(ActionEvent e) {
201: try {
202: bTrack.addProject(DataModel.getCurrentProject());
203: } catch (Exception E) {
204: E.printStackTrace();
205: }
206: }
207: });
208:
209: //if (!bTrack.isUserExistsInBugDB()) addCurrentProjectItem.setEnabled(false);
210: bTrackSubMenu.add(addCurrentProjectItem);
211:
212: toolsMenu.addSeparator();
213: toolsMenu.add(bTrackSubMenu);
214:
215: }
216:
217: }
|