- Timestamp:
- 01/26/21 09:45:54 (3 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gio/gesture/StandardGestureActions.java
r1532 r1548 4716 4716 * attributes, so it is not checked. 4717 4717 * 4718 * 25/01/2021: If the user has Items attached to the cursor, they are used to 4719 * specify what attributes to extract. For example, if the user has "Width:" 4720 * attached to their cursor, only the width attribute will be extracted rather 4721 * than all of them. 4722 * 4718 4723 * @param toExtract 4719 4724 * Item containing the Item to extract the attributes from. … … 4723 4728 return; 4724 4729 } 4725 4726 if (FreeItems.hasItemsAttachedToCursor()) { 4727 return; 4728 } 4729 4730 4730 4731 Item attribs; 4731 4732 Item item = toExtract; 4733 Object toExtractFrom = item.isFrameName() ? item.getParent() : item; 4734 4732 4735 // Extract the frames attributes when the user clicks on the frame name 4733 4736 FrameGraphics.changeHighlightMode(item, HighlightMode.None); 4734 4737 if (item.isFrameName()) { 4735 attribs = AttributeUtils.extractAttributes( item.getParent());4738 attribs = AttributeUtils.extractAttributes(toExtractFrom); 4736 4739 } else { 4737 attribs = AttributeUtils.extractAttributes(item); 4740 attribs = AttributeUtils.extractAttributes(toExtractFrom); 4741 } 4742 4743 if (FreeItems.hasItemsAttachedToCursor()) { 4744 return; 4738 4745 } 4739 4746 -
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.