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/Frame.java

    r362 r376  
    204204                boolean oldValue = _change;
    205205
    206                 if (value) {
    207                         notifyObservers();
    208                 }
     206                // if (value) {
     207                // notifyObservers();
     208                // }
    209209
    210210                if (oldValue == value)
     
    219219        }
    220220
    221         public void notifyObservers() {
     221        //private static int updateCount = 0;
     222
     223        /**
     224         * Notify items observing the data on this frame that the frame content has
     225         * changed.
     226         *
     227         * @param recalculate
     228         *            true if the frame should be recalculated first.
     229         */
     230        public void notifyObservers(boolean bRecalculate) {
     231                if(bRecalculate){
     232                        recalculate();
     233                }
    222234                // Notify the frame listeners that the frame has changed
    223                 for (FrameObserver fl : _observers) {
    224                         fl.update();
     235                /*
     236                 * Avoid ConcurrentMod Exceptions when user anchors an item onto this
     237                 * frame which is observing this frame, by NOT using foreach loop.
     238                 * Calling update on a dataFrameWidget resets its subjects hence
     239                 * changing this frames observer list.
     240                 */
     241                Collection<FrameObserver> observersCopy = new LinkedList<FrameObserver>(
     242                                _observers);
     243                //System.out.println(++updateCount + " update");
     244
     245                for (FrameObserver fl : observersCopy) {
     246                        if (/* !Item.isLocked(fl) && */fl.isVisible())
     247                                fl.update();
    225248                }
    226249        }
     
    370393                        if (UserSettings.TitleTemplate == null) {
    371394                                frameTitle = new Text(getNextItemID(), title);
     395                                /*
     396                                 * Need to set the parent otherwise an exception is thrown when
     397                                 * new profile is created
     398                                 */
     399                                frameTitle.setParent(this);
    372400                                frameTitle.resetTitlePosition();
    373401                        } else {
     
    721749                item.onParentStateChanged(new ItemParentStateChangedEvent(this,
    722750                                ItemParentStateChangedEvent.EVENT_TYPE_ADDED));
    723                 if (recalculate && item.recalculateWhenChanged())
    724                         recalculate();
     751
     752                // if (recalculate && item.recalculateWhenChanged())
     753                // recalculate();
    725754
    726755                change();
     
    799828                        }
    800829                        // TODO Improve efficiency when removeAll is called
    801                         if (recalculate && item.recalculateWhenChanged())
    802                                 recalculate();
     830                        // if (recalculate && item.recalculateWhenChanged())
     831                        // recalculate();
    803832                }
    804833        }
     
    834863                Item undo = null;
    835864                boolean bReparse = false;
     865                boolean bRecalculate = false;
    836866
    837867                if (_undo.size() <= 0)
     
    871901                        for (Item i : toRestore) {
    872902                                bReparse |= i.hasOverlay();
     903                                bRecalculate |= i.recalculateWhenChanged();
    873904                                if (i instanceof Line) {
    874905                                        Line line = (Line) i;
     
    885916                if (bReparse)
    886917                        FrameUtils.Parse(this, false);
     918                else {
     919                        notifyObservers(bRecalculate);
     920                }
    887921                FrameGraphics.Repaint();
    888922                ItemUtils.EnclosedCheck(_body);
     
    14551489                // t.setMaxWidth(FrameGraphics.getMaxFrameSize().width);
    14561490                // if (t.getWidth() <= 0) {
    1457 //              String maxWidthString = getAnnotationValue("maxwidth");
    1458 //              int width = FrameGraphics.getMaxFrameSize().width;
    1459 //              if (maxWidthString != null) {
    1460 //                      try {
    1461 //                              width = Math.min(width, Integer.parseInt(maxWidthString));
    1462 //                      } catch (NumberFormatException nfe) {
    1463 //                      }
    1464 //              }
    1465 //
    1466 //              t.setRightMargin(width);
     1491                // String maxWidthString = getAnnotationValue("maxwidth");
     1492                // int width = FrameGraphics.getMaxFrameSize().width;
     1493                // if (maxWidthString != null) {
     1494                // try {
     1495                // width = Math.min(width, Integer.parseInt(maxWidthString));
     1496                // } catch (NumberFormatException nfe) {
     1497                // }
     1498                // }
     1499                //
     1500                // t.setRightMargin(width);
    14671501                // }
    14681502                addItem(t);
     
    20232057
    20242058        public void recalculate() {
     2059
    20252060                for (Item i : getItems()) {
    20262061                        if (i.hasFormula() && !i.isAnnotation()) {
     
    21182153                }
    21192154        }
     2155
     2156        public boolean hasObservers() {
     2157                return _observers != null && _observers.size() > 0;
     2158        }
    21202159}
Note: See TracChangeset for help on using the changeset viewer.