- Timestamp:
- 2003-10-16T11:49:12+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r5593 r5660 184 184 Object esrc = event.getSource(); 185 185 if (esrc == add) { 186 (new AppendMetadataTask()).start(); 186 ElementWrapper element = tree.getSelectedMetadataElement(); 187 String value = tree.getSelectedValue(); 188 (new AppendMetadataTask(element, value)).start(); 189 value = null; 190 element = null; 187 191 } 188 192 else if (esrc == update) { 189 (new UpdateMetadataTask()).start(); 193 ElementWrapper element = tree.getSelectedMetadataElement(); 194 String value = tree.getSelectedValue(); 195 (new UpdateMetadataTask(element, value)).start(); 196 value = null; 197 element = null; 190 198 } 191 199 else if (esrc == remove) { 192 200 (new RemoveMetadataTask()).start(); 193 201 } 194 202 else if (esrc == expand) { … … 205 213 extends Thread { 206 214 207 private AppendMetadataTask() { } 208 209 public void run() { 215 private ElementWrapper element = null; 216 private String value = null; 217 218 private AppendMetadataTask(ElementWrapper element, String value) { 219 this.element = element; 220 // Transform the raw text to be GREENSTONE and DOM compatible - as that will be its next destination immediately after being added to the value model 221 this.value = Codec.transform(value, Codec.REMOVE_SQUARE_BRACKET); 222 this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM); 223 } 224 225 public void run() { 226 System.err.println("Add metadata - '" + value + "'"); 210 227 // Check the new metadata is valid 211 ElementWrapper element = tree.getSelectedMetadataElement();212 String value = tree.getSelectedValue();213 Gatherer.println("Adding value:");214 228 if(records != null && element != null && value != null) { 215 // Check the records, and if they are folders then display the warning. 216 if(!records[0].isLeaf()) { 229 // Check the records, and if they are folders then display the warning. 230 Metadata added_metadata = null; 231 if(!records[0].isLeaf()) { 217 232 WarningDialog dialog = new WarningDialog("warning.DirectoryLevelMetadata", true); 218 233 if(dialog.display() == JOptionPane.OK_OPTION) { 219 Gatherer.c_man.getCollection().msm.addMetadata(System.currentTimeMillis(), records, element, value);234 added_metadata = Gatherer.c_man.getCollection().msm.addMetadata(System.currentTimeMillis(), records, element, value); 220 235 } 221 236 dialog.dispose(); … … 223 238 } 224 239 else { 225 Gatherer.c_man.getCollection().msm.addMetadata(System.currentTimeMillis(), records, element, value);240 added_metadata = Gatherer.c_man.getCollection().msm.addMetadata(System.currentTimeMillis(), records, element, value); 226 241 } 227 GValueNode value_node = ((GValueModel) tree.getModel()).addValue(value);228 Metadata added_metadata = new Metadata(element, value_node);229 242 model.selectMetadataWhenBuildingComplete(added_metadata); 230 243 } … … 235 248 extends Thread { 236 249 237 private UpdateMetadataTask() { } 250 private ElementWrapper element; 251 private String value; 252 253 private UpdateMetadataTask(ElementWrapper element, String value) { 254 this.element = element; 255 // Transform the raw text to be DOM compatible - as that will be its next destination immediately after being added to the value model 256 this.value = Codec.transform(value, Codec.REMOVE_SQUARE_BRACKET); 257 this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM); 258 } 238 259 239 260 public void run() { 240 261 // You can only update if there is a selected_metadata and 241 262 // you have valid values in all fields. 242 ElementWrapper element = tree.getSelectedMetadataElement();243 String value = tree.getSelectedValue();244 263 Gatherer.println("Replacing value:"); 245 264 if(selected_metadata != null && records != null && element != null && value != null) { … … 252 271 private class RemoveMetadataTask 253 272 extends Thread { 254 255 private RemoveMetadataTask() {}256 273 274 private RemoveMetadataTask() {} 275 257 276 public void run() { 258 277 Gatherer.println("Removing value:"); … … 1185 1204 for (int i = 0; i < tree_node.getChildCount(); i++) { 1186 1205 GValueNode child_node = (GValueNode) tree_node.getChildAt(i); 1187 if (child_node.toString( ).equals(token)) {1206 if (child_node.toString(GValueNode.DOM).equals(token)) { 1188 1207 // The matching node has been found, so move onto the next token 1189 1208 tree_node = child_node; … … 1197 1216 for (int i = 0; i < tree_node.getChildCount(); i++) { 1198 1217 GValueNode child_node = (GValueNode) tree_node.getChildAt(i); 1199 if (child_node.toString( ).startsWith(token)) {1218 if (child_node.toString(GValueNode.DOM).startsWith(token)) { 1200 1219 // The closest node has been found, so return its path 1201 1220 return new TreePath(child_node.getPath()); … … 1278 1297 private void validate() 1279 1298 { 1280 String value_text = getSelectedValue();1299 String value_text = Codec.transform(getSelectedValue(), Codec.TEXT_TO_DOM); 1281 1300 ///ystem.err.println("\n(Validate) Value text: " + value_text); 1282 1301 … … 1285 1304 TreePath closest_path = getClosestPath(value_text); 1286 1305 1306 ///ystem.err.println("The closest path is: " + closest_path); 1307 1287 1308 // Select the new path in the tree 1288 1309 // The tree selection event this causes must be ignored, since it alters value
Note:
See TracChangeset
for help on using the changeset viewer.