]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/ModificationAdapter.java
Some enhancements to GraphLayer-related utilities for Diagram layers
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / ModificationAdapter.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 org.simantics.db.WriteGraph;
15
16 /**
17  * @author Tuukka Lehtonen
18  */
19 public class ModificationAdapter implements IModification {
20
21     public static final Double HIGH_PRIORITY                = 1d;
22
23     public static final Double REMOVE_EDGE_PRIORITY         = 2d;
24     public static final Double REMOVE_BRANCH_PRIORITY       = 3d;
25     public static final Double REMOVE_CONNECTION_PRIORITY   = 4d;
26     public static final Double REMOVE_NODE_PRIORITY         = 5d;
27
28     public static final Double ADD_NODE_PRIORITY            = 6d;
29     public static final Double ADD_CONNECTION_PRIORITY      = 7d;
30     public static final Double ADD_BRANCH_PRIORITY          = 8d;
31     public static final Double ADD_EDGE_PRIORITY            = 9d;
32     public static final Double SET_CONNECTION_TYPE_PRIORITY = 9.5d;
33
34     public static final Double LOW_PRIORITY                 = 10d;
35
36     final Double priority;
37
38     Throwable exception;
39     boolean complete = false;
40     protected ModificationAdapter(Double priority) {
41         assert priority != null;
42         this.priority = priority;
43     }
44     @Override
45     public boolean isComplete() {
46         return complete;
47     }
48     @Override
49     public void markComplete() {
50         this.complete = true;
51     }
52     @Override
53     public void perform(WriteGraph g) throws Exception {
54     }
55     @Override
56     public void completed() {
57     }
58     @Override
59     public Throwable getException() {
60         return exception;
61     }
62     @Override
63     public void setException(Throwable t) {
64         this.exception = t;
65     }
66     //@Override
67     //public String toString() {
68     //    return getClass().getSimpleName();
69     //}
70     @Override
71     public Double getPriority() {
72         return priority;
73     }
74     @Override
75     public int compareTo(IModification arg0) {
76         return priority.compareTo(arg0.getPriority());
77     }
78     @Override
79     public String toString() {
80         return getClass().getSimpleName() + "$" + System.identityHashCode(this);
81     }
82 }