Changeset 1548 for trunk/src/org/expeditee/gui/AttributeUtils.java
- Timestamp:
- 01/26/21 09:45:54 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/AttributeUtils.java
r1513 r1548 22 22 import java.lang.reflect.InvocationTargetException; 23 23 import java.lang.reflect.Method; 24 import java.util.Collection; 24 25 import java.util.HashMap; 25 26 import java.util.LinkedList; … … 427 428 throw new IncorrectTypeException("toExtract", "Item | Frame"); 428 429 } 429 430 431 // If there are Items attached to cursor, extract only those properties being asked for 432 if (FreeItems.hasItemsAttachedToCursor()) { 433 extractSpecifiedAttributes(toExtract, attribSet); 434 return null; 435 } 436 430 437 // StringBuffer to store all the extracted Attribute:Value pairs 431 438 StringBuffer attributes = new StringBuffer(); … … 468 475 } 469 476 477 /** 478 * Extracts only the attributes specified by the FreeItems. 479 * Designed to be called exclusively from AttributeUtils::extractAttributes 480 * @param toExtract The Item or Frame to extract attributes from 481 * @param attributes The set of attributes to consult 482 */ 483 private static void extractSpecifiedAttributes(Object toExtract, AttributeSet attributes) { 484 Collection<Text> textItemsOnCursor = FreeItems.getTextItems(); 485 List<String> keys = attributes.keys; 486 487 for (Text canditate: textItemsOnCursor) { 488 String canditateContent = canditate.getText().trim(); 489 if (canditateContent.charAt(canditateContent.length() - 1) == ':') { 490 String attributeName = canditateContent.substring(0, canditateContent.length() - 1); 491 String attributeNameLower = attributeName.toLowerCase(); 492 if (keys.contains(attributeNameLower)) { 493 Attribute a = attributes.get(attributeNameLower); 494 // Make sure the classes of the methods match the item 495 if (a != null && a.getter != null && a.getter.getDeclaringClass().isAssignableFrom(toExtract.getClass())) { 496 String value = getValue(attributeNameLower, a, toExtract, true); 497 if (value == null) { 498 continue; 499 } 500 canditate.setText(attributeName + ": " + value); 501 } 502 } 503 } 504 } 505 } 506 470 507 /** 471 508 * Gets a string form of the value for a given item get method.
Note:
See TracChangeset
for help on using the changeset viewer.