blob: fdc1afd34856b9016800286e9129e465ec07ad83 (
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
120
121
|
/*****************************************************************************
* Copyright (c) 2013 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.moka.debug;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.papyrus.moka.Activator;
import org.eclipse.papyrus.moka.MokaConstants;
/**
* An implementation of IDebugElement factorizing methods and properties for
* other debug classes provided by Moka.
*
*/
public abstract class MokaDebugElement extends PlatformObject implements IDebugElement {
/**
* The moka debug target associated with this debug element
*/
protected MokaDebugTarget debugTarget;
/**
* Constructs a new debug element contained in the given moka debug target.
*
* @param target
* Moka debug target
*/
public MokaDebugElement(MokaDebugTarget target) {
this.debugTarget = target;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
*/
public String getModelIdentifier() {
return MokaConstants.MOKA_DEBUG_MODEL_ID;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
*/
public IDebugTarget getDebugTarget() {
return this.debugTarget;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
*/
public ILaunch getLaunch() {
return this.debugTarget.getLaunch();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
if (adapter == IDebugElement.class) {
return this;
}
return super.getAdapter(adapter);
}
/**
* Convenience method for the setting the debug target of this debug element
*
* @param debugTarget
* The debug target for this debug element
*/
public void setDebugTarget(MokaDebugTarget debugTarget) {
this.debugTarget = debugTarget;
}
/**
* Convenience method for aborting execution
*
* @param message
* @param e
* @throws DebugException
*/
protected void abort(String message, Throwable e) throws DebugException {
throw new DebugException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, DebugPlugin.INTERNAL_ERROR, message, e));
}
/**
* Convenience method for firing a debug event to the debug plugin
*
* @param event
* the event to be fired
*/
protected void fireEvent(DebugEvent event) {
DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event });
}
}
|