plugins/org.symbian.tools.tmw.debug/src/org/symbian/tools/tmw/debug/ui/actions/JsBreakpointPropertiesRulerAction.java
changeset 471 06589bf52fa7
child 484 f5df819c1852
equal deleted inserted replaced
470:d4809db37847 471:06589bf52fa7
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Symbian Foundation - initial contribution.
       
    11  * Contributors:
       
    12  * Description:
       
    13  * Overview:
       
    14  * Details:
       
    15  * Platforms/Drives/Compatibility:
       
    16  * Assumptions/Requirement/Pre-requisites:
       
    17  * Failures and causes:
       
    18  *******************************************************************************/
       
    19 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
       
    20 // Use of this source code is governed by a BSD-style license that can be
       
    21 // found in the LICENSE file.
       
    22 
       
    23 package org.symbian.tools.tmw.debug.ui.actions;
       
    24 
       
    25 import org.chromium.debug.core.model.ChromiumLineBreakpoint;
       
    26 import org.eclipse.debug.core.model.IBreakpoint;
       
    27 import org.eclipse.debug.ui.actions.RulerBreakpointAction;
       
    28 import org.eclipse.jface.text.source.IVerticalRulerInfo;
       
    29 import org.eclipse.jface.viewers.ISelection;
       
    30 import org.eclipse.jface.viewers.ISelectionChangedListener;
       
    31 import org.eclipse.jface.viewers.ISelectionProvider;
       
    32 import org.eclipse.jface.viewers.StructuredSelection;
       
    33 import org.eclipse.ui.dialogs.PropertyDialogAction;
       
    34 import org.eclipse.ui.texteditor.ITextEditor;
       
    35 import org.eclipse.ui.texteditor.IUpdate;
       
    36 
       
    37 /**
       
    38  * Action to bring up the breakpoint properties dialog.
       
    39  */
       
    40 public class JsBreakpointPropertiesRulerAction extends RulerBreakpointAction
       
    41 		implements IUpdate {
       
    42 	private IBreakpoint breakpoint;
       
    43 
       
    44 	public JsBreakpointPropertiesRulerAction(ITextEditor editor,
       
    45 			IVerticalRulerInfo rulerInfo) {
       
    46 		super(editor, rulerInfo);
       
    47 		setText("Breakpoint Properties...");
       
    48 	}
       
    49 
       
    50 	@Override
       
    51 	public void run() {
       
    52 		if (getBreakpoint() != null) {
       
    53 			PropertyDialogAction action = new PropertyDialogAction(getEditor()
       
    54 					.getEditorSite(), new ISelectionProvider() {
       
    55 				public void addSelectionChangedListener(
       
    56 						ISelectionChangedListener listener) {
       
    57 				}
       
    58 
       
    59 				public ISelection getSelection() {
       
    60 					return new StructuredSelection(getBreakpoint());
       
    61 				}
       
    62 
       
    63 				public void removeSelectionChangedListener(
       
    64 						ISelectionChangedListener listener) {
       
    65 				}
       
    66 
       
    67 				public void setSelection(ISelection selection) {
       
    68 				}
       
    69 			});
       
    70 			action.run();
       
    71 		}
       
    72 	}
       
    73 
       
    74 	public void update() {
       
    75 		breakpoint = null;
       
    76 		IBreakpoint activeBreakpoint = getBreakpoint();
       
    77 		if (activeBreakpoint != null
       
    78 				&& activeBreakpoint instanceof ChromiumLineBreakpoint) {
       
    79 			breakpoint = activeBreakpoint;
       
    80 		}
       
    81 		setEnabled(breakpoint != null);
       
    82 	}
       
    83 
       
    84 }