1 23 package org.enhydra.kelp.common.swing; 24 25 import org.enhydra.tool.common.InnerPanel; 27 import org.enhydra.tool.common.DataValidationException; 28 29 import org.enhydra.kelp.common.node.OtterNode; 31 import org.enhydra.kelp.common.node.OtterProject; 32 33 import java.awt.*; 35 import java.awt.event.FocusAdapter ; 36 import java.awt.event.FocusEvent ; 37 import java.awt.event.WindowEvent ; 38 import java.awt.event.WindowAdapter ; 39 import java.beans.*; 40 import java.lang.ref.WeakReference ; 41 import javax.swing.*; 42 43 public class AddinInnerPanel extends InnerPanel { 44 45 private WeakReference nodeRef = null; 46 47 public AddinInnerPanel() { 48 super(); 49 } 50 51 public void clearAll() { 53 super.clearAll(); 54 if (nodeRef != null) { 55 nodeRef.clear(); 56 } 57 nodeRef = null; 58 } 59 60 public void save() { 62 try { 63 write(getNode()); 64 } catch (DataValidationException e) { 65 System.err.println(e.getValidationMessage()); 66 } 67 } 68 69 public void read(OtterNode node) { 70 nodeRef = new WeakReference (node); 71 } 72 73 public void write(OtterNode node) throws DataValidationException { 74 nodeRef = new WeakReference (node); 75 } 76 77 protected OtterNode getNode() { 78 OtterNode node = null; 79 80 if (nodeRef != null) { 81 node = (OtterNode) nodeRef.get(); 82 } 83 return node; 84 } 85 86 protected OtterProject getProject() { 87 OtterNode node = null; 88 OtterProject project = null; 89 90 node = getNode(); 91 if (node == null) { 92 project = null; 93 } else if (node instanceof OtterProject) { 94 project = (OtterProject) node; 95 } else { 96 project = node.getProject(); 97 } 98 return project; 99 } 100 101 } 102 | Popular Tags |