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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.diagram.synchronization;
\r
14 import org.simantics.db.WriteGraph;
\r
17 * @author Tuukka Lehtonen
\r
19 public class ModificationAdapter implements IModification {
\r
21 public static final Double HIGH_PRIORITY = 1d;
\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
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
34 public static final Double LOW_PRIORITY = 10d;
\r
36 final Double priority;
\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
45 public boolean isComplete() {
\r
49 public void markComplete() {
\r
50 this.complete = true;
\r
53 public void perform(WriteGraph g) throws Exception {
\r
56 public void completed() {
\r
59 public Throwable getException() {
\r
63 public void setException(Throwable t) {
\r
67 //public String toString() {
\r
68 // return getClass().getSimpleName();
\r
71 public Double getPriority() {
\r
75 public int compareTo(IModification arg0) {
\r
76 return priority.compareTo(arg0.getPriority());
\r
79 public String toString() {
\r
80 return getClass().getSimpleName() + "$" + System.identityHashCode(this);
\r