]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/internal/DebugPolicy.java
Fix diagram profiles to work with latest DB changes
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / internal / DebugPolicy.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.internal;
13
14 import org.eclipse.core.runtime.Platform;
15 import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;
16 import org.simantics.diagram.synchronization.IModifiableSynchronizationContext;
17
18 /**
19  * @author Tuukka Lehtonen
20  */
21 public final class DebugPolicy {
22
23     public static boolean DEBUG = false;
24
25     public static boolean DEBUG_GRAPH_WRITEBACK               = false;
26     public static boolean DEBUG_GRAPH_WRITEBACK_MODIFICATION  = false;
27
28     public static boolean DEBUG_TERMINAL_SEARCH               = false;
29
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;
36
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;
40
41     public static boolean DEBUG_EDGE_LISTENER                 = false;
42
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;
51
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;
56
57     /**
58      * Enables tracing of
59      * {@link IModifiableSynchronizationContext#set(org.simantics.utils.datastructures.hints.IHintContext.Key, Object)}
60      * operations.
61      */
62     public static boolean DEBUG_SYNC_CONTEXT                 = false;
63
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;
68
69     public static boolean DEBUG_RELATIONSHIP                 = false;
70     public static boolean DEBUG_GET_RELATIONSHIP             = false;
71
72     public static boolean DEBUG_LAYERS                       = false;
73
74     public static boolean DEBUG_MUTATOR                      = false;
75     public static boolean DEBUG_MUTATOR_COMMIT               = false;
76
77     public static boolean DEBUG_WRITE_TRANSACTIONS           = false;
78
79     /**
80      * Enables default copy paste handler debug output.
81      */
82     public static boolean DEBUG_COPY_PASTE                   = false;
83
84     /**
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.
90      */
91     public static boolean DISABLE_DIAGRAM_UPDATES            = false;
92
93     /**
94      * Indicates whether certain performance timings are performed and the
95      * results printed out.
96      */
97     public static boolean PERFORM_TIMING                     = false;
98
99     static {
100         if (Activator.getDefault().isDebugging()) {
101             DEBUG = true;
102             String sTrue = Boolean.TRUE.toString();
103
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$
106
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$
117
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$
120
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$
127
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$
133
134             DEBUG_SYNC_CONTEXT = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/context")); //$NON-NLS-1$
135
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$
140
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$
143
144             DEBUG_LAYERS = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/layers")); //$NON-NLS-1$
145
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$
148
149             DEBUG_WRITE_TRANSACTIONS = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/transactions/write")); //$NON-NLS-1$
150
151             DEBUG_COPY_PASTE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/copyPaste")); //$NON-NLS-1$
152
153             //--
154
155             DISABLE_DIAGRAM_UPDATES = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/control/update/diagram/disable")); //$NON-NLS-1$
156
157             //--
158
159             PERFORM_TIMING = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/perf/generalDiagramTiming")); //$NON-NLS-1$
160         }
161     }
162
163     private static double parseDouble(String value, double defaultValue) {
164         if (value == null)
165             return defaultValue;
166         try {
167             return Double.parseDouble(value);
168         } catch (NumberFormatException e) {
169             return defaultValue;
170         }
171     }
172
173 }