KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > loader > CssDataObject


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * CssDataObject.java
22  *
23  * Created on December 8, 2004, 11:04 PM
24  */

25
26 package org.netbeans.modules.css.loader;
27
28 import org.netbeans.modules.css.editor.CssEditorSupport;
29 import org.netbeans.modules.css.visual.model.CssMetaModel;
30 import org.openide.cookies.SaveCookie;
31 import org.openide.filesystems.FileObject;
32 import org.openide.loaders.DataObjectExistsException;
33 import org.openide.loaders.MultiDataObject;
34 import org.openide.loaders.UniFileLoader;
35 import org.openide.nodes.CookieSet;
36 import org.openide.nodes.Node.Cookie;
37 import org.openide.nodes.Node;
38
39 /**
40  * Data Object that represents one css file.
41  * @author Winston Prakash
42  * @version 1.0
43  */

44 public class CssDataObject extends MultiDataObject{
45
46     /** Creates a new instance of CssDataObject */
47     public CssDataObject(FileObject fileObject, UniFileLoader loader) throws DataObjectExistsException{
48         super(fileObject, loader);
49         
50         CookieSet cookieSet = getCookieSet();
51         cookieSet.add(new CssEditorSupport(this));
52         // XXX This is an ugly hack for some classes to get the
53
// DataObject. Find other neat ways. (I hate this, but time is running out)
54
CssMetaModel.setDataObject(this);
55     }
56
57     protected Node createNodeDelegate() {
58         return new CssDataNode(this);
59     }
60
61     /** Add the save cookie to the css data object **/
62     public void addSaveCookie(SaveCookie saveCookie){
63         if(getCookie(SaveCookie.class) == null) {
64             getCookieSet().add(saveCookie);
65             setModified(true);
66         }
67     }
68
69     /** Remove save cookie from the css data object **/
70     public void removeSaveCookie(SaveCookie saveCookie){
71         Cookie cookie = getCookie(SaveCookie.class);
72         if(cookie != null && cookie.equals(saveCookie)) {
73             getCookieSet().remove(saveCookie);
74             setModified(false);
75         }
76     }
77 }
78
Popular Tags