KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > gui > action > SwitchLoadProfileOrBehaviorsModeAction


1 /*
2  * CLIF is a Load Injection Framework
3  * Copyright (C) 2004 France Telecom R&D
4  * Copyright (C) 2004 INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * CLIF
21  *
22  * Contact: clif@objectweb.org
23  */

24 package org.objectweb.clif.scenario.util.isac.gui.action;
25
26 import java.net.URL JavaDoc;
27
28 import org.apache.log4j.Category;
29 import org.eclipse.jface.action.Action;
30 import org.eclipse.jface.resource.ImageDescriptor;
31 import org.eclipse.jface.window.ApplicationWindow;
32 import org.objectweb.clif.scenario.util.isac.FileName;
33 import org.objectweb.clif.scenario.util.isac.gui.ScenarioGUIEditor;
34 /**
35  * Action which switch load profile or behaviors editor
36  *
37  * @author JC Meillaud
38  * @author A Peyrard
39  */

40 public class SwitchLoadProfileOrBehaviorsModeAction extends Action {
41     /**
42      * The application window, which launch this action
43      */

44     ScenarioGUIEditor window;
45     static Category cat = Category
46             .getInstance(SwitchLoadProfileOrBehaviorsModeAction.class.getName());
47
48     private static final String JavaDoc fullBehaviorsModeText = "Full behaviors mode";
49     private static final String JavaDoc fullLoadProfileModeText = "Full load profile mode";
50     private static final String JavaDoc fullBehaviorsModeToolTipText = "Full behaviors mode";
51     private static final String JavaDoc fullLoadProfileModeToolTipText = "Full load profile mode";
52     private static final String JavaDoc splitModeText = "Split mode";
53     private static final String JavaDoc splitModeToolTipText = "Split mode";
54     private int typeMode ;
55     /**
56      * Build a new 'exit' action
57      *
58      * @param w
59      * The application window which launch the action
60      */

61     public SwitchLoadProfileOrBehaviorsModeAction(ApplicationWindow w, int type) {
62         cat.debug("-> constructor");
63         this.window = (ScenarioGUIEditor) w;
64         this.typeMode = type ;
65         try {
66             // set The image and the text
67
switch (type) {
68                 case ScenarioGUIEditor.FULL_BEHAVIORS_MODE :
69                     setText(fullBehaviorsModeText);
70                     setToolTipText(fullBehaviorsModeToolTipText) ;
71                     this.setImageDescriptor(ImageDescriptor
72                             .createFromURL(new URL JavaDoc("file:"
73                                     + FileName.FULL_ICON)));
74                     break;
75                 case ScenarioGUIEditor.FULL_LOAD_PROFILE_MODE :
76                     setText(fullLoadProfileModeText);
77                     setToolTipText(fullLoadProfileModeToolTipText) ;
78                     this.setImageDescriptor(ImageDescriptor
79                             .createFromURL(new URL JavaDoc("file:"
80                                     + FileName.FULL_ICON)));
81                     break;
82                 case ScenarioGUIEditor.SPLIT_MODE :
83                     setText(splitModeText);
84                     setToolTipText(splitModeToolTipText) ;
85                     this.setImageDescriptor(ImageDescriptor
86                             .createFromURL(new URL JavaDoc("file:"
87                                     + FileName.SPLIT_ICON)));
88                     break;
89                 default :
90             // no other type
91
}
92         } catch (Exception JavaDoc e) {
93             cat.warn("Unable to find Switch MODE icon file");
94         }
95     }
96
97     public void run() {
98         this.window.changeSplitMode(typeMode) ;
99     }
100 }
Popular Tags