Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 24aea1be26c0e9c7193dfee3d8dcd5df7a07874e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*****************************************************************************
 * Copyright (c) 2012 CEA LIST.
 *
 *    
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Ansgar Radermacher (CEA LIST) - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.services.tracepoints;

import org.eclipse.core.resources.IMarker;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.infra.services.decoration.IDecorationSpecificFunctions;
import org.eclipse.papyrus.infra.services.decoration.util.Decoration.PreferedPosition;
import org.eclipse.papyrus.infra.services.decoration.util.IPapyrusDecoration;
import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker;


public class TraceFunctions implements IDecorationSpecificFunctions {

	public static final String activeBreakpoint16 = "icons/etool16/brkp_16x16.gif"; //$NON-NLS-1$

	public static final String inActiveBreakpoint16 = "icons/etool16/brkpd_16x16.gif"; //$NON-NLS-1$

	public static final String activeTracepoint16 = "icons/etool16/trcp_16x16.gif"; //$NON-NLS-1$

	public static final String inActiveTracepoint16 = "icons/etool16/trcpd_16x16.gif"; //$NON-NLS-1$

	public static final String activeBreakpoint9 = "icons/etool16/brkp_9x9.gif"; //$NON-NLS-1$

	public static final String inActiveBreakpoint9 = "icons/etool16/brkpd_9x9.gif"; //$NON-NLS-1$

	public static final String activeTracepoint11 = "icons/etool16/trcp_11x12.gif"; //$NON-NLS-1$

	public static final String inActiveTracepoint11 = "icons/etool16/trcp_11x12.gif"; //$NON-NLS-1$

	/**
	 * Return the image descriptor associated with a trace or breakpoint marker
	 */
	public ImageDescriptor getImageDescriptorForGE(IPapyrusMarker marker) {


		org.eclipse.papyrus.infra.widgets.Activator widgetsActivator =
			org.eclipse.papyrus.infra.widgets.Activator.getDefault();
		ImageDescriptor overlay = null;
		boolean isActive = marker.getAttribute(TracepointConstants.isActive, false);
		boolean isTracepoint = marker.getAttribute(TracepointConstants.isTracepoint, false);
		if(isTracepoint) {
			overlay = isActive ?
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeTracepoint16) :
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveTracepoint16);
		}
		else {
			overlay = isActive ?
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeBreakpoint16) :
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveBreakpoint16);
		}

		return overlay;
	}

	/**
	 * Return the image descriptor associated with a trace or breakpoint marker
	 */
	public ImageDescriptor getImageDescriptorForME(IPapyrusMarker marker) {
		org.eclipse.papyrus.infra.widgets.Activator widgetsActivator =
			org.eclipse.papyrus.infra.widgets.Activator.getDefault();
		ImageDescriptor overlay = null;
		boolean isActive = marker.getAttribute(TracepointConstants.isActive, false);
		boolean isTracepoint = marker.getAttribute(TracepointConstants.isTracepoint, false);
		if(isTracepoint) {
			overlay = isActive ?
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeTracepoint11) :
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveTracepoint11);
		}
		else {
			overlay = isActive ?
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, activeBreakpoint9) :
				widgetsActivator.getImageDescriptor(Activator.PLUGIN_ID, inActiveBreakpoint9);
		}

		return overlay;
	}

	public PreferedPosition getPreferedPosition(IPapyrusMarker marker) {
		return PreferedPosition.SOUTH_EAST;
	}

	public String getMessage(IPapyrusMarker marker) {
		boolean isActive = marker.getAttribute(TracepointConstants.isActive, false);
		boolean isTracepoint = marker.getAttribute(TracepointConstants.isTracepoint, false);
		return (isActive ? "active" : "inactive") + " " +   //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
			(isTracepoint ? "trace point" : "break point");  //$NON-NLS-1$//$NON-NLS-2$
	}

	public int getPriority(IMarker marker) {
		return 0; // all markers have same priority (and we should not have multiple markers on the same model element). 
	}

	public IPapyrusDecoration markerPropagation(EList<IPapyrusDecoration> childDecorations) {
		return null;
	}

	public MarkChildren supportsMarkerPropagation() {
		return MarkChildren.NO;
	}

	@Override
	public int getPriority(IPapyrusMarker marker) {
		// TODO Auto-generated method stub
		return 0;
	}
}

Back to the top