mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
[296257] [disassembly] Merge 'Go to Address' and 'Go to Symbol' actions and expose it as a combo box in the toolbar
Patch by Navid Mehregani
This commit is contained in:
parent
b224735385
commit
9150108ed8
10 changed files with 443 additions and 16 deletions
BIN
dsf/org.eclipse.cdt.dsf.ui/icons/address_warning.gif
Normal file
BIN
dsf/org.eclipse.cdt.dsf.ui/icons/address_warning.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 100 B |
BIN
dsf/org.eclipse.cdt.dsf.ui/icons/source.gif
Normal file
BIN
dsf/org.eclipse.cdt.dsf.ui/icons/source.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 583 B |
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 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
|
||||
|
@ -11,10 +11,12 @@
|
|||
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +38,19 @@ public class DisassemblyEditor extends DisassemblyPart implements IEditorPart {
|
|||
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(IWorkbenchActionConstants.GO_TO, fActionGotoSymbol);
|
||||
manager.appendToGroup("group.bottom", fActionRefreshView); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IEditorPart#getEditorInput()
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 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
|
||||
|
@ -38,6 +38,8 @@ public class DisassemblyImageRegistry extends AbstractImageRegistry {
|
|||
public static final String ICON_Refresh_disabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/dlcl16"}, "refresh_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
public static final String ICON_Copy_enabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/etool16"}, "copy_edit.gif"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
public static final String ICON_Copy_disabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/dtool16"}, "copy_edit.gif"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
public static final String ICON_Home_enabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/elcl16"}, "home_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
public static final String ICON_Home_disabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/dlcl16"}, "home_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static DisassemblyImageRegistry INSTANCE= new DisassemblyImageRegistry(DsfUIPlugin.getDefault());
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 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
|
||||
|
@ -91,6 +91,10 @@ public final class DisassemblyMessages extends NLS {
|
|||
public static String EditionFinderJob_name;
|
||||
public static String EditionFinderJob_task_get_timestamp;
|
||||
public static String EditionFinderJob_task_search_history;
|
||||
public static String Disassembly_GotoLocation_initial_text;
|
||||
public static String Disassembly_GotoLocation_warning;
|
||||
public static String Disassembly_Error_Dialog_title;
|
||||
public static String Disassembly_Error_Dialog_ok_button;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(BUNDLE_NAME, DisassemblyMessages.class);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
##########################################################################
|
||||
# Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
# Copyright (c) 2007, 2009 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
|
||||
|
@ -46,6 +46,12 @@ Disassembly_GotoAddressDialog_error_not_a_number=Not a valid number format
|
|||
Disassembly_GotoSymbolDialog_title=Go to Symbol
|
||||
Disassembly_GotoSymbolDialog_label=Symbol:
|
||||
|
||||
Disassembly_GotoLocation_initial_text=Enter location here
|
||||
Disassembly_GotoLocation_warning=Specified location is invalid
|
||||
|
||||
Disassembly_Error_Dialog_title=Error
|
||||
Disassembly_Error_Dialog_ok_button=OK
|
||||
|
||||
Disassembly_message_notConnected=No debug context
|
||||
|
||||
Disassembly_log_error_retrieveFrameAddress=Error retrieving frame address
|
||||
|
|
|
@ -34,6 +34,8 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionGotoAddre
|
|||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionGotoProgramCounter;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionGotoSymbol;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionOpenPreferences;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AddressBarContributionItem;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.JumpToAddressAction;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.TextOperationAction;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.AddressRangePosition;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.BreakpointsAnnotationModel;
|
||||
|
@ -98,8 +100,10 @@ import org.eclipse.jface.action.IMenuManager;
|
|||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.action.ToolBarManager;
|
||||
import org.eclipse.jface.commands.ActionHandler;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
|
@ -156,6 +160,7 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.ToolBar;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IPartListener2;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
|
@ -171,6 +176,7 @@ import org.eclipse.ui.handlers.IHandlerActivation;
|
|||
import org.eclipse.ui.handlers.IHandlerService;
|
||||
import org.eclipse.ui.ide.IGotoMarker;
|
||||
import org.eclipse.ui.part.WorkbenchPart;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
||||
import org.eclipse.ui.texteditor.AnnotationPreference;
|
||||
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
|
||||
|
@ -223,11 +229,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
|
||||
protected AbstractDisassemblyAction fActionGotoPC;
|
||||
protected AbstractDisassemblyAction fActionGotoAddress;
|
||||
private AbstractDisassemblyAction fActionGotoSymbol;
|
||||
protected AbstractDisassemblyAction fActionGotoSymbol;
|
||||
protected AbstractDisassemblyAction fActionToggleSource;
|
||||
private AbstractDisassemblyAction fActionToggleFunctionColumn;
|
||||
private AbstractDisassemblyAction fActionToggleSymbols;
|
||||
private AbstractDisassemblyAction fActionRefreshView;
|
||||
protected AbstractDisassemblyAction fActionRefreshView;
|
||||
private Action fActionOpenPreferences;
|
||||
private AbstractDisassemblyAction fActionToggleAddressColumn;
|
||||
private AbstractDisassemblyAction fActionToggleBreakpointEnablement;
|
||||
|
@ -339,7 +345,9 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
private DsfServicesTracker fServicesTracker;
|
||||
private IFrameDMContext fTargetFrameContext;
|
||||
protected IFrameDMData fTargetFrameData;
|
||||
|
||||
|
||||
private AddressBarContributionItem fAddressBar = null;
|
||||
private Action fJumpToAddressAction = new JumpToAddressAction(this);
|
||||
|
||||
private final class ActionRefreshView extends AbstractDisassemblyAction {
|
||||
public ActionRefreshView() {
|
||||
|
@ -679,7 +687,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
hookRulerContextMenu();
|
||||
hookContextMenu();
|
||||
contributeToActionBars();
|
||||
|
||||
|
||||
fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
updateSelectionDependentActions();
|
||||
|
@ -1197,7 +1205,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
if (navigateMenu != null) {
|
||||
navigateMenu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fActionGotoPC);
|
||||
navigateMenu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fActionGotoAddress);
|
||||
navigateMenu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fActionGotoSymbol);
|
||||
}
|
||||
bars.updateActionBars();
|
||||
}
|
||||
|
@ -1210,9 +1217,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
manager.add(new GroupMarker("group.top")); // ICommonMenuConstants.GROUP_TOP //$NON-NLS-1$
|
||||
manager.add(new Separator("group.breakpoints")); //$NON-NLS-1$
|
||||
manager.add(new Separator(IWorkbenchActionConstants.GO_TO));
|
||||
manager.add(fActionGotoPC);
|
||||
manager.add(fActionGotoAddress);
|
||||
manager.add(fActionGotoSymbol);
|
||||
manager.add(new Separator("group.debug")); //$NON-NLS-1$
|
||||
manager.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
|
||||
manager.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.COPY));
|
||||
|
@ -1221,8 +1225,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
manager.add(fActionToggleSource);
|
||||
manager.add(fActionToggleSymbols);
|
||||
manager.add(fActionOpenPreferences);
|
||||
manager.add(new Separator());
|
||||
manager.add(fActionRefreshView);
|
||||
manager.add(new Separator("group.bottom")); //$NON-NLS-1$
|
||||
// Other plug-ins can contribute their actions here
|
||||
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||
}
|
||||
|
@ -1252,8 +1255,17 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
}
|
||||
|
||||
protected void fillLocalToolBar(IToolBarManager manager) {
|
||||
final int ADDRESS_BAR_WIDTH = 190;
|
||||
ToolBar toolbar = ((ToolBarManager)manager).getControl();
|
||||
fAddressBar = new AddressBarContributionItem(fJumpToAddressAction);
|
||||
fAddressBar.createAddressBox(toolbar, ADDRESS_BAR_WIDTH, DisassemblyMessages.Disassembly_GotoLocation_initial_text, DisassemblyMessages.Disassembly_GotoLocation_warning);
|
||||
manager.add(fAddressBar);
|
||||
fJumpToAddressAction.setEnabled(fDebugSessionId!=null);
|
||||
|
||||
manager.add(new Separator());
|
||||
manager.add(fActionRefreshView);
|
||||
manager.add(fActionGotoPC);
|
||||
manager.add(fActionGotoAddress);
|
||||
manager.add(fActionToggleSource);
|
||||
}
|
||||
|
||||
protected void updateSelectionDependentActions() {
|
||||
|
@ -1293,6 +1305,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
|
||||
fActionGotoPC = new ActionGotoProgramCounter(this);
|
||||
fActionGotoPC.setActionDefinitionId(COMMAND_ID_GOTO_PC);
|
||||
fActionGotoPC.setImageDescriptor(DisassemblyImageRegistry.getImageDescriptor(DisassemblyImageRegistry.ICON_Home_enabled));
|
||||
fActionGotoPC.setDisabledImageDescriptor(DisassemblyImageRegistry.getImageDescriptor(DisassemblyImageRegistry.ICON_Home_disabled));
|
||||
fStateDependentActions.add(fActionGotoPC);
|
||||
registerWithHandlerService(fActionGotoPC);
|
||||
|
||||
|
@ -1308,6 +1322,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
|
||||
fActionToggleSource = new ActionToggleSource();
|
||||
fStateDependentActions.add(fActionToggleSource);
|
||||
fActionToggleSource.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(DsfUIPlugin.PLUGIN_ID, "icons/source.gif")); //$NON-NLS-1$
|
||||
fVerticalRuler.getControl().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
|
@ -2344,6 +2359,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
fUpdatePending = false;
|
||||
resetViewer();
|
||||
if (fDebugSessionId != null) {
|
||||
fJumpToAddressAction.setEnabled(true);
|
||||
fAddressBar.enableAddressBox(true);
|
||||
try {
|
||||
final DsfSession session= getSession();
|
||||
session.getExecutor().execute(new DsfRunnable() {
|
||||
|
@ -2365,6 +2382,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
}
|
||||
fViewer.addViewportListener(this);
|
||||
} else {
|
||||
fJumpToAddressAction.setEnabled(false);
|
||||
fAddressBar.enableAddressBox(false);
|
||||
fViewer.removeViewportListener(this);
|
||||
fGotoMarkerPending = null;
|
||||
// invokeLater(new Runnable() {
|
||||
|
@ -3381,5 +3400,14 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public AddressBarContributionItem getAddressBar() {
|
||||
return fAddressBar;
|
||||
}
|
||||
|
||||
public void generateErrorDialog(String message) {
|
||||
MessageDialog messageDialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), DisassemblyMessages.Disassembly_Error_Dialog_title, null, message, MessageDialog.ERROR, new String[]{DisassemblyMessages.Disassembly_Error_Dialog_ok_button}, 0);
|
||||
messageDialog.open();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2009 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
|
||||
|
@ -76,6 +76,7 @@ public class DisassemblyView extends DisassemblyPart implements IViewPart {
|
|||
protected void contributeToActionBars(IActionBars bars) {
|
||||
super.contributeToActionBars(bars);
|
||||
fillLocalPullDown(bars.getMenuManager());
|
||||
fillLocalToolBar(bars.getToolBarManager());
|
||||
}
|
||||
|
||||
protected void fillLocalPullDown(IMenuManager manager) {
|
||||
|
|
|
@ -0,0 +1,307 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Texas Instruments.
|
||||
* 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:
|
||||
* Texas Instruments - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions;
|
||||
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
import org.eclipse.jface.action.ContributionItem;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.dnd.TextTransfer;
|
||||
import org.eclipse.swt.dnd.Transfer;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
import org.eclipse.swt.events.FocusListener;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.KeyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.TraverseEvent;
|
||||
import org.eclipse.swt.events.TraverseListener;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.ToolBar;
|
||||
import org.eclipse.swt.widgets.ToolItem;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
|
||||
public class AddressBarContributionItem extends ContributionItem {
|
||||
private Combo addressBox;
|
||||
private IAction action;
|
||||
private ToolItem item;
|
||||
private int width;
|
||||
private String initialText;
|
||||
private Image warningImage = null;
|
||||
private Label warningLabel = null;
|
||||
private String warningText = null;
|
||||
|
||||
/**
|
||||
* Use this constructor to create an AddressBarContributionItem.
|
||||
*
|
||||
* @param action
|
||||
* a contribution action.
|
||||
*/
|
||||
public AddressBarContributionItem(IAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* After constructing this object, call this method to create an address
|
||||
* box.
|
||||
*
|
||||
* @param parent
|
||||
* a ToolBar object. Can be obtain with the getControl() method
|
||||
* in the ToolBarManager class.
|
||||
* @param width
|
||||
* the width of the combo box.
|
||||
* @param initialText
|
||||
* the initial text displayed in the combo box (e.g. 'Enter
|
||||
* address here')
|
||||
* @param warningText
|
||||
* the tooltip of the warning label if it ever becomes visible.
|
||||
* May be null.
|
||||
*/
|
||||
public void createAddressBox(ToolBar parent, int width, String initialText,
|
||||
String warningText) {
|
||||
this.width = width;
|
||||
this.initialText = initialText;
|
||||
this.warningText = warningText;
|
||||
fill(parent, 0);
|
||||
|
||||
parent.addDisposeListener(new DisposeListener() {
|
||||
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
if (warningImage != null)
|
||||
warningImage.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't call this method from the client, use the createAddressBox method.
|
||||
*/
|
||||
@Override
|
||||
public void fill(ToolBar parent, int index) {
|
||||
item = new ToolItem(parent, SWT.SEPARATOR);
|
||||
Control box = internalCreateAddressBox(parent);
|
||||
item.setControl(box);
|
||||
item.setWidth(width);
|
||||
|
||||
enableAddressBox(action.isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the address bar text
|
||||
*/
|
||||
public void setText(String text) {
|
||||
if (addressBox != null)
|
||||
addressBox.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the address bar text
|
||||
*
|
||||
* @return The text in the address bar.
|
||||
*/
|
||||
public String getText() {
|
||||
if (addressBox != null)
|
||||
return addressBox.getText();
|
||||
else
|
||||
return initialText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility of the warning icon. Should be set to true when there
|
||||
* is a problem jumping to the specified address; false otherwise
|
||||
*
|
||||
* @param visible
|
||||
* True for visible, false for hidden.
|
||||
*/
|
||||
public void setWarningIconVisible(boolean visible) {
|
||||
if (warningLabel == null)
|
||||
return;
|
||||
warningLabel.setVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the warning icon is visible or not.
|
||||
*
|
||||
* @return True if visible, otherwise false.
|
||||
*/
|
||||
public boolean isWarningIconVisible() {
|
||||
if (warningLabel == null)
|
||||
return false;
|
||||
return warningLabel.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the address combo box.
|
||||
*
|
||||
* @param enable
|
||||
* true to enable, else false.
|
||||
*/
|
||||
public void enableAddressBox(boolean enable) {
|
||||
if (addressBox != null) {
|
||||
item.setEnabled(enable);
|
||||
addressBox.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the combo box and add it to the toolbar.
|
||||
*
|
||||
* @param parent
|
||||
* the parent, toolbar.
|
||||
* @return the combo box address control.
|
||||
*/
|
||||
private Control internalCreateAddressBox(Composite parent) {
|
||||
Composite top = new Composite(parent, SWT.NULL);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.marginHeight = layout.marginWidth = 0;
|
||||
layout.verticalSpacing = layout.horizontalSpacing = 2;
|
||||
layout.numColumns = 3;
|
||||
top.setLayout(layout);
|
||||
|
||||
warningLabel = new Label(top, SWT.NONE);
|
||||
|
||||
warningImage = AbstractUIPlugin
|
||||
.imageDescriptorFromPlugin(
|
||||
DsfUIPlugin.PLUGIN_ID, "icons/address_warning.gif").createImage(); //$NON-NLS-1$
|
||||
warningLabel.setImage(warningImage);
|
||||
warningLabel.setToolTipText(warningText);
|
||||
setWarningIconVisible(false);
|
||||
|
||||
addressBox = new Combo(top, SWT.DROP_DOWN);
|
||||
|
||||
addressBox.setText(initialText);
|
||||
action.setText(initialText);
|
||||
|
||||
addressBox.addFocusListener(new FocusListener() {
|
||||
// [nmehregani]: Support Ctrl+C in address bar
|
||||
KeyListener keyListener = new KeyListener() {
|
||||
|
||||
public void keyPressed(KeyEvent e) {
|
||||
/* Not used */
|
||||
}
|
||||
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.stateMask == SWT.CTRL
|
||||
&& (((char) e.keyCode) == 'c' || ((char) e.keyCode) == 'C')) {
|
||||
String selection = null;
|
||||
|
||||
Point selectionPoint = addressBox.getSelection();
|
||||
if (selectionPoint.x == selectionPoint.y)
|
||||
return;
|
||||
|
||||
selection = addressBox.getText().substring(
|
||||
selectionPoint.x, selectionPoint.y);
|
||||
|
||||
if ((selection != null)
|
||||
&& (!(selection.trim().length() == 0))) {
|
||||
Clipboard clipboard = null;
|
||||
try {
|
||||
clipboard = new Clipboard(addressBox
|
||||
.getDisplay());
|
||||
clipboard.setContents(
|
||||
new Object[] { selection },
|
||||
new Transfer[] { TextTransfer
|
||||
.getInstance() });
|
||||
} finally {
|
||||
if (clipboard != null)
|
||||
clipboard.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
// Erase the guide text when the focus is gained.
|
||||
if (addressBox.getText().trim().equals(initialText))
|
||||
addressBox.setText(""); //$NON-NLS-1$
|
||||
|
||||
// [nmehregani]: Support Ctrl+C in address bar
|
||||
addressBox.addKeyListener(keyListener);
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e) {
|
||||
// Re-insert the guide text when the focus is lost and the text
|
||||
// field is empty.
|
||||
if (addressBox.getText().trim().length() == 0)
|
||||
addressBox.setText(initialText);
|
||||
|
||||
// [nmehregani]: Support Ctrl+C in address bar
|
||||
addressBox.removeKeyListener(keyListener);
|
||||
}
|
||||
});
|
||||
|
||||
addressBox.addTraverseListener(new TraverseListener() {
|
||||
|
||||
public void keyTraversed(TraverseEvent e) {
|
||||
if (e.detail == SWT.TRAVERSE_RETURN) {
|
||||
String addressBoxStr = addressBox.getText();
|
||||
|
||||
// don't accept the initial text
|
||||
if (addressBoxStr.equals(initialText))
|
||||
return;
|
||||
|
||||
Event event = new Event();
|
||||
event.data = addressBoxStr;
|
||||
action.runWithEvent(event);
|
||||
|
||||
boolean bExist = false;
|
||||
for (int i = 0; i < addressBox.getItemCount(); ++i) {
|
||||
String itemText = addressBox.getItem(i);
|
||||
if (itemText.equals(addressBoxStr)) {
|
||||
bExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!bExist) && (addressBox.getText() != null)
|
||||
&& (!(addressBox.getText().trim().length() == 0)))
|
||||
addressBox.add(addressBox.getText());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
addressBox.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent selectionEvent) {
|
||||
int selection = addressBox.getSelectionIndex();
|
||||
if (selection >= 0) {
|
||||
String addressBoxStr = addressBox.getItem(selection);
|
||||
Event event = new Event();
|
||||
event.data = addressBoxStr;
|
||||
action.runWithEvent(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addressBox.setLayoutData(new GridData(GridData.FILL,
|
||||
GridData.BEGINNING, true, false));
|
||||
return top;
|
||||
}
|
||||
|
||||
// [nmehregani]: Support Ctrl+C in address bar
|
||||
public void clearSelection() {
|
||||
addressBox.clearSelection();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Texas Instruments, 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Texas Instruments[nmehregani] - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart;
|
||||
import org.eclipse.jface.action.Action;
|
||||
|
||||
public class JumpToAddressAction extends Action {
|
||||
|
||||
DisassemblyPart fDisassemblyPart = null;
|
||||
|
||||
public JumpToAddressAction(DisassemblyPart disassemblyPart) {
|
||||
fDisassemblyPart = disassemblyPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AddressBarContributionItem addressBar = fDisassemblyPart.getAddressBar();
|
||||
if (addressBar!=null && addressBar.isEnabled() && fDisassemblyPart.isSuspended()) {
|
||||
String location = addressBar.getText();
|
||||
|
||||
if (location==null || location.trim().length()==0)
|
||||
return;
|
||||
|
||||
location = location.trim();
|
||||
BigInteger address = null;
|
||||
try {
|
||||
address = DisassemblyPart.decodeAddress(location);
|
||||
if (address.compareTo(BigInteger.ZERO) < 0) {
|
||||
address = null;
|
||||
addressBar.setWarningIconVisible(true);
|
||||
fDisassemblyPart.generateErrorDialog(DisassemblyMessages.Disassembly_GotoAddressDialog_error_invalid_address);
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException x) {
|
||||
// This will be handled below. location will be treated as a symbol
|
||||
}
|
||||
|
||||
// hide warning icon if it was shown before
|
||||
addressBar.setWarningIconVisible(false);
|
||||
|
||||
/* Location is an address */
|
||||
if (address!=null) {
|
||||
fDisassemblyPart.gotoAddress(address);
|
||||
}
|
||||
/* Location is a symbol */
|
||||
else {
|
||||
fDisassemblyPart.gotoSymbol(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue