--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.diagram.internal;\r
+\r
+import org.eclipse.core.runtime.Platform;\r
+import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;\r
+import org.simantics.diagram.synchronization.IModifiableSynchronizationContext;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public final class DebugPolicy {\r
+\r
+ public static boolean DEBUG = false;\r
+\r
+ public static boolean DEBUG_GRAPH_WRITEBACK = false;\r
+ public static boolean DEBUG_GRAPH_WRITEBACK_MODIFICATION = false;\r
+\r
+ public static boolean DEBUG_TERMINAL_SEARCH = false;\r
+\r
+ public static boolean DEBUG_LOAD = false;\r
+ public static boolean DEBUG_NODE_LOAD = false;\r
+ public static boolean DEBUG_CONNECTION_LOAD = false;\r
+ public static boolean DEBUG_EDGE_LOAD = false;\r
+ public static boolean DEBUG_CONNECTION_VISUALS_LOAD = false;\r
+ public static boolean DEBUG_TRANSFORM_LOAD = false;\r
+\r
+ public static double DETERMINANT_LIMIT_HIGH = 1e24;\r
+ public static double DETERMINANT_LIMIT_LOW = 1e-24;\r
+ public static double TRANSLATION_LIMIT_HIGH = 1e32;\r
+\r
+ public static boolean DEBUG_EDGE_LISTENER = false;\r
+\r
+ public static boolean DEBUG_GENERAL_ELEMENT_UPDATE = false;\r
+ public static boolean DEBUG_GENERAL_ELEMENT_UPDATE_DETAIL = false;\r
+ public static boolean DEBUG_GRAPH_UPDATE = false;\r
+ public static boolean DEBUG_DIAGRAM_UPDATE = false;\r
+ public static boolean DEBUG_DIAGRAM_UPDATE_DETAIL = false;\r
+ public static boolean DEBUG_NODE_UPDATE = false;\r
+ public static boolean DEBUG_CONNECTION_UPDATE = false;\r
+ public static boolean DEBUG_EDGE_UPDATE = false;\r
+\r
+ public static boolean DEBUG_LISTENER_BASE = false;\r
+ public static boolean DEBUG_DIAGRAM_LISTENER = false;\r
+ public static boolean DEBUG_NODE_LISTENER = false;\r
+ public static boolean DEBUG_CONNECTION_LISTENER = false;\r
+\r
+ /**\r
+ * Enables tracing of\r
+ * {@link IModifiableSynchronizationContext#set(org.simantics.utils.datastructures.hints.IHintContext.Key, Object)}\r
+ * operations.\r
+ */\r
+ public static boolean DEBUG_SYNC_CONTEXT = false;\r
+\r
+ public static boolean DEBUG_STATE = false;\r
+ public static boolean DEBUG_MAPPING = false;\r
+ public static boolean DEBUG_ELEMENT_LIFECYCLE = false;\r
+ public static boolean DEBUG_CONNECTION = false;\r
+\r
+ public static boolean DEBUG_RELATIONSHIP = false;\r
+ public static boolean DEBUG_GET_RELATIONSHIP = false;\r
+\r
+ public static boolean DEBUG_LAYERS = false;\r
+\r
+ public static boolean DEBUG_MUTATOR = false;\r
+ public static boolean DEBUG_MUTATOR_COMMIT = false;\r
+\r
+ public static boolean DEBUG_WRITE_TRANSACTIONS = false;\r
+\r
+ /**\r
+ * Enables default copy paste handler debug output.\r
+ */\r
+ public static boolean DEBUG_COPY_PASTE = false;\r
+\r
+ /**\r
+ * This will disable all node/edge/diagram content query listeners from\r
+ * performing updates. Maybe useful for debugging since\r
+ * {@link GraphToDiagramSynchronizer} will only load the initial diagram\r
+ * contents and process updates to those elements, but will not process\r
+ * updates to the diagram structure.\r
+ */\r
+ public static boolean DISABLE_DIAGRAM_UPDATES = false;\r
+\r
+ /**\r
+ * Indicates whether certain performance timings are performed and the\r
+ * results printed out.\r
+ */\r
+ public static boolean PERFORM_TIMING = false;\r
+\r
+ static {\r
+ if (Activator.getDefault().isDebugging()) {\r
+ DEBUG = true;\r
+ String sTrue = Boolean.TRUE.toString();\r
+\r
+ DEBUG_GRAPH_WRITEBACK = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/graphWriteback")); //$NON-NLS-1$\r
+ DEBUG_GRAPH_WRITEBACK_MODIFICATION = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/graphWriteback/modifications")); //$NON-NLS-1$\r
+\r
+ DEBUG_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load")); //$NON-NLS-1$\r
+ DEBUG_NODE_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/node")); //$NON-NLS-1$\r
+ DEBUG_CONNECTION_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/connection")); //$NON-NLS-1$\r
+ DEBUG_EDGE_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/edge")); //$NON-NLS-1$\r
+ DEBUG_CONNECTION_VISUALS_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/connectionVisuals")); //$NON-NLS-1$\r
+ DEBUG_TERMINAL_SEARCH = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/terminalSearch")); //$NON-NLS-1$\r
+ DEBUG_TRANSFORM_LOAD = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform")); //$NON-NLS-1$\r
+ DETERMINANT_LIMIT_HIGH = parseDouble(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform/determinanLimitHigh"), DETERMINANT_LIMIT_HIGH); //$NON-NLS-1$\r
+ DETERMINANT_LIMIT_LOW = parseDouble(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform/determinantLimitLow"), DETERMINANT_LIMIT_LOW); //$NON-NLS-1$\r
+ TRANSLATION_LIMIT_HIGH = parseDouble(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/load/transform/translationLimitHigh"), TRANSLATION_LIMIT_HIGH); //$NON-NLS-1$\r
+\r
+ DEBUG_GENERAL_ELEMENT_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/generalElementUpdate")); //$NON-NLS-1$\r
+ DEBUG_GENERAL_ELEMENT_UPDATE_DETAIL = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/generalElementUpdate/detail")); //$NON-NLS-1$\r
+\r
+ DEBUG_GRAPH_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update")); //$NON-NLS-1$\r
+ DEBUG_DIAGRAM_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/diagram")); //$NON-NLS-1$\r
+ DEBUG_DIAGRAM_UPDATE_DETAIL = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/diagram/detail")); //$NON-NLS-1$\r
+ DEBUG_NODE_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/node")); //$NON-NLS-1$\r
+ DEBUG_CONNECTION_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/connection")); //$NON-NLS-1$\r
+ DEBUG_EDGE_UPDATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/update/edge")); //$NON-NLS-1$\r
+\r
+ DEBUG_LISTENER_BASE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener")); //$NON-NLS-1$\r
+ DEBUG_DIAGRAM_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/diagram")); //$NON-NLS-1$\r
+ DEBUG_NODE_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/node")); //$NON-NLS-1$\r
+ DEBUG_CONNECTION_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/connection")); //$NON-NLS-1$\r
+ DEBUG_EDGE_LISTENER = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/listener/edge")); //$NON-NLS-1$\r
+\r
+ DEBUG_SYNC_CONTEXT = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/context")); //$NON-NLS-1$\r
+\r
+ DEBUG_STATE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/state")); //$NON-NLS-1$\r
+ DEBUG_MAPPING = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/mapping")); //$NON-NLS-1$\r
+ DEBUG_ELEMENT_LIFECYCLE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/elementLifecycle")); //$NON-NLS-1$\r
+ DEBUG_CONNECTION = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/topology/connection")); //$NON-NLS-1$\r
+\r
+ DEBUG_RELATIONSHIP = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/relationship")); //$NON-NLS-1$\r
+ DEBUG_GET_RELATIONSHIP = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/relationship/get")); //$NON-NLS-1$\r
+\r
+ DEBUG_LAYERS = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/layers")); //$NON-NLS-1$\r
+\r
+ DEBUG_MUTATOR = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/mutator")); //$NON-NLS-1$\r
+ DEBUG_MUTATOR_COMMIT = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/mutator/commit")); //$NON-NLS-1$\r
+\r
+ DEBUG_WRITE_TRANSACTIONS = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/synchronizer/transactions/write")); //$NON-NLS-1$\r
+\r
+ DEBUG_COPY_PASTE = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/debug/copyPaste")); //$NON-NLS-1$\r
+\r
+ //--\r
+\r
+ DISABLE_DIAGRAM_UPDATES = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/control/update/diagram/disable")); //$NON-NLS-1$\r
+\r
+ //--\r
+\r
+ PERFORM_TIMING = sTrue.equalsIgnoreCase(Platform.getDebugOption(Activator.PLUGIN_ID + "/perf/generalDiagramTiming")); //$NON-NLS-1$\r
+ }\r
+ }\r
+\r
+ private static double parseDouble(String value, double defaultValue) {\r
+ if (value == null)\r
+ return defaultValue;\r
+ try {\r
+ return Double.parseDouble(value);\r
+ } catch (NumberFormatException e) {\r
+ return defaultValue;\r
+ }\r
+ }\r
+\r
+}\r