Ignore:
Timestamp:
08/29/08 08:17:54 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r284 r286  
    22
    33import java.awt.Point;
     4import java.awt.Rectangle;
    45import java.awt.event.ActionEvent;
    56import java.awt.event.ActionListener;
     
    1011import java.awt.event.MouseWheelEvent;
    1112import java.awt.event.MouseWheelListener;
     13import java.text.NumberFormat;
    1214import java.util.ArrayList;
    1315import java.util.Collection;
     
    683685                        // check item permissions
    684686                        if (!clicked.hasPermission(Permission.followLinks)) {
    685                                 MessageBay
    686                                                 .displayMessage("Insufficient permissions to perform action on item");
    687                                 return;
     687                                Item editTarget = clicked.getEditTarget();
     688                                if (editTarget != clicked
     689                                                && editTarget.hasPermission(Permission.followLinks)) {
     690                                        clicked = editTarget;
     691                                } else {
     692                                        MessageBay
     693                                                        .displayMessage("Insufficient permission to perform action on item");
     694                                        return;
     695                                }
    688696                        }
    689697
     
    869877                        // check permissions
    870878                        if (!clicked.hasPermission(Permission.full)) {
    871                                 MessageBay
    872                                                 .displayMessage("Insufficient permission to pick up item");
    873                                 return;
     879                                Item editTarget = clicked.getEditTarget();
     880                                if (editTarget != clicked
     881                                                && editTarget.hasPermission(Permission.full)) {
     882                                        clicked = editTarget;
     883                                } else {
     884                                        MessageBay
     885                                                        .displayMessage("Insufficient permission to pick up item");
     886                                        return;
     887                                }
    874888                        }
    875889
     
    12501264                                        }
    12511265                                } else if (!clicked.hasPermission(Permission.copy)) {
    1252                                         MessageBay
    1253                                                         .displayMessage("Insufficient permission to copy");
    1254                                         return;
     1266                                        Item editTarget = clicked.getEditTarget();
     1267                                        if (editTarget != clicked
     1268                                                        && editTarget.hasPermission(Permission.copy)) {
     1269                                                clicked = editTarget;
     1270                                        } else {
     1271                                                MessageBay
     1272                                                                .displayMessage("Insufficient permission to copy");
     1273                                                return;
     1274                                        }
    12551275                                }
    12561276
     
    15481568
    15491569        private static boolean _controlDown;
    1550        
     1570
    15511571        public static boolean isControlDown() {
    15521572                return _controlDown;
     
    15961616                MouseX = e.getX();
    15971617                MouseY = e.getY();
    1598                 //System.out.println(MouseX + "," + MouseY);
     1618                // System.out.println(MouseX + "," + MouseY);
    15991619
    16001620                // Moving the mouse a certain distance removes the last edited text if
     
    18131833                                // Item.SelectedMode.Connected);
    18141834                                // TODO: The method below is for the most part redundant
    1815                                 on = FrameGraphics.Highlight(on);
     1835                                on = FrameGraphics.Highlight(on.getEditTarget());
    18161836                        }
    18171837                        // if the last item highlighted is still highlighted, clear it
     
    20012021         */
    20022022        public static boolean tdfc(Item linker) throws RuntimeException {
    2003                 // if (linker instanceof Line)
    2004                 // return false;
    2005 
    20062023                // if this is a non-usable item
    20072024                if (linker.getID() < 0)
    20082025                        return false;
     2026
     2027                // Check if its an image that can be resized to fit a box
     2028                // around it
     2029                String text = linker.getText();
     2030                if (text.equals("@v") || text.equals("@f")) {
     2031                        Collection<Item> enclosure = FrameUtils.getEnclosingLineEnds(linker
     2032                                        .getPosition());
     2033                        if (enclosure != null) {
     2034                                for (Item i : enclosure) {
     2035                                        if (i.isLineEnd() && i.isEnclosed()) {
     2036                                                DisplayIO.getCurrentFrame().removeAllItems(enclosure);
     2037                                                Rectangle rect = i.getEnclosedRectangle();
     2038                                                long width = Math.round(rect.getWidth());
     2039                                                if (text.equals("@v")) {
     2040                                                        NumberFormat nf = Vector.getNumberFormatter();
     2041                                                        linker.setText("@v: "
     2042                                                                        + nf.format((width / FrameGraphics
     2043                                                                                        .getMaxFrameSize().getWidth())));
     2044                                                } else {
     2045                                                        linker.setText("@f: " + width);
     2046                                                }
     2047
     2048                                                linker.setPosition(new Point(rect.x, rect.y));
     2049                                                linker.setThickness(i.getThickness());
     2050                                                linker.setBorderColor(i.getColor());
     2051                                                break;
     2052                                        }
     2053                                }
     2054                                FrameMouseActions.deleteItems(enclosure, false);
     2055                        }
     2056                }
    20092057
    20102058                boolean mouseMoved;
     
    21782226                        // check permissions
    21792227                        if (!toDelete.hasPermission(Permission.full)) {
    2180                                 MessageBay
    2181                                                 .displayMessage("Insufficient permission to delete item");
    2182                                 return;
     2228                                Item editTarget = toDelete.getEditTarget();
     2229                                if (editTarget != toDelete
     2230                                                && editTarget.hasPermission(Permission.full)) {
     2231                                        toDelete = editTarget;
     2232                                } else {
     2233                                        MessageBay
     2234                                                        .displayMessage("Insufficient permission to delete item");
     2235                                        return;
     2236                                }
    21832237                        }
    21842238
     
    25322586
    25332587                if (!toGrab.hasPermission(Permission.full)) {
    2534                         MessageBay
    2535                                         .displayMessage("Insufficient permission pickup the item");
     2588                        if (toGrab.getEditTarget() != toGrab) {
     2589                                pickup(toGrab.getEditTarget());
     2590                        } else {
     2591                                MessageBay
     2592                                                .displayMessage("Insufficient permission pickup the item");
     2593                        }
    25362594                        return;
    25372595                }
     
    25392597                if (toGrab instanceof Circle)
    25402598                        toGrab.setHighlightMode(HighlightMode.Connected);
    2541                 else
     2599                //Dont set the highlight mode if a vector is being picked up
     2600                else if(toGrab.isVisible()){
    25422601                        toGrab.setHighlightMode(HighlightMode.Normal);
     2602                }
    25432603
    25442604                // Brook: If the widget corner is being picked up. Instead refer to
     
    25592619
    25602620        public static void pickup(Collection<Item> toGrab) {
    2561                 if(toGrab == null || toGrab.size() == 0)
     2621                if (toGrab == null || toGrab.size() == 0)
    25622622                        return;
    2563                
     2623
    25642624                boolean bReparse = false;
    25652625                Frame frame = DisplayIO.getCurrentFrame();
     
    25942654                                for (Item copy : copies) {
    25952655                                        FreeItems.getInstance().add(copy);
     2656                                        copy.setEditTarget(i);
    25962657                                        copy.setFloating(true);
    25972658                                        copy.setParent(null);
     2659                                        //copy.setHighlightMode(HighlightMode.Connected);
    25982660                                }
    25992661                        }
     
    26362698                } else {
    26372699                        MessageBay
    2638                                         .displayMessage("Insufficient permission pickup the items");
     2700                                        .displayMessage("Insufficient permission to pickup the items");
    26392701                }
    26402702                if (bReparse)
Note: See TracChangeset for help on using the changeset viewer.