1 19 20 package org.netbeans.modules.web.core.palette.items; 21 import javax.swing.text.BadLocationException ; 22 import javax.swing.text.JTextComponent ; 23 import org.netbeans.modules.web.core.palette.JSPPaletteUtilities; 24 import org.openide.text.ActiveEditorDrop; 25 26 27 31 public class GetProperty implements ActiveEditorDrop { 32 33 public static final String [] implicitBeans = new String [] { "request", 35 "response", 36 "pageContext", 37 "session", 38 "application", 39 "out", 40 "config", 41 "page", 42 "exception" 43 }; 44 public static final int BEAN_DEFAULT = -1; 45 public static final String [] implicitTypes = new String [] { "javax.servlet.http.HttpServletRequest", 47 "javax.servlet.http.HttpServletResponse", 48 "javax.servlet.jsp.PageContext", 49 "javax.servlet.http.HttpSession", 50 "javax.servlet.ServletContext", 51 "javax.servlet.jsp.JspWriter", 52 "javax.servlet.ServletConfig", 53 "java.lang.Object", 54 "java.lang.Throwable" 55 }; 56 57 private int beanIndex = BEAN_DEFAULT; 58 private String bean = ""; 59 private String property = ""; 60 61 public GetProperty() { 62 } 63 64 public boolean handleTransfer(JTextComponent targetComponent) { 65 66 GetPropertyCustomizer c = new GetPropertyCustomizer(this, targetComponent); 67 boolean accept = c.showDialog(); 68 if (accept) { 69 String body = createBody(); 70 try { 71 JSPPaletteUtilities.insert(body, targetComponent); 72 } catch (BadLocationException ble) { 73 accept = false; 74 } 75 } 76 77 return accept; 78 } 79 80 private String createBody() { 81 82 String strBean = " name=\"\""; if (beanIndex == -1) 84 strBean = " name=\"" + bean + "\""; else 86 strBean = " name=\"" + implicitBeans[beanIndex] + "\""; 88 String strProperty = " property=\"" + property + "\""; 90 String gp = "<jsp:getProperty" + strBean + strProperty + " />"; 92 return gp; 93 } 94 95 public int getBeanIndex() { 96 return beanIndex; 97 } 98 99 public void setBeanIndex(int beanIndex) { 100 this.beanIndex = beanIndex; 101 } 102 103 public String getBean() { 104 return bean; 105 } 106 107 public void setBean(String bean) { 108 this.bean = bean; 109 } 110 111 public String getProperty() { 112 return property; 113 } 114 115 public void setProperty(String property) { 116 this.property = property; 117 } 118 119 } 120 | Popular Tags |