]> gerrit.simantics Code Review - simantics/interop.git/blob - org.simantics.interop.update/src/org/simantics/interop/update/model/ModelUpdate.java
Process changes in smaller chunks
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / ModelUpdate.java
1 package org.simantics.interop.update.model;
2
3 import java.util.ArrayDeque;
4 import java.util.ArrayList;
5 import java.util.Collections;
6 import java.util.Deque;
7 import java.util.List;
8 import java.util.Map.Entry;
9
10 import org.eclipse.core.runtime.IProgressMonitor;
11 import org.eclipse.core.runtime.NullProgressMonitor;
12 import org.simantics.Simantics;
13 import org.simantics.db.ReadGraph;
14 import org.simantics.db.Resource;
15 import org.simantics.db.Session;
16 import org.simantics.db.Statement;
17 import org.simantics.db.VirtualGraph;
18 import org.simantics.db.WriteGraph;
19 import org.simantics.db.common.request.ReadRequest;
20 import org.simantics.db.common.request.WriteRequest;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.db.layer0.util.Layer0Utils;
23 import org.simantics.db.request.Read;
24 import org.simantics.interop.test.GraphChanges;
25 import org.simantics.interop.test.GraphChanges.Modification;
26 import org.simantics.interop.test.GraphComparator;
27 import org.simantics.utils.datastructures.Pair;
28
29 public abstract class ModelUpdate {
30         
31         private Resource oldModel;      // old model that is going to be updated (User modified model)
32         private Resource newModel;      // new model that contains the updates   (New design model)
33         private Resource originalModel; // original model (optional) that is used for detecting and retaining user made changes (Old design model)
34         
35         private GraphChanges changes;   // changes between old /new
36         private UpdateTree updateTree;
37         private UpdateList updateList;
38         
39         private GraphChanges changes2;  // changes between original / old
40         private UpdateTree updateTree2;
41         private UpdateList updateList2;
42         
43         private GraphChanges changes3;  // changes between original / new
44         private UpdateTree updateTree3;
45         private UpdateList updateList3;
46         
47         private UpdateNode3 updateNode3;
48         
49         private List<ChangeFilter> filters = new ArrayList<ChangeFilter>();
50         private List<ChangeFilter2> userFilters = new ArrayList<ChangeFilter2>();
51         
52         boolean init = false;
53         private int chunkSize = -1;
54         
55         public void setInput(Resource oldModel, Resource newModel) throws DatabaseException {
56                 setInput(oldModel, newModel, null, false);
57         }
58         
59         /**
60          * Initialises the ModelUpdate with given input
61          * @param oldModel the model that is going to be updated (User modified model)
62          * @param newModel the model containing updates (New design model)
63          * @param originalModel the model that is used for detecting and retaining user made changes (Old design model). Parameter can be null.
64          * @param newDistinct when originalModel is given, additions to the old and the new model (when compared to the original model) are forced to be distinct. 
65          * @throws DatabaseException
66          */
67         public void setInput(Resource oldModel, Resource newModel, Resource originalModel, boolean newDistinct) throws DatabaseException{
68                 this.setInput(oldModel, newModel, originalModel, newDistinct, null);
69         }
70         public void setInput(Resource oldModel, Resource newModel, Resource originalModel, boolean newDistinct, IProgressMonitor monitor) throws DatabaseException{
71                 
72                 this.oldModel = oldModel;
73                 this.newModel = newModel;
74                 this.originalModel = originalModel;
75                 
76                 if (monitor == null)
77                         monitor = new NullProgressMonitor();
78 //              addFilters(filters);
79                 if (originalModel != null) {
80                         // tree way comparison
81                         // compare the original and the old model
82                         Pair<GraphComparator,String> result2 = getChanges(originalModel, oldModel);
83                         GraphComparator comparator2  = result2.first;
84                         if (result2.second != null)
85                                 showWarning(result2.second);
86                         comparator2.test(getSession(), monitor);
87                         changes2 = comparator2.getChanges();
88                         comparator2.dispose();
89                         if (monitor.isCanceled()) {
90                                 dispose();
91                                 return;
92                         }
93                         changes2 = getSession().syncRequest(createFilterRead(changes2, filters));
94                         Pair<UpdateTree, UpdateList> chg2 = createChangeObjects(changes2, null);
95                         updateTree2 = chg2.first;
96                         updateList2 = chg2.second;
97                         
98                         // compare the original and the new model
99                         Pair<GraphComparator,String> result3 = getChanges(originalModel,newModel);
100                         GraphComparator comparator3  = result3.first;
101                         if (result3.second != null)
102                                 showWarning(result3.second);
103                         comparator3.test(getSession(), monitor);
104                         changes3 = comparator3.getChanges();
105                         comparator2.dispose();
106                         changes3 = getSession().syncRequest(createFilterRead(changes3, filters));
107                 }
108                 if (monitor.isCanceled()) {
109                         dispose();
110                         return;
111                 }
112                 
113                 Pair<GraphComparator,String> result = getChanges(oldModel,newModel);
114                 GraphComparator comparator  = result.first;
115                 if (result.second != null)
116                         showWarning(result.second);
117                 if (originalModel != null) {
118                         // three-way comparison: use change information to configure
119                         // the comparison between the old and the new model.
120                         
121                         // 1. map comparable resources
122                         for (Entry<Resource, Resource> origToOld : changes2.getComparable().getEntries()) {
123                                 Resource oldR = origToOld.getValue();
124                                 Resource newR = changes3.getComparable().getRight(origToOld.getKey());
125                                 if (newR != null) {
126                                         comparator.addComparableResources(oldR, newR);
127                                 }
128                         }
129                         // 2. mark removed resources as distinct, so that comparison does not pair them
130                         for (Statement s : changes2.getDeletions()) {
131                                 if (changes3.getComparable().containsLeft(s.getObject()))
132                                         comparator.addNonMatchedRight(changes3.getComparable().getRight(s.getObject()));
133                         }
134                         
135                         for (Statement s : changes3.getDeletions()) {
136                                 if (changes2.getComparable().containsLeft(s.getObject()))
137                                         comparator.addNonMatchedLeft(changes2.getComparable().getRight(s.getObject()));
138                         }
139                         if (newDistinct) {
140                                 // 3. mark added resources as distinct, so that comparison does not pair them
141                                 for (Statement s : changes2.getAdditions()) {
142                                         comparator.addNonMatchedLeft(s.getObject());
143                                 }
144                                 
145                                 for (Statement s : changes3.getAdditions()) {
146                                         comparator.addNonMatchedRight(s.getObject());
147                                 }
148                         }
149                 }
150                 if (monitor.isCanceled()) {
151                         dispose();
152                         return;
153                 }
154                 comparator.test(getSession(), monitor);
155                 monitor.setTaskName("Processing changes...");
156                 monitor.subTask("");
157                 changes = comparator.getChanges();
158                 comparator.dispose();
159                 changes = getSession().syncRequest(createFilterRead(changes, filters));
160                 Pair<UpdateTree, UpdateList> chg = createChangeObjects(changes, monitor);
161                 if (chg == null) {
162                         dispose();
163                         return;
164                 }
165         updateTree = chg.first;
166         updateList = chg.second;
167                 if (userFilters.size() != 0) {
168                         refreshUserFilters();
169                 }
170                 
171                 
172                 if (originalModel != null) {
173                         defaultSelections();
174                 }
175                 init = true;
176         }
177         
178         public void setInput(Resource oldModel, Resource newModel, GraphChanges changes, IProgressMonitor monitor) throws DatabaseException{
179                 if (!oldModel.equals(changes.getResource1()) ||
180                         !newModel.equals(changes.getResource2())) {
181                         throw new DatabaseException("GraphChanges does not match input models");
182                 }
183                 this.changes = getSession().syncRequest(createFilterRead(changes, filters));
184                 Pair<UpdateTree, UpdateList> chg = createChangeObjects(changes, monitor);
185                 if (chg == null) {
186                         dispose();
187                         return;
188                 }
189         updateTree = chg.first;
190         updateList = chg.second;
191                 if (userFilters.size() != 0) {
192                         refreshUserFilters();
193                 }
194                 
195                 
196                 if (originalModel != null) {
197                         defaultSelections();
198                 }
199                 init = true;
200         }
201         
202         public void addFilter(ChangeFilter filter) {
203                 if (init)
204                         throw new IllegalStateException("ModelUpdate has been initialized, adjusting filters is no longer possible.");
205                 filters.add(filter);
206                 
207         }
208         
209         public List<ChangeFilter> getFilters() {
210                 return Collections.unmodifiableList(filters);
211         }
212         
213         /**
214          * Adds an user filter. Use refreshUserFilters() to apply the changes.
215          * @param filter
216          */
217         public void addUserFilter(ChangeFilter2 filter) {
218                 userFilters.add(filter);
219         }
220         
221         /**
222          * Removes an user filter. Use refreshUserFilters() to apply the changes.
223          * @param filter
224          */
225         public void removeUserFilter(ChangeFilter2 filter) {
226                 userFilters.remove(filter);
227         }
228         
229         /**
230          * Clears user filters.  Use refreshUserFilters() to apply the changes.
231          */
232         public void clearUserFilters() {
233                 userFilters.clear();
234         }
235         
236         public List<ChangeFilter2> getUserFilters() {
237                 return userFilters;
238         }
239         
240         public int getChunkSize() {
241                 return chunkSize;
242         }
243         
244         public void setChunkSize(int chunkSize) {
245                 this.chunkSize = chunkSize;
246         }
247         
248         public void refreshUserFilters() throws DatabaseException{
249                 // use user filters to set visible flags of changes.
250                 // First, set all changes visible.
251                 Deque<UpdateNode> stack = new ArrayDeque<>();
252                 stack.push(updateTree.getRootNode());
253                 while (!stack.isEmpty()) {
254                         UpdateNode n = stack.pop();
255                         n.setVisible(true);
256                         stack.addAll(n.getChildren());
257                 }
258                 for (PropertyChange pc : updateList.getChanges()) {
259                         pc.setVisible(true);
260                 }
261                 if (userFilters.size() > 0) {
262                     if (changes2 != null && changes3 != null) {
263                         getUpdateTree3();
264                     }
265                     getSession().syncRequest(new ReadRequest() {
266                 
267                 @Override
268                 public void run(ReadGraph graph) throws DatabaseException {
269                     for (PropertyChange change : updateList.getChanges()) {
270                         boolean visible = true;
271                         for (ChangeFilter2 filter : userFilters) {
272                             if (!filter.accept(graph, change)) {
273                                 visible = false;
274                                 break;
275                             }
276                         }
277                         change.setVisible(visible);
278                     }
279                     if (updateTree3 != null) {
280                         Deque<UpdateNode3> stack = new ArrayDeque<>();
281                         stack.add(getUpdateNode3());
282                         while (!stack.isEmpty()) {
283                             UpdateNode3 n = stack.pop();
284                             boolean visible = true;
285                             for (ChangeFilter2 filter : userFilters) {
286                                 if (!filter.accept(graph, n)) {
287                                     visible = false;
288                                     break;
289                                 }
290                             }
291                             n.setVisible(visible);
292                             for (UpdateNode3 c : n.getChildren())
293                                 stack.push(c);
294                         }
295                     } else {
296                     
297                         Deque<UpdateNode> stack = new ArrayDeque<>();
298                         stack.add(updateTree.getRootNode());
299                         while (!stack.isEmpty()) {
300                             UpdateNode n = stack.pop();
301                             boolean visible = true;
302                             for (ChangeFilter2 filter : userFilters) {
303                                 if (!filter.accept(graph, n)) {
304                                     visible = false;
305                                     break;
306                                 }
307                             }
308                             n.setVisible(visible);
309                             for (UpdateNode c : n.getChildren())
310                                 stack.push(c);
311                         }
312                     }
313                 }
314             });
315                 }
316         }
317         
318         protected abstract Pair<GraphComparator,String> getChanges(Resource r1, Resource r2)  throws DatabaseException;
319         
320         protected Pair<UpdateTree, UpdateList> createChangeObjects(GraphChanges changes, IProgressMonitor monitor) throws DatabaseException{
321                 if (monitor != null) {
322                         if (monitor.isCanceled())
323                                 return null;
324                         monitor.subTask("Processing structural changes");
325                 }
326                 UpdateTree updateTree = getUpdateTree(changes, monitor);
327                 if (monitor != null) {
328                         if (monitor.isCanceled())
329                                 return null;
330                         monitor.subTask("Processing property changes");
331                 }
332         UpdateList updateList = getUpdateList(changes, monitor);
333         if (monitor != null) {
334                 if (monitor.isCanceled())
335                                 return null;
336                 monitor.subTask("Postprocessing changes");
337         }
338         postProcess(updateTree, updateList);
339         return new Pair<UpdateTree, UpdateList>(updateTree, updateList);
340         }
341         
342         protected abstract UpdateTree getUpdateTree(GraphChanges changes, IProgressMonitor monitor) throws DatabaseException;
343         protected UpdateList getUpdateList(GraphChanges changes, IProgressMonitor monitor) throws DatabaseException {
344                 return new UpdateList(changes, changes.getModifications());
345         }
346         
347
348         protected void postProcess(UpdateTree updateTree, UpdateList updateList) throws DatabaseException{
349             
350         }
351         
352         public Resource getOldModel() {
353                 return oldModel;
354         }
355         
356         public Resource getNewModel() {
357                 return newModel;
358         }
359         
360         public Resource getOriginalModel() {
361                 return originalModel;
362         }
363         
364         public boolean isInit() {
365                 return init;
366         }
367         
368         public GraphChanges getChanges() {
369                 return changes;
370         }
371         public UpdateTree getUpdateTree() {
372                 return updateTree;
373         }
374         public UpdateList getUpdateList() {
375                 return updateList;
376         }
377         public GraphChanges getChanges2() {
378                 return changes2;
379         }
380         
381         public UpdateTree getUpdateTree2() {
382                 return updateTree2;
383         }
384         public UpdateList getUpdateList2() {
385                 return updateList2;
386         }
387         
388         public GraphChanges getChanges3() {
389                 return changes3;
390         }
391         
392         public UpdateTree getUpdateTree3() throws DatabaseException{
393                 if (updateTree3 == null && changes3 != null) {
394                     Pair<UpdateTree, UpdateList> chg3 = createChangeObjects(changes3, null);
395             updateTree3 = chg3.first;
396             updateList3 = chg3.second;
397                 }
398                 return updateTree3;
399         }
400         public UpdateList getUpdateList3() throws DatabaseException {
401                 if (updateList3 == null && changes3 != null) {
402                         Pair<UpdateTree, UpdateList> chg3 = createChangeObjects(changes3, null);
403                         updateTree3 = chg3.first;
404                         updateList3 = chg3.second;
405                 }
406                 return updateList3;
407         }
408         
409         public UpdateNode3 getUpdateNode3() throws DatabaseException {
410             if (updateNode3 == null && changes2 != null && changes3 != null) {
411                 updateNode3 = UpdateNode3.getCombinedTree(this);
412             }
413             return updateNode3;
414         }
415
416         public void applyAll(WriteGraph graph) throws DatabaseException {
417                 List<PropertyChange> list = updateList.getChanges();
418                 apply(graph, list, "Apply all model updates");
419                 
420                 updateTree.getUpdateOps().applyAll(graph);
421         }
422         
423         public void applySelected(WriteGraph graph) throws DatabaseException {
424                 List<PropertyChange> list = new ArrayList<PropertyChange>();
425                 for (PropertyChange mod : updateList.getChanges()) {
426                         if (mod.selected())
427                                 list.add(mod);
428                 }
429                 apply(graph, list, "Apply selected model updates");
430                 
431                 updateTree.getUpdateOps().applySelected(graph);
432         }
433         
434         public void applyAll(Session session, VirtualGraph vg) throws DatabaseException {
435                 List<PropertyChange> list = updateList.getChanges();
436                 apply(session, list, "Apply all model updates", vg);
437                 
438                 updateTree.getUpdateOps().applyAll(session, vg);
439         }
440         
441         public void applySelected(Session session, VirtualGraph vg) throws DatabaseException {
442                 List<PropertyChange> list = new ArrayList<PropertyChange>();
443                 for (PropertyChange mod : updateList.getChanges()) {
444                         if (mod.selected())
445                                 list.add(mod);
446                 }
447                 apply(session, list, "Apply selected model updates", vg);
448                 
449                 updateTree.getUpdateOps().applySelected(session, vg);
450                 
451         }
452         
453         protected void apply(WriteGraph graph, List<PropertyChange> list, String message) throws DatabaseException {
454                 Layer0Utils.addCommentMetadata(graph, message);
455                 graph.markUndoPoint();
456                 for (PropertyChange mod : list) {
457                         mod.apply(graph);
458                 }
459         }
460         
461         protected void apply(Session session, List<PropertyChange> list, String message, VirtualGraph vg) throws DatabaseException {
462                 if (getChunkSize() > 0) {
463                         for (int s = 0; s < list.size(); ) {
464                                 int e = s + getChunkSize();
465                                 if (e > list.size())
466                                         e = list.size();
467                                 List<PropertyChange> subList = updateList.getChanges().subList(e, e);
468                                 if (s == 0) {
469                                         session.syncRequest(new WriteRequest(vg) {
470                                                 public void perform(WriteGraph graph) throws DatabaseException {
471                                                         Layer0Utils.addCommentMetadata(graph, message);
472                                                         graph.markUndoPoint();
473                                                 }
474                                         });
475                                 }
476                                 session.syncRequest(new WriteRequest(vg) {
477                                         
478                                         @Override
479                                         public void perform(WriteGraph graph) throws DatabaseException {
480                                                 for (PropertyChange mod : subList) {
481                                                         mod.apply(graph);
482                                                 }
483                                         }
484                                 });
485                                 s = e;
486                         }
487                 } else {
488                         session.syncRequest(new WriteRequest(vg) {
489                                 
490                                 @Override
491                                 public void perform(WriteGraph graph) throws DatabaseException {
492                                         Layer0Utils.addCommentMetadata(graph, message);
493                                         graph.markUndoPoint();
494                                         for (PropertyChange mod : list) {
495                                                 mod.apply(graph);
496                                         }
497                                 }
498                         });
499                 }
500         }
501         
502         
503         protected Session getSession() {
504                 return Simantics.getSession();
505         }
506         
507         public Read<GraphChanges> createFilterRead(GraphChanges changes, List<ChangeFilter> filters) {
508                 return new FilterChangesRead(changes, filters);
509         }
510         
511         
512         
513         public static class FilterChangesRead implements Read<GraphChanges> {
514                 private GraphChanges changes;
515                 private List<ChangeFilter> filters;
516                 
517                 public FilterChangesRead(GraphChanges changes, List<ChangeFilter> filters) {
518                         this.changes = changes;
519                         this.filters = filters;
520                 }
521                 
522                 @Override
523                 public GraphChanges perform(ReadGraph graph) throws DatabaseException {
524                         return filterChanges(graph, changes);
525                 }
526                 
527                 /**
528                  * Filters changes:
529                  * 1. Changes that are not essential for model update (changes that can be found when the models are exactly the same)
530                  * 2. Runs custom filters for value changes. 
531                  * 
532                  * @param g
533                  * @param changes
534                  * @return
535                  * @throws DatabaseException
536                  */
537                 protected GraphChanges filterChanges(ReadGraph g, GraphChanges changes) throws DatabaseException 
538             {
539                         
540                         List<Modification> modifications = new ArrayList<Modification>();
541                         
542                 for (Modification mod : changes.getModifications()) {
543                         
544                         boolean accept = true;
545                         for (ChangeFilter filter : filters) {
546                                 if (!filter.accept(g, mod)) {
547                                         accept = false;
548                                         break;
549                                 }       
550                         }
551                         if (accept)
552                                 modifications.add(mod);
553                 }
554                 List<Statement> deletions = new ArrayList<Statement>();
555                 for (Statement del : changes.getDeletions()) {
556                 
557                 boolean accept = true;
558                 for (ChangeFilter filter : filters) {
559                     if (!filter.acceptDeletion(g, del)) {
560                         accept = false;
561                         break;
562                     }   
563                 }
564                 if (accept)
565                     deletions.add(del);
566             }
567                 List<Statement> additions = new ArrayList<Statement>();
568             for (Statement del : changes.getAdditions()) {
569                 
570                 boolean accept = true;
571                 for (ChangeFilter filter : filters) {
572                     if (!filter.acceptAddition(g, del)) {
573                         accept = false;
574                         break;
575                     }   
576                 }
577                 if (accept)
578                     additions.add(del);
579             }
580
581                 GraphChanges newChanges =  new GraphChanges(changes.getResource1(),changes.getResource2(),deletions, additions, modifications, changes.getComparable());
582                 return newChanges;
583             }
584         }
585
586         /**
587          * Interface for built-in filters that are used for processing raw change data before forming UpdateTree + UpdateList
588          * @author luukkainen
589          *
590          */
591         public interface ChangeFilter {
592                 public boolean accept(ReadGraph g, Modification change) throws DatabaseException;
593                 public boolean acceptAddition(ReadGraph g, Statement addition) throws DatabaseException;
594                 public boolean acceptDeletion(ReadGraph g, Statement deletion) throws DatabaseException;
595         }
596         
597         /**
598          * Interface for user defined filters. 
599          * 
600          * This filter only affects visible flags.
601          *  
602          * @author luukkainen
603          *
604          */
605         public interface ChangeFilter2 {
606             public boolean accept(ReadGraph g, PropertyChange change) throws DatabaseException;
607             public boolean accept(ReadGraph g, UpdateNode change) throws DatabaseException;
608             public boolean accept(ReadGraph g, UpdateNode3 change) throws DatabaseException;
609         }
610
611         
612         /**
613          * 
614          * Filters floating point value changes (default filter is set filter when the change is less than 1%)  
615          *
616          */
617         protected class FPValueFilter implements ChangeFilter  {
618                 
619                 private double percentage = 0.01;
620                 
621                 public FPValueFilter() {
622                         
623                 }
624                 
625                 public FPValueFilter(double percentage) {
626                         if (percentage < 0.0 || percentage > 1.0)
627                                 throw new IllegalArgumentException("Percentage must be between 0.0 and 1.0.");
628                         this.percentage = percentage;
629                 }
630                 
631                 @Override
632                 public boolean accept(ReadGraph g, Modification change) throws DatabaseException {
633                         //filter floating point values that have less than 1% difference.
634                         if (change.getLeftStm() == null || change.getRightStm() == null)
635                                 return true;
636                         if (!g.hasValue(change.getLeftStm().getObject()) || !g.hasValue(change.getRightStm().getObject()))
637                                 return true;
638                 Object v1 = g.getValue(change.getLeftStm().getObject());
639                 Object v2 = g.getValue(change.getRightStm().getObject());
640                 
641                 if (v1 instanceof Double && v2 instanceof Double) {
642                         double d1 = (Double)v1;
643                         double d2 = (Double)v2;
644                         if (Math.abs(d1-d2) / Math.max(Math.abs(d1), Math.abs(d2)) < percentage)
645                                 return false;
646                 } else if (v1 instanceof Float && v2 instanceof Float) {
647                         float d1 = (Float)v1;
648                         float d2 = (Float)v2;
649                         if (Math.abs(d1-d2) / Math.max(Math.abs(d1), Math.abs(d2)) < percentage)
650                                 return false;
651                 }
652
653                 return true;
654                 }
655                 
656                 @Override
657                 public boolean acceptAddition(ReadGraph g, Statement addition) throws DatabaseException {
658                     return true;
659                 }
660                 
661                 @Override
662                 public boolean acceptDeletion(ReadGraph g, Statement deletion) throws DatabaseException {
663                     return true;
664                 }
665         }
666         
667         public void defaultSelections() {
668                 if (changes3 == null) {
669                         return;
670                 }
671                 // select all changes
672                 for (Entry<Resource, UpdateOp> op : updateTree.getUpdateOps().getResourceMap().entrySet()) {
673                         op.getValue().select(true);
674                 }
675                 
676                 
677                 for (PropertyChange pair : updateList.getChanges()) {
678                         pair.select(true);
679                 }
680                 
681                 // preserve user-made changes (by removing selections)
682                 for (Entry<Resource, UpdateOp> op : updateTree.getUpdateOps().getResourceMap().entrySet()) {
683                         UpdateOp op2 = updateTree2.getUpdateOps().getUpdateOp(op.getKey());
684                         if (op2 == null) {
685                                 if (changes3.getComparable().containsRight(op.getKey())){
686                                         op2 = updateTree2.getUpdateOps().getUpdateOp(changes3.getComparable().getLeft(op.getKey()));
687                                 }
688                         }
689                         if (op2 != null && op.getValue().getClass() == op2.getClass()) {
690                                 op.getValue().select(false);
691                         }
692                 }
693                 
694                 for (PropertyChange pair : updateList.getChanges()) {
695                         if (pair.getFirst() != null) {
696                                 boolean found = false;
697                                 for (PropertyChange pair2 : updateList2.getChanges()) {
698                                         if (pair.getFirst() != null && pair.getFirst().equals(pair2.getSecond())) {
699                                                 found = true;
700                                                 break;
701                                         }
702                                 }
703                                 if (found) {
704                                         pair.select(false);
705                                 }
706                         }
707                 }
708                 
709         }
710         
711         private void showWarning(String string) {
712                 for (WarningListener l : warningListeners)
713                         l.showWarning(this, string);
714         }
715         
716         private List<WarningListener> warningListeners = new ArrayList<>();
717         
718         public static interface WarningListener {
719                 void showWarning(ModelUpdate update, String warning);
720         }
721         
722         public void addListener(WarningListener listener) {
723                 warningListeners.add(listener);
724         }
725         
726         public void removeListener(WarningListener listener) {
727                 warningListeners.remove(listener);
728         }
729         
730         public void dispose() {
731                 changes = null;
732                 changes2 = null;
733                 changes3 = null;
734                 filters = null;
735                 userFilters = null;
736                 updateList = null;
737                 updateList2 = null;
738                 updateList3 = null;
739                 updateTree = null;
740                 updateTree2 = null;
741                 updateTree3 = null;
742                 updateNode3 = null;
743                 init = false;
744         }
745 }