| 62 | /** |
| 63 | */ |
| 64 | @SuppressWarnings({"serial","rawtypes","unchecked"}) |
| 65 | @CreoleResource(name = "Resource Features", guiType = GuiType.SMALL, |
| 66 | resourceDisplayed = "gate.util.FeatureBearer") |
| 67 | public class FeaturesSchemaEditor extends XJTable |
| 68 | implements ResizableVisualResource, FeatureMapListener{ |
| 69 | public FeaturesSchemaEditor(){ |
| 70 | // setBackground(UIManager.getDefaults().getColor("Table.background")); |
| 71 | instance = this; |
| 72 | } |
| 73 | |
| 74 | public void setTargetFeatures(FeatureMap features){ |
| 75 | if(targetFeatures != null) targetFeatures.removeFeatureMapListener(this); |
| 76 | this.targetFeatures = features; |
| 77 | populate(); |
| 78 | if(targetFeatures != null) targetFeatures.addFeatureMapListener(this); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | @Override |
| 83 | public void cleanup() { |
| 84 | if(targetFeatures != null){ |
| 85 | targetFeatures.removeFeatureMapListener(this); |
| 86 | targetFeatures = null; |
| 87 | } |
| 88 | target = null; |
| 89 | schema = null; |
| 90 | } |
| 91 | |
| 92 | /* (non-Javadoc) |
| 93 | * @see gate.VisualResource#setTarget(java.lang.Object) |
| 94 | */ |
| 95 | @Override |
| 96 | public void setTarget(Object target){ |
| 97 | this.target = (FeatureBearer)target; |
| 98 | setTargetFeatures(this.target.getFeatures()); |
| 99 | } |
| 100 | |
| 101 | public void setSchema(AnnotationSchema schema){ |
| 102 | this.schema = schema; |
| 103 | featuresModel.fireTableRowsUpdated(0, featureList.size() - 1); |
| 104 | } |
| 105 | |
| 106 | /* (non-Javadoc) |
| 107 | * @see gate.event.FeatureMapListener#featureMapUpdated() |
| 108 | * Called each time targetFeatures is changed. |
| 109 | */ |
| 110 | @Override |
| 111 | public void featureMapUpdated(){ |
| 112 | SwingUtilities.invokeLater(new Runnable(){ |
| 113 | @Override |
| 114 | public void run(){ |
| 115 | populate(); |
| 116 | } |
| 117 | }); |
| 118 | } |
| 119 | |
| 120 | |
| 121 | /** Initialise this resource, and return it. */ |
nothing calls this directly
no outgoing calls
no test coverage detected