1 19 20 package org.netbeans.modules.languages.dataobject; 21 22 import org.netbeans.api.languages.LanguagesManager; 23 import org.netbeans.modules.languages.LanguagesManagerImpl; 24 import org.netbeans.modules.languages.LanguagesManagerImpl.LanguagesManagerListener; 25 import org.openide.filesystems.FileObject; 26 import org.openide.loaders.DataObjectExistsException; 27 import org.openide.loaders.MultiDataObject; 28 import org.openide.loaders.UniFileLoader; 29 import org.openide.util.NbBundle; 30 31 import java.io.IOException ; 32 import java.util.Iterator ; 33 34 public class LanguagesDataLoader extends UniFileLoader { 35 36 private static final long serialVersionUID = 1L; 37 38 public LanguagesDataLoader() { 39 super("org.netbeans.modules.languages.dataobject.LanguagesDataObject"); 40 } 41 42 protected String defaultDisplayName() { 43 return NbBundle.getMessage(LanguagesDataLoader.class, "LBL_mf_loader_name"); 44 } 45 46 protected void initialize() { 47 super.initialize(); 48 Iterator it = LanguagesManager.getDefault ().getSupportedMimeTypes (). 49 iterator (); 50 while (it.hasNext ()) { 51 String mimeType = (String ) it.next (); 52 if (mimeType.equals ("text/xml")) continue; 53 getExtensions().addMimeType (mimeType); 54 } 55 ((LanguagesManagerImpl) LanguagesManager.getDefault ()). 56 addLanguagesManagerListener (new LanguagesManagerListener () { 57 58 public void languageAdded (String mimeType) { 59 getExtensions().addMimeType (mimeType); 60 } 61 62 public void languageRemoved (String mimeType) { 63 getExtensions().removeMimeType (mimeType); 64 } 65 66 public void languageChanged (String mimeType) { 67 } 68 }); 69 } 70 71 protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException { 72 return new LanguagesDataObject(primaryFile, this); 73 } 74 75 protected String actionsContext() { 76 return "Loaders/Languages/Actions"; 77 } 78 } 79 | Popular Tags |