Ignore:
Timestamp:
11/02/08 13:05:01 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

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

    r307 r376  
    55import java.util.Collections;
    66import java.util.Comparator;
     7import java.util.HashSet;
    78import java.util.List;
    89
     
    4546        @Override
    4647        public Frame process(Frame start) {
    47                 //TODO What will happen if user runs the SIMPLE form of this...
    48                 //Does format box need to be disabled?!?!
    49                 //Check the position of the cursor and only format stuff inside the same box as the cursor
     48                // TODO What will happen if user runs the SIMPLE form of this...
     49                // Does format box need to be disabled?!?!
     50                // Check the position of the cursor and only format stuff inside the
     51                // same box as the cursor
    5052                Collection<Text> itemsToFormat = FrameUtils.getCurrentTextItems();
    51                 if(itemsToFormat.size() < 1){
     53
     54                // If the cursor is not inside a box...
     55                if (itemsToFormat.size() < 1) {
     56                        // Add all the items that are in free space
    5257                        itemsToFormat = start.getBodyTextItems(true);
     58                        // Remove all the enclosed items
     59                        Collection<Item> seen = new HashSet<Item>();
     60                        for (Item i : start.getVisibleItems()) {
     61                                if (!seen.contains(i) && i.isEnclosed()) {
     62                                        seen.addAll(i.getEnclosingDots());
     63                                        itemsToFormat.removeAll(i.getEnclosedItems());
     64                                }
     65                        }
    5366                }
    54                
     67
    5568                ArrayList<Item> columnHeads = new ArrayList<Item>();
    5669
     
    175188                        overwriteMessage("Formatting complete.");
    176189        }
    177        
     190
    178191        @Override
    179192        protected void message(String message) {
Note: See TracChangeset for help on using the changeset viewer.