1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

[248627] Support "Show Full Path" action for DSF

This commit is contained in:
Marc Khouzam 2010-04-22 23:44:30 +00:00
parent f29a16e895
commit caa6d148db
6 changed files with 117 additions and 10 deletions

View file

@ -15,10 +15,15 @@ import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.internal.ui.CDebugModelPresentation;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.views.launch.LaunchView;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.custom.BusyIndicator;
@ -59,7 +64,6 @@ public class ShowFullPathsAction extends ViewFilterAction {
BusyIndicator.showWhile( viewer.getControl().getDisplay(),
new Runnable() {
public void run() {
viewer.refresh();
IPreferenceStore store = getPreferenceStore();
String key = getView().getSite().getId() + "." + getPreferenceKey(); //$NON-NLS-1$
// We must first set a special key, to be able to tell that our preference is really set
@ -69,9 +73,40 @@ public class ShowFullPathsAction extends ViewFilterAction {
store.setValue( isSetKey, true );
store.setValue( key, getValue() );
CDebugUIPlugin.getDefault().savePluginPreferences();
// Refresh the viewer after we've set the preference because
// DSF-based debuggers trigger off this preference.
viewer.refresh();
}
} );
}
}
}
/*
* Some debugger integrations don`t use debugTargets (e.g., DSF), so we
* verify if the launch has the proper attribute instead.
* If we don`t find any launches that allow us to enable the action, we should
* call our parent class to keep any previous debugger integration properly
* working with this feature.
*/
/** @since 7.0 */
@Override
public void selectionChanged(IAction action, ISelection selection) {
IDebugView view = (IDebugView)getView().getAdapter(IDebugView.class);
// Debug view
if (view instanceof LaunchView) {
ILaunchManager launchmgr = DebugPlugin.getDefault().getLaunchManager();
ILaunch[] launches = launchmgr.getLaunches();
for (ILaunch launch : launches) {
if (launch.getAttribute(ICDebugPreferenceConstants.PREF_SHOW_FULL_PATHS) != null &&
launch.isTerminated() == false) {
setEnabled(true);
return;
}
}
}
super.selectionChanged(action, selection);
}
}

View file

