1 19 20 package org.netbeans.modules.web.core.jsploader; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 import javax.swing.text.Document ; 25 import java.net.URLClassLoader ; 26 import java.util.Iterator ; 27 import java.util.Map ; 28 import java.util.HashMap ; 29 import java.util.StringTokenizer ; 30 31 import org.openide.ErrorManager; 32 import org.openide.util.Lookup; 33 import org.openide.filesystems.FileObject; 34 import org.openide.text.CloneableEditorSupport; 35 36 import org.netbeans.modules.web.jsps.parserapi.JspParserFactory; 37 import org.netbeans.modules.web.jsps.parserapi.JspParserAPI; 38 import org.netbeans.modules.web.core.syntax.spi.JSPColoringData; 39 import org.netbeans.modules.web.core.syntax.spi.JspContextInfo; 40 import org.netbeans.modules.web.api.webmodule.WebModule; 41 import org.openide.filesystems.FileStateInvalidException; 42 import org.openide.loaders.DataObject; 43 import org.openide.loaders.DataNode; 44 45 public class JspContextInfoImpl extends JspContextInfo { 46 47 public JspContextInfoImpl() { 48 } 49 50 private static TagLibParseSupport getTagLibParseSupport(Document doc, FileObject fo){ 51 TagLibParseSupport tlps = null; 52 if (fo != null && fo.isValid()){ 53 try { 54 tlps = (TagLibParseSupport)DataObject.find(fo).getCookie(TagLibParseSupport.class); 55 } 56 catch (org.openide.loaders.DataObjectNotFoundException e){ 57 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 58 } 59 } 60 return tlps; 61 } 62 63 public URLClassLoader getModuleClassLoader(Document doc, FileObject fo){ 64 return JspParserFactory.getJspParser().getModuleClassLoader(JspParserAccess.getJspParserWM (WebModule.getWebModule (fo))); 65 } 66 67 70 public Map getTaglibMap(Document doc, FileObject fo) { 71 try { 72 JspParserAPI parser = JspParserFactory.getJspParser(); 73 if (parser == null) { 74 ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, 75 new NullPointerException ()); 76 } 77 else { 78 return parser.getTaglibMap(JspParserAccess.getJspParserWM (WebModule.getWebModule (fo))); 79 } 80 } 81 catch (IOException e) { 82 ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, e); 83 } 84 return null; 85 } 86 87 93 public java.awt.Image getIcon(Document doc, FileObject fo){ 94 95 java.awt.Image icon = null; 96 97 try { 98 icon = DataObject.find(fo).getNodeDelegate().getIcon(java.beans.BeanInfo.ICON_COLOR_16x16); 99 } 100 catch(org.openide.loaders.DataObjectNotFoundException e) { 101 e.printStackTrace(System.out); 102 } 103 104 return icon; 105 } 106 107 108 public JspParserAPI.ParseResult getCachedParseResult (Document doc, FileObject fo, boolean successfulOnly, boolean preferCurrent, boolean forceParse) { 109 TagLibParseSupport sup = getTagLibParseSupport (doc, fo); 110 if (sup != null) { 111 return sup.getCachedParseResult (successfulOnly, preferCurrent, forceParse); 112 } 113 return null; 114 } 115 116 public JspParserAPI.ParseResult getCachedParseResult (Document doc, FileObject fo, boolean successfulOnly, boolean preferCurrent) { 117 return getCachedParseResult(doc, fo, successfulOnly, preferCurrent, false); 118 } 119 120 public JSPColoringData getJSPColoringData (Document doc, FileObject fo) { 121 TagLibParseSupport sup = getTagLibParseSupport (doc, fo); 122 if (sup != null) { 123 return sup.getJSPColoringData (); 124 } 125 return null; 126 } 127 128 public org.netbeans.modules.web.jsps.parserapi.JspParserAPI.JspOpenInfo getCachedOpenInfo(Document doc, FileObject fo, boolean preferCurrent) { 129 TagLibParseSupport sup = getTagLibParseSupport (doc, fo); 130 if (sup != null) { 131 return sup.getCachedOpenInfo(preferCurrent, true); 132 } 133 return null; 134 } 135 136 public FileObject guessWebModuleRoot (Document doc, FileObject fo) { 137 WebModule wm = WebModule.getWebModule (fo); 138 if (wm != null) 139 return wm.getDocumentBase (); 140 return null; 141 } 142 } | Popular Tags |