1 23 package org.enhydra.kelp.jbuilder.properties; 24 25 import com.borland.primetime.properties.PropertyPage; 27 import com.borland.primetime.help.HelpTopic; 28 import com.borland.primetime.node.TextFileNode; 29 import com.borland.primetime.help.ZipHelpTopic; 30 31 import org.enhydra.tool.common.ToolException; 33 34 import org.enhydra.kelp.KelpInfo; 36 import org.enhydra.kelp.common.node.OtterTemplateNode; 37 import org.enhydra.kelp.common.properties.TemplateNodePropertyPanel; 38 39 import org.enhydra.kelp.jbuilder.node.PrimeTemplateNode; 41 42 import java.awt.BorderLayout ; 44 import java.lang.ref.WeakReference ; 45 46 public class TemplateNodePropertyPage extends PropertyPage { 48 49 private final String HELP_LINK = KelpInfo.getAddinHelpURL(); 52 private TemplateNodePropertyPanel nodePanel = null; 54 private WeakReference nodeRef = null; 55 private BorderLayout layoutMain = null; 56 57 public TemplateNodePropertyPage(Object topic) { 58 if (topic instanceof TextFileNode) { 59 try { 60 jbInit(); 61 pmInit((TextFileNode) topic); 62 } catch (Exception e) { 63 e.printStackTrace(); 64 } 65 } 66 } 67 68 public void readProperties() { 69 if (nodeRef != null) { 70 nodePanel.read((OtterTemplateNode) nodeRef.get()); 71 } 72 } 73 74 public HelpTopic getHelpTopic() { 75 ZipHelpTopic t = new ZipHelpTopic(null, HELP_LINK); 76 77 return t; 78 } 79 80 public void writeProperties() { 81 nodePanel.save(); 82 } 83 84 public TemplateNodePropertyPage() { 85 try { 86 jbInit(); 87 } catch (Exception e) { 88 e.printStackTrace(); 89 } 90 } 91 92 private void pmInit(TextFileNode nativeNode) throws ToolException { 94 OtterTemplateNode otterNode; 95 96 otterNode = new PrimeTemplateNode(nativeNode); 97 nodePanel.read(otterNode); 98 nodeRef = new WeakReference (otterNode); 99 } 100 101 private void jbInit() throws Exception { 102 layoutMain = new BorderLayout (); 103 nodePanel = new TemplateNodePropertyPanel(); 104 nodePanel.setIconView(true); 105 this.setLayout(layoutMain); 106 this.add(nodePanel, BorderLayout.CENTER); 107 } 108 109 } 110 | Popular Tags |