Changeset 336
- Timestamp:
- 09/26/08 13:03:26 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Misc.java
r311 r336 498 498 + "' could not be found."); 499 499 } 500 } 501 502 public static void MessageLn(Item message) { 503 if (message instanceof Text) 504 MessageBay.displayMessage((Text) message); 500 505 } 501 506 -
trunk/src/org/expeditee/actions/Simple.java
r313 r336 1253 1253 Frame frame2 = (Frame) context.getPointers().getVariable( 1254 1254 tokens[2]).getValue(); 1255 // Check that all the items on the frame are the same 1256 List<Item> items1 = frame1.getVisibleItems(); 1257 List<Item> items2 = frame2.getVisibleItems(); 1258 if (items1.size() != items2.size()) { 1259 throw new UnitTestFailedException(items1.size() + " items", 1260 items2.size() + " items"); 1261 } else { 1262 for (int i = 0; i < items1.size(); i++) { 1263 Item i1 = items1.get(i); 1264 Item i2 = items2.get(i); 1265 String s1 = i1.getText(); 1266 String s2 = i2.getText(); 1267 if (!s1.equals(s2)) { 1268 throw new UnitTestFailedException(s1, s2); 1269 } 1270 } 1271 } 1255 frame1.assertEquals(frame2); 1272 1256 } else if (tokens[0].equals("assertdefined")) { 1273 1257 assertExactParametreCount(tokens, 1); … … 1687 1671 double delay = context.getPrimitives().getDoubleValue(tokens[1]); 1688 1672 String s = getMessage(tokens, context, code.toString(), " ", 2); 1689 for (int i = 0; i < s.length(); i++) { 1690 FrameKeyboardActions.processChar(s.charAt(i), false); 1691 Thread.sleep((int) (delay * 1000)); 1692 } 1673 DisplayIO.typeStringDirect(delay, s); 1693 1674 } else if (tokens[0].equals("type") || tokens[0].equals("typenospaces")) { 1694 1675 1695 1676 String s = getMessage(tokens, context, code.toString(), tokens[0] 1696 1677 .equals("type") ? " " : "", 1); 1697 for (int i = 0; i < s.length(); i++) { 1698 FrameKeyboardActions.processChar(s.charAt(i), false); 1699 Thread.sleep(25); 1700 } 1678 1679 DisplayIO.typeStringDirect(0.025, s); 1701 1680 } else if (tokens[0].equals("runstring")) { 1702 1681 String codeText = getMessage(tokens, context, code.toString(), " ", -
trunk/src/org/expeditee/agents/SearchGreenstone.java
r313 r336 33 33 34 34 private static boolean _showAbstract = false; 35 35 36 private static boolean _showKeywords = false; 37 36 38 private static boolean _showAuthors = false; 39 37 40 private static boolean _showDate = false; 38 41 … … 89 92 if (settings == null) 90 93 return; 94 95 _maxResults = "10"; 96 _showAbstract = false; 97 _showKeywords = false; 98 _showAuthors = false; 99 _showDate = false; 100 _locationChoice = 1; 91 101 92 102 // Set the settings … … 330 340 if (_showDate && rd.metadataExists("Date")) 331 341 text += ", " + rd.getDate(); 332 342 333 343 if (_showAbstract && rd.metadataExists("Abstract")) 334 344 text += "\n " + rd.getAbstract(); 335 345 336 346 if (_showAuthors && rd.metadataExists("Creator")) 337 347 text += "\nAuthors" + rd.getAuthors().toString(); 338 348 339 349 if (_showKeywords && rd.getKeywords().size() > 0) 340 350 text += "\nKeywords" + rd.getKeywords().toString(); -
trunk/src/org/expeditee/gui/DisplayIO.java
r311 r336 8 8 import java.awt.Robot; 9 9 import java.awt.Toolkit; 10 import java.awt.event.KeyEvent; 10 11 import java.awt.geom.Point2D; 11 12 import java.awt.image.MemoryImageSource; … … 55 56 @SuppressWarnings("unchecked") 56 57 private static Stack<String>[] _VisitedFrames = new Stack[2]; 58 57 59 @SuppressWarnings("unchecked") 58 60 private static Stack<String>[] _BackedUpFrames = new Stack[2]; 59 61 60 62 // used to change the mouse cursor position on the screen 61 63 private static Robot _Robot; 62 64 63 65 private static boolean _TwinFrames = false; 64 66 65 67 /** Notified whenever the frame changes */ 66 68 private static HashSet<DisplayIOObserver> _displayIOObservers = new HashSet<DisplayIOObserver>(); … … 102 104 } 103 105 } 104 106 105 107 /** 106 108 * Adds a DisplayIOObserver to the DisplayIO. DisplayIOObserver's are … … 110 112 * 111 113 * @param observer 112 * 114 * The observer to add 113 115 * 114 116 * @throws NullPointerException 115 * 117 * If observer is null. 116 118 */ 117 119 public static void addDisplayIOObserver(DisplayIOObserver observer) { 118 if (observer == null) throw new NullPointerException("observer"); 120 if (observer == null) 121 throw new NullPointerException("observer"); 119 122 _displayIOObservers.add(observer); 120 123 } 121 122 /** 123 * Removes a DisplayIOObserver from the DisplayIO. 124 125 /** 126 * Removes a DisplayIOObserver from the DisplayIO. 124 127 * 125 128 * @see #addDisplayIOObserver(DisplayIOObserver) 126 129 * 127 130 * @param observer 128 * 131 * The observer to add 129 132 * 130 133 * @throws NullPointerException 131 * 134 * If observer is null. 132 135 */ 133 136 public static void removeDisplayIOObserver(DisplayIOObserver observer) { 134 if (observer == null) throw new NullPointerException("observer"); 137 if (observer == null) 138 throw new NullPointerException("observer"); 135 139 _displayIOObservers.remove(observer); 136 140 } 137 141 138 142 public static void setTextCursor(Text text, int cursorMovement) { 139 143 setTextCursor(text, cursorMovement, false, false); … … 366 370 return null; 367 371 } 368 372 369 373 public static void setCurrentFrame(Frame frame, boolean incrementStats) { 370 374 if (frame == null) 371 375 return; 372 376 373 377 if (_TwinFrames) { 374 378 if (_CurrentFrames[0] == null) { … … 390 394 + " is already the current frame."); 391 395 return; 392 } else if (incrementStats) {396 } else if (incrementStats) { 393 397 SessionStats.AccessedFrame(); 394 398 } … … 411 415 // Changing frames is a Save point for saveable entities: 412 416 EntitySaveManager.getInstance().saveAll(); 413 417 414 418 if (_TwinFrames) { 415 419 // if the same frame is being shown in both sides, load a fresh … … 545 549 if (_Browser == null) 546 550 return 0; 547 551 548 552 if (_TwinFrames 549 553 && FrameMouseActions.MouseX >= (_Browser.getWidth() / 2F) … … 647 651 // If the top frame on the backup stack is the current frame go back 648 652 // again... or if it has been deleted 649 // Recursively backup the stack650 if (frame == null || frame.equals(getCurrentFrame())) {653 // Recursively backup the stack 654 if (frame == null || frame.equals(getCurrentFrame())) { 651 655 Back(); 652 656 return false; … … 677 681 return true; 678 682 } 679 683 680 684 public static boolean Forward() { 681 685 int side = getCurrentSide(); … … 699 703 // If the top frame on the backup stack is the current frame go back 700 704 // again... or if it has been deleted 701 // Recursively backup the stack702 if (frame == null || frame.equals(getCurrentFrame())) {705 // Recursively backup the stack 706 if (frame == null || frame.equals(getCurrentFrame())) { 703 707 Forward(); 704 708 return false; … … 750 754 _CurrentFrames[current].refreshSize(); 751 755 if (_CurrentFrames[opposite] != null) 752 _CurrentFrames[opposite] 753 .refreshSize(); 756 _CurrentFrames[opposite].refreshSize(); 754 757 755 758 FrameGraphics.Clear(); … … 792 795 } 793 796 794 public static void clickMouse(int buttons) {797 public static void clickMouse(int buttons) throws InterruptedException { 795 798 _Robot.mousePress(buttons); 799 Thread.sleep(100); 796 800 _Robot.mouseRelease(buttons); 801 } 802 803 public static void typeKey(int key) throws InterruptedException { 804 _Robot.keyPress(key); 805 // _Robot.waitForIdle(); 806 _Robot.keyRelease(key); 807 // _Robot.waitForIdle(); 808 Thread.sleep(100); 809 } 810 811 public static void typeText(String s) throws InterruptedException { 812 for (int i = 0; i < s.length(); i++) { 813 char c = s.charAt(i); 814 if(Character.isUpperCase(c)) 815 _Robot.keyPress(KeyEvent.VK_SHIFT); 816 typeKey(getKeyCode(c)); 817 if(Character.isUpperCase(c)) 818 _Robot.keyRelease(KeyEvent.VK_SHIFT); 819 } 820 } 821 822 protected static int getKeyCode(char c) { 823 switch(c){ 824 case '\n': 825 return KeyEvent.VK_ENTER; 826 case ' ': 827 return KeyEvent.VK_SPACE; 828 } 829 830 if(Character.isSpaceChar(c)) 831 return KeyEvent.VK_SPACE; 832 else if(Character.isDigit(c)){ 833 return (int)(KeyEvent.VK_0 + c - '0'); 834 }else if(Character.isUpperCase(c)){ 835 return c; 836 } 837 838 return (int)(KeyEvent.VK_A + c - 'a'); 797 839 } 798 840 … … 814 856 _BackedUpFrames[getCurrentSide()].clear(); 815 857 } 858 859 /** 860 * @param secondsDelay 861 * @param s 862 * @throws InterruptedException 863 */ 864 public static void typeStringDirect(double secondsDelay, String s) throws InterruptedException { 865 for (int i = 0; i < s.length(); i++) { 866 FrameKeyboardActions.processChar(s.charAt(i), false); 867 Thread.sleep((int) (secondsDelay * 1000)); 868 } 869 } 816 870 } -
trunk/src/org/expeditee/gui/Frame.java
r311 r336 33 33 import org.expeditee.items.widgets.InteractiveWidget; 34 34 import org.expeditee.items.widgets.WidgetCorner; 35 import org.expeditee.simple.UnitTestFailedException; 35 36 import org.expeditee.stats.SessionStats; 36 37 … … 998 999 s.append(String.format("Name: %s%d%n", _frameset, _number)); 999 1000 s.append(String.format("Version: %d%n", _version)); 1000 s.append(String.format("Permission: %s%n", _permission.toString()));1001 s.append(String.format("Owner: %s%n", _owner));1002 s.append(String.format("Date Created: %s%n", _creationDate));1003 s.append(String.format("Last Mod. User: %s%n", _modifiedUser));1004 s.append(String.format("Last Mod. Date: %s%n", _modifiedDate));1001 //s.append(String.format("Permission: %s%n", _permission.toString())); 1002 //s.append(String.format("Owner: %s%n", _owner)); 1003 //s.append(String.format("Date Created: %s%n", _creationDate)); 1004 //s.append(String.format("Last Mod. User: %s%n", _modifiedUser)); 1005 //s.append(String.format("Last Mod. Date: %s%n", _modifiedDate)); 1005 1006 s.append(String.format("Items: %d%n", _body.size())); 1006 1007 return s.toString(); … … 1307 1308 addOverlay(o); 1308 1309 1310 // Add all the vectors from the overlay frame to this frame 1311 for (Vector v : toAdd.Frame.getVectors()) 1312 addVector(v); 1313 1309 1314 // Now add the items for this overlay 1310 1315 Permission permission = Permission.min(toAdd.Frame.getPermission(), … … 1320 1325 _overlayItems.add(i); 1321 1326 } 1327 1322 1328 return true; 1323 1329 } … … 2082 2088 return getAnnotationValue("file"); 2083 2089 } 2090 2091 public void assertEquals(Frame frame2) { 2092 // Check that all the items on the frame are the same 2093 List<Item> items1 = getVisibleItems(); 2094 List<Item> items2 = frame2.getVisibleItems(); 2095 if (items1.size() != items2.size()) { 2096 throw new UnitTestFailedException(items1.size() + " items", items2 2097 .size() 2098 + " items"); 2099 } else { 2100 for (int i = 0; i < items1.size(); i++) { 2101 Item i1 = items1.get(i); 2102 Item i2 = items2.get(i); 2103 String s1 = i1.getText(); 2104 String s2 = i2.getText(); 2105 if (!s1.equals(s2)) { 2106 throw new UnitTestFailedException(s1, s2); 2107 } 2108 } 2109 } 2110 } 2084 2111 } -
trunk/src/org/expeditee/gui/FrameIO.java
r311 r336 180 180 String fullPath = FrameIO.getFrameFullPathName(PUBLIC_PATH, frameName); 181 181 182 if (fullPath == null)182 if (fullPath == null) 183 183 return null; 184 184 185 185 File frameFile = new File(fullPath); 186 186 if (frameFile.exists() && frameFile.canRead()) { … … 209 209 } 210 210 } 211 211 212 212 if (loaded == null && FrameShare.getInstance() != null) { 213 213 loaded = FrameShare.getInstance().loadFrame(framename, knownPath); … … 359 359 360 360 // do not put 0 frames or virtual frames into the cache 361 // Why are zero frames not put in the cache 361 362 if (_Cache.size() > MAX_CACHE) 362 363 _Cache.clear(); … … 601 602 602 603 // disable caching of 0 frames 603 SuspendCache(); 604 // Mike says: Why is caching of 0 frames being disabled? 605 /* 606 * Especially since 0 frames are not event put into the cache in the 607 * frist place 608 */ 609 // SuspendCache(); 610 /* 611 * Suspending the cache causes infinate loops when trying to load a zero 612 * frame which has a ao which contains an v or av which contains a link 613 * to the ao frame 614 */ 615 604 616 String zeroFrameName = frameset + "0"; 605 617 Frame destFramesetZero = LoadFrame(zeroFrameName); -
trunk/src/org/expeditee/gui/FrameUtils.java
r314 r336 585 585 else if (attribute.equals("networksettings")) 586 586 FrameShare.init(item.getChild()); 587 else if (attribute.equals("greenstonesettings")) 587 else if (attribute.equals("greenstonesettings")) { 588 588 SearchGreenstone.init(item.getChild()); 589 else if (attribute.equals("reminders"))589 } else if (attribute.equals("reminders")) 590 590 Reminders.init(item.getChild()); 591 591 else if (attribute.equals("antialias")) … … 811 811 } else if (i.hasOverlay()) { 812 812 i.setVisible(true); 813 // int x = i.getBoundsHeight();813 // int x = i.getBoundsHeight(); 814 814 } 815 815 } … … 873 873 ItemUtils.TAG_VECTOR) 874 874 && i.getLink() != null) { 875 addVector(vectors, Permission.none, permission, i); 875 if (!i.getAbsoluteLink().equals(toParse.getName())) 876 addVector(vectors, Permission.none, permission, 877 i); 876 878 } else if (!FrameGraphics.isXRayMode() 877 879 && ItemUtils.startsWithTag(i, 878 880 ItemUtils.TAG_ACTIVE_VECTOR) 879 881 && i.getLink() != null) { 880 addVector(vectors, Permission.followLinks, 881 permission, i); 882 if (!i.getAbsoluteLink().equals(toParse.getName())) 883 addVector(vectors, Permission.followLinks, 884 permission, i); 882 885 } 883 886 // check for new OVERLAY items … … 1032 1035 // thread-safe protocol for this project... 1033 1036 toParse.clearOverlays(); 1037 toParse.clearVectors(); 1034 1038 toParse.addAllOverlays(overlays); 1035 toParse.clearVectors();1036 1039 toParse.addAllVectors(vectors); 1037 1040 } … … 1049 1052 // @v which points back to the frame with the @ao 1050 1053 Frame vector = FrameIO.LoadFrame(i.getAbsoluteLink()); 1054 1051 1055 // Get the permission from off the vector frame 1052 1056 Permission vectorPermission = Permission.getPermission(vector -
trunk/src/org/expeditee/gui/MessageBay.java
r307 r336 18 18 19 19 /** 20 * The bay at the bottom of the expeditee browser which displays messages. 21 * TODOmake it thread safe!20 * The bay at the bottom of the expeditee browser which displays messages. TODO 21 * make it thread safe! 22 22 * 23 23 */ … … 75 75 _messages[i].setOffset(0, 76 76 -FrameGraphics.getMaxFrameSize().height); 77 // _messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width);77 // _messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width); 78 78 } 79 79 } 80 80 81 81 _messageLink.setOffset(0, -FrameGraphics.getMaxFrameSize().height); 82 // _messageLink.setMaxWidth(FrameGraphics.getMaxFrameSize().width);82 // _messageLink.setMaxWidth(FrameGraphics.getMaxFrameSize().width); 83 83 // _messageLink.setPosition(FrameGraphics.getMaxFrameSize().width 84 84 // - MESSAGE_LINK_Y_OFFSET, MESSAGE_LINK_X); … … 127 127 if (_messageBuffer != null) { 128 128 _dirtyAreas.clear(); 129 addDirtyArea(new Rectangle(0, FrameGraphics.getMaxFrameSize().height, 130 _messageBuffer.getWidth(), _messageBuffer.getHeight())); 129 addDirtyArea(new Rectangle(0, 130 FrameGraphics.getMaxFrameSize().height, _messageBuffer 131 .getWidth(), _messageBuffer.getHeight())); 131 132 } 132 133 } … … 134 135 private static boolean initBuffer() { 135 136 if (_messageBuffer == null) { 136 if (FrameGraphics.isAudienceMode() || 137 FrameGraphics.getMaxSize().width <= 0) return false; 138 137 if (FrameGraphics.isAudienceMode() 138 || FrameGraphics.getMaxSize().width <= 0) 139 return false; 140 139 141 GraphicsEnvironment ge = GraphicsEnvironment 140 142 .getLocalGraphicsEnvironment(); … … 177 179 * The color of the message background 178 180 */ 179 public static synchronized void refresh(boolean useInvalidation, Graphics g,180 Color background) {181 public static synchronized void refresh(boolean useInvalidation, 182 Graphics g, Color background) { 181 183 182 184 if (FrameGraphics.getMaxSize().width <= 0) … … 220 222 221 223 private static void updateBuffer(Color background, Area clip) { 222 if (!initBuffer()) return; 224 if (!initBuffer()) 225 return; 223 226 224 227 Graphics2D g = _messageBuffer.createGraphics(); … … 255 258 return displayMessage(message, link, actions, color, true); 256 259 } 257 258 public static Text displayMessage(String message, String link, 259 Color color,boolean displayAlways, String action) {260 261 public static Text displayMessage(String message, String link, Color color, 262 boolean displayAlways, String action) { 260 263 List<String> actions = new LinkedList<String>(); 261 264 actions.add(action); … … 299 302 _messages[i].setOffset(0, 300 303 -FrameGraphics.getMaxFrameSize().height); 301 // _messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width);304 // _messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width); 302 305 _messages[i].setColor(color); 303 306 _messages[i].setLink(link); … … 337 340 338 341 refresh(false, FrameGraphics.createGraphics(), Item.DEFAULT_BACKGROUND); 339 342 340 343 return last; 341 344 } … … 344 347 overwriteMessage(message, null); 345 348 } 346 349 347 350 public static void overwriteMessage(String message, Color color) { 348 351 for (int ind = _messages.length - 1; ind >= 0; ind--) { … … 412 415 413 416 public static Text displayMessage(Text message) { 414 return displayMessage(message.getFirstLine(), message.getLink(), message 415 .getAction(), message.getColor()); 417 Text t = null; 418 String link = message.getLink(); 419 List<String> action = message.getAction(); 420 Color color = message.getColor(); 421 for (String s : message.getTextList()) { 422 t = displayMessage(s, link, action, color); 423 } 424 return t; 416 425 // Misc.Beep(); 417 426 } -
trunk/src/org/expeditee/items/Text.java
r324 r336 602 602 if (text.charAt(0) == KeyEvent.VK_BACK_SPACE) { 603 603 if (hasSelection()) { 604 cutSelectedText(); 605 clearSelection(); 604 pos = deleteSelection(pos); 606 605 } else if (insertPos > 0) { 607 606 deleteChar(insertPos - 1); … … 612 611 } else if (text.charAt(0) == KeyEvent.VK_DELETE) { 613 612 if (hasSelection()) { 614 cutSelectedText(); 615 clearSelection(); 613 pos = deleteSelection(pos); 616 614 } else if (insertPos < _text.length()) { 617 615 deleteChar(insertPos); … … 719 717 } 720 718 719 /** 720 * @param pos 721 * @return 722 */ 723 private int deleteSelection(int pos) { 724 int selectionLength = getSelectionSize(); 725 cutSelectedText(); 726 clearSelection(); 727 pos -= selectionLength; 728 return pos; 729 } 730 721 731 public Point2D.Float moveCursor(int direction, float mouseX, float mouseY, 722 732 boolean setSelection) {
Note:
See TracChangeset
for help on using the changeset viewer.