Changeset 1460 for trunk


Ignore:
Timestamp:
11/29/19 15:32:17 (4 years ago)
Author:
bnemhaus
Message:

Added debug statement and ability to only show debug statements when requested.

Add item needed to adhere to the current surrogate mode when inserting a item. There are now four cases: an item is either a primary or surrogate and it can either can be currently seen or not.

Location:
trunk/src/org/expeditee/gui
Files:
2 edited

Legend:

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

    r1434 r1460  
    141141public class Browser implements SaveStateChangedEventListener {
    142142       
     143        public static final boolean DEBUG = true;
     144       
    143145        public static final Ecosystem ECOSYSTEM_TYPE = Ecosystem.Swing;
    144146
  • trunk/src/org/expeditee/gui/Frame.java

    r1450 r1460  
    729729                _frameName = new Text(id);
    730730                _frameName.setParent(this);
    731                 _frameName.setOwner(this.getOwner());
    732731                _frameName.setText(getFramesetName() + _number);
    733732                _frameName.resetFrameNamePosition();
     
    782781         *            The owner to use for this Frame.
    783782         */
    784         public void setOwner(String owner)
    785         {
     783        public void setOwner(String owner) {
    786784                _owner = owner;
     785                if (_frameName != null) {
     786                        _frameName.setOwner(owner);
     787                } else {
     788                        if (Browser.DEBUG) {
     789                                System.err.println(" *** Attempted to set owner of Frame when _frameName was null. *** ");
     790                        }
     791                }
    787792        }
    788793
     
    879884
    880885        public void addItem(Item item, boolean recalculate)     {
    881                 if (item == null) { return; }
    882                
    883                 addItem(item, recalculate, getBody(false));
     886                if (item == null) {
     887                        return;
     888                }
     889
     890                // Get the associated encryption label if it has one.  Surrogates use their primaries encryption label.
     891                String encryptionLabel = item.getEncryptionLabel();
    884892                if (item.isSurrogate()) {
    885                         addItem(item, recalculate, getSurrogateBody());
     893                        encryptionLabel = item.getPrimary().getEncryptionLabel();
     894                }
     895               
     896                if (encryptionLabel == null) {
     897                        // If we do not have an encryption label to go off, then we cannot be a surrogate.
     898                        // Add item to body and primaryBody
     899                        addItem(item, recalculate, getBody(false));
     900                        addItem(item, recalculate, getPrimaryBody());
    886901                } else {
    887                         addItem(item, recalculate, getPrimaryBody());
     902                        List<String> accessibleLabelsNames = Label.getAccessibleLabelsNames(getPrimaryBody());
     903                        if (item.isSurrogate() && accessibleLabelsNames.contains(encryptionLabel)) {
     904                                // .. If it is a surrogate and its encryption label is currently active, it needs to be added to surrogateBody only
     905                                // .. This will result in the item disappearing when placed (as it is now accessible in only surrogate mode)
     906                                addItem(item, recalculate, getSurrogateBody());
     907                        } else if (item.isSurrogate() && !accessibleLabelsNames.contains(encryptionLabel)) {
     908                                // .. If it is a surrogate and its encryption label is not currently active, it needs to be added to body and surrogateBody
     909                                // .. This will result in the item being visible on the frame.
     910                                addItem(item, recalculate, getBody(false));
     911                                addItem(item, recalculate, getSurrogateBody());
     912                        } else if (!item.isSurrogate() && accessibleLabelsNames.contains(encryptionLabel)) {
     913                                // .. If it is a primary and its encryption label is currently active, it needs to be added to body and primaryBody
     914                                // .. This will result in the item being visible on the frame.
     915                                addItem(item, recalculate, getBody(false));
     916                                addItem(item, recalculate, getPrimaryBody());
     917//                              for (Item surrogate: item.getSurrogates()) {
     918//                                      surrogate.invalidateBounds(); // Should Item::invalidateBounds invalidate its surrogates bounds as well?
     919//                              }
     920                        } else { // !item.isSurrogate() && !accessibleLabelsNames.contains(encryptionLabel)
     921                                // .. If it is a primary and its encryption label is not currently active, it needs to be added to primaryBody only
     922                                // .. This will result in the item disappearing when placed (as the current surrogate mode does not contain its label)
     923                                // Note from Bryce: I am not sure this else condition will ever run, but it will not hurt.
     924                                addItem(item, recalculate, getPrimaryBody());
     925//                              for (Item surrogate: item.getSurrogates()) {
     926//                                      surrogate.invalidateBounds();
     927//                              }
     928                        }
    888929                }
    889930        }
     
    26992740
    27002741        public Collection<Item> getAllItems() {
    2701                 ItemsList allItems = new ItemsList(getBody(true));
     2742                Collection<Item> allItems = getBody(true).cloneList();
    27022743               
    27032744                allItems.addAll(_overlayItems);
    27042745                allItems.addAll(_vectorItems);
    2705                 return allItems.underlying();
     2746                return allItems;
    27062747        }
    27072748
     
    28832924       
    28842925        public Collection<Item> getBodyItemsWithInsufficientPermissions() {
    2885                 return _bodyHiddenDueToPermissions.underlying();
     2926                return _bodyHiddenDueToPermissions.cloneList();
    28862927        }
    28872928       
     
    30743115         */
    30753116        private List<Item> getAllFrameItemsRaw() {
    3076                 Collection<Item> primaries = getPrimaryBody().underlying();
    3077                 Collection<Item> surrogateBody = getSurrogateBody().underlying();
     3117                List<Item> primaries = getPrimaryBody().cloneList();
     3118                List<Item> surrogateBody = getSurrogateBody().cloneList();
    30783119                primaries.addAll(surrogateBody);
    30793120                List<Item> allFrameItems = primaries.stream().distinct().collect(Collectors.toList());
Note: See TracChangeset for help on using the changeset viewer.