KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > monitor > action > UnScheduleMenu


1 package org.oddjob.monitor.action;
2
3 import org.oddjob.designer.model.DesignDefinition;
4 import org.oddjob.monitor.model.ExplorerContext;
5 import org.oddjob.monitor.model.JobAction;
6 import org.oddjob.monitor.model.JobMenu;
7 import org.oddjob.monitor.model.JobOption;
8 import org.oddjob.monitor.model.JobSchedulerSummary;
9 import org.oddjob.monitor.model.SchedulerTraker;
10
11 /**
12  * Creates a menu of available schedulers.
13  *
14  * @author Rob Gordon
15  */

16
17 public class UnScheduleMenu extends JobMenu {
18 // private static final Logger logger = Logger.getLogger(UnScheduleMenu.class);
19

20     private boolean enabled;
21     
22     private JobOption[] options;
23     
24     /**
25      * Get the name of the action.
26      */

27     public String JavaDoc getName() {
28         return "UnSchedule Job";
29     }
30
31     public void select(Object JavaDoc component, ExplorerContext eContext) {
32         enabled = true;
33         SchedulerTraker st = eContext.getSchedulerTraker();
34         JobSchedulerSummary[] summaries = st.getSchedulerSummaries(component);
35         if (summaries.length == 0) {
36             options = new JobOption[1];
37             options[0] = new NotScheduled();
38         }
39         else {
40             options = new JobOption[summaries.length];
41             for (int i = 0; i < summaries.length; ++i) {
42                 options[i] = new UnScheduleAction(summaries[i].getScheduler(),
43                         summaries[i].getSummary().getId());
44                 options[i].optionSelect(component, eContext);
45             }
46         }
47         
48     }
49     
50     public void deSelect() {
51         enabled = false;
52     }
53     
54     public boolean enabled() {
55         return enabled;
56     }
57     
58     public JobOption[] options() {
59         return options;
60     }
61
62     class NotScheduled extends JobAction {
63         public boolean enabled() {
64             return false;
65         }
66         public String JavaDoc getName() {
67             return "Not Scheduled";
68         }
69         public void select(Object JavaDoc component, ExplorerContext eContext) {
70         }
71         public void deSelect() {
72         }
73         public void action() throws Exception JavaDoc {
74         }
75         public DesignDefinition form() {
76             return null;
77         }
78     }
79 }
80
Popular Tags