1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.internal;
14 import org.eclipse.core.runtime.Platform;
15 import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;
16 import org.simantics.diagram.synchronization.IModifiableSynchronizationContext;
19 * @author Tuukka Lehtonen
21 public final class DebugPolicy {
23 public static boolean DEBUG = false;
25 public static boolean DEBUG_GRAPH_WRITEBACK = false;
26 public static boolean DEBUG_GRAPH_WRITEBACK_MODIFICATION = false;
28 public static boolean DEBUG_TERMINAL_SEARCH = false;
30 public static boolean DEBUG_LOAD = false;
31 public static boolean DEBUG_NODE_LOAD = false;
32 public static boolean DEBUG_CONNECTION_LOAD = false;
33 public static boolean DEBUG_EDGE_LOAD = false;
34 public static boolean DEBUG_CONNECTION_VISUALS_LOAD = false;
35 public static boolean DEBUG_TRANSFORM_LOAD = false;
37 public static double DETERMINANT_LIMIT_HIGH = 1e24;
38 public static double DETERMINANT_LIMIT_LOW = 1e-24;
39 public static double TRANSLATION_LIMIT_HIGH = 1e32;
41 public static boolean DEBUG_EDGE_LISTENER = false;
43 public static boolean DEBUG_GENERAL_ELEMENT_UPDATE = false;
44 public static boolean DEBUG_GENERAL_ELEMENT_UPDATE_DETAIL = false;
45 public static boolean DEBUG_GRAPH_UPDATE = false;
46 public static boolean DEBUG_DIAGRAM_UPDATE = false;
47 public static boolean DEBUG_DIAGRAM_UPDATE_DETAIL = false;
48 public static boolean DEBUG_NODE_UPDATE = false;
49 public static boolean DEBUG_CONNECTION_UPDATE = false;
50 public static boolean DEBUG_EDGE_UPDATE = false;
52 public static boolean DEBUG_LISTENER_BASE = false;
53 public static boolean DEBUG_DIAGRAM_LISTENER = false;
54 public static boolean DEBUG_NODE_LISTENER = false;
55 public static boolean DEBUG_CONNECTION_LISTENER = false;
59 * {@link IModifiableSynchronizationContext#set(org.simantics.utils.datastructures.hints.IHintContext.Key, Object)}
62 public static boolean DEBUG_SYNC_CONTEXT = false;
64 public static boolean DEBUG_STATE = false;
65 public static boolean DEBUG_MAPPING = false;
66 public static boolean DEBUG_ELEMENT_LIFECYCLE = false;
67 public static boolean DEBUG_CONNECTION = false;
69 public static boolean DEBUG_RELATIONSHIP = false;
70 public static boolean DEBUG_GET_RELATIONSHIP = false;
72 public static boolean DEBUG_LAYERS = false;
74 public static boolean DEBUG_MUTATOR = false;
75 public static boolean DEBUG_MUTATOR_COMMIT = false;
77 public static boolean DEBUG_WRITE_TRANSACTIONS = false;
80 * Enables default copy paste handler debug output.
82 public static boolean DEBUG_COPY_PASTE = false;
85 * This will disable all node/edge/diagram content query listeners from
86 * performing updates. Maybe useful for debugging since
87 * {@link GraphToDiagramSynchronizer} will only load the initial diagram
88 * contents and process updates to those elements, but will not process
89 * updates to the diagram structure.
91 public static boolean DISABLE_DIAGRAM_UPDATES = false;
94 * Indicates whether certain performance timings are performed and the
95 * results printed out.
97 public static boolean PERFORM_TIMING = false;
100 if (Activator.getDefault().isDebugging()) {
102 String sTrue = Boolean.TRUE.toString();
104 DEBUG_GRAPH_WRITEBACK = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/graphWriteback")); //$NON-NLS-1$
105 DEBUG_GRAPH_WRITEBACK_MODIFICATION = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/graphWriteback/modifications")); //$NON-NLS-1$
107 DEBUG_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load")); //$NON-NLS-1$
108 DEBUG_NODE_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/node")); //$NON-NLS-1$
109 DEBUG_CONNECTION_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/connection")); //$NON-NLS-1$
110 DEBUG_EDGE_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/edge")); //$NON-NLS-1$
111 DEBUG_CONNECTION_VISUALS_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/connectionVisuals")); //$NON-NLS-1$
112 DEBUG_TERMINAL_SEARCH = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/terminalSearch")); //$NON-NLS-1$
113 DEBUG_TRANSFORM_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform")); //$NON-NLS-1$
114 DETERMINANT_LIMIT_HIGH = parseDouble(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform/determinanLimitHigh"), DETERMINANT_LIMIT_HIGH); //$NON-NLS-1$
115 DETERMINANT_LIMIT_LOW = parseDouble(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform/determinantLimitLow"), DETERMINANT_LIMIT_LOW); //$NON-NLS-1$
116 TRANSLATION_LIMIT_HIGH = parseDouble(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform/translationLimitHigh"), TRANSLATION_LIMIT_HIGH); //$NON-NLS-1$
118 DEBUG_GENERAL_ELEMENT_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/generalElementUpdate")); //$NON-NLS-1$
119 DEBUG_GENERAL_ELEMENT_UPDATE_DETAIL = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/generalElementUpdate/detail")); //$NON-NLS-1$
121 DEBUG_GRAPH_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update")); //$NON-NLS-1$
122 DEBUG_DIAGRAM_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/diagram")); //$NON-NLS-1$
123 DEBUG_DIAGRAM_UPDATE_DETAIL = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/diagram/detail")); //$NON-NLS-1$
124 DEBUG_NODE_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/node")); //$NON-NLS-1$
125 DEBUG_CONNECTION_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/connection")); //$NON-NLS-1$
126 DEBUG_EDGE_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/edge")); //$NON-NLS-1$
128 DEBUG_LISTENER_BASE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener")); //$NON-NLS-1$
129 DEBUG_DIAGRAM_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/diagram")); //$NON-NLS-1$
130 DEBUG_NODE_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/node")); //$NON-NLS-1$
131 DEBUG_CONNECTION_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/connection")); //$NON-NLS-1$
132 DEBUG_EDGE_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/edge")); //$NON-NLS-1$
134 DEBUG_SYNC_CONTEXT = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/context")); //$NON-NLS-1$
136 DEBUG_STATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/state")); //$NON-NLS-1$
137 DEBUG_MAPPING = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/mapping")); //$NON-NLS-1$
138 DEBUG_ELEMENT_LIFECYCLE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/elementLifecycle")); //$NON-NLS-1$
139 DEBUG_CONNECTION = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/topology/connection")); //$NON-NLS-1$
141 DEBUG_RELATIONSHIP = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/relationship")); //$NON-NLS-1$
142 DEBUG_GET_RELATIONSHIP = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/relationship/get")); //$NON-NLS-1$
144 DEBUG_LAYERS = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/layers")); //$NON-NLS-1$
146 DEBUG_MUTATOR = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/mutator")); //$NON-NLS-1$
147 DEBUG_MUTATOR_COMMIT = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/mutator/commit")); //$NON-NLS-1$
149 DEBUG_WRITE_TRANSACTIONS = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/transactions/write")); //$NON-NLS-1$
151 DEBUG_COPY_PASTE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/copyPaste")); //$NON-NLS-1$
155 DISABLE_DIAGRAM_UPDATES = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/control/update/diagram/disable")); //$NON-NLS-1$
159 PERFORM_TIMING = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/perf/generalDiagramTiming")); //$NON-NLS-1$
163 private static double parseDouble(String value, double defaultValue) {
167 return Double.parseDouble(value);
168 } catch (NumberFormatException e) {