From 83e897d92d05f877d1aeed2dbad11b784fb4b3d7 Mon Sep 17 00:00:00 2001 From: incastrix Date: Mon, 16 Feb 2009 18:03:38 +0000 Subject: [PATCH] Fix #759. --- net.sourceforge.phpeclipse.xdebug.ui/plugin.xml | 9 ++- .../xdebug/ui/XDebugUIMessages.properties | 4 + .../RulerEnableDisableXDebugBreakpointAction.java | 72 ++++++++++++++++++++ ...nableDisableXDebugBreakpointActionDelegate.java | 57 +++++++++++++++ .../php/launching/PHPDebugModelPresentation.java | 16 ++--- 5 files changed, 146 insertions(+), 12 deletions(-) create mode 100644 net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointAction.java create mode 100644 net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointActionDelegate.java diff --git a/net.sourceforge.phpeclipse.xdebug.ui/plugin.xml b/net.sourceforge.phpeclipse.xdebug.ui/plugin.xml index db39686..75cc1cf 100644 --- a/net.sourceforge.phpeclipse.xdebug.ui/plugin.xml +++ b/net.sourceforge.phpeclipse.xdebug.ui/plugin.xml @@ -74,11 +74,18 @@ + + diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugUIMessages.properties b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugUIMessages.properties index 711cbbd..64a1c25 100644 --- a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugUIMessages.properties +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/XDebugUIMessages.properties @@ -48,3 +48,7 @@ EventDetailsDialog.previous=View details of previous event EventDetailsDialog.next=View details of next event EventDetailsDialog.copy=Copy event details to clipboard +EnableXDebugBreakpoint.label=Enable XDebug breakpoint +DisableXDebugBreakpoint.label=Disable XDebug breakpoint +RulerEnableDisableBreakpointAction_0=Error +RulerEnableDisableBreakpointAction_1=Failed to toggle breakpoint enablement \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointAction.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointAction.java new file mode 100644 index 0000000..d5218a0 --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointAction.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2005, 2008 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 + * PHPEclipse team + * Mauro "Incastrix" Casciari + *******************************************************************************/ +package net.sourceforge.phpeclipse.xdebug.ui.actions; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IBreakpoint; +import net.sourceforge.phpeclipse.xdebug.ui.XDebugUIPlugin; +import org.eclipse.debug.ui.actions.RulerBreakpointAction; +import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.ui.texteditor.IUpdate; + +/** + * @since 3.2 + * + */ +public class RulerEnableDisableXDebugBreakpointAction extends RulerBreakpointAction implements IUpdate { + private static final String ENABLE_XDEBUG_BREAKPOINT_LABEL = "EnableXDebugBreakpoint.label"; //$NON-NLS-1$ + private static final String DISABLE_XDEBUG_BREAKPOINT_LABEL = "DisableXDebugBreakpoint.label"; //$NON-NLS-1$ + private static final String RULER_ENABLE_EDISABLE_BREAKPOINT_ACTION_0 = "RulerEnableDisableBreakpointAction_0"; //$NON-NLS-1$ + private static final String RULER_ENABLE_EDISABLE_BREAKPOINT_ACTION_1 = "RulerEnableDisableBreakpointAction_1"; //$NON-NLS-1$ + + private IBreakpoint fBreakpoint; + + public RulerEnableDisableXDebugBreakpointAction(ITextEditor editor, IVerticalRulerInfo info) { + super(editor, info); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.Action#run() + */ + public void run() { + if (fBreakpoint != null) { + try { + fBreakpoint.setEnabled(!fBreakpoint.isEnabled()); + } catch (CoreException e) { + XDebugUIPlugin.errorDialog(getEditor().getSite().getShell(), XDebugUIPlugin.getString(RULER_ENABLE_EDISABLE_BREAKPOINT_ACTION_0), XDebugUIPlugin.getString(RULER_ENABLE_EDISABLE_BREAKPOINT_ACTION_1), e.getStatus()); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.IUpdate#update() + */ + public void update() { + fBreakpoint = getBreakpoint(); + setEnabled(fBreakpoint != null); + if (fBreakpoint != null) { + try { + if (fBreakpoint.isEnabled()) { + setText(XDebugUIPlugin.getString(DISABLE_XDEBUG_BREAKPOINT_LABEL)); + } else { + setText(XDebugUIPlugin.getString(ENABLE_XDEBUG_BREAKPOINT_LABEL)); + } + } catch (CoreException e) { + } + } else { + setText(XDebugUIPlugin.getString(ENABLE_XDEBUG_BREAKPOINT_LABEL)); + } + } + +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointActionDelegate.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointActionDelegate.java new file mode 100644 index 0000000..4bae8ae --- /dev/null +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/actions/RulerEnableDisableXDebugBreakpointActionDelegate.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2005, 2008 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 + * PHPEclipse team + * Mauro "Incastrix" Casciari + *******************************************************************************/ +package net.sourceforge.phpeclipse.xdebug.ui.actions; + +import net.sourceforge.phpeclipse.xdebug.ui.actions.RulerEnableDisableXDebugBreakpointAction; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; +import org.eclipse.ui.texteditor.ITextEditor; + +/** + * Toggles enablement of a breakpoint in a vertical ruler. + * This action can be contributed to a vertical ruler context menu via the + * popupMenus extension point, by referencing the ruler's context + * menu identifier in the targetID attribute. + *
+ * <extension point="org.eclipse.ui.popupMenus">
+ *   <viewerContribution
+ *     targetID="example.rulerContextMenuId"
+ *     id="example.RulerPopupActions">
+ *       <action
+ *         label="Enable Breakpoint"
+ *         class="org.eclipse.debug.ui.actions.RulerEnableDisableBreakpointActionDelegate"
+ *         menubarPath="additions"
+ *         id="example.rulerContextMenu.toggleBreakpointAction">
+ *       </action>
+ *   </viewerContribution>
+ * 
+ *

+ *

+ * Clients may refer to this class as an action delegate in plug-in XML. + *

+ * @since 3.2 + * @noextend This class is not intended to be subclassed by clients. + * @noinstantiate This class is not intended to be instantiated by clients. + * + */ +public class RulerEnableDisableXDebugBreakpointActionDelegate extends AbstractRulerActionDelegate { + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.IVerticalRulerInfo) + */ + protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { + return new RulerEnableDisableXDebugBreakpointAction(editor, rulerInfo); + } + +} diff --git a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPDebugModelPresentation.java b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPDebugModelPresentation.java index c68dafe..75baa34 100644 --- a/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPDebugModelPresentation.java +++ b/net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPDebugModelPresentation.java @@ -118,7 +118,11 @@ public class PHPDebugModelPresentation extends LabelProvider implements if (element instanceof XDebugLineBreakpoint) { return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT); } else if (element instanceof IMarker) { - return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT); + if (((IMarker) element).getAttribute(IBreakpoint.ENABLED, false)) { + return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT); + } else { + return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED); + } } else if (element instanceof XDebugStackFrame || element instanceof XDebugThread || element instanceof XDebugTarget) { @@ -131,16 +135,6 @@ public class PHPDebugModelPresentation extends LabelProvider implements return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_BREAKPOINT); } -// private Image getVariableImage(XDebugVariable phpVar) { - /* - * if (phpVar != null) { if (phpVar.isLocal()) return - * DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE); if - * (phpVar.isHashValue()) return - * DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE); } - */ - // return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_VARIABLE); - //} - private Image getVariableImage(XDebugVariable phpVar) { if (phpVar.getVisibility().equals("protected")) { return XDebugUIPluginImages.get(XDebugUIPluginImages.IMG_FIELD_PROTECTED); -- 1.7.1