/** * The properties are copied only the first time, in this way we can save only the layers * effectively modified from the original one */ @Override public void putOriginalPropertiesInCache(AbstractMementoOriginalProperties memento) { boolean treeInitialized = (Boolean) Registry.get(UserSessionEnum.TREE_LOADED.name()); if (treeInitialized) { if (memento != null && !this.modifiedLayersMap.containsKey(memento.getRefBaseElement())) { this.modifiedLayersMap.put(memento.getRefBaseElement(), memento); if (super.peek() == null) { this.observable.setChanged(); this.observable.notifyObservers(LayerEvents.SAVE_CACHE_NOT_EMPTY); /*System.out.println("Event SAVE_CACHE_NOT_EMPTY notified to " + this.observable.countObservers() + " observers");*/ } } } }
@Override public boolean add(IMemento<ISave> memento) { boolean treeInitialized = (Boolean) Registry.get(UserSessionEnum.TREE_LOADED.name()); boolean condition = false; if (treeInitialized) { condition = super.add(memento); if (condition && super.size() == 1) { this.observable.setChanged(); this.observable.notifyObservers(LayerEvents.SAVE_CACHE_NOT_EMPTY); /*System.out.println("Event SAVE_CACHE_NOT_EMPTY notified to " + this.observable.countObservers() + " observers");*/ } // System.out.println("GPLayerSaveCache: added " + memento.getClass().getName()); } return condition; }