1
/*******************************************************************************
2
* Copyright (c) 2008 Wind River Systems, Inc. and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Wind River Systems - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions;
13
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages;
14
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart;
15
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
16
import org.eclipse.cdt.internal.ui.text.CWordFinder;
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.jface.dialogs.InputDialog;
19
import org.eclipse.jface.text.BadLocationException;
20
import org.eclipse.jface.text.IDocument;
21
import org.eclipse.jface.text.IRegion;
22
import org.eclipse.jface.text.ITextViewer;
23
import org.eclipse.swt.widgets.Shell;
25
@SuppressWarnings("restriction")
26
public final class ActionGotoSymbol extends AbstractDisassemblyAction {
27
public ActionGotoSymbol(IDisassemblyPart disassemblyPart) {
28
super(disassemblyPart);
29
setText(DisassemblyMessages.Disassembly_action_GotoSymbol_label);
33
ITextViewer viewer = getDisassemblyPart().getTextViewer();
34
IDocument document= viewer.getDocument();
35
IRegion wordRegion = CWordFinder.findWord(document, viewer.getSelectedRange().x);
36
String defaultValue = null;
37
if (wordRegion != null) {
39
defaultValue = document.get(wordRegion.getOffset(), wordRegion.getLength());
40
} catch (BadLocationException e) {
44
if (defaultValue == null) {
45
defaultValue = DsfUIPlugin.getDefault().getDialogSettings().get("gotoSymbol"); //$NON-NLS-1$
46
if (defaultValue == null) {
47
defaultValue = ""; //$NON-NLS-1$
50
String dlgTitle = DisassemblyMessages.Disassembly_GotoSymbolDialog_title;
51
String dlgLabel = DisassemblyMessages.Disassembly_GotoSymbolDialog_label;
52
final Shell shell= getDisassemblyPart().getSite().getShell();
53
InputDialog dlg = new InputDialog(shell, dlgTitle, dlgLabel, defaultValue, null);
54
if (dlg.open() == IDialogConstants.OK_ID) {
55
String value = dlg.getValue();
56
DsfUIPlugin.getDefault().getDialogSettings().put("gotoSymbol", value); //$NON-NLS-1$
57
getDisassemblyPart().gotoSymbol(value);