OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 for (DebugEvent event : events) { | 91 for (DebugEvent event : events) { |
92 if (event.getKind() == DebugEvent.CREATE && event.getSource() instanceof I
Process) { | 92 if (event.getKind() == DebugEvent.CREATE && event.getSource() instanceof I
Process) { |
93 attachConsoleListener((IProcess) event.getSource()); | 93 attachConsoleListener((IProcess) event.getSource()); |
94 } else if (event.getKind() == DebugEvent.TERMINATE | 94 } else if (event.getKind() == DebugEvent.TERMINATE |
95 && event.getSource() instanceof IDebugTarget) { | 95 && event.getSource() instanceof IDebugTarget) { |
96 handleDebugTargetTerminated((IDebugTarget) event.getSource()); | 96 handleDebugTargetTerminated((IDebugTarget) event.getSource()); |
97 } | 97 } |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
| 101 /** |
| 102 * Check if the debugger view has been contributed |
| 103 */ |
| 104 public boolean hasDebuggerView() { |
| 105 IViewDescriptor[] views = DartDebugUIPlugin.getDefault().getWorkbench().getV
iewRegistry().getViews(); |
| 106 for (IViewDescriptor view : views) { |
| 107 if (view.getId().equals(DebuggerView.ID)) { |
| 108 return true; |
| 109 } |
| 110 } |
| 111 return false; |
| 112 } |
| 113 |
101 @Override | 114 @Override |
102 public void launchAdded(ILaunch launch) { | 115 public void launchAdded(ILaunch launch) { |
103 try { | 116 try { |
104 if (launch.getLaunchConfiguration().getType().getIdentifier().startsWith("
com.google") | 117 if (launch.getLaunchConfiguration().getType().getIdentifier().startsWith("
com.google") |
105 && launch.getLaunchMode().equals(ILaunchManager.DEBUG_MODE)) { | 118 && launch.getLaunchMode().equals(ILaunchManager.DEBUG_MODE)) { |
106 // add the suspend trigger listener | 119 // add the suspend trigger listener |
107 ISuspendTrigger trigger = (ISuspendTrigger) launch.getAdapter(ISuspendTr
igger.class); | 120 ISuspendTrigger trigger = (ISuspendTrigger) launch.getAdapter(ISuspendTr
igger.class); |
108 | 121 |
109 if (trigger != null) { | 122 if (trigger != null) { |
110 trigger.addSuspendTriggerListener(this); | 123 trigger.addSuspendTriggerListener(this); |
(...skipping 21 matching lines...) Expand all Loading... |
132 if (trigger != null) { | 145 if (trigger != null) { |
133 trigger.removeSuspendTriggerListener(this); | 146 trigger.removeSuspendTriggerListener(this); |
134 } | 147 } |
135 } | 148 } |
136 } | 149 } |
137 } catch (CoreException e) { | 150 } catch (CoreException e) { |
138 DartUtil.logError(e); | 151 DartUtil.logError(e); |
139 } | 152 } |
140 } | 153 } |
141 | 154 |
| 155 public void openDebuggerView() { |
| 156 try { |
| 157 IWorkbenchWindow window = DartDebugUIPlugin.getDefault().getWorkbench().ge
tActiveWorkbenchWindow(); |
| 158 |
| 159 if (window == null) { |
| 160 IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindo
ws(); |
| 161 |
| 162 if (windows.length > 0) { |
| 163 IWorkbenchPage[] pages = windows[0].getPages(); |
| 164 |
| 165 if (pages.length > 0) { |
| 166 pages[0].showView(DebuggerView.ID, null, IWorkbenchPage.VIEW_ACTIVAT
E); |
| 167 } |
| 168 } |
| 169 } else { |
| 170 DartToolsPlugin.showView(DebuggerView.ID); |
| 171 } |
| 172 } catch (PartInitException e) { |
| 173 DartUtil.logError(e); |
| 174 } |
| 175 } |
| 176 |
142 @Override | 177 @Override |
143 public void suspended(ILaunch launch, Object context) { | 178 public void suspended(ILaunch launch, Object context) { |
144 Display.getDefault().asyncExec(new Runnable() { | 179 Display.getDefault().asyncExec(new Runnable() { |
145 @Override | 180 @Override |
146 public void run() { | 181 public void run() { |
147 if (hasDebuggerView()) { | 182 if (hasDebuggerView()) { |
148 openDebuggerView(); | 183 openDebuggerView(); |
149 IWorkbenchWindow window = DartDebugUIPlugin.getDefault().getWorkbench(
).getActiveWorkbenchWindow(); | 184 IWorkbenchWindow window = DartDebugUIPlugin.getDefault().getWorkbench(
).getActiveWorkbenchWindow(); |
150 | 185 |
151 if (window == null) { | 186 if (window == null) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (page.findView(viewId) != null) { | 251 if (page.findView(viewId) != null) { |
217 return windows[i]; | 252 return windows[i]; |
218 } | 253 } |
219 } | 254 } |
220 | 255 |
221 } | 256 } |
222 } | 257 } |
223 | 258 |
224 return null; | 259 return null; |
225 } | 260 } |
226 | |
227 /** | |
228 * Check if the debugger view has been contributed | |
229 */ | |
230 private boolean hasDebuggerView() { | |
231 IViewDescriptor[] views = DartDebugUIPlugin.getDefault().getWorkbench().getV
iewRegistry().getViews(); | |
232 for (IViewDescriptor view : views) { | |
233 if (view.getId().equals(DebuggerView.ID)) { | |
234 return true; | |
235 } | |
236 } | |
237 return false; | |
238 } | |
239 | |
240 private void openDebuggerView() { | |
241 try { | |
242 IWorkbenchWindow window = DartDebugUIPlugin.getDefault().getWorkbench().ge
tActiveWorkbenchWindow(); | |
243 | |
244 if (window == null) { | |
245 IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindo
ws(); | |
246 | |
247 if (windows.length > 0) { | |
248 IWorkbenchPage[] pages = windows[0].getPages(); | |
249 | |
250 if (pages.length > 0) { | |
251 pages[0].showView(DebuggerView.ID, null, IWorkbenchPage.VIEW_ACTIVAT
E); | |
252 } | |
253 } | |
254 } else { | |
255 DartToolsPlugin.showView(DebuggerView.ID); | |
256 } | |
257 } catch (PartInitException e) { | |
258 DartUtil.logError(e); | |
259 } | |
260 } | |
261 | |
262 } | 261 } |
OLD | NEW |