Ignore:
Timestamp:
08/04/08 12:42:11 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/Sort.java

    r130 r185  
    33import java.awt.Point;
    44import java.util.ArrayList;
     5import java.util.Collection;
    56import java.util.Collections;
    67import java.util.Comparator;
     
    89import org.expeditee.gui.Frame;
    910import org.expeditee.gui.FrameGraphics;
    10 import org.expeditee.items.Item;
     11import org.expeditee.gui.FrameUtils;
    1112import org.expeditee.items.Text;
    1213
     
    1819         */
    1920        public Frame process(Frame start) {
     21                // Check the position of the cursor and only format stuff inside the
     22                // same box as the cursor
     23                Collection<Text> itemsToSort = FrameUtils.getCurrentTextItems();
     24                if (itemsToSort.size() < 1) {
     25                        itemsToSort = start.getBodyTextItems(false);
     26                }
     27
    2028                ArrayList<Text> textItems = new ArrayList<Text>();
    21 
    22                 for (Item i : start.getItems())
    23                         if (i instanceof Text)
    24                                 // do not sort title and framename
    25                                 if (i.getID() > -1 && i != start.getTitleItem()
    26                                                 && !i.isAnnotation()) {
    27                                         textItems.add((Text) i);
    28                                 }
     29                textItems.addAll(itemsToSort);
    2930
    3031                // copy current positions of items
     
    3738                Collections.sort(textItems, new Comparator<Text>() {
    3839                        public int compare(Text a, Text b) {
    39                                 return String.CASE_INSENSITIVE_ORDER.compare(a.getText(),
    40                                                 b.getText());
     40                                return String.CASE_INSENSITIVE_ORDER.compare(a.getText(), b
     41                                                .getText());
    4142                        }
    4243                });
Note: See TracChangeset for help on using the changeset viewer.