1 42 43 package org.jfree.ui.tabbedui; 44 45 import javax.swing.JComponent ; 46 47 52 public abstract class DetailEditor extends JComponent { 53 54 55 private Object object; 56 57 private boolean confirmed; 58 59 62 public DetailEditor() { 63 } 65 66 69 public void update() { 70 if (this.object == null) { 71 throw new IllegalStateException (); 72 } 73 else { 74 updateObject(this.object); 75 } 76 setConfirmed(false); 77 } 78 79 84 public Object getObject() { 85 return this.object; 86 } 87 88 93 public void setObject(final Object object) { 94 if (object == null) { 95 throw new NullPointerException (); 96 } 97 this.object = object; 98 setConfirmed(false); 99 fillObject(); 100 } 101 102 111 protected static int parseInt(final String text, final int def) { 112 try { 113 return Integer.parseInt(text); 114 } 115 catch (NumberFormatException fe) { 116 return def; 117 } 118 } 119 120 123 public abstract void clear(); 124 125 129 protected abstract void fillObject(); 130 131 136 protected abstract void updateObject(Object object); 137 138 143 public boolean isConfirmed() { 144 return this.confirmed; 145 } 146 147 152 protected void setConfirmed(final boolean confirmed) { 153 final boolean oldConfirmed = this.confirmed; 154 this.confirmed = confirmed; 155 firePropertyChange("confirmed", oldConfirmed, confirmed); 156 } 157 158 159 } 160 | Popular Tags |