Changeset 740
- Timestamp:
- 01/22/14 16:45:34 (10 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/agents/Format.java
r427 r740 51 51 // same box as the cursor 52 52 Collection<Text> itemsToFormat = getItemsToFormat(start); 53 54 List<Item> changedItems = new ArrayList<Item>(); 53 55 54 56 ArrayList<Item> columnHeads = new ArrayList<Item>(); … … 129 131 130 132 if (xCheck < FrameGraphics.getMaxSize().width) { 131 if (columnHeads.get(i + 1).getX() < maxX 132 && columnHeads.get(i + 1).getY() < maxY) 133 columnHeads.get(i + 1).setX(maxX); 134 135 for (Item it : columns.get(i + 1)) 136 if (it.getX() < maxX && it.getY() < maxY) 133 Item columnHead = columnHeads.get(i + 1); 134 if (columnHead.getX() < maxX && columnHead.getY() < maxY) { 135 if(columnHead.getX() != maxX && !changedItems.contains(columnHead)) { 136 Item copy = columnHead.copy(); 137 copy.setID(columnHead.getID()); 138 changedItems.add(copy); 139 } 140 columnHead.setX(maxX); 141 } 142 143 for (Item it : columns.get(i + 1)) { 144 if (it.getX() < maxX && it.getY() < maxY) { 145 if(it.getX() != maxX && !changedItems.contains(it)) { 146 Item copy = it.copy(); 147 copy.setID(it.getID()); 148 changedItems.add(copy); 149 } 137 150 it.setX(maxX); 138 } 139 140 res = FrameUtils.Align(columns.get(i + 1), true, _adjust); 151 } 152 } 153 } 154 155 res = FrameUtils.Align(columns.get(i + 1), true, _adjust, changedItems); 141 156 _success = _success && (res >= 0); 142 157 } … … 148 163 */ 149 164 start.setChanged(true); 165 start.addToUndo(changedItems); 150 166 FrameGraphics.requestRefresh(true); 151 167 return null; -
trunk/src/org/expeditee/gui/Frame.java
r737 r740 95 95 96 96 // list of deleted items that can be restored 97 private Stack< Item> _undo = new Stack<Item>();97 private Stack<List<Item>> _undo = new Stack<List<Item>>(); 98 98 99 99 // basically just a list of smaller objects? … … 898 898 * The List of Items to add to the undo stack. 899 899 */ 900 public void add AllToUndo(Collection<Item> items) {900 public void addToUndo(Collection<Item> items) { 901 901 if (items.size() < 1) 902 902 return; 903 904 String id = "" + _undo.size(); 905 906 for (Item i : items) { 907 i.setTag(id); 908 _undo.push(i); 909 } 910 } 911 912 public void addToUndo(Item item) { 913 if (item == null) 914 return; 915 916 item.setTag("" + _undo.size()); 917 _undo.push(item); 903 904 // System.out.println("Added: " + items); 905 906 _undo.push(new LinkedList<Item>(items)); 918 907 } 919 908 920 909 public void undo() { 921 Itemundo = null;910 List<Item> undo = null; 922 911 boolean bReparse = false; 923 912 boolean bRecalculate = false; … … 927 916 928 917 undo = _undo.pop(); 929 930 // if the change was to characteristics 931 if (undo.isVisible() && _body.contains(undo)) { 932 Item old = _body.get(_body.indexOf(undo)); 933 _body.set(_body.indexOf(old), undo); 918 919 // System.out.println("Undoing: " + undo); 920 921 for(Item i : undo) { 922 // if the change was to characteristics 923 if(i.isVisible() && _body.contains(i)) { 924 _body.set(_body.indexOf(i), i); 934 925 // the item was deleted 935 } else { 936 List<Item> toRestore = new LinkedList<Item>(); 937 toRestore.add(undo); 938 if (undo.hasOverlay()) 939 bReparse = true; 940 941 // remove any connected items at the top of the stack 942 while (_undo.size() > 0) { 943 Item next = _undo.peek(); 944 // if this item was connected to one already picked up, remove 945 // it from the stack 946 if (toRestore.contains(next)) 947 _undo.pop(); 948 // else, if this item should be restored (deleted in an enclosed 949 // set) 950 else if (next.getTag().equals(undo.getTag())) { 951 _undo.pop(); 952 toRestore.add(next); 953 if (next.hasOverlay()) 954 bReparse = true; 955 956 // otherwise, we are done 957 } else 958 break; 959 } 960 961 // if these items were deleted from a frame, add them 962 addAllItems(toRestore); 963 964 for (Item i : toRestore) { 926 } else { 927 _body.add(i); 965 928 bReparse |= i.hasOverlay(); 966 929 bRecalculate |= i.recalculateWhenChanged(); … … 974 937 } 975 938 } 976 977 939 change(); 978 940 FrameMouseActions.getInstance().refreshHighlights(); … … 1515 1477 } 1516 1478 _body.removeAll(newBody); 1517 add AllToUndo(_body);1479 addToUndo(_body); 1518 1480 _body = newBody; 1519 1481 change(); -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r737 r740 774 774 case KeyEvent.VK_C: 775 775 if(FreeItems.itemsAttachedToCursor()) { 776 ItemSelection.copyClone( FreeItems.getInstance());776 ItemSelection.copyClone(); 777 777 return; 778 778 } … … 801 801 return; 802 802 case KeyEvent.VK_X: 803 ItemSelection.cut( FreeItems.getInstance());803 ItemSelection.cut(); 804 804 return; 805 805 case KeyEvent.VK_M: -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r738 r740 1676 1676 // System.out.println("Left window"); 1677 1677 if(FreeItems.itemsAttachedToCursor()) 1678 ItemSelection.cut( FreeItems.getInstance());1678 ItemSelection.cut(); 1679 1679 } 1680 1680 … … 2669 2669 SessionStats.DeletedItems(toUndo); 2670 2670 if (parent != null) { 2671 parent.add AllToUndo(toUndo);2671 parent.addToUndo(toUndo); 2672 2672 parent.removeAllItems(toUndo); // toDelete.getConnected() 2673 2673 } … … 2755 2755 // the current frame as well as the overlay frame 2756 2756 Frame currentFrame = DisplayIO.getCurrentFrame(); 2757 currentFrame.add AllToUndo(itemList);2757 currentFrame.addToUndo(itemList); 2758 2758 itemList.clear(); 2759 2759 if (bReparse) { -
trunk/src/org/expeditee/gui/FrameUtils.java
r737 r740 163 163 * @return 164 164 */ 165 public static int Align(List<Text> toAlign, boolean moveAll, int adjust ) {165 public static int Align(List<Text> toAlign, boolean moveAll, int adjust, List<Item> changedItems) { 166 166 Collections.sort(toAlign); 167 167 … … 199 199 200 200 if (sameBulletType(lastBullet, currentBullet)) { 201 String oldText = currentText.getText(); 202 201 203 currentText.stripFirstWord(); 202 204 … … 204 206 lastBullet = FrameKeyboardActions.getAutoBullet(currentText 205 207 .getText()); 208 209 // if we changed the item, add to changedItems list 210 if(changedItems != null && oldText != currentText.getText() && !changedItems.contains(currentText)) { 211 Item copy = currentText.copy(); 212 copy.setID(currentText.getID()); 213 copy.setText(oldText); 214 changedItems.add(copy); 215 } 206 216 } 207 217 } … … 255 265 && above != curr.getTitleItem()) { 256 266 x = above.getX(); 257 from.setY((int) above.getPolygon().getBounds().getMaxY()267 int y = (int) above.getPolygon().getBounds().getMaxY() 258 268 + space 259 269 + ((int) (from.getY() - from.getPolygon().getBounds() 260 .getMinY()))); 261 from.setX(x); 270 .getMinY())); 271 272 if(changedItems != null && (from.getX() != x || from.getY() != y) && !changedItems.contains(from)) { 273 Item copy = from.copy(); 274 copy.setID(from.getID()); 275 changedItems.add(copy); 276 } 277 from.setPosition(x, y); 262 278 } else { 263 279 x = from.getX(); … … 280 296 int newPos = bottom + space + diff; 281 297 298 if(changedItems != null && ((moveAll && current.getX() != x) || current.getY() != newPos) && !changedItems.contains(current)) { 299 Item copy = current.copy(); 300 copy.setID(current.getID()); 301 changedItems.add(copy); 302 } 303 282 304 if (moveAll) { 283 305 current.setPosition(x, newPos); … … 294 316 int y = from.getY() + from.getBoundsHeight() + space; 295 317 return y; 318 } 319 320 public static int Align(List<Text> toAlign, boolean moveAll, int adjust) { 321 return Align(toAlign, moveAll, adjust, null); 296 322 } 297 323 -
trunk/src/org/expeditee/io/ItemSelection.java
r738 r740 12 12 import java.io.IOException; 13 13 import java.io.Serializable; 14 import java.util.ArrayList; 14 15 import java.util.Arrays; 15 16 import java.util.List; … … 102 103 } 103 104 104 105 public static void cut(List<Item> items) { 106 107 copy(items); 105 private static List<Item> getAllToCopy() { 106 List<Item> tmp = new ArrayList<Item>(FreeItems.getInstance()); 107 List<Item> toCopy = new ArrayList<Item>(tmp); 108 for(Item i : tmp) { 109 for(Item c : i.getAllConnected()) { 110 if(! toCopy.contains(c)) { 111 toCopy.add(c); 112 FrameMouseActions.pickup(c); 113 } 114 } 115 } 116 return toCopy; 117 } 118 119 public static void cut() { 120 121 List<Item> toCopy = getAllToCopy(); 122 123 copy(toCopy); 108 124 109 125 // remove the items attached to the cursor 110 items.clear(); 126 DisplayIO.getCurrentFrame().removeAllItems(toCopy); 127 FreeItems.getInstance().clear(); 111 128 112 129 FrameGraphics.refresh(false); 113 130 } 114 131 115 public static void copyClone( List<Item> items) {116 117 copy(ItemUtils.CopyItems( items));132 public static void copyClone() { 133 134 copy(ItemUtils.CopyItems(getAllToCopy())); 118 135 119 136 }
Note:
See TracChangeset
for help on using the changeset viewer.