KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > spi > multiview > CloseOperationState


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.core.spi.multiview;
21
22 import javax.swing.Action JavaDoc;
23
24
25 /**
26  * instances of this class describe the MultiViewElement's state when the component is
27  * about to be closed. (See {@link org.netbeans.core.spi.multiview.MultiViewElement#canCloseElement})
28  * New instances are created by {@link org.netbeans.core.spi.multiview.MultiViewFactory#createUnsafeCloseState} factory method.
29  */

30 public final class CloseOperationState {
31
32     /**
33      * Singleton instance of a close operation state, to be used whenever {@link org.netbeans.core.spi.multiview.MultiViewElement} is in consistent state
34      * and can be safely closed.
35      */

36     public static final CloseOperationState STATE_OK = MultiViewFactory.createSafeCloseState();
37     
38     private boolean canClose;
39     private String JavaDoc id;
40     private Action JavaDoc proceedAction;
41     private Action JavaDoc discardAction;
42     
43     
44     CloseOperationState(boolean close, String JavaDoc warningId, Action JavaDoc proceed, Action JavaDoc discard) {
45         canClose = close;
46         proceedAction = proceed;
47         discardAction = discard;
48         id = warningId;
49     }
50     
51     /**
52      * The return value denotes wheather the {@link org.netbeans.core.spi.multiview.MultiViewElement} can be closed or not.
53      * @return can close element or not
54      */

55     
56     public boolean canClose() {
57         return canClose;
58     }
59     
60     /**
61      * A preferably unique id of the reason why the element cannot be closed.
62      * {@link org.netbeans.core.spi.multiview.CloseOperationHandler} implementation can use it when deciding about UI shown or action taken.
63      */

64     
65     public String JavaDoc getCloseWarningID() {
66         return id;
67     }
68     
69     /**
70      * Action is used when user wants to complete the closing of the component without loosing changed data.
71      * Used by {@link org.netbeans.core.spi.multiview.CloseOperationHandler}.
72      * @return action which will be triggered when user confirms changes
73      */

74     public Action JavaDoc getProceedAction() {
75         return proceedAction;
76     }
77
78     /**
79      * Action is used when user wants to complete the closing of the component and discard any changes.
80      * Used by {@link org.netbeans.core.spi.multiview.CloseOperationHandler}.
81      * @return action which will be triggered when user discards changes
82      */

83     
84     public Action JavaDoc getDiscardAction() {
85         return discardAction;
86     }
87     
88     
89 }
90
91
Popular Tags