source: src/main/java/weka/gui/scripting/event/ScriptExecutionEvent.java @ 9

Last change on this file since 9 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 3.0 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 * ScriptExecutionEvent.java
19 * Copyright (C) 2009 University of Waikato, Hamilton, New Zealand
20 */
21
22package weka.gui.scripting.event;
23
24import weka.gui.scripting.Script;
25
26import java.util.EventObject;
27
28/**
29 * Event that gets sent when a script is executed.
30 *
31 * @author  fracpete (fracpete at waikato dot ac dot nz)
32 * @version $Revision: 5142 $
33 */
34public class ScriptExecutionEvent
35  extends EventObject {
36
37  /** for serialization. */
38  private static final long serialVersionUID = -8357216611114356632L;
39
40  /**
41   * Defines the type of event.
42   *
43   * @author  fracpete (fracpete at waikato dot ac dot nz)
44   * @version $Revision: 5142 $
45   */
46  public enum Type {
47    /** started execution. */
48    STARTED,
49    /** finished normal. */
50    FINISHED,
51    /** finished with error. */
52    ERROR,
53    /** got stopped by user. */
54    STOPPED
55  }
56 
57  /** the type of event. */
58  protected Type m_Type;
59 
60  /** optional additional information. */
61  protected Object m_Additional;
62 
63  /**
64   * Initializes the event.
65   *
66   * @param source      the script that triggered the event
67   * @param type        the type of finish
68   */
69  public ScriptExecutionEvent(Script source, Type type) {
70    this(source, type, null);
71  }
72 
73  /**
74   * Initializes the event.
75   *
76   * @param source      the script that triggered the event
77   * @param type        the type of finish
78   * @param additional  additional information, can be null
79   */
80  public ScriptExecutionEvent(Script source, Type type, Object additional) {
81    super(source);
82   
83    m_Type       = type;
84    m_Additional = additional;
85  }
86 
87  /**
88   * Returns the script that triggered the event.
89   *
90   * @return            the script
91   */
92  public Script getScript() {
93    return (Script) getSource();
94  }
95 
96  /**
97   * Returns the type of event.
98   *
99   * @return            the type
100   */
101  public Type getType() {
102    return m_Type;
103  }
104 
105  /**
106   * Returns whether additional information is available.
107   *
108   * @return            true if additional information is available
109   * @see               #getAdditional()
110   */
111  public boolean hasAdditional() {
112    return (m_Additional != null);
113  }
114 
115  /**
116   * Returns the additional information.
117   *
118   * @return            the additional information, can be null
119   */
120  public Object getAdditional() {
121    return m_Additional;
122  }
123}
Note: See TracBrowser for help on using the repository browser.