1 30 package com.genimen.djeneric.tools.specifier.components; 31 32 import java.awt.event.FocusEvent ; 33 import java.awt.event.FocusListener ; 34 35 import com.genimen.djeneric.repository.exceptions.DjenericException; 36 import com.genimen.djeneric.tools.specifier.interfaces.ObjectViewer; 37 import com.genimen.djeneric.ui.DjCodeEditor; 38 import com.genimen.djeneric.util.DjLogger; 39 40 public class DjCodeArea extends DjCodeEditor implements DjBindable, FocusListener 41 { 42 private static final long serialVersionUID = 1L; 43 private BindingMediator _mediator = new BindingMediator(this); 44 ObjectViewer _viewer; 45 46 public DjCodeArea() 47 { 48 try 49 { 50 getEditor().addFocusListener(this); 51 } 52 catch (Exception e) 53 { 54 DjLogger.log(e); 55 } 56 } 57 58 public void apply() throws DjenericException 59 { 60 _mediator.setValue(getEditor().getText()); 61 } 62 63 public boolean isComponentWritable() 64 { 65 return _mediator.isComponentWritable(); 66 } 67 68 public void focusGained(FocusEvent e) 69 { 70 } 71 72 public void focusLost(FocusEvent e) 73 { 74 try 75 { 76 apply(); 77 } 78 catch (Exception x) 79 { 80 DjLogger.log(x); 81 } 82 } 83 84 public void setPropertyName(String propertyName) throws DjenericException 85 { 86 _mediator.setPropertyName(propertyName); 87 } 88 89 public void setViewer(ObjectViewer viewer) 90 { 91 _viewer = viewer; 92 _mediator.setViewer(viewer); 93 } 94 95 public void synchronize() throws DjenericException 96 { 97 getEditor().setText(_mediator.getPropertyValueString()); 98 getEditor().setCaretPosition(0); 99 getUndomanager().discardAllEdits(); 100 } 101 102 public Object getDisplayedValue() 103 { 104 return getEditor().getText(); 105 } 106 107 public String getPropertyName() 108 { 109 return _mediator.getPropertyName(); 110 } 111 112 protected ObjectViewer getViewer() 113 { 114 return _viewer; 115 } 116 117 public boolean isMemo() 118 { 119 return true; 120 } 121 } | Popular Tags |