KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > bridge > CommitListener


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.modules.java.bridge;
21
22 import java.util.EventListener JavaDoc;
23 import java.util.Set JavaDoc;
24 import java.util.Map JavaDoc;
25
26 import org.openide.src.SourceException;
27
28 /**
29  * The interface defines a listener that listens for outcome of atomic operations
30  * on the model. CommitListeners are contacted before the atomic operation completes
31  * and are given a chance to abort the whole operation. The commit is simple two-phase
32  * one; in the first phase, all listeners are contacted and queried to confirm
33  * the change integrity. In the second phase, if no listener aborts the operation,
34  * the listeners are notified that the operation completed successfully. There is
35  * no notification that the operation was aborted, currently.
36  *
37  * @author Svatopluk Dedic <mailto:sdedic@netbeans.org>
38  * @version 0.1
39  */

40 public interface CommitListener extends EventListener JavaDoc {
41     /**
42      * Notifies the listener about changes that are made to the model. The method
43      * is only a notification message and can not abort the operation, for that
44      * purposes, use {@link #queryCommitChanges} instead.<P>
45      * The method is called just before the write lock on the model is released.
46      * Avoid lengthy operations from within this method, use RequestProcessor, if necessary.
47      * Recipients are not allowed to alter the source model.
48      * @param created set of elements that were created within the atomic operation.
49      * @param removed set of elements that were removed during the operation
50      * @param changed map indexed by elements that were changed during the operation.
51      * values of the map are elements of the same type containing saved state of
52      * the changed element.
53      */

54     public void changesCommited(Set JavaDoc created, Set JavaDoc removed, Map JavaDoc changed);
55
56     public interface Veto extends CommitListener {
57         /**
58          * Asks the listener whether it is satisfied with the changes made so far.
59          * Recipients are not allowed to alter the source model.
60          * @param created set of elements that were created within the atomic operation.
61          * @param removed set of elements that were removed during the operation
62          * @param changed map indexed by elements that were changed during the operation.
63          * values of the map are elements of the same type containing saved state of
64          * the changed element.
65          * @param zero, if the operation is going out of the write lock; if zero, this is
66          * the last chance to prevent the modification from being done.
67          * @throws SourceException if the listener is not satisfied with impact of the
68          * changes on the model.
69          */

70         public void queryCommitChanges(Set JavaDoc created, Set JavaDoc removed, Map JavaDoc changed,
71             int lockLevel)
72             throws SourceException;
73     }
74 }
75
Popular Tags