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/gui/FrameUtils.java

    r373 r376  
    240240                        }
    241241
    242                         if (above != curr.getNameItem() && above != curr.getTitleItem())
     242                        // Need to do things differently for FORMAT than for DROPPING
     243                        if (moveAll && above != curr.getNameItem()
     244                                        && above != curr.getTitleItem()) {
    243245                                x = above.getX();
     246                                from.setY((int) above.getPolygon().getBounds().getMaxY()
     247                                                + space
     248                                                + ((int) (from.getY() - from.getPolygon().getBounds()
     249                                                                .getMinY())));
     250                                from.setX(x);
     251                        } else {
     252                                x = from.getX();
     253                        }
    244254
    245255                        space += adjust;
    246 
    247                         from.setY((int) above.getPolygon().getBounds().getMaxY()
    248                                         + space
    249                                         + ((int) (from.getY() - from.getPolygon().getBounds()
    250                                                         .getMinY())));
    251 
    252                         if (moveAll)
    253                                 from.setX(x);
    254                 }
    255 
     256                }
    256257                for (int i = 1; i < toAlign.size(); i++) {
    257258                        Item current = toAlign.get(i);
     
    580581                // check for all tags setting user values
    581582                for (Text item : profile.getBodyTextItems(false)) {
    582 
    583                         AttributeValuePair avp = new AttributeValuePair(item.getText());
    584                         String attributeFullCase = avp.getAttributeOrValue();
    585 
    586                         if (attributeFullCase == null)
    587                                 continue;
    588                         String attribute = attributeFullCase.toLowerCase();
    589 
    590                         if (attribute.equals("homeframe")) {
    591                                 String first = getLink(item, UserSettings.HomeFrame);
    592                                 // do not use non-existant frames as the first frame
    593                                 if (FrameIO.isValidFrameName(first)) {
    594                                         UserSettings.HomeFrame = first;
    595                                 }
    596                                 // warn the user
    597                                 else {
    598                                         // MessageBay.warningMessage("Home frame: " + first
    599                                         // + " is not a valid frame.");
    600                                         UserSettings.HomeFrame = profile.getName();
    601                                 }
    602                         } else if (attribute.equals("username")) {
    603                                 UserSettings.UserName = avp.getValue();
    604                         } else if (attribute.equals("spellchecker")) {
    605 
    606                                 try {
    607                                         JSpellChecker.create();
    608                                 } catch (FileNotFoundException e) {
    609                                         MessageBay.errorMessage("Could not find dictionary: "
    610                                                         + e.getMessage());
    611                                 } catch (IOException e) {
    612                                         // TODO Auto-generated catch block
    613                                         e.printStackTrace();
    614                                 }
    615                         } else if (attribute.equals("defaultframe"))
    616                                 UserSettings.DefaultFrame = getLink(item,
    617                                                 UserSettings.DefaultFrame);
    618                         else if (attribute.equals("mailsettings"))
    619                                 MailSession.init(item.getChild());
    620                         else if (attribute.equals("networksettings"))
    621                                 FrameShare.init(item.getChild());
    622                         else if (attribute.equals("greenstonesettings")) {
    623                                 SearchGreenstone.init(item.getChild());
    624                         } else if (attribute.equals("reminders"))
    625                                 Reminders.init(item.getChild());
    626                         else if (attribute.equals("antialias"))
    627                                 UserSettings.AntiAlias = avp.getBooleanValue();
    628                         else if (attribute.equals("gravity"))
    629                                 UserSettings.Gravity = avp.getIntegerValue();
    630                         else if (attribute.equals("showlinehighlight"))
    631                                 UserSettings.LineHighlight = avp.getBooleanValue();
    632                         else if (attribute.equals("linestraightenthreshold"))
    633                                 UserSettings.LineStraightenThreshold = avp.getIntegerValue();
    634                         else if (attribute.equals("noopthreshold"))
    635                                 UserSettings.NoOpThreshold = avp.getIntegerValue();
    636                         else if (attribute.equals("formatspacingmin")) {
    637                                 FrameUtils.MINIMUM_SPACING_RATIO = avp.getDoubleValue();
    638                         } else if (attribute.equals("formatspacingmax")) {
    639                                 FrameUtils.MAXIMUM_SPACING_RATIO = avp.getDoubleValue();
    640                         } else if (attribute.equals("initialwidth")) {
    641                                 UserSettings.InitialWidth = avp.getIntegerValue();
    642                         } else if (attribute.equals("initialheight")) {
    643                                 UserSettings.InitialHeight = avp.getIntegerValue();
    644                         } else if (attribute.equals("titleposition")) {
    645                                 UserSettings.TitlePosition = avp.getIntegerValue();
    646                         } else if (attribute.equals("logging")) {
    647                                 UserSettings.Logging = avp.getBooleanValue();
    648                         } else if (attribute.equals("itemtemplate")) {
    649                                 UserSettings.ItemTemplate = ((Text) item).getTemplateForm();
    650                         } else if (attribute.equals("annotationtemplate")) {
    651                                 UserSettings.AnnotationTemplate = ((Text) item)
    652                                                 .getTemplateForm();
    653                         } else if (attribute.equals("statstemplate")) {
    654                                 UserSettings.StatTemplate = ((Text) item).getTemplateForm();
    655                         } else if (attribute.equals("commenttemplate")) {
    656                                 UserSettings.CodeCommentTemplate = ((Text) item)
    657                                                 .getTemplateForm();
    658                         } else if (attribute.equals("dottemplate")) {
    659                                 UserSettings.DotTemplate = ((Text) item).getTemplateForm();
    660                         } else if (attribute.equals("framesetdir")) {
    661                                 String dir = getDir(avp.getValue());
    662                                 if (dir != null) {
    663                                         UserSettings.FrameDirs.add(dir);
    664                                 }
    665                         } else if (attribute.equals("logdir")) {
    666                                 org.expeditee.gui.FrameIO.LOGS_DIR = getDir(avp.getValue());
    667                         } else if (attribute.equals("imagedir")) {
    668                                 String dir = getDir(avp.getValue());
    669                                 if (dir != null)
    670                                         UserSettings.ImageDirs.add(0, dir);
    671                         } else if (attribute.equals("threading")) {
    672                                 UserSettings.Threading = avp.getBooleanValue();
    673                         } else if (attribute.equals("colorwheel")) {
    674                                 Item.COLOR_WHEEL = getColorWheel(item);
    675                         } else if (attribute.equals("fillcolorwheel")) {
    676                                 Item.FILL_COLOR_WHEEL = getColorWheel(item);
    677                         } else if (attribute.equals("backgroundcolorwheel")) {
    678                                 Frame.COLOR_WHEEL = getColorWheel(item);
    679                         } else if (attribute.equals("framesetdirs")) {
    680                                 UserSettings.FrameDirs.addAll(getDirs(item));
    681                         } else if (attribute.equals("imagedirs")) {
    682                                 UserSettings.ImageDirs.addAll(getDirs(item));
    683                         } else if (attribute.equals("style")) {
    684                                 UserSettings.Style = getStyle(item.getChild());
    685                         } else {
    686                                 errors.add(attributeFullCase + " is not a profile frame tag");
     583                        try {
     584
     585                                AttributeValuePair avp = new AttributeValuePair(item.getText());
     586                                String attributeFullCase = avp.getAttributeOrValue();
     587
     588                                if (attributeFullCase == null)
     589                                        continue;
     590                                String attribute = attributeFullCase.toLowerCase();
     591
     592                                if (attribute.equals("homeframe")) {
     593                                        String first = getLink(item, UserSettings.HomeFrame);
     594                                        // do not use non-existant frames as the first frame
     595                                        if (FrameIO.isValidFrameName(first)) {
     596                                                UserSettings.HomeFrame = first;
     597                                        }
     598                                        // warn the user
     599                                        else {
     600                                                // MessageBay.warningMessage("Home frame: " + first
     601                                                // + " is not a valid frame.");
     602                                                UserSettings.HomeFrame = profile.getName();
     603                                        }
     604                                } else if (attribute.equals("username")) {
     605                                        UserSettings.UserName = avp.getValue();
     606                                } else if (attribute.equals("spellchecker")) {
     607
     608                                        try {
     609                                                JSpellChecker.create();
     610                                        } catch (FileNotFoundException e) {
     611                                                MessageBay.errorMessage("Could not find dictionary: "
     612                                                                + e.getMessage());
     613                                        } catch (IOException e) {
     614                                                // TODO Auto-generated catch block
     615                                                e.printStackTrace();
     616                                        }
     617                                } else if (attribute.equals("defaultframe"))
     618                                        UserSettings.DefaultFrame = getLink(item,
     619                                                        UserSettings.DefaultFrame);
     620                                else if (attribute.equals("mailsettings"))
     621                                        MailSession.init(item.getChild());
     622                                else if (attribute.equals("networksettings"))
     623                                        FrameShare.init(item.getChild());
     624                                else if (attribute.equals("spelling"))
     625                                        JSpellChecker.create(item.getChild());
     626                                else if (attribute.equals("greenstonesettings")) {
     627                                        SearchGreenstone.init(item.getChild());
     628                                } else if (attribute.equals("reminders"))
     629                                        Reminders.init(item.getChild());
     630                                else if (attribute.equals("antialias"))
     631                                        UserSettings.AntiAlias = avp.getBooleanValue();
     632                                else if (attribute.equals("gravity"))
     633                                        UserSettings.Gravity = avp.getIntegerValue();
     634                                else if (attribute.equals("showlinehighlight"))
     635                                        UserSettings.LineHighlight = avp.getBooleanValue();
     636                                else if (attribute.equals("linestraightenthreshold"))
     637                                        UserSettings.LineStraightenThreshold = avp
     638                                                        .getIntegerValue();
     639                                else if (attribute.equals("noopthreshold"))
     640                                        UserSettings.NoOpThreshold = avp.getIntegerValue();
     641                                else if (attribute.equals("formatspacingmin")) {
     642                                        FrameUtils.MINIMUM_SPACING_RATIO = avp.getDoubleValue();
     643                                } else if (attribute.equals("formatspacingmax")) {
     644                                        FrameUtils.MAXIMUM_SPACING_RATIO = avp.getDoubleValue();
     645                                } else if (attribute.equals("initialwidth")) {
     646                                        UserSettings.InitialWidth = avp.getIntegerValue();
     647                                } else if (attribute.equals("initialheight")) {
     648                                        UserSettings.InitialHeight = avp.getIntegerValue();
     649                                } else if (attribute.equals("titleposition")) {
     650                                        UserSettings.TitlePosition = avp.getIntegerValue();
     651                                } else if (attribute.equals("logging")) {
     652                                        UserSettings.Logging = avp.getBooleanValue();
     653                                } else if (attribute.equals("itemtemplate")) {
     654                                        UserSettings.ItemTemplate = ((Text) item).getTemplateForm();
     655                                } else if (attribute.equals("annotationtemplate")) {
     656                                        UserSettings.AnnotationTemplate = ((Text) item)
     657                                                        .getTemplateForm();
     658                                } else if (attribute.equals("statstemplate")) {
     659                                        UserSettings.StatTemplate = ((Text) item).getTemplateForm();
     660                                } else if (attribute.equals("commenttemplate")) {
     661                                        UserSettings.CodeCommentTemplate = ((Text) item)
     662                                                        .getTemplateForm();
     663                                } else if (attribute.equals("dottemplate")) {
     664                                        UserSettings.DotTemplate = ((Text) item).getTemplateForm();
     665                                } else if (attribute.equals("framesetdir")) {
     666                                        String dir = getDir(avp.getValue());
     667                                        if (dir != null) {
     668                                                UserSettings.FrameDirs.add(dir);
     669                                        }
     670                                } else if (attribute.equals("logdir")) {
     671                                        org.expeditee.gui.FrameIO.LOGS_DIR = getDir(avp.getValue());
     672                                } else if (attribute.equals("imagedir")) {
     673                                        String dir = getDir(avp.getValue());
     674                                        if (dir != null)
     675                                                UserSettings.ImageDirs.add(0, dir);
     676                                } else if (attribute.equals("threading")) {
     677                                        UserSettings.Threading = avp.getBooleanValue();
     678                                } else if (attribute.equals("colorwheel")) {
     679                                        Item.COLOR_WHEEL = getColorWheel(item);
     680                                } else if (attribute.equals("fillcolorwheel")) {
     681                                        Item.FILL_COLOR_WHEEL = getColorWheel(item);
     682                                } else if (attribute.equals("backgroundcolorwheel")) {
     683                                        Frame.COLOR_WHEEL = getColorWheel(item);
     684                                } else if (attribute.equals("framesetdirs")) {
     685                                        UserSettings.FrameDirs.addAll(getDirs(item));
     686                                } else if (attribute.equals("imagedirs")) {
     687                                        UserSettings.ImageDirs.addAll(getDirs(item));
     688                                } else if (attribute.equals("style")) {
     689                                        UserSettings.Style = getStyle(item.getChild());
     690                                } else {
     691                                        errors.add(attributeFullCase
     692                                                        + " is not a profile frame tag");
     693                                }
     694                        } catch (Exception e) {
     695                                e.printStackTrace();
     696                                errors.add("Error parsing [" + item.getText() + "] on "
     697                                                + profile.getName());
    687698                        }
    688699                }
     
    692703
    693704        private static List<Text> getStyle(Frame child) {
     705                if (child == null)
     706                        return new LinkedList<Text>();
     707
    694708                List<Text> style = new ArrayList<Text>(8);
    695709                for (int i = 0; i < 10; i++) {
     
    750764                        return alt;
    751765
    752                 String value = new AttributeValuePair(item.getText()).getValue().trim();
    753                 if (value.length() > 0) {
    754                         item.setLink(value);
    755                         return value;
    756                 } else if (item.getLink() != null)
    757                         return item.getLink();
     766                AttributeValuePair avp = new AttributeValuePair(item.getText());
     767                assert (avp != null);
     768               
     769                if (avp.hasPair()) {
     770                        item.setLink(avp.getValue());
     771                        return avp.getValue();
     772                } else if (item.getLink() != null) {
     773                        return item.getAbsoluteLink();
     774                }
    758775
    759776                return alt;
     
    11251142        }
    11261143
     1144        public static Item onItem(float floatX, float floatY,
     1145                        boolean changeLastEdited) {
     1146                return onItem(DisplayIO.getCurrentFrame(), floatX, floatY,
     1147                                changeLastEdited);
     1148        }
     1149
    11271150        /**
    11281151         * Searches through the list of items on this frame to find one at the given
     
    11351158         * @return The Item at the given coordinates, or NULL if none is found.
    11361159         */
    1137         public static Item onItem(Frame toCheck, float floatX, float floatY) {
     1160        public static Item onItem(Frame toCheck, float floatX, float floatY,
     1161                        boolean bResetLastEdited) {
    11381162                // System.out.println("MouseX: " + floatX + " MouseY: " + floatY);
    11391163                int x = Math.round(floatX);
     
    11721196                        // otherwise, the mouse is on the frame
    11731197                } else {
    1174                         if (LastEdited != null && /*
    1175                                                                                  * LastEdited.isVisible() &&
    1176                                                                                  */LastEdited.contains(x, y)
    1177                                         && !FreeItems.getInstance().contains(LastEdited)
    1178                                         && LastEdited.getParent() == DisplayIO.getCurrentFrame()
    1179                                         && LastEdited.getParent().getItems().contains(LastEdited)) {
    1180                                 LastEdited.setPermission(Permission.full);
    1181                                 return LastEdited;
    1182                         } else {
    1183                                 setLastEdited(null);
     1198                        if (LastEdited != null) {
     1199                                if (LastEdited.contains(x, y)
     1200                                                && !FreeItems.getInstance().contains(LastEdited)
     1201                                                && LastEdited.getParent() == DisplayIO
     1202                                                                .getCurrentFrame()
     1203                                                && LastEdited.getParent().getItems().contains(
     1204                                                                LastEdited)) {
     1205                                        LastEdited.setPermission(Permission.full);
     1206                                        return LastEdited;
     1207                                } else if (bResetLastEdited) {
     1208                                        setLastEdited(null);
     1209                                }
    11841210                        }
    11851211                        ArrayList<Item> checkList = new ArrayList<Item>();
     
    12361262        public synchronized static Item getCurrentItem() {
    12371263                return onItem(DisplayIO.getCurrentFrame(), DisplayIO.getMouseX(),
    1238                                 FrameMouseActions.getY());
     1264                                FrameMouseActions.getY(), true);
    12391265        }
    12401266
     
    14331459
    14341460                yPos += spacing;
    1435                 profile.addText(xPos, yPos, "@HomeFrame: " + profile.getName(), null,
     1461                profile.addText(xPos, yPos, "@HomeFrame", null,
    14361462                                profile.getName());
    14371463                yPos += spacing;
    14381464                String defaultFrameName = profile.getFramesetName() + "0";
    1439                 profile.addText(xPos, yPos, "@DefaultFrame: " + defaultFrameName, null,
     1465                profile.addText(xPos, yPos, "@DefaultFrame", null,
    14401466                                defaultFrameName);
    14411467                yPos += spacing;
     
    15391565
    15401566        public static void setLastEdited(Text lastEdited) {
     1567
    15411568                // If the lastEdited is being changed then check if its @i
    15421569                Frame toReparse = null;
    15431570                Frame toRecalculate = null;
    1544                 if (LastEdited != null) {
     1571                Frame toUpdateObservers = null;
     1572
     1573                if (LastEdited == null) {
     1574                        // System.out.print("N");
     1575                } else if (LastEdited != null) {
     1576                        // System.out.print("T");
     1577                        Frame parent = LastEdited.getParentOrCurrentFrame();
     1578
    15451579                        if (lastEdited != LastEdited) {
    15461580                                if (LastEdited.startsWith("@i")) {
     
    15741608                                                }
    15751609                                        }
    1576                                         toReparse = LastEdited.getParent();
     1610                                        toReparse = parent;
    15771611                                } else if (LastEdited.recalculateWhenChanged()) {
    1578                                         toRecalculate = LastEdited.getParentOrCurrentFrame();
     1612                                        toRecalculate = parent;
     1613                                }
     1614
     1615                                if (parent.hasObservers()) {
     1616                                        toUpdateObservers = parent;
    15791617                                }
    15801618                                // Update the formula if in XRay mode
     
    15841622                        }
    15851623                        if (lastEdited != LastEdited && LastEdited.getText().length() == 0) {
    1586                                 LastEdited.getParentOrCurrentFrame().removeItem(LastEdited);
     1624                                parent.removeItem(LastEdited);
    15871625                        }
    15881626                }
     
    15921630                        if (toReparse != null) {
    15931631                                Parse(toReparse, false, false);
    1594                         } else if (toRecalculate != null) {
    1595                                 toRecalculate.recalculate();
     1632                        } else {
     1633                                if (toRecalculate != null) {
     1634                                        toRecalculate.recalculate();
     1635                                }
     1636
     1637                                if (toUpdateObservers != null) {
     1638                                        toUpdateObservers.notifyObservers(false);
     1639                                }
    15961640                        }
    15971641                }
Note: See TracChangeset for help on using the changeset viewer.