KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > editor > fold > FoldHierarchyTransaction


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.spi.editor.fold;
21
22 import org.netbeans.modules.editor.fold.FoldHierarchyTransactionImpl;
23
24 /**
25  * Class encapsulating a modification
26  * of the code folding hierarchy.
27  * <br>
28  * It's provided by {@link FoldOperation#openTransaction()}.
29  * <br>
30  * It can accumulate arbitrary number of changes of various folds
31  * by being passed as argument to particular methods in the FoldOperation.
32  * <br>
33  * Only one transaction can be active at the time.
34  * <br>
35  * Once all the modifications are done the transaction must be
36  * committed by {@link #commit()} which creates
37  * a {@link org.netbeans.api.editor.fold.FoldHierarchyEvent}
38  * and fires it to the listeners automatically.
39  * <br>
40  * Once the transaction is committed no additional
41  * changes can be made to it.
42  * <br>
43  * There is currently no way to rollback the transaction.
44  *
45  * @author Miloslav Metelka
46  * @version 1.00
47  */

48
49 public final class FoldHierarchyTransaction {
50     
51     private final FoldHierarchyTransactionImpl impl;
52
53     FoldHierarchyTransaction(FoldHierarchyTransactionImpl impl) {
54         this.impl = impl;
55     }
56
57     /**
58      * Commit this transaction.
59      * <br>
60      * Transaction can only be committed once.
61      *
62      * @throws IllegalStateException if the transaction is attempted
63      * to be commited more than once.
64      */

65     public void commit() {
66         impl.commit();
67     }
68     
69     FoldHierarchyTransactionImpl getImpl() {
70         return impl;
71     }
72
73 }
74
Popular Tags