1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-17 05:05:43 +02:00

The last fix didn't cover the case of unpinning a view where there is no active debug context, related to bug 337376.

This commit is contained in:
Patrick Chuong 2011-03-11 15:42:02 +00:00
parent 1ba6e16383
commit 461e44b498

View file

@ -39,12 +39,15 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartConstants; import org.eclipse.ui.IWorkbenchPartConstants;
import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.WorkbenchPart;
/** /**
* Pin the selected debug context for the view. * Pin the selected debug context for the view.
*/ */
public class PinDebugContextActionDelegate implements IViewActionDelegate, IActionDelegate2, IDebugContextListener { public class PinDebugContextActionDelegate implements IViewActionDelegate, IActionDelegate2, IDebugContextListener {
private IViewPart fPart; private IViewPart fPart;
private String fPinnedContextLabel = ""; //$NON-NLS-1$
private String fLastKnownDescription = ""; //$NON-NLS-1$
private IAction fAction; private IAction fAction;
private IPartListener2 fPartListener; private IPartListener2 fPartListener;
private DebugContextPinProvider fProvider; private DebugContextPinProvider fProvider;
@ -66,14 +69,16 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
if (action.isChecked()) { if (action.isChecked()) {
fProvider = DebugEventFilterService.getInstance().addDebugEventFilter(fPart, getActiveDebugContext()); fProvider = DebugEventFilterService.getInstance().addDebugEventFilter(fPart, getActiveDebugContext());
if (fProvider != null) { if (fProvider != null) {
updatePinContextColor(fProvider); fLastKnownDescription = ((WorkbenchPart) fPart).getContentDescription();
updatePinContextLabel(fProvider); fPinnedContextLabel = getPinContextLabel(fProvider);
} PinCloneUtils.setPartContentDescription(fPart, fPinnedContextLabel);
updatePinContextColor(fProvider);
}
} else { } else {
fProvider = null; fProvider = null;
DebugEventFilterService.getInstance().removeDebugEventFilter(fPart); DebugEventFilterService.getInstance().removeDebugEventFilter(fPart);
updatePinContextColor(fProvider); updatePinContextColor(fProvider);
updatePinContextLabel(fProvider); PinCloneUtils.setPartContentDescription(fPart, fLastKnownDescription);
} }
} }
@ -105,8 +110,17 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
fPart.addPropertyListener(new IPropertyListener() { fPart.addPropertyListener(new IPropertyListener() {
public void propertyChanged(Object source, int propId) { public void propertyChanged(Object source, int propId) {
if (IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION == propId) { if (IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION == propId) {
if (fAction != null && fAction.isChecked()) // if the content description is not the pinned context label,
updatePinContextLabel(fProvider); // then cache it so that we can set it back when the action is unchecked.
String desc = ((WorkbenchPart) fPart).getContentDescription();
if (!fPinnedContextLabel.equals(desc)) {
fLastKnownDescription = desc;
}
// if action is checked, than set it back to the pinned context label.
if (fAction != null && fAction.isChecked()) {
PinCloneUtils.setPartContentDescription(fPart, fPinnedContextLabel);
}
} else if (IWorkbenchPartConstants.PROP_PART_NAME == propId) { } else if (IWorkbenchPartConstants.PROP_PART_NAME == propId) {
PinCloneUtils.setPartTitle(fPart); PinCloneUtils.setPartTitle(fPart);
} }
@ -153,7 +167,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
return contextService.getActiveContext(); return contextService.getActiveContext();
} }
private void updatePinContextLabel(DebugContextPinProvider provider) { private String getPinContextLabel(DebugContextPinProvider provider) {
String description = ""; //$NON-NLS-1$ String description = ""; //$NON-NLS-1$
if (provider != null) { if (provider != null) {
@ -174,8 +188,7 @@ public class PinDebugContextActionDelegate implements IViewActionDelegate, IActi
} }
} }
} }
return description;
PinCloneUtils.setPartContentDescription(fPart, description);
} }
private String getLabel(IPinElementHandle handle) { private String getLabel(IPinElementHandle handle) {