|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.debug.ui.actions; |
|
6 |
|
7 import org.chromium.debug.core.model.ChromiumLineBreakpoint; |
|
8 import org.eclipse.debug.core.model.IBreakpoint; |
|
9 import org.eclipse.debug.ui.actions.RulerBreakpointAction; |
|
10 import org.eclipse.jface.text.source.IVerticalRulerInfo; |
|
11 import org.eclipse.jface.viewers.ISelection; |
|
12 import org.eclipse.jface.viewers.ISelectionChangedListener; |
|
13 import org.eclipse.jface.viewers.ISelectionProvider; |
|
14 import org.eclipse.jface.viewers.StructuredSelection; |
|
15 import org.eclipse.ui.dialogs.PropertyDialogAction; |
|
16 import org.eclipse.ui.texteditor.ITextEditor; |
|
17 import org.eclipse.ui.texteditor.IUpdate; |
|
18 |
|
19 /** |
|
20 * Action to bring up the breakpoint properties dialog. |
|
21 */ |
|
22 public class JsBreakpointPropertiesRulerAction extends RulerBreakpointAction implements IUpdate { |
|
23 |
|
24 private IBreakpoint breakpoint; |
|
25 |
|
26 public JsBreakpointPropertiesRulerAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { |
|
27 super(editor, rulerInfo); |
|
28 setText(Messages.JsBreakpointPropertiesRulerAction_ItemLabel); |
|
29 } |
|
30 |
|
31 @Override |
|
32 public void run() { |
|
33 if (getBreakpoint() != null) { |
|
34 PropertyDialogAction action = |
|
35 new PropertyDialogAction(getEditor().getEditorSite(), |
|
36 new ISelectionProvider() { |
|
37 public void addSelectionChangedListener(ISelectionChangedListener listener) { |
|
38 } |
|
39 |
|
40 public ISelection getSelection() { |
|
41 return new StructuredSelection(getBreakpoint()); |
|
42 } |
|
43 |
|
44 public void removeSelectionChangedListener(ISelectionChangedListener listener) { |
|
45 } |
|
46 |
|
47 public void setSelection(ISelection selection) { |
|
48 } |
|
49 }); |
|
50 action.run(); |
|
51 } |
|
52 } |
|
53 |
|
54 public void update() { |
|
55 breakpoint = null; |
|
56 IBreakpoint activeBreakpoint = getBreakpoint(); |
|
57 if (activeBreakpoint != null && |
|
58 activeBreakpoint instanceof ChromiumLineBreakpoint) { |
|
59 breakpoint = activeBreakpoint; |
|
60 } |
|
61 setEnabled(breakpoint != null); |
|
62 } |
|
63 |
|
64 } |