]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/CompositeModification.java
Some enhancements to GraphLayer-related utilities for Diagram layers
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / CompositeModification.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.synchronization;
13
14 import java.util.Collection;
15
16 import org.simantics.db.WriteGraph;
17
18 /**
19  * @author Tuukka Lehtonen
20  */
21 public class CompositeModification extends ModificationAdapter {
22
23     private final Collection<IModification> modifications;
24
25     public CompositeModification(Double priority, Collection<IModification> modifications) {
26         super(priority);
27         this.modifications = modifications;
28     }
29
30     @Override
31     public void perform(WriteGraph g) throws Exception {
32         for (IModification m : modifications) {
33             m.perform(g);
34             m.markComplete();
35         }
36     }
37
38     @Override
39     public void completed() {
40         for (IModification m : modifications) {
41             m.completed();
42         }
43     }
44
45     @Override
46     public String toString() {
47         StringBuilder sb = new StringBuilder();
48         sb.append(getClass().getSimpleName());
49         sb.append('(');
50         sb.append(modifications.size());
51         sb.append(')');
52         sb.append(modifications);
53         return sb.toString();
54     }
55
56 }