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 salomeTMF_plug.cronExec;
025:
026: import java.awt.event.ActionEvent;
027: import java.awt.event.ActionListener;
028: import java.util.Vector;
029:
030: import javax.swing.JButton;
031: import javax.swing.JOptionPane;
032: import javax.swing.JPanel;
033:
034: import org.java.plugin.ExtensionPoint;
035: import org.java.plugin.Plugin;
036: import org.java.plugin.PluginDescriptor;
037: import org.java.plugin.PluginManager;
038: import org.objectweb.salome_tmf.api.Util;
039: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
040: import org.objectweb.salome_tmf.plugins.UICompCst;
041: import org.objectweb.salome_tmf.plugins.core.Common;
042:
043: import salomeTMF_plug.cronExec.languages.Language;
044:
045: /**
046: *
047: * @author marchemi
048: */
049: public class CronExecPlugin extends Plugin implements Common {
050:
051: boolean alreadyCron = false;
052:
053: CronTimer timer = null;
054:
055: JButton cronButton = null;
056:
057: /** Creates a new instance of cronExecPlugin */
058: public CronExecPlugin(PluginManager manager, PluginDescriptor descr) {
059: super (manager, descr);
060: }
061:
062: /********************* extends Plugin**********************************/
063:
064: /**
065: * @see org.java.plugin.Plugin()
066: */
067: protected void doStart() throws Exception {
068: Util.log("[cronExecPlugin:doStart] chargement du plugin");
069: }
070:
071: /**
072: * @see org.java.plugin.Plugin()
073: */
074: protected void doStop() throws Exception {
075: // no-op
076: }
077:
078: //********************* interface common ********************//
079:
080: public void activatePluginInCampToolsMenu(javax.swing.JMenu jMenu) {
081: }
082:
083: public void activatePluginInDataToolsMenu(javax.swing.JMenu jMenu) {
084: }
085:
086: public void activatePluginInDynamicComponent(Integer integer) {
087: }
088:
089: public void activatePluginInStaticComponent(Integer integer) {
090:
091: JPanel cronExecPanel = (JPanel) SalomeTMFContext.getInstance()
092: .getUIComponent(integer);
093:
094: cronButton = new JButton("");
095: cronButton.setToolTipText(Language.getInstance().getText(
096: "Cron_exécutions"));
097: cronButton
098: .setIcon(new javax.swing.ImageIcon(
099: getClass()
100: .getResource(
101: "/salomeTMF_plug/cronExec/resources/cron_off.gif")));
102:
103: cronButton.addActionListener(new ActionListener() {
104: public void actionPerformed(ActionEvent e) {
105: if (alreadyCron) {
106: Object[] options = {
107: Language.getInstance().getText("Oui"),
108: Language.getInstance().getText("Non") };
109: int choice = JOptionPane
110: .showOptionDialog(
111: SalomeTMFContext.getInstance()
112: .getSalomeFrame(),
113: Language
114: .getInstance()
115: .getText(
116: "Des_exécutions_sont_déjà_programmées_pour_être_lancées!\n")
117: + Language
118: .getInstance()
119: .getText(
120: "Voulez-vous_annuler_ces_exécutions_et_recommencer?"),
121: Language.getInstance().getText(
122: "Attention_!"),
123: JOptionPane.YES_NO_OPTION,
124: JOptionPane.WARNING_MESSAGE, null,
125: options, options[1]);
126: if (choice == JOptionPane.YES_OPTION) {
127: if (timer != null) {
128: timer.cancel();
129: timer = new CronTimer(CronExecPlugin.this );
130: } else {
131: timer = new CronTimer(CronExecPlugin.this );
132: }
133: new ExecChooser(CronExecPlugin.this , timer);
134: }
135: } else {
136: if (timer != null) {
137: timer.cancel();
138: timer = new CronTimer(CronExecPlugin.this );
139: } else {
140: timer = new CronTimer(CronExecPlugin.this );
141: }
142: new ExecChooser(CronExecPlugin.this , timer);
143: }
144: }
145: });
146:
147: cronExecPanel.add(cronButton);
148: }
149:
150: public void activatePluginInTestToolsMenu(javax.swing.JMenu jMenu) {
151: }
152:
153: public void freeze() {
154: }
155:
156: public java.util.Vector getUsedUIComponents() {
157: Vector uiComponentsUsed = new Vector();
158:
159: uiComponentsUsed.add(0, UICompCst.CAMP_FIRST_BUTTONS_PANEL);
160:
161: return uiComponentsUsed;
162: }
163:
164: public void init(Object pIhm) {
165: }
166:
167: public boolean isActivableInCampToolsMenu() {
168: return false;
169: }
170:
171: public boolean isActivableInDataToolsMenu() {
172: return false;
173: }
174:
175: public boolean isActivableInTestToolsMenu() {
176: return false;
177: }
178:
179: public boolean isFreezable() {
180: return false;
181: }
182:
183: public boolean isFreezed() {
184: return false;
185: }
186:
187: public void unFreeze() {
188: }
189:
190: public boolean usesOtherUIComponents() {
191: return true;
192: }
193:
194: public void allPluginActived(ExtensionPoint commonExtensions,
195: ExtensionPoint testDriverExtensions,
196: ExtensionPoint scriptEngineExtensions,
197: ExtensionPoint bugTrackerExtensions) {
198:
199: }
200:
201: /**
202: * @param alreadyCron The alreadyCron to set.
203: */
204: public void setAlreadyCron(boolean alreadyCron) {
205: this .alreadyCron = alreadyCron;
206: }
207:
208: /**
209: * @return Returns the cronButton.
210: */
211: public JButton getCronButton() {
212: return cronButton;
213: }
214: }
|