| 1 16 17 package org.mc4j.console.swing.editor; 18 19 import org.openide.explorer.propertysheet.ExPropertyEditor; 20 import org.openide.explorer.propertysheet.InplaceEditor; 21 import org.openide.explorer.propertysheet.PropertyEnv; 22 import org.openide.explorer.propertysheet.PropertyModel; 23 24 import java.awt.Component ; 25 import java.awt.Graphics ; 26 import java.awt.Rectangle ; 27 import java.awt.event.ActionListener ; 28 import java.beans.PropertyEditor ; 29 import java.beans.PropertyEditorSupport ; 30 import java.util.Date ; 31 32 import javax.swing.JComponent ; 33 import javax.swing.KeyStroke ; 34 35 40 public class DateEditor extends PropertyEditorSupport implements ExPropertyEditor, InplaceEditor.Factory { 41 42 private Date currentDate; 43 44 45 46 protected PropertyEditor editor; 47 protected PropertyEnv env; 48 protected PropertyModel propertyModel; 49 50 private DateEditorInplace renderer; 51 52 53 public void attachEnv(PropertyEnv env) { 54 this.env = env; 55 this.env.registerInplaceEditorFactory(this); 56 } 57 58 59 public boolean isPaintable() { 60 return true; 61 } 62 63 public void paintValue(Graphics gfx, Rectangle box) { 64 if (renderer == null) { 65 renderer = new DateEditorInplace(); 66 } 67 68 renderer.setSize (box.width, box.height); 69 renderer.doLayout(); 70 Graphics g = gfx.create(box.x, box.y, box.width, box.height); 71 renderer.setOpaque(true); 72 renderer.paint (g); 73 g.dispose(); 74 } 75 public InplaceEditor getInplaceEditor() { 76 return new DateEditorInplace(); 77 } 78 79 80 public void setValue(Object value) { 81 super.setValue(value); 82 currentDate = (Date ) value; 83 } 84 85 public Object getValue() { 86 return currentDate; 87 } 88 89 90 91 92 class DateEditorInplace extends CalendarComboBox implements InplaceEditor { 93 94 public DateEditorInplace() { 95 super(false); 96 super.setDate(currentDate); 97 98 } 99 100 101 public void connect(PropertyEditor pe, PropertyEnv env) { 102 } 103 104 public JComponent getComponent() { 105 return this; 106 } 107 108 public void clear() { 109 } 110 111 public Object getValue() { 112 return null; 113 } 114 115 public void setValue(Object o) { 116 } 117 118 public boolean supportsTextEntry() { 119 return false; 120 } 121 122 public void reset() { 123 } 124 125 public void addActionListener(ActionListener al) { 126 } 127 128 public void removeActionListener(ActionListener al) { 129 } 130 131 public KeyStroke [] getKeyStrokes() { 132 return new KeyStroke [0]; 133 } 134 135 public PropertyEditor getPropertyEditor() { 136 return null; 137 } 138 139 public PropertyModel getPropertyModel() { 140 return null; 141 } 142 143 public void setPropertyModel(PropertyModel pm) { 144 } 145 146 public boolean isKnownComponent(Component c) { 147 return true; 148 } 149 } 150 151 } 152 | Popular Tags |