]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/ModificationAdapter.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / ModificationAdapter.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.diagram.synchronization;\r
13 \r
14 import org.simantics.db.WriteGraph;\r
15 \r
16 /**\r
17  * @author Tuukka Lehtonen\r
18  */\r
19 public class ModificationAdapter implements IModification {\r
20 \r
21     public static final Double HIGH_PRIORITY                = 1d;\r
22 \r
23     public static final Double REMOVE_EDGE_PRIORITY         = 2d;\r
24     public static final Double REMOVE_BRANCH_PRIORITY       = 3d;\r
25     public static final Double REMOVE_CONNECTION_PRIORITY   = 4d;\r
26     public static final Double REMOVE_NODE_PRIORITY         = 5d;\r
27 \r
28     public static final Double ADD_NODE_PRIORITY            = 6d;\r
29     public static final Double ADD_CONNECTION_PRIORITY      = 7d;\r
30     public static final Double ADD_BRANCH_PRIORITY          = 8d;\r
31     public static final Double ADD_EDGE_PRIORITY            = 9d;\r
32     public static final Double SET_CONNECTION_TYPE_PRIORITY = 9.5d;\r
33 \r
34     public static final Double LOW_PRIORITY                 = 10d;\r
35 \r
36     final Double priority;\r
37 \r
38     Throwable exception;\r
39     boolean complete = false;\r
40     protected ModificationAdapter(Double priority) {\r
41         assert priority != null;\r
42         this.priority = priority;\r
43     }\r
44     @Override\r
45     public boolean isComplete() {\r
46         return complete;\r
47     }\r
48     @Override\r
49     public void markComplete() {\r
50         this.complete = true;\r
51     }\r
52     @Override\r
53     public void perform(WriteGraph g) throws Exception {\r
54     }\r
55     @Override\r
56     public void completed() {\r
57     }\r
58     @Override\r
59     public Throwable getException() {\r
60         return exception;\r
61     }\r
62     @Override\r
63     public void setException(Throwable t) {\r
64         this.exception = t;\r
65     }\r
66     //@Override\r
67     //public String toString() {\r
68     //    return getClass().getSimpleName();\r
69     //}\r
70     @Override\r
71     public Double getPriority() {\r
72         return priority;\r
73     }\r
74     @Override\r
75     public int compareTo(IModification arg0) {\r
76         return priority.compareTo(arg0.getPriority());\r
77     }\r
78     @Override\r
79     public String toString() {\r
80         return getClass().getSimpleName() + "$" + System.identityHashCode(this);\r
81     }\r
82 }