1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 326636 - [disassembly][source lookup] Enable disassembly view as "editor"

This commit is contained in:
Anton Leherbauer 2010-11-10 06:50:00 +00:00
parent 78f40855d0
commit 85b40d1d99
5 changed files with 143 additions and 81 deletions

View file

@ -698,5 +698,16 @@
<adapter type="org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover"/>
</factory>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyEditor"
default="false"
icon="icons/disassembly.gif"
id="org.eclipse.cdt.dsf.ui.disassembly"
name="%disassemblyView.name">
</editor>
</extension>
</plugin>

View file

@ -11,12 +11,17 @@
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PartInitException;
/**
@ -25,6 +30,8 @@ import org.eclipse.ui.PartInitException;
public class DisassemblyEditor extends DisassemblyPart implements IEditorPart {
private IEditorInput fInput;
private ToolBarManager fToolBarManager;
private Label fContentDescriptionLabel;
/**
*
@ -33,23 +40,55 @@ public class DisassemblyEditor extends DisassemblyPart implements IEditorPart {
super();
}
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout(1, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);
Composite topBar = new Composite(parent, SWT.NONE);
topBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
GridLayout layout2 = new GridLayout(2, false);
layout2.marginTop = 1;
layout2.marginLeft = 1;
layout2.marginWidth = 0;
layout2.marginHeight = 0;
topBar.setLayout(layout2);
fContentDescriptionLabel = new Label(topBar, SWT.NONE);
fContentDescriptionLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
fToolBarManager = new ToolBarManager();
ToolBar toolbar = fToolBarManager.createControl(topBar);
toolbar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
Composite inner = new Composite(parent, SWT.NONE);
inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
super.createPartControl(inner);
}
/*
* @see org.eclipse.ui.part.WorkbenchPart#setContentDescription(java.lang.String)
*/
@Override
protected void setContentDescription(String description) {
fContentDescriptionLabel.setText(description);
fContentDescriptionLabel.getParent().layout(true);
}
@Override
protected IActionBars getActionBars() {
return getEditorSite().getActionBars();
}
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
protected void fillContextMenu(IMenuManager manager) {
super.fillContextMenu(manager);
manager.appendToGroup(IWorkbenchActionConstants.GO_TO, fActionGotoPC);
manager.appendToGroup(IWorkbenchActionConstants.GO_TO, fActionGotoAddress);
manager.appendToGroup("group.bottom", fActionRefreshView); //$NON-NLS-1$
protected void contributeToActionBars(IActionBars bars) {
super.contributeToActionBars(bars);
fillLocalToolBar(fToolBarManager);
fToolBarManager.update(true);
}
/*
* @see org.eclipse.ui.IEditorPart#getEditorInput()
*/

View file

@ -70,6 +70,8 @@ import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
@ -229,7 +231,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private Color fLabelColor;
private Control fRedrawControl;
private RGB fPCAnnotationRGB;
private Composite fComposite;
protected Composite fComposite;
private DropTarget fDropTarget;
private DragSource fDragSource;
@ -325,35 +327,37 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private AddressBarContributionItem fAddressBar = null;
private Action fJumpToAddressAction = new JumpToAddressAction(this);
private final class SyncActiveDebugContextAction extends Action {
public SyncActiveDebugContextAction() {
setChecked(DisassemblyPart.this.isSyncWithActiveDebugContext());
setText(DisassemblyMessages.Disassembly_action_Sync_label);
setImageDescriptor(DisassemblyImageRegistry.getImageDescriptor(DisassemblyImageRegistry.ICON_Sync_enabled));
setDisabledImageDescriptor(DisassemblyImageRegistry.getImageDescriptor(DisassemblyImageRegistry.ICON_Sync_disabled));
}
@Override
public void run() {
DisassemblyPart.this.setSyncWithDebugView(this.isChecked());
}
}
private final class TrackExpressionAction extends Action {
public TrackExpressionAction() {
setChecked(DisassemblyPart.this.isTrackExpression());
setEnabled(!fSynchWithActiveDebugContext);
setText(DisassemblyMessages.Disassembly_action_TrackExpression_label);
}
@Override
public void run() {
DisassemblyPart.this.setTrackExpression(this.isChecked());
}
}
private final class ActionRefreshView extends AbstractDisassemblyAction {
private IDebugContextListener fDebugContextListener;
private final class SyncActiveDebugContextAction extends Action {
public SyncActiveDebugContextAction() {
setChecked(DisassemblyPart.this.isSyncWithActiveDebugContext());
setText(DisassemblyMessages.Disassembly_action_Sync_label);
setImageDescriptor(DisassemblyImageRegistry.getImageDescriptor(DisassemblyImageRegistry.ICON_Sync_enabled));
setDisabledImageDescriptor(DisassemblyImageRegistry.getImageDescriptor(DisassemblyImageRegistry.ICON_Sync_disabled));
}
@Override
public void run() {
DisassemblyPart.this.setSyncWithDebugView(this.isChecked());
}
}
private final class TrackExpressionAction extends Action {
public TrackExpressionAction() {
setChecked(DisassemblyPart.this.isTrackExpression());
setEnabled(!fSynchWithActiveDebugContext);
setText(DisassemblyMessages.Disassembly_action_TrackExpression_label);
}
@Override
public void run() {
DisassemblyPart.this.setTrackExpression(this.isChecked());
}
}
private final class ActionRefreshView extends AbstractDisassemblyAction {
public ActionRefreshView() {
super(DisassemblyPart.this);
setText(DisassemblyMessages.Disassembly_action_RefreshView_label);
@ -439,7 +443,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private final class ActionToggleSource extends AbstractDisassemblyAction {
public ActionToggleSource() {
super(DisassemblyPart.this);
super(DisassemblyPart.this, IAction.AS_CHECK_BOX);
setText(DisassemblyMessages.Disassembly_action_ShowSource_label);
}
@Override
@ -459,7 +463,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private final class ActionToggleSymbols extends AbstractDisassemblyAction {
public ActionToggleSymbols() {
super(DisassemblyPart.this);
super(DisassemblyPart.this, IAction.AS_CHECK_BOX);
setText(DisassemblyMessages.Disassembly_action_ShowSymbols_label);
}
@Override
@ -708,6 +712,13 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
protected void setSite(IWorkbenchPartSite site) {
super.setSite(site);
site.getPage().addPartListener(fPartListener);
DebugUITools.getDebugContextManager().addDebugContextListener(fDebugContextListener = new IDebugContextListener() {
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) != 0) {
updateDebugContext();
}
}
});
}
private DisassemblyDocument createDocument() {
@ -720,6 +731,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
*/
@Override
public void dispose() {
if (fDebugContextListener != null) {
DebugUITools.getDebugContextManager().removeDebugContextListener(fDebugContextListener);
fDebugContextListener = null;
}
IWorkbenchPartSite site = getSite();
site.setSelectionProvider(null);
site.getPage().removePartListener(fPartListener);
@ -1200,7 +1215,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
manager.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
manager.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.COPY));
manager.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
// TODO add only if this is an editor
manager.add(new Separator(ITextEditorActionConstants.GROUP_SETTINGS));
manager.add(fActionToggleSource);
manager.add(fActionToggleSymbols);
@ -1862,7 +1876,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
resetViewer();
if (fDebugSessionId != null) {
fJumpToAddressAction.setEnabled(true);
fAddressBar.enableAddressBox(true);
if (fAddressBar != null)
fAddressBar.enableAddressBox(true);
int activeFrame = getActiveStackFrame();
if (activeFrame > 0) {
@ -1880,7 +1895,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fViewer.addViewportListener(this);
} else {
fJumpToAddressAction.setEnabled(false);
fAddressBar.enableAddressBox(false);
if (fAddressBar != null)
fAddressBar.enableAddressBox(false);
fViewer.removeViewportListener(this);
fGotoMarkerPending = null;
}
@ -2090,8 +2106,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (fActive) {
gotoFrame(frame);
} else {
// this will trigger an update in #setActive()
fTargetFrame = -1;
// this will trigger an update in #setActive()
fTargetFrame = -1;
}
}

View file

@ -12,9 +12,6 @@
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IActionBars;
@ -31,8 +28,6 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants;
*/
public class DisassemblyView extends DisassemblyPart implements IViewPart {
private IDebugContextListener fDebugContextListener;
/**
*
*/
@ -64,22 +59,14 @@ public class DisassemblyView extends DisassemblyPart implements IViewPart {
*/
public void init(IViewSite site, IMemento memento) throws PartInitException {
setSite(site);
if (memento != null) {
Boolean trackExpression = memento.getBoolean(DisassemblyPreferenceConstants.TRACK_EXPRESSION);
if (trackExpression != null)
fTrackExpression = trackExpression;
Boolean syncContext = memento.getBoolean(DisassemblyPreferenceConstants.SYNC_ACTIVE_CONTEXT);
if (syncContext != null)
fSynchWithActiveDebugContext = syncContext;
}
DebugUITools.getDebugContextManager().addDebugContextListener(fDebugContextListener = new IDebugContextListener() {
public void debugContextChanged(DebugContextEvent event) {
if ((event.getFlags() & DebugContextEvent.ACTIVATED) != 0) {
updateDebugContext();
}
}
});
if (memento != null) {
Boolean trackExpression = memento.getBoolean(DisassemblyPreferenceConstants.TRACK_EXPRESSION);
if (trackExpression != null)
fTrackExpression = trackExpression;
Boolean syncContext = memento.getBoolean(DisassemblyPreferenceConstants.SYNC_ACTIVE_CONTEXT);
if (syncContext != null)
fSynchWithActiveDebugContext = syncContext;
}
}
/*
@ -89,7 +76,7 @@ public class DisassemblyView extends DisassemblyPart implements IViewPart {
memento.putBoolean(DisassemblyPreferenceConstants.TRACK_EXPRESSION, isTrackExpression());
memento.putBoolean(DisassemblyPreferenceConstants.SYNC_ACTIVE_CONTEXT, isSyncWithActiveDebugContext());
}
@Override
protected void contributeToActionBars(IActionBars bars) {
super.contributeToActionBars(bars);
@ -117,13 +104,4 @@ public class DisassemblyView extends DisassemblyPart implements IViewPart {
protected void closePart() {
getViewSite().getPage().hideView(this);
}
@Override
public void dispose() {
if (fDebugContextListener != null) {
DebugUITools.getDebugContextManager().removeDebugContextListener(fDebugContextListener);
fDebugContextListener = null;
}
super.dispose();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2010 Wind River Systems, Inc. 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
@ -34,6 +34,24 @@ public abstract class AbstractDisassemblyAction extends Action implements IUpdat
fDisassemblyPart.addPropertyListener(this);
}
/**
* Create a disassembly action.
*
* @param disassemblyPart
* @param style
* one of <code>AS_PUSH_BUTTON</code>,
* <code>AS_CHECK_BOX</code>, <code>AS_DROP_DOWN_MENU</code>,
* <code>AS_RADIO_BUTTON</code>, and
* <code>AS_UNSPECIFIED</code>.
*/
public AbstractDisassemblyAction(IDisassemblyPart disassemblyPart, int style) {
super(null, style);
Assert.isLegal(disassemblyPart != null);
fDisassemblyPart= disassemblyPart;
fDisassemblyPart.addPropertyListener(this);
}
/**
* @return the disassembly part
*/