1 23 24 package org.enhydra.kelp.forte.node; 25 26 import java.io.IOException ; 27 28 import org.openide.actions.*; 29 import org.openide.filesystems.FileObject; 30 import org.openide.filesystems.FileUtil; 31 import org.openide.loaders.*; 32 import org.openide.util.NbBundle; 33 import org.openide.util.actions.SystemAction; 34 35 import java.util.Enumeration ; 36 import java.io.*; 37 38 42 public class DodsDataLoader extends MultiFileLoader { 43 44 static final long serialVersionUID = 7377840573359349120L; 45 46 private static final String TEMP_EXT = "in"; 47 49 public static final String PROP_DODS_EXTENSIONS = "dods.extensions"; 50 51 public DodsDataLoader () 52 { 53 this (DodsDataObject.class); 54 } 55 56 public DodsDataLoader (Class recognizedObject) 57 { 58 super (recognizedObject); 59 } 60 61 protected void initialize () { 62 63 setDisplayName (NbBundle.getMessage(DodsDataLoader.class, "LBL_Dodsloader")); 64 65 setActions (new SystemAction[] { 66 null, 68 null, 70 null, 71 77 null, 79 null, 81 null, 83 null, 84 null, 86 null, 88 null, 89 null, 91 null 94 }); 95 96 98 } 99 100 protected FileObject findPrimaryFile (FileObject fo) { 101 Enumeration extSet = getExtensions().extensions(); 103 while (extSet.hasMoreElements()) 104 { 105 String ext = (String )extSet.nextElement(); 106 if (fo.hasExt (ext)) 107 return fo; 108 } 109 return null; 110 } 111 112 protected MultiDataObject createMultiObject (FileObject primaryFile) 113 throws DataObjectExistsException, IOException { 114 return new DodsDataObject (primaryFile, this); 115 } 116 117 protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) { 118 return new FileEntry (obj, primaryFile); 120 } 122 123 protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, FileObject secondaryFile) { 124 secondaryFile.setImportant (false); 125 return new FileEntry.Numb (obj, secondaryFile); } 127 128 131 public ExtensionList getExtensions () { 132 ExtensionList extensions = (ExtensionList)getProperty(PROP_DODS_EXTENSIONS); 133 if (extensions == null) { 134 extensions = new ExtensionList(); 135 extensions.addExtension(TEMP_EXT); 137 139 putProperty(PROP_DODS_EXTENSIONS, extensions, false); 140 } 141 return extensions; 142 } 143 144 147 public void setExtensions(ExtensionList ext) { 148 putProperty(PROP_DODS_EXTENSIONS, ext, true); 149 } 150 151 } 152 | Popular Tags |