@ -115,7 +115,12 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi
* content. Closing those gaps would not be easy, and thus not worth the
* effort as no harm is done by an unintentional enablement.
*
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
* For the Debug view case, we check debugTargets in the base method to
* be backwards compatible as this was the criteria from the start.
* A specific action can specialize this method but should call super.selectionChanged
* to maintain backwards compatibility.
*
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
@ -200,11 +205,20 @@ public abstract class ViewFilterAction extends ViewerFilter implements IViewActi
}
/**
* Returns whether this action is seleted/checked.
* Returns whether this action is selected/checked.
*
* @return whether this action is seleted/checked
* @return whether this action is selected/checked
*/
protected boolean getValue() {
return fAction.isChecked();
}
/**
* Sets whether the action should be enabled or not.
*
* @since 7.0
*/
protected void setEnabled(boolean enabled) {
fAction.setEnabled(enabled);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 Wind River Systems and others.
* Copyright (c) 2006, 2010 Wind River Systems 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
@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.ui;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.debug.ui.IDebugUIConstants;
/**
* @noimplement This interface is not intended to be implemented by clients.
@ -86,4 +88,12 @@ public interface IDsfDebugUIConstants {
* @since 2.1
*/
public static final String ID_EXPRESSION_HOVER= PLUGIN_ID + ".expression_hover"; //$NON-NLS-1$
/**
* Property id to know if we should show full paths in the debug view.
* The value of this id must match what is being used as a full key in ShowFullPathsAction.run()
*
* @since 2.1 */
public static final String DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY = IDebugUIConstants.ID_DEBUG_VIEW + "." + ICDebugPreferenceConstants.PREF_SHOW_FULL_PATHS; //$NON-NLS-1$
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 Wind River Systems and others.
* Copyright (c) 2006, 2010 Wind River Systems 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
@ -17,6 +17,7 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
@ -86,6 +87,10 @@ public class AbstractLaunchVMProvider extends AbstractDMVMProvider
}};
store.addPropertyChangeListener(fPreferencesListener);
final IPreferenceStore cStore= CDebugUIPlugin.getDefault().getPreferenceStore();
getPresentationContext().setProperty(IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY, cStore.getBoolean(IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY));
cStore.addPropertyChangeListener(fPreferencesListener);
// Register the LaunchVM provider as a listener to debug and launch
// events. These events are used by the launch and processes nodes.
DebugPlugin.getDefault().addDebugEventListener(this);
@ -209,6 +214,9 @@ public class AbstractLaunchVMProvider extends AbstractDMVMProvider
final IPreferenceStore store= DsfUIPlugin.getDefault().getPreferenceStore();
store.removePropertyChangeListener(fPreferencesListener);
final IPreferenceStore cStore= CDebugUIPlugin.getDefault().getPreferenceStore();
cStore.removePropertyChangeListener(fPreferencesListener);
super.dispose();
}
@ -275,6 +283,8 @@ public class AbstractLaunchVMProvider extends AbstractDMVMProvider
protected void handlePropertyChanged(final IPreferenceStore store, final PropertyChangeEvent event) {
String property = event.getProperty();
boolean processEvent = false;
if (IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT_ENABLE.equals(property)
|| IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT.equals(property)) {
if (store.getBoolean(IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT_ENABLE)) {
@ -282,6 +292,13 @@ public class AbstractLaunchVMProvider extends AbstractDMVMProvider
} else {
getPresentationContext().setProperty(IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT, null);
}
processEvent = true;
} else if (IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY.equals(property)) {
getPresentationContext().setProperty(IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY, event.getNewValue());
processEvent = true;
}
if (processEvent) {
getExecutor().execute(new DsfRunnable() {
public void run() {
handleEvent(event);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 Wind River Systems and others.
* Copyright (c) 2006, 2010 Wind River Systems 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
@ -26,12 +26,12 @@ import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IStack;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerSuspendedDMEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExitedDMEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
import org.eclipse.cdt.dsf.debug.service.IStack;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
@ -55,7 +55,9 @@ import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelColumnInfo;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
@ -432,7 +434,15 @@ public class StackFramesVMNode extends AbstractDMVMNode
if (address != null) {
update.setProperty(ILaunchVMConstants.PROP_FRAME_ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$
}
update.setProperty(ILaunchVMConstants.PROP_FRAME_FILE, data.getFile());
IPath filePath = new Path(data.getFile());
String fileName = filePath.toOSString();
Object showFullPathPreference = getVMProvider().getPresentationContext().getProperty(IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY);
if (showFullPathPreference instanceof Boolean && (Boolean)showFullPathPreference == false) {
fileName = filePath.lastSegment();
}
update.setProperty(ILaunchVMConstants.PROP_FRAME_FILE, fileName);
update.setProperty(ILaunchVMConstants.PROP_FRAME_FUNCTION, data.getFunction());
update.setProperty(ILaunchVMConstants.PROP_FRAME_LINE, data.getLine());
update.setProperty(ILaunchVMConstants.PROP_FRAME_COLUMN, data.getColumn());
@ -562,6 +572,8 @@ public class StackFramesVMNode extends AbstractDMVMNode
|| IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT.equals(property))
{
return IModelDelta.CONTENT;
} else if (IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY.equals(property)) {
return IModelDelta.STATE;
}
} else {
}
@ -610,6 +622,8 @@ public class StackFramesVMNode extends AbstractDMVMNode
|| IDsfDebugUIConstants.PREF_STACK_FRAME_LIMIT.equals(property))
{
buildDeltaForStackFrameLimitPreferenceChangedEvent(parent, rm);
} else if (IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY.equals(property)) {
buildDeltaForShowFullPathPreferenceChangedEvent(parent, rm);
} else {
rm.done();
}
@ -724,6 +738,11 @@ public class StackFramesVMNode extends AbstractDMVMNode
rm.done();
}
private void buildDeltaForShowFullPathPreferenceChangedEvent(final VMDelta parentDelta, final RequestMonitor rm) {
parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.STATE);
rm.done();
}
private String produceFrameElementName( String viewName , IFrameDMContext frame ) {
/*
* We are addressing Bugzilla 211490 which wants the Register View to keep the same expanded

View file

@ -28,6 +28,13 @@ import org.eclipse.debug.core.model.ISourceLocator;
*/
public class DsfLaunch extends Launch {
/*
* Used to indicate that this launch supports the "Show Full Path" action in the debug view.
* This constant must have the same value as ICDebugPreferenceConstants.PREF_SHOW_FULL_PATHS
* We have our own copy to avoid a dependency.
*/
private static final String PREF_SHOW_FULL_PATHS = "org.eclipse.cdt.debug.ui.cDebug.show_full_paths"; //$NON-NLS-1$
private class EventSchedulingRule implements ISchedulingRule {
DsfLaunch fLaunch = DsfLaunch.this;
@ -51,6 +58,11 @@ public class DsfLaunch extends Launch {
public DsfLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
super(launchConfiguration, mode, locator);
// Just set this attribute to any value. It's presence indicates that the
// "Show Full Path" action is supported in the debug view.
// see org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction
setAttribute(PREF_SHOW_FULL_PATHS, ""); //$NON-NLS-1$
}
@Override