1 23 24 package org.infoglue.cms.plugins.codeeditor; 25 26 import java.awt.Color ; 27 import java.awt.Dimension ; 28 29 import javax.swing.BorderFactory ; 30 import javax.swing.JApplet ; 31 import javax.swing.JScrollPane ; 32 33 import netscape.javascript.JSObject; 34 35 36 public class InfoGlueCodeEditorApplet extends JApplet implements InfoGlueCodeEditorController 37 { 38 private InfoGlueTextArea textArea = null; 39 40 private String attributeId = ""; 41 private String deliverySettingsUrl = ""; 42 43 44 public void init() 45 { 46 try 47 { 48 attributeId = this.getParameter("attributeId"); 49 deliverySettingsUrl = this.getParameter("deliverySettingsUrl"); 50 System.out.println("attributeId:" + attributeId); 51 System.out.println("deliverySettingsUrl:" + deliverySettingsUrl); 52 } 53 catch(Exception e) 54 { 55 e.printStackTrace(); 56 } 57 58 this.setSize(500, 400); 59 this.getContentPane().setBackground(Color.WHITE); 60 61 textArea = new InfoGlueTextArea(this); 62 textArea.setSize(700, 600); 63 textArea.setBounds(0, 0, 700, 600); 64 65 JScrollPane areaScrollPane = new JScrollPane (textArea); 66 areaScrollPane.setPreferredSize(new Dimension (500, 400)); 67 areaScrollPane.setBorder(BorderFactory.createLineBorder(Color.black)); 68 69 textArea.setScrollPane(areaScrollPane); 70 71 this.getContentPane().add(areaScrollPane); 72 73 Object [] args = {this.attributeId}; 74 String text = (String )callJavascript("getValue", args); 75 this.setText(text); 76 77 callJavascript("setAppletIsActive", args); 78 } 79 80 83 84 public void setText(String text) 85 { 86 this.textArea.setText(text); 88 } 89 90 93 94 public String getText() 95 { 96 return this.textArea.getText(); 97 } 98 99 100 103 104 public String getDeliverySettingsUrl() 105 { 106 return this.deliverySettingsUrl; 107 } 108 109 112 113 public void executeSave(String text) 114 { 115 try 117 { 118 JSObject win = JSObject.getWindow(this); 119 Object [] args = {this.attributeId, text}; 120 String functionName = "saveValue"; 121 win.call(functionName, args); 123 } 124 catch(Exception e) 125 { 126 System.out.println("An error occurred while we tried to call a javascript: " + e); 127 } 128 } 129 130 133 134 public Object callJavascript(String functionName, Object [] args) 135 { 136 Object returnValue = null; 137 try 138 { 139 JSObject win = JSObject.getWindow(this); 140 returnValue = win.call(functionName, args); 142 } 143 catch(Exception e) 144 { 145 System.out.println("An error occurred while we tried to call a javascript: " + e); 146 e.printStackTrace(); 147 } 148 return returnValue; 149 } 150 151 } | Popular Tags |