| /******************************************************************************* |
| * Copyright (c) 2010 IBM Corporation and others. |
| * 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: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.wst.jsdt.debug.internal.ui.actions; |
| |
| import org.eclipse.jface.action.IAction; |
| import org.eclipse.jface.viewers.ISelection; |
| import org.eclipse.jface.viewers.IStructuredSelection; |
| import org.eclipse.ui.IObjectActionDelegate; |
| import org.eclipse.ui.IWorkbenchPart; |
| import org.eclipse.ui.PlatformUI; |
| import org.eclipse.ui.dialogs.PreferencesUtil; |
| import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint; |
| |
| /** |
| * Action that opens the properties page for a {@link IJavaScriptBreakpoint} |
| * |
| * @since 1.0 |
| */ |
| public class BreakpointPropertiesAction implements IObjectActionDelegate { |
| |
| IJavaScriptBreakpoint breakpoint = null; |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) |
| */ |
| public void setActivePart(IAction action, IWorkbenchPart targetPart) {} |
| |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) |
| */ |
| public void run(IAction action) { |
| if(this.breakpoint != null) { |
| PreferencesUtil.createPropertyDialogOn( |
| PlatformUI.getWorkbench().getDisplay().getActiveShell(), |
| this.breakpoint, |
| null, |
| null, |
| null).open(); |
| } |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) |
| */ |
| public void selectionChanged(IAction action, ISelection selection) { |
| if (selection instanceof IStructuredSelection) { |
| IStructuredSelection ss= (IStructuredSelection)selection; |
| if (ss.isEmpty() || ss.size() > 1) { |
| return; |
| } |
| Object element= ss.getFirstElement(); |
| if (element instanceof IJavaScriptBreakpoint) { |
| this.breakpoint = (IJavaScriptBreakpoint) element; |
| } |
| else { |
| this.breakpoint = null; |
| } |
| } |
| } |
| |
| } |