KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > view > ui > toolbars > ToolbarProcessor


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.windows.view.ui.toolbars;
21
22 import org.openide.cookies.InstanceCookie;
23 import org.openide.loaders.XMLDataObject;
24 import org.openide.util.WeakListeners;
25
26 import java.io.IOException JavaDoc;
27
28 /**
29  * ToolbarProcessor is cookie of XMLDataObject which creates ToolbarConfiguration.
30  *
31  * @author Libor Kramolis
32  */

33 public class ToolbarProcessor implements XMLDataObject.Processor, InstanceCookie {
34     /** XML data object. */
35     protected XMLDataObject xmlDataObject;
36     /** created configuration */
37     private ToolbarConfiguration configuration;
38
39     /** Attach XML data object to processor. */
40     public void attachTo (XMLDataObject o) {
41         xmlDataObject = o;
42     }
43
44     /**
45      * The bean name for the instance.
46      */

47     public String JavaDoc instanceName () {
48         return instanceClass().getName();
49     }
50
51     /**
52      * The representation type that may be created as instances.
53      */

54     public Class JavaDoc instanceClass () {
55         return ToolbarConfiguration.class;
56     }
57
58     /**
59      * Create an instance of ToolbarConfiguration.
60      */

61     public Object JavaDoc instanceCreate () throws IOException JavaDoc {
62         if (configuration != null) {
63             return configuration;
64         }
65         ToolbarConfiguration tc = new ToolbarConfiguration (xmlDataObject);
66         xmlDataObject.addPropertyChangeListener(WeakListeners.propertyChange (
67                                                     tc, xmlDataObject
68                                                     ));
69         configuration = tc;
70         return tc;
71     }
72 }
73
74
Popular Tags