KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > group > GroupShadowLoader


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
21 package org.netbeans.modules.group;
22
23
24 import org.openide.actions.*;
25 import org.openide.filesystems.*;
26 import org.openide.loaders.*;
27 import org.openide.util.actions.SystemAction;
28 import org.openide.util.NbBundle;
29
30
31 /**
32  * Loader for <code>GroupShadow</code> data object.
33  *
34  * @author Jaroslav Tulach
35  */

36 public class GroupShadowLoader extends DataLoader {
37
38     /** generated serial version UID */
39     static final long serialVersionUID =-2768192459953761627L;
40
41     /**
42      * extension of files representing groups.
43      * This extension is initially the only item in the list of recognized
44      * extensions.
45      *
46      * @see #setExtensions
47      */

48     public static final String JavaDoc GS_EXTENSION = "group"; // NOI18N
49

50     /**
51      * list of extensions of group shadow files
52      *
53      * @see #setExtensions
54      */

55     private ExtensionList extensions;
56
57     
58     /** Creates a new loader. */
59     public GroupShadowLoader() {
60         super("org.netbeans.modules.group.GroupShadow"); // NOI18N
61

62         extensions = new ExtensionList();
63         extensions.addExtension(GS_EXTENSION);
64     }
65     
66     
67     /** */
68     protected String JavaDoc defaultDisplayName() {
69         return NbBundle.getMessage(GroupShadowLoader.class,
70                                    "PROP_GroupShadowName"); //NOI18N
71
}
72     
73     /** */
74     protected SystemAction[] defaultActions() {
75         return new SystemAction[] {
76             SystemAction.get(OpenLocalExplorerAction.class),
77             SystemAction.get(FileSystemAction.class),
78             null,
79             SystemAction.get(CutAction.class),
80             SystemAction.get(CopyAction.class),
81             SystemAction.get(PasteAction.class),
82             null,
83             SystemAction.get(DeleteAction.class),
84             SystemAction.get(RenameAction.class),
85             null,
86             SystemAction.get(SaveAsTemplateAction.class),
87             null,
88             SystemAction.get(ToolsAction.class),
89             SystemAction.get(PropertiesAction.class)
90         };
91     }
92
93     
94     /**
95      * @return {@link GroupShadow} for the given <code>FileObject</code>;
96      * or <code>null</code> if the <code>FileObject</code>
97      * does not have the expected extension
98      * @see #GS_EXTENSION
99      */

100     protected DataObject handleFindDataObject(
101             FileObject fo,
102             DataLoader.RecognizedFiles recognized) throws java.io.IOException JavaDoc {
103         if (getExtensions().isRegistered(fo)) {
104             return new GroupShadow(fo, this);
105         }
106         return null;
107     }
108
109     /**
110      * Returns a list of extensions of group shadow files.
111      * Files having an extension among the specified extensions are
112      * recognized as files representing group shadow files.
113      *
114      * @return list of extensions of group shadow files
115      */

116     public ExtensionList getExtensions() {
117         return extensions;
118     }
119
120     /**
121      * Sets a list of extensions of group shadow files.
122      * Files having an extension among the specified extensions will then be
123      * recognized as files representing group shadow files.
124      *
125      * @param extensions new list of extensions
126      */

127     public void setExtensions(ExtensionList extensions) {
128         this.extensions = extensions;
129     }
130 }
131
Popular Tags