Changeset 336


Ignore:
Timestamp:
09/26/08 13:03:26 (16 years ago)
Author:
ra33
Message:

Fixed minor bugs

Location:
trunk/src/org/expeditee
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Misc.java

    r311 r336  
    498498                                        + "' could not be found.");
    499499                }
     500        }
     501
     502        public static void MessageLn(Item message) {
     503                if (message instanceof Text)
     504                        MessageBay.displayMessage((Text) message);
    500505        }
    501506
  • trunk/src/org/expeditee/actions/Simple.java

    r313 r336  
    12531253                                Frame frame2 = (Frame) context.getPointers().getVariable(
    12541254                                                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);
    12721256                        } else if (tokens[0].equals("assertdefined")) {
    12731257                                assertExactParametreCount(tokens, 1);
     
    16871671                        double delay = context.getPrimitives().getDoubleValue(tokens[1]);
    16881672                        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);
    16931674                } else if (tokens[0].equals("type") || tokens[0].equals("typenospaces")) {
    16941675
    16951676                        String s = getMessage(tokens, context, code.toString(), tokens[0]
    16961677                                        .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);
    17011680                } else if (tokens[0].equals("runstring")) {
    17021681                        String codeText = getMessage(tokens, context, code.toString(), " ",
  • trunk/src/org/expeditee/agents/SearchGreenstone.java

    r313 r336  
    3333
    3434        private static boolean _showAbstract = false;
     35
    3536        private static boolean _showKeywords = false;
     37
    3638        private static boolean _showAuthors = false;
     39
    3740        private static boolean _showDate = false;
    3841
     
    8992                if (settings == null)
    9093                        return;
     94
     95                _maxResults = "10";
     96                _showAbstract = false;
     97                _showKeywords = false;
     98                _showAuthors = false;
     99                _showDate = false;
     100                _locationChoice = 1;
    91101
    92102                // Set the settings
     
    330340                if (_showDate && rd.metadataExists("Date"))
    331341                        text += ", " + rd.getDate();
    332                
     342
    333343                if (_showAbstract && rd.metadataExists("Abstract"))
    334344                        text += "\n  " + rd.getAbstract();
    335                
     345
    336346                if (_showAuthors && rd.metadataExists("Creator"))
    337347                        text += "\nAuthors" + rd.getAuthors().toString();
    338                
     348
    339349                if (_showKeywords && rd.getKeywords().size() > 0)
    340350                        text += "\nKeywords" + rd.getKeywords().toString();
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r311 r336  
    88import java.awt.Robot;
    99import java.awt.Toolkit;
     10import java.awt.event.KeyEvent;
    1011import java.awt.geom.Point2D;
    1112import java.awt.image.MemoryImageSource;
     
    5556        @SuppressWarnings("unchecked")
    5657        private static Stack<String>[] _VisitedFrames = new Stack[2];
     58
    5759        @SuppressWarnings("unchecked")
    5860        private static Stack<String>[] _BackedUpFrames = new Stack[2];
    59        
     61
    6062        // used to change the mouse cursor position on the screen
    6163        private static Robot _Robot;
    6264
    6365        private static boolean _TwinFrames = false;
    64        
     66
    6567        /** Notified whenever the frame changes */
    6668        private static HashSet<DisplayIOObserver> _displayIOObservers = new HashSet<DisplayIOObserver>();
     
    102104                }
    103105        }
    104        
     106
    105107        /**
    106108         * Adds a DisplayIOObserver to the DisplayIO. DisplayIOObserver's are
     
    110112         *
    111113         * @param observer
    112          *              The observer to add
     114         *            The observer to add
    113115         *
    114116         * @throws NullPointerException
    115          *              If observer is null.
     117         *             If observer is null.
    116118         */
    117119        public static void addDisplayIOObserver(DisplayIOObserver observer) {
    118                 if (observer == null) throw new NullPointerException("observer");
     120                if (observer == null)
     121                        throw new NullPointerException("observer");
    119122                _displayIOObservers.add(observer);
    120123        }
    121        
    122         /**
    123          * Removes a DisplayIOObserver from the DisplayIO. 
     124
     125        /**
     126         * Removes a DisplayIOObserver from the DisplayIO.
    124127         *
    125128         * @see #addDisplayIOObserver(DisplayIOObserver)
    126129         *
    127130         * @param observer
    128          *              The observer to add
     131         *            The observer to add
    129132         *
    130133         * @throws NullPointerException
    131          *              If observer is null.
     134         *             If observer is null.
    132135         */
    133136        public static void removeDisplayIOObserver(DisplayIOObserver observer) {
    134                 if (observer == null) throw new NullPointerException("observer");
     137                if (observer == null)
     138                        throw new NullPointerException("observer");
    135139                _displayIOObservers.remove(observer);
    136140        }
    137        
     141
    138142        public static void setTextCursor(Text text, int cursorMovement) {
    139143                setTextCursor(text, cursorMovement, false, false);
     
    366370                return null;
    367371        }
    368        
     372
    369373        public static void setCurrentFrame(Frame frame, boolean incrementStats) {
    370374                if (frame == null)
    371375                        return;
    372                
     376
    373377                if (_TwinFrames) {
    374378                        if (_CurrentFrames[0] == null) {
     
    390394                                        + " is already the current frame.");
    391395                        return;
    392                 } else if(incrementStats) {
     396                } else if (incrementStats) {
    393397                        SessionStats.AccessedFrame();
    394398                }
     
    411415                // Changing frames is a Save point for saveable entities:
    412416                EntitySaveManager.getInstance().saveAll();
    413                
     417
    414418                if (_TwinFrames) {
    415419                        // if the same frame is being shown in both sides, load a fresh
     
    545549                if (_Browser == null)
    546550                        return 0;
    547                
     551
    548552                if (_TwinFrames
    549553                                && FrameMouseActions.MouseX >= (_Browser.getWidth() / 2F)
     
    647651                // If the top frame on the backup stack is the current frame go back
    648652                // again... or if it has been deleted
    649                 //Recursively backup the stack
    650                 if(frame == null || frame.equals(getCurrentFrame())) {
     653                // Recursively backup the stack
     654                if (frame == null || frame.equals(getCurrentFrame())) {
    651655                        Back();
    652656                        return false;
     
    677681                return true;
    678682        }
    679        
     683
    680684        public static boolean Forward() {
    681685                int side = getCurrentSide();
     
    699703                // If the top frame on the backup stack is the current frame go back
    700704                // again... or if it has been deleted
    701                 //Recursively backup the stack
    702                 if(frame == null || frame.equals(getCurrentFrame())) {
     705                // Recursively backup the stack
     706                if (frame == null || frame.equals(getCurrentFrame())) {
    703707                        Forward();
    704708                        return false;
     
    750754                        _CurrentFrames[current].refreshSize();
    751755                if (_CurrentFrames[opposite] != null)
    752                         _CurrentFrames[opposite]
    753                                         .refreshSize();
     756                        _CurrentFrames[opposite].refreshSize();
    754757
    755758                FrameGraphics.Clear();
     
    792795        }
    793796
    794         public static void clickMouse(int buttons) {
     797        public static void clickMouse(int buttons) throws InterruptedException {
    795798                _Robot.mousePress(buttons);
     799                Thread.sleep(100);
    796800                _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');
    797839        }
    798840
     
    814856                _BackedUpFrames[getCurrentSide()].clear();
    815857        }
     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        }
    816870}
  • trunk/src/org/expeditee/gui/Frame.java

    r311 r336  
    3333import org.expeditee.items.widgets.InteractiveWidget;
    3434import org.expeditee.items.widgets.WidgetCorner;
     35import org.expeditee.simple.UnitTestFailedException;
    3536import org.expeditee.stats.SessionStats;
    3637
     
    998999                s.append(String.format("Name: %s%d%n", _frameset, _number));
    9991000                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));
    10051006                s.append(String.format("Items: %d%n", _body.size()));
    10061007                return s.toString();
     
    13071308                        addOverlay(o);
    13081309
     1310                // Add all the vectors from the overlay frame to this frame
     1311                for (Vector v : toAdd.Frame.getVectors())
     1312                        addVector(v);
     1313
    13091314                // Now add the items for this overlay
    13101315                Permission permission = Permission.min(toAdd.Frame.getPermission(),
     
    13201325                        _overlayItems.add(i);
    13211326                }
     1327
    13221328                return true;
    13231329        }
     
    20822088                return getAnnotationValue("file");
    20832089        }
     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        }
    20842111}
  • trunk/src/org/expeditee/gui/FrameIO.java

    r311 r336  
    180180                String fullPath = FrameIO.getFrameFullPathName(PUBLIC_PATH, frameName);
    181181
    182                 if(fullPath == null)
     182                if (fullPath == null)
    183183                        return null;
    184                
     184
    185185                File frameFile = new File(fullPath);
    186186                if (frameFile.exists() && frameFile.canRead()) {
     
    209209                        }
    210210                }
    211                
     211
    212212                if (loaded == null && FrameShare.getInstance() != null) {
    213213                        loaded = FrameShare.getInstance().loadFrame(framename, knownPath);
     
    359359
    360360                        // do not put 0 frames or virtual frames into the cache
     361                        // Why are zero frames not put in the cache
    361362                        if (_Cache.size() > MAX_CACHE)
    362363                                _Cache.clear();
     
    601602
    602603                // 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
    604616                String zeroFrameName = frameset + "0";
    605617                Frame destFramesetZero = LoadFrame(zeroFrameName);
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r314 r336  
    585585                        else if (attribute.equals("networksettings"))
    586586                                FrameShare.init(item.getChild());
    587                         else if (attribute.equals("greenstonesettings"))
     587                        else if (attribute.equals("greenstonesettings")) {
    588588                                SearchGreenstone.init(item.getChild());
    589                         else if (attribute.equals("reminders"))
     589                        } else if (attribute.equals("reminders"))
    590590                                Reminders.init(item.getChild());
    591591                        else if (attribute.equals("antialias"))
     
    811811                                } else if (i.hasOverlay()) {
    812812                                        i.setVisible(true);
    813                                         //int x = i.getBoundsHeight();
     813                                        // int x = i.getBoundsHeight();
    814814                                }
    815815                        }
     
    873873                                                                                ItemUtils.TAG_VECTOR)
    874874                                                                && 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);
    876878                                                } else if (!FrameGraphics.isXRayMode()
    877879                                                                && ItemUtils.startsWithTag(i,
    878880                                                                                ItemUtils.TAG_ACTIVE_VECTOR)
    879881                                                                && 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);
    882885                                                }
    883886                                                // check for new OVERLAY items
     
    10321035                        // thread-safe protocol for this project...
    10331036                        toParse.clearOverlays();
     1037                        toParse.clearVectors();
    10341038                        toParse.addAllOverlays(overlays);
    1035                         toParse.clearVectors();
    10361039                        toParse.addAllVectors(vectors);
    10371040                }
     
    10491052                // @v which points back to the frame with the @ao
    10501053                Frame vector = FrameIO.LoadFrame(i.getAbsoluteLink());
     1054
    10511055                // Get the permission from off the vector frame
    10521056                Permission vectorPermission = Permission.getPermission(vector
  • trunk/src/org/expeditee/gui/MessageBay.java

    r307 r336  
    1818
    1919/**
    20  * The bay at the bottom of the expeditee browser which displays messages.
    21  * TODO make it thread safe!
     20 * The bay at the bottom of the expeditee browser which displays messages. TODO
     21 * make it thread safe!
    2222 *
    2323 */
     
    7575                                _messages[i].setOffset(0,
    7676                                                -FrameGraphics.getMaxFrameSize().height);
    77                                 //_messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width);
     77                                // _messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width);
    7878                        }
    7979                }
    8080
    8181                _messageLink.setOffset(0, -FrameGraphics.getMaxFrameSize().height);
    82                 //_messageLink.setMaxWidth(FrameGraphics.getMaxFrameSize().width);
     82                // _messageLink.setMaxWidth(FrameGraphics.getMaxFrameSize().width);
    8383                // _messageLink.setPosition(FrameGraphics.getMaxFrameSize().width
    8484                // - MESSAGE_LINK_Y_OFFSET, MESSAGE_LINK_X);
     
    127127                if (_messageBuffer != null) {
    128128                        _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()));
    131132                }
    132133        }
     
    134135        private static boolean initBuffer() {
    135136                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
    139141                        GraphicsEnvironment ge = GraphicsEnvironment
    140142                                        .getLocalGraphicsEnvironment();
     
    177179         *            The color of the message background
    178180         */
    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) {
    181183
    182184                if (FrameGraphics.getMaxSize().width <= 0)
     
    220222
    221223        private static void updateBuffer(Color background, Area clip) {
    222                 if (!initBuffer()) return;
     224                if (!initBuffer())
     225                        return;
    223226
    224227                Graphics2D g = _messageBuffer.createGraphics();
     
    255258                return displayMessage(message, link, actions, color, true);
    256259        }
    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) {
    260263                List<String> actions = new LinkedList<String>();
    261264                actions.add(action);
     
    299302                                        _messages[i].setOffset(0,
    300303                                                        -FrameGraphics.getMaxFrameSize().height);
    301                                         //_messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width);
     304                                        // _messages[i].setMaxWidth(FrameGraphics.getMaxFrameSize().width);
    302305                                        _messages[i].setColor(color);
    303306                                        _messages[i].setLink(link);
     
    337340
    338341                refresh(false, FrameGraphics.createGraphics(), Item.DEFAULT_BACKGROUND);
    339                
     342
    340343                return last;
    341344        }
     
    344347                overwriteMessage(message, null);
    345348        }
    346        
     349
    347350        public static void overwriteMessage(String message, Color color) {
    348351                for (int ind = _messages.length - 1; ind >= 0; ind--) {
     
    412415
    413416        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;
    416425                // Misc.Beep();
    417426        }
  • trunk/src/org/expeditee/items/Text.java

    r324 r336  
    602602                        if (text.charAt(0) == KeyEvent.VK_BACK_SPACE) {
    603603                                if (hasSelection()) {
    604                                         cutSelectedText();
    605                                         clearSelection();
     604                                        pos = deleteSelection(pos);
    606605                                } else if (insertPos > 0) {
    607606                                        deleteChar(insertPos - 1);
     
    612611                        } else if (text.charAt(0) == KeyEvent.VK_DELETE) {
    613612                                if (hasSelection()) {
    614                                         cutSelectedText();
    615                                         clearSelection();
     613                                        pos = deleteSelection(pos);
    616614                                } else if (insertPos < _text.length()) {
    617615                                        deleteChar(insertPos);
     
    719717        }
    720718
     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
    721731        public Point2D.Float moveCursor(int direction, float mouseX, float mouseY,
    722732                        boolean setSelection) {
Note: See TracChangeset for help on using the changeset viewer.