1 23 24 package org.enhydra.kelp.forte.node; 25 26 import java.io.IOException ; 27 import java.util.Vector ; 28 29 import org.openide.actions.*; 30 import org.openide.filesystems.FileObject; 31 import org.openide.filesystems.FileUtil; 32 import org.openide.loaders.*; 33 import org.openide.util.NbBundle; 34 import org.openide.util.actions.SystemAction; 35 36 import java.util.Enumeration ; 37 import java.io.*; 38 39 43 public class XMLCDataLoader extends MultiFileLoader { 44 45 static final long serialVersionUID = -5042424699146221934L; 46 47 public static final String PROP_XMLC_EXTENSIONS = "xmlc.extensions"; 48 49 50 public XMLCDataLoader () 51 { 52 this (XMLCDataObject.class); 53 } 54 55 public XMLCDataLoader (Class recognizedObject) 56 { 57 super (recognizedObject); 58 } 59 60 protected void initialize () { 61 62 setDisplayName (NbBundle.getMessage (XMLCDataLoader.class, "LBL_XMLCloader")); 63 64 setActions (new SystemAction[] { 65 SystemAction.get (ViewAction.class), 66 SystemAction.get (OpenAction.class), 67 SystemAction.get (FileSystemAction.class), 68 null, 69 SystemAction.get (CutAction.class), 73 SystemAction.get (CopyAction.class), 74 SystemAction.get (PasteAction.class), 75 null, 76 SystemAction.get (DeleteAction.class), 77 SystemAction.get (RenameAction.class), 78 null, 79 SystemAction.get (SaveAsTemplateAction.class), 80 SystemAction.get (PropertiesAction.class), 83 }); 84 85 super.initialize(); 86 87 } 88 89 protected FileObject findPrimaryFile (FileObject fo) { 90 Enumeration extSet = getExtensions().extensions(); 92 while (extSet.hasMoreElements()) 93 { 94 String ext = (String )extSet.nextElement(); 95 if (fo.hasExt (ext)) 96 return fo; 97 } 98 return null; 102 } 103 104 protected MultiDataObject createMultiObject (FileObject primaryFile) 105 throws DataObjectExistsException, IOException { 106 return new XMLCDataObject (primaryFile, this); 107 } 108 109 protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) { 110 return new FileEntry (obj, primaryFile); 112 } 113 114 117 public ExtensionList getExtensions () { 118 ExtensionList extensions = null; 119 ForteProject project = new ForteProject(); 120 if (project != null){ 121 String exts[] = project.getDocTypes(); 122 if (exts != null) { 123 extensions = new ExtensionList(); 125 for (int i = 0; i < exts.length; i++) 126 extensions.addExtension(exts[i]); 127 putProperty(PROP_XMLC_EXTENSIONS, extensions, false); 128 } 129 } 130 else 131 extensions = (ExtensionList)getProperty(PROP_XMLC_EXTENSIONS); 132 return extensions; 133 } 134 135 138 public void setExtensions(ExtensionList ext) { 139 putProperty(PROP_XMLC_EXTENSIONS, ext, true); 140 ForteProject project = new ForteProject(); 141 if (project != null){ 142 Vector v = new Vector (); 143 Enumeration e = ext.extensions(); 144 while (e.hasMoreElements()) 145 v.add(e.nextElement()); 146 String exts[] = new String [0]; 147 exts = (String [])v.toArray(exts); 148 project.setDocTypes(exts); 149 } 150 } 151 152 protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, FileObject secondaryFile) { 153 secondaryFile.setImportant (false); 154 return new FileEntry.Numb (obj, secondaryFile); } 156 157 } 158 | Popular Tags |