KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > pdf > PDFDataLoader


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.modules.pdf;
21
22 import java.io.IOException JavaDoc;
23 import org.openide.filesystems.FileObject;
24 import org.openide.loaders.DataObjectExistsException;
25 import org.openide.loaders.ExtensionList;
26 import org.openide.loaders.MultiDataObject;
27 import org.openide.loaders.UniFileLoader;
28 import org.openide.util.NbBundle;
29
30 /** Loader for PDF files (Portable Document Format).
31  * Permits simple viewing of them.
32  * @author Jesse Glick
33  */

34 public class PDFDataLoader extends UniFileLoader {
35
36     /** Generated serial version UID. */
37     private static final long serialVersionUID = -4354042385752587850L;
38     /** MIME-type of PDF files */
39     private static final String JavaDoc PDF_MIME_TYPE = "application/pdf"; //NOI18N
40

41     
42     /** Creates loader. */
43     public PDFDataLoader() {
44         super("org.netbeans.modules.pdf.PDFDataObject"); // NOI18N
45
}
46
47     
48     /** Initizalized loader, i.e. its extension list. Overrides superclass method. */
49     protected void initialize () {
50         super.initialize();
51
52         ExtensionList extensions = new ExtensionList ();
53         extensions.addMimeType(PDF_MIME_TYPE);
54         extensions.addMimeType("application/x-pdf"); //NOI18N
55
extensions.addMimeType("application/vnd.pdf"); //NOI18N
56
extensions.addMimeType("application/acrobat"); //NOI18N
57
extensions.addMimeType("text/pdf"); //NOI18N
58
extensions.addMimeType("text/x-pdf"); //NOI18N
59
setExtensions (extensions);
60     }
61     
62     /** Gets default display name. Overrides superclass method. */
63     protected String JavaDoc defaultDisplayName() {
64         return NbBundle.getMessage (PDFDataLoader.class, "LBL_loaderName");
65     }
66     
67     /**
68      * This methods uses the layer action context so it returns
69      * a non-<code>null</code> value.
70      *
71      * @return name of the context on layer files to read/write actions to
72      */

73     protected String JavaDoc actionsContext () {
74         return "Loaders/application/pdf/Actions/"; //NOI18N
75
}
76     
77     /** Creates multi data objcte for specified primary file.
78      * Implements superclass abstract method. */

79     protected MultiDataObject createMultiObject (FileObject primaryFile)
80     throws DataObjectExistsException, IOException JavaDoc {
81         return new PDFDataObject (primaryFile, this);
82     }
83
84 }
85
Popular Tags