KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > jarloader > JarDataLoader


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 package org.netbeans.modules.java.jarloader;
20
21 import java.io.IOException JavaDoc;
22 import org.openide.actions.CopyAction;
23 import org.openide.actions.CutAction;
24 import org.openide.actions.DeleteAction;
25 import org.openide.actions.FileSystemAction;
26 import org.openide.actions.PasteAction;
27 import org.openide.actions.PropertiesAction;
28 import org.openide.actions.RenameAction;
29 import org.openide.actions.ToolsAction;
30 import org.openide.filesystems.FileObject;
31 import org.openide.loaders.DataObjectExistsException;
32 import org.openide.loaders.ExtensionList;
33 import org.openide.loaders.MultiDataObject;
34 import org.openide.loaders.UniFileLoader;
35 import org.openide.util.NbBundle;
36 import org.openide.util.actions.SystemAction;
37
38 /**
39  * Recognizes JAR files and shows their contents.
40  * @author Jesse Glick
41  */

42 public final class JarDataLoader extends UniFileLoader {
43     
44     private static final long serialVersionUID = 1L;
45     
46     public JarDataLoader() {
47         super("org.netbeans.modules.java.jarloader.JarDataObject"); // NOI18N
48
}
49     
50     protected String JavaDoc defaultDisplayName() {
51         return NbBundle.getMessage(JarDataLoader.class, "LBL_loaderName");
52     }
53     
54     protected void initialize() {
55         super.initialize();
56         ExtensionList extensions = new ExtensionList();
57         extensions.addExtension("jar"); // NOI18N
58
extensions.addExtension("zip"); // NOI18N
59
extensions.addExtension("war"); // NOI18N
60
extensions.addExtension("ear"); // NOI18N
61
// XXX could add others, perhaps...
62
// or could use FileUtil.isArchiveFile, but that might be too slow
63
setExtensions(extensions);
64     }
65     
66     protected SystemAction[] defaultActions() {
67         return new SystemAction[] {
68             SystemAction.get(FileSystemAction.class),
69             null,
70             SystemAction.get(CutAction.class),
71             SystemAction.get(CopyAction.class),
72             SystemAction.get(PasteAction.class),
73             null,
74             SystemAction.get(DeleteAction.class),
75             SystemAction.get(RenameAction.class),
76             null,
77             SystemAction.get(ToolsAction.class),
78             SystemAction.get(PropertiesAction.class),
79         };
80     }
81     
82     protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException JavaDoc {
83         return new JarDataObject(primaryFile, this);
84     }
85     
86 }
87
Popular Tags