1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.jguiraffe.gui.builder.window.ctrl;
17
18 /**
19 * <p>
20 * A specialized {@code FormControllerEvent} class for events related to the
21 * form associated with a {@link FormController}.
22 * </p>
23 * <p>
24 * When the form associated with a {@link FormController} is closed the
25 * controller fires an event of this type. From the properties of this event
26 * listeners can find out whether the form was committed (e.g. the OK button was
27 * clicked) or canceled. A listener could then do something with the data
28 * entered by the user. For instance, if the form was committed, a listener
29 * could save the data somewhere.
30 * </p>
31 *
32 * @author Oliver Heger
33 * @version $Id: FormControllerFormEvent.java 205 2012-01-29 18:29:57Z oheger $
34 */
35 public class FormControllerFormEvent extends FormControllerEvent
36 {
37 /**
38 * The serial version UID.
39 */
40 private static final long serialVersionUID = 20100619L;
41
42 /** The type of this event. */
43 private final Type type;
44
45 /**
46 * Creates a new instance of {@code FormControllerFormEvent} and initializes
47 * it.
48 *
49 * @param ctrl the {@code FormController} which fired this event
50 * @param t the type the event
51 */
52 public FormControllerFormEvent(FormController ctrl, Type t)
53 {
54 super(ctrl);
55 type = t;
56 }
57
58 /**
59 * Returns the type of this event.
60 *
61 * @return the type of this event
62 */
63 public Type getType()
64 {
65 return type;
66 }
67
68 /**
69 * An enumeration class defining the possible types of {@code
70 * FormControllerFormEvent} events. Basically, the type determines whether
71 * the form was committed or canceled.
72 */
73 public static enum Type
74 {
75 /**
76 * Indicates that the form was committed. This means that the user
77 * closed the form with the intension to save the data that was entered.
78 */
79 FORM_COMMITTED,
80
81 /**
82 * Indicates that the form was canceled. The user hit the cancel button,
83 * pressed escape or did something else to abort the edit operation.
84 */
85 FORM_CANCELED;
86 }
87 }