KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.oddjob.monitor.action;
2
3 import org.oddjob.Resetable;
4 import org.oddjob.designer.model.DesignDefinition;
5 import org.oddjob.monitor.model.ExplorerContext;
6 import org.oddjob.monitor.model.JobAction;
7 import org.oddjob.util.ThreadManager;
8
9 /**
10  * Perform a soft reset action.
11  *
12  * @author Rob Gordon
13  */

14
15 public class SoftResetAction extends JobAction {
16
17     /** The job. */
18     private Object JavaDoc job = null;
19
20     /** The ThreadManager that will run the reset. */
21     private ThreadManager threadManager;
22
23     /** Is the action enabled. */
24     private boolean enabled;
25     
26     /*
27      * (non-Javadoc)
28      * @see org.oddjob.monitor.model.JobOption#getName()
29      */

30     public String JavaDoc getName() {
31         return "Soft Reset";
32     }
33
34     /*
35      * (non-Javadoc)
36      * @see org.oddjob.monitor.model.JobOption#select(java.lang.Object, org.oddjob.monitor.model.ExplorerContext)
37      */

38     protected void select(Object JavaDoc component, ExplorerContext eContext) {
39         if (!(component instanceof Resetable)) {
40             this.job = null;
41             this.enabled = false;
42             return;
43         }
44         
45         this.job = component;
46         this.enabled = true;
47         this.threadManager = eContext.getThreadManager();
48     }
49
50     /*
51      * (non-Javadoc)
52      * @see org.oddjob.monitor.model.JobOption#deSelect()
53      */

54     protected void deSelect() {
55         job = null;
56         enabled = false;
57     }
58     
59     /*
60      * (non-Javadoc)
61      * @see org.oddjob.monitor.model.JobOption#enabled()
62      */

63     public boolean enabled() {
64         return enabled;
65     }
66     
67     /*
68      * (non-Javadoc)
69      * @see org.oddjob.monitor.model.JobAction#form()
70      */

71     public DesignDefinition form() {
72         return null;
73     }
74     
75     /*
76      * (non-Javadoc)
77      * @see org.oddjob.monitor.model.JobAction#action()
78      */

79     public void action() throws Exception JavaDoc {
80         threadManager.run(new Runnable JavaDoc() {
81             public void run() {
82                 ((Resetable)job).softReset();
83             }
84         }, "Soft Reset of " + job);
85     }
86     
87 }
88
Popular Tags