diff options
author | Darin Wright | 2005-03-23 22:59:06 +0000 |
---|---|---|
committer | Darin Wright | 2005-03-23 22:59:06 +0000 |
commit | 1b7ae6f738fd70c88b343c9c2135767ef8aecf12 (patch) | |
tree | 581156928a111b9a4c616b37d8d9a605b521b3ae /org.eclipse.debug.ui | |
parent | 4bc179d7000fa9939cab77ef6de5db7555c48457 (diff) | |
download | eclipse.platform.debug-1b7ae6f738fd70c88b343c9c2135767ef8aecf12.tar.gz eclipse.platform.debug-1b7ae6f738fd70c88b343c9c2135767ef8aecf12.tar.xz eclipse.platform.debug-1b7ae6f738fd70c88b343c9c2135767ef8aecf12.zip |
Bug 88945 - [Memory View] Add code page preference for Memory View
Diffstat (limited to 'org.eclipse.debug.ui')
18 files changed, 454 insertions, 80 deletions
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties index 9910e3c8c..e86e91d72 100644 --- a/org.eclipse.debug.ui/plugin.properties +++ b/org.eclipse.debug.ui/plugin.properties @@ -330,4 +330,6 @@ SetDefaultColumnSizeActionName =Set Default Column Size ... SetPaddedStrActionName = Set Padded String ... DropToFrameAction.label=Drop to Frame -DropToFrameAction.tooltip=Drop to Frame
\ No newline at end of file +DropToFrameAction.tooltip=Drop to Frame + +SelectCodepagesAction.label = Select Codepages...
\ No newline at end of file diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index 57d15f188..3ccd92ba1 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml @@ -884,6 +884,14 @@ style="push" menubarPath="additions" id="org.eclipse.debug.ui.setPaddedStrAction"/> + <action + class="org.eclipse.debug.internal.ui.views.memory.SelectCodePagesAction" + helpContextId="SelectCodePagesAction_context" + id="org.eclipse.debug.ui.selectCodePage" + label="%SelectCodepagesAction.label" + menubarPath="additions" + style="push" + tooltip="%SelectCodepagesAction.label"/> </viewContribution> </extension> <extension diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties index c717dc764..0935470ca 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIMessages.properties @@ -95,6 +95,19 @@ GoToAddressDialog.Address = Address: GoToAddressDialog.GoToAddress = Go To Address... DefaultColumnSizeDialog.DefaultColumnSize = Default Column Size DefaultColumnSizeDialog.ColumnSize = &Column Size: +CodePagesPrefDialog.1=Select Codepages +CodePagesPrefDialog.2=Codepage for rendering memory to ASCII strings: +CodePagesPrefDialog.3=Change... +CodePagesPrefDialog.4=Codepage for rendering memory to EBCDIC strings: +CodePagesPrefDialog.5=Change... +CodePagesPrefDialog.6=Invalid codepage +CodePagesPrefDialog.7=ASCII codepage entered is invalid. +CodePagesPrefDialog.8=Invalid codepage +CodePagesPrefDialog.9=EBCDIC codepage entered is invalid. +CodePagesPrefDialog.0=The codepage is not supported. +CodePagesPrefDialog.10=Select Codepage +CodePagesPrefDialog.11=Select Codepage +CodePagesPrefDialog.13=Restore Defaults ############################################################## # View Tab diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java index 8ab0121b8..f383ab56b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java @@ -93,7 +93,13 @@ public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer IDebugPreferenceConstants.PREF_COLUMN_SIZE_DEFAULT); // set default padded string - prefs.setDefault(IDebugPreferenceConstants.PREF_PADDED_STR, + prefs.setDefault(IDebugUIConstants.PREF_PADDED_STR, IDebugPreferenceConstants.PREF_PADDED_STR_DEFAULT); + + // set default code page for ascii and ebcdic + prefs.setDefault(IDebugUIConstants.PREF_DEFAULT_ASCII_CODE_PAGE, + IDebugPreferenceConstants.DEFAULT_ASCII_CP); + prefs.setDefault(IDebugUIConstants.PREF_DEFAULT_EBCDIC_CODE_PAGE, + IDebugPreferenceConstants.DEFAULT_EBCDIC_CP); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java index 2da12096b..415de3d45 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java @@ -144,17 +144,24 @@ public interface IDebugPreferenceConstants { public static final int PREF_COLUMN_SIZE_DEFAULT = 4; /** - * Padded string preference for renderings + * Default padded string for renderings + * * @since 3.1 */ - public static final String PREF_PADDED_STR = "org.eclipse.debug.ui.memory.abstractTableRendering.paddedStr"; //$NON-NLS-1$ + public static final String PREF_PADDED_STR_DEFAULT = "??"; //$NON-NLS-1$ /** - * Default padded string for renderings - * + * Default ASCII code page if ASCII code page preference is not set. * @since 3.1 */ - public static final String PREF_PADDED_STR_DEFAULT = "??"; //$NON-NLS-1$ + public static final String DEFAULT_ASCII_CP = "windows-1252"; //$NON-NLS-1$ + + + /** + * Default EBCDIC code page if EBCDIC code page preference is not set. + * @since 3.1 + */ + public static final String DEFAULT_EBCDIC_CP = "IBM-1047"; //$NON-NLS-1$ } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CodePagesPrefDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CodePagesPrefDialog.java new file mode 100644 index 000000000..a4cb9169f --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CodePagesPrefDialog.java @@ -0,0 +1,251 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.memory; + +import java.nio.charset.Charset; +import java.util.Set; +import java.util.SortedMap; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.internal.ui.DebugUIMessages; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; +import org.eclipse.ui.internal.help.WorkbenchHelpSystem; + + +/** + * Dialog to allow user to change code page preference + * @since 3.1 + */ +public class CodePagesPrefDialog extends Dialog { + + private Text fAsciiCodePage; + private Text fEbcdicCodePage; + + private static CharSetInfo[] fCodePages; + + private class CharSetInfo + { + String fCharSetName; + String fDisplayName; + + public CharSetInfo(String charSetName, String displayName) { + + fCharSetName = charSetName; + fDisplayName = displayName; + } + + public String toString() { + return fDisplayName; + } + } + + /** + * @param parentShell + */ + public CodePagesPrefDialog(Shell parentShell) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); + WorkbenchHelpSystem.getInstance().setHelp(parentShell, DebugUIPlugin.getUniqueIdentifier() + ".CodePagesPrefDialog_context"); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + + getShell().setText(DebugUIMessages.getString("CodePagesPrefDialog.1")); //$NON-NLS-1$ + setShellStyle(SWT.RESIZE); + + Composite canvas = new Composite(parent, SWT.NONE); + canvas.setLayout(new GridLayout(2, false)); + GridData spec2= new GridData(); + spec2.grabExcessVerticalSpace= true; + spec2.grabExcessHorizontalSpace= true; + spec2.horizontalAlignment= GridData.FILL; + spec2.verticalAlignment= GridData.CENTER; + canvas.setLayoutData(spec2); + + Label textLabel = new Label(canvas, SWT.WRAP); + textLabel.setText(DebugUIMessages.getString("CodePagesPrefDialog.2")); //$NON-NLS-1$ + GridData textLayout = new GridData(); + textLayout.widthHint = 280; + textLayout.horizontalSpan = 2; + textLabel.setLayoutData(textLayout); + + fAsciiCodePage = new Text(canvas, SWT.READ_ONLY | SWT.BORDER); + GridData asciispec= new GridData(); + asciispec.grabExcessVerticalSpace= false; + asciispec.grabExcessHorizontalSpace= true; + asciispec.horizontalAlignment= GridData.FILL; + asciispec.verticalAlignment= GridData.BEGINNING; + asciispec.horizontalSpan = 1; + fAsciiCodePage.setLayoutData(asciispec); + + String codepage = DebugUITools.getPreferenceStore().getString(IDebugUIConstants.PREF_DEFAULT_ASCII_CODE_PAGE); + if (codepage == null || codepage.length() == 0) + codepage = "CP1252"; //$NON-NLS-1$ + fAsciiCodePage.setText(codepage); + + Button asciiButton = new Button(canvas, SWT.PUSH); + asciiButton.setText(DebugUIMessages.getString("CodePagesPrefDialog.3")); //$NON-NLS-1$ + asciiButton.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + Shell shell = DebugUIPlugin.getShell(); + if (shell != null) + openCodePageSelectionDialog(shell, fAsciiCodePage.getText(), fAsciiCodePage); + }}); + Label ebcdicLabel = new Label(canvas, SWT.WRAP); + ebcdicLabel.setText(DebugUIMessages.getString("CodePagesPrefDialog.4")); //$NON-NLS-1$ + GridData ebcdicLayout = new GridData(); + ebcdicLayout.widthHint = 280; + ebcdicLayout.horizontalSpan = 2; + ebcdicLabel.setLayoutData(ebcdicLayout); + + fEbcdicCodePage = new Text(canvas, SWT.READ_ONLY | SWT.BORDER); + GridData ebcdicspec= new GridData(); + ebcdicspec.grabExcessVerticalSpace= false; + ebcdicspec.grabExcessHorizontalSpace= true; + ebcdicspec.horizontalAlignment= GridData.FILL; + ebcdicspec.verticalAlignment= GridData.BEGINNING; + ebcdicspec.horizontalSpan = 1; + fAsciiCodePage.setLayoutData(ebcdicspec); + fEbcdicCodePage.setLayoutData(asciispec); + + codepage = DebugUITools.getPreferenceStore().getString(IDebugUIConstants.PREF_DEFAULT_EBCDIC_CODE_PAGE); + fEbcdicCodePage.setText(codepage); + + if (codepage == null || codepage.length() == 0) + codepage = "CP1047"; //$NON-NLS-1$ + + Button ebcdicButon = new Button(canvas, SWT.PUSH); + ebcdicButon.setText(DebugUIMessages.getString("CodePagesPrefDialog.5")); //$NON-NLS-1$ + + ebcdicButon.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + Shell shell = DebugUIPlugin.getShell(); + if (shell != null) + openCodePageSelectionDialog(shell, fEbcdicCodePage.getText(), fEbcdicCodePage); + }}); + + return canvas; + } + protected void okPressed() { + + // check that the codepages are supported + String asciiCodePage = fAsciiCodePage.getText(); + if (!Charset.isSupported(asciiCodePage)) + { + Shell shell = DebugUIPlugin.getShell(); + if (shell != null) + { + IStatus status = DebugUIPlugin.newErrorStatus(DebugUIMessages.getString("CodePagesPrefDialog.0"), null); //$NON-NLS-1$ + ErrorDialog.openError(shell, DebugUIMessages.getString("CodePagesPrefDialog.6"), DebugUIMessages.getString("CodePagesPrefDialog.7"), status); //$NON-NLS-1$ //$NON-NLS-2$ + } + return; + } + + String ebcdicCodePage = fEbcdicCodePage.getText(); + if (!Charset.isSupported(ebcdicCodePage)) + { + Shell shell = DebugUIPlugin.getShell(); + if (shell != null) + { + IStatus status = DebugUIPlugin.newErrorStatus(DebugUIMessages.getString("CodePagesPrefDialog.0"), null); //$NON-NLS-1$ + ErrorDialog.openError(shell, DebugUIMessages.getString("CodePagesPrefDialog.8"), DebugUIMessages.getString("CodePagesPrefDialog.9"), status); //$NON-NLS-1$ //$NON-NLS-2$ + } + return; + } + + IPreferenceStore store = DebugUITools.getPreferenceStore(); + store.setValue(IDebugUIConstants.PREF_DEFAULT_ASCII_CODE_PAGE, asciiCodePage); + store.setValue(IDebugUIConstants.PREF_DEFAULT_EBCDIC_CODE_PAGE, ebcdicCodePage); + + super.okPressed(); + } + + /** + * @param shell + */ + private void openCodePageSelectionDialog(Shell shell, String initialSelection, Text text) { + ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider(){}); + dialog.setTitle(DebugUIMessages.getString("CodePagesPrefDialog.10")); //$NON-NLS-1$ + dialog.setMessage(DebugUIMessages.getString("CodePagesPrefDialog.11")); //$NON-NLS-1$ + dialog.setMultipleSelection(false); + + WorkbenchHelpSystem.getInstance().setHelp(shell, DebugUIPlugin.getUniqueIdentifier() + ".SelectCodepageDialog_context"); //$NON-NLS-1$ + + if (fCodePages == null) + { + SortedMap map = Charset.availableCharsets(); + Set keys = map.keySet(); + Object[] charSetKeys = keys.toArray(); + + fCodePages = new CharSetInfo[charSetKeys.length]; + + for (int i=0; i<fCodePages.length; i++) + { + fCodePages[i] = new CharSetInfo((String)charSetKeys[i], Charset.forName((String)charSetKeys[i]).displayName()); + } + } + dialog.setElements(fCodePages); + + // find initial selection + CharSetInfo selected = null; + for (int i=0; i<fCodePages.length; i++){ + if (fCodePages[i].fCharSetName.equals(initialSelection)) + { + selected = fCodePages[i]; + break; + } + } + if (selected != null) + dialog.setFilter(selected.fCharSetName); + + dialog.open(); + Object selection = dialog.getFirstResult(); + if (selection instanceof CharSetInfo) + text.setText(((CharSetInfo)selection).fCharSetName); + } + + protected void createButtonsForButtonBar(Composite parent) { + Button defaultButton = createButton(parent, 3, DebugUIMessages.getString("CodePagesPrefDialog.13"), false); //$NON-NLS-1$ + defaultButton.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + String defaultASCII = IDebugPreferenceConstants.DEFAULT_ASCII_CP; + fAsciiCodePage.setText(defaultASCII); + String defaulgEBCDIC = IDebugPreferenceConstants.DEFAULT_EBCDIC_CP; + fEbcdicCodePage.setText(defaulgEBCDIC); + }}); + super.createButtonsForButtonBar(parent); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java index 77a90b5c9..462d334d6 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Hashtable; import org.eclipse.debug.core.DebugEvent; -import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IMemoryBlockListener; import org.eclipse.debug.core.model.IDebugElement; @@ -167,7 +166,6 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView if (newInput != fDebugTarget && newInput instanceof IDebugTarget) { fDebugTarget = (IDebugTarget)newInput; - maintainMemoryBlocksReference(false); fMemoryBlocks.clear(); getMemoryBlocks(); updateActionsEnablement(); @@ -191,9 +189,6 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView if (!fMemoryBlocks.contains(memoryBlocks[i])) { fMemoryBlocks.add(memoryBlocks[i]); - - if (memoryBlocks[i] instanceof IMemoryBlockExtension && fVisible) - ((IMemoryBlockExtension)memoryBlocks[i]).connect(getInstance()); } } } @@ -236,9 +231,6 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView if (!fMemoryBlocks.contains(memoryBlocks[i])) { fMemoryBlocks.add(memoryBlocks[i]); - - if (memoryBlocks[i] instanceof IMemoryBlockExtension && fVisible) - ((IMemoryBlockExtension)memoryBlocks[i]).connect(getInstance()); } } @@ -258,8 +250,6 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView public void run() { for (int i=0; i<memory.length; i++) { - if (memory[i] instanceof IMemoryBlockExtension) - ((IMemoryBlockExtension)memory[i]).disconnect(getInstance()); fMemoryBlocks.remove(memory[i]); } @@ -364,20 +354,12 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView String memoryBlockLabel = " "; //$NON-NLS-1$ if (memoryBlock instanceof IMemoryBlockExtension) { + // simply return the expression without the address + // do not want to keep track of changes in the address if (((IMemoryBlockExtension)memoryBlock).getExpression() != null) { memoryBlockLabel += ((IMemoryBlockExtension)memoryBlock).getExpression(); } - - try { - if (((IMemoryBlockExtension)memoryBlock).getBigBaseAddress() != null) - { - memoryBlockLabel += " = 0x" + ((IMemoryBlockExtension)memoryBlock).getBigBaseAddress().toString(16); //$NON-NLS-1$ - } - } catch (DebugException e) { - // return whatever we have for label - return memoryBlockLabel; - } } else { @@ -432,37 +414,9 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView fTreeViewer.setSelection(new StructuredSelection(memoryBlocks[0])); } - maintainMemoryBlocksReference(fVisible); - return fTreeViewer.getControl(); } - private void maintainMemoryBlocksReference(boolean add) - { - if (fMemoryBlocks == null) - return; - IMemoryBlock[] memoryBlocks = (IMemoryBlock[])fMemoryBlocks.toArray(new IMemoryBlock[fMemoryBlocks.size()]); - - if (add){ - for (int i=0; i<memoryBlocks.length; i++) - { - if (memoryBlocks[i] instanceof IMemoryBlockExtension) - { - ((IMemoryBlockExtension)memoryBlocks[i]).connect(this); - } - } - } - else { - for (int i=0; i<memoryBlocks.length; i++) - { - if (memoryBlocks[i] instanceof IMemoryBlockExtension) - { - ((IMemoryBlockExtension)memoryBlocks[i]).disconnect(this); - } - } - } - } - /** * @@ -496,7 +450,6 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView public void dispose() { - maintainMemoryBlocksReference(false); fMemoryBlocks.clear(); DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getSelectionService().removeSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, this); //$NON-NLS-1$ fContentProvider.dispose(); @@ -590,11 +543,6 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView public ISelectionProvider getSelectionProvider() { return fSelectionProvider; } - - private IMemoryViewPane getInstance() - { - return this; - } /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.views.memory.IMemoryViewPane#restoreViewPane() @@ -621,8 +569,6 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, IMemoryView if(fVisible) fTreeViewer.refresh(); - - maintainMemoryBlocksReference(fVisible); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SelectCodePagesAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SelectCodePagesAction.java new file mode 100644 index 000000000..0e5b906a1 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SelectCodePagesAction.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.memory; + +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +/** + * Action to allow user to change code page preference. + * @since 3.1 + */ +public class SelectCodePagesAction implements IViewActionDelegate { + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) + */ + public void init(IViewPart view) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + Shell shell = DebugUIPlugin.getActiveWorkbenchWindow().getShell(); + + CodePagesPrefDialog dialog = new CodePagesPrefDialog(shell); + dialog.open(); + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ASCIIRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ASCIIRendering.java index c6ae20226..39c47db37 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ASCIIRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ASCIIRendering.java @@ -13,7 +13,10 @@ package org.eclipse.debug.internal.ui.views.memory.renderings; import java.math.BigInteger; import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.AbstractTextRendering; +import org.eclipse.jface.util.PropertyChangeEvent; @@ -24,13 +27,22 @@ import org.eclipse.debug.ui.memory.AbstractTextRendering; */ public class ASCIIRendering extends AbstractTextRendering{ - private final static String ASCII_CODE_PAGE = "CP1252"; //$NON-NLS-1$ private final int numCharsPerByte = 1; public ASCIIRendering(String renderingId) { - super(renderingId, ASCII_CODE_PAGE); + super(renderingId); + String codepage = DebugUITools.getPreferenceStore().getString(IDebugUIConstants.PREF_DEFAULT_ASCII_CODE_PAGE); + setCodePage(codepage); + + // add as preference store listener + DebugUITools.getPreferenceStore().addPropertyChangeListener(this); + } + + public void dispose() { + DebugUITools.getPreferenceStore().removePropertyChangeListener(this); + super.dispose(); } /* (non-Javadoc) @@ -93,4 +105,23 @@ public class ASCIIRendering extends AbstractTextRendering{ return super.getString(renderingId, address, copy); } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + + // handle code page changed event + if (event.getProperty().equals(IDebugUIConstants.PREF_DEFAULT_ASCII_CODE_PAGE)) + { + String codePage = (String)event.getNewValue(); + setCodePage(codePage); + + if (isVisible()) + // just update labels, don't need to reget memory + updateLabels(); + } + + super.propertyChange(event); + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/HexRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/HexRendering.java index b76291310..d49e28934 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/HexRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/HexRendering.java @@ -14,7 +14,7 @@ import java.math.BigInteger; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.AbstractTableRendering; /** @@ -34,7 +34,7 @@ public class HexRendering extends AbstractTableRendering { MemoryByte[] data) { StringBuffer strBuffer = new StringBuffer(); - String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugPreferenceConstants.PREF_PADDED_STR); + String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); for (int i=0; i<data.length; i++) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SetPaddedStringDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SetPaddedStringDialog.java index a5a808f5e..504527759 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SetPaddedStringDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SetPaddedStringDialog.java @@ -13,7 +13,6 @@ package org.eclipse.debug.internal.ui.views.memory.renderings; import org.eclipse.debug.internal.ui.DebugUIMessages; import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.dialogs.Dialog; @@ -61,7 +60,7 @@ public class SetPaddedStringDialog extends Dialog { GridData textLayout = new GridData(); textLabel.setLayoutData(textLayout); - fPaddedString = new StringFieldEditor(IDebugPreferenceConstants.PREF_PADDED_STR, "",content ); //$NON-NLS-1$ + fPaddedString = new StringFieldEditor(IDebugUIConstants.PREF_PADDED_STR, "",content ); //$NON-NLS-1$ fPaddedString.fillIntoGrid(content, 2); fPaddedString.setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore()); fPaddedString.load(); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java index 031133304..9e79fba74 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/SignedIntegerRendering.java @@ -14,7 +14,7 @@ import java.math.BigInteger; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.ui.IDebugUIConstants; /** * @@ -139,7 +139,7 @@ public class SignedIntegerRendering extends AbstractIntegerRendering { public String getString(String dataType, BigInteger address, MemoryByte[] data) { boolean invalid = false; - String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugPreferenceConstants.PREF_PADDED_STR); + String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); for (int i=0; i<data.length; i++) { if (!data[i].isReadable()) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java index cfc0723d4..0f626736a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java @@ -19,8 +19,8 @@ import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIMessages; import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.AbstractTableRendering; import org.eclipse.jface.viewers.ICellModifier; import org.eclipse.swt.widgets.TableItem; @@ -279,7 +279,7 @@ public class TableRenderingCellModifier implements ICellModifier */ public String getPaddedString(int start, int end) { StringBuffer buf = new StringBuffer(); - String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugPreferenceConstants.PREF_PADDED_STR); + String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); for (int i=start; i<end; i++) { buf.append(paddedStr); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java index 269d58950..db3478501 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentProvider.java @@ -28,7 +28,7 @@ import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIMessages; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; @@ -226,7 +226,7 @@ public class TableRenderingContentProvider extends BasicDebugViewContentProvider IMemoryBlockExtension extMemoryBlock = null; MemoryByte[] memoryBuffer = null; - String paddedString = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugPreferenceConstants.PREF_PADDED_STR); + String paddedString = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); long reqNumBytes = 0; try diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java index 4c3cf341a..2d126c515 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/UnsignedIntegerRendering.java @@ -14,7 +14,7 @@ import java.math.BigInteger; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.ui.IDebugUIConstants; /** * Represent unsigned integer rendering @@ -124,7 +124,7 @@ public class UnsignedIntegerRendering extends AbstractIntegerRendering { */ public String getString(String dataType, BigInteger address, MemoryByte[] data) { - String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugPreferenceConstants.PREF_PADDED_STR); + String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); boolean invalid = false; for (int i=0; i<data.length; i++) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java index d0db0dc66..1bde1865f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java @@ -982,4 +982,23 @@ public interface IDebugUIConstants { * @since 3.1 */ public static final String EXTENSION_POINT_BREAKPOINT_ORGANIZERS = "breakpointOrganizers"; //$NON-NLS-1$ + + /** + * Padded string preference for renderings. Padded string is the string to be used in place of + * of a memory byte if a rendering cannot render the data properly. + * @since 3.1 + */ + public static final String PREF_PADDED_STR = PLUGIN_ID + ".memory.paddedStr"; //$NON-NLS-1$ + + /** + * ASCII code page for rendering memory to ASCII strings. + * @since 3.1 + */ + public static final String PREF_DEFAULT_ASCII_CODE_PAGE = PLUGIN_ID + ".defaultAsciiCodePage"; //$NON-NLS-1$ + + /** + * EBCDIC code page for rendering memory to EBCDIC strings. + * @since 3.1 + */ + public static final String PREF_DEFAULT_EBCDIC_CODE_PAGE = PLUGIN_ID + ".defaultEbcdicCodePage"; //$NON-NLS-1$ } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java index 6258c8c05..ef5cbe940 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java @@ -270,7 +270,7 @@ public abstract class AbstractTableRendering extends AbstractMemoryRendering imp return; } - if (event.getProperty().equals(IDebugPreferenceConstants.PREF_PADDED_STR)) + if (event.getProperty().equals(IDebugUIConstants.PREF_PADDED_STR)) { if (!fIsDisposed) { @@ -2443,7 +2443,11 @@ public abstract class AbstractTableRendering extends AbstractMemoryRendering imp public void becomesHidden() { if (isVisible() == false) + { + // super should always be called + super.becomesHidden(); return; + } super.becomesHidden(); @@ -2466,7 +2470,11 @@ public abstract class AbstractTableRendering extends AbstractMemoryRendering imp // do not do anything if already visible if (isVisible() == true) + { + // super should always be called + super.becomesVisible(); return; + } super.becomesVisible(); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTextRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTextRendering.java index ec06d47d2..d5d5a9866 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTextRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTextRendering.java @@ -15,7 +15,7 @@ import java.math.BigInteger; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.ui.IDebugUIConstants; /** * Abstract implementation of a rendering that translates memory into @@ -29,6 +29,16 @@ import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; abstract public class AbstractTextRendering extends AbstractTableRendering { private String fCodePage; + + /** + * Constructs a text rendering of the specified type. + * + * @param renderingId memory rendering type identifier + */ + public AbstractTextRendering(String renderingId) + { + super(renderingId); + } /** * Constructs a text rendering of the specified type on the given @@ -45,12 +55,37 @@ abstract public class AbstractTextRendering extends AbstractTableRendering { fCodePage = codePage; } + /** + * Sets the code page for this rendering. This does not cause + * the rendering to be updated with the new code page. Clients need + * to update the rendering manually when the code page is changed. + * + * @param codePage the name of a supported + * {@link java.nio.charset.Charset </code>charset<code>}, for + * example <code>CP1252</code> + */ + public void setCodePage(String codePage) + { + fCodePage = codePage; + } + + /** + * Returns the current code page used by this rendering. Returns null + * if not set. + * @return Returns the current code page used by this rendering. Returns null + * if not set. + */ + public String getCodePage() + { + return fCodePage; + } + /* (non-Javadoc) * @see org.eclipse.debug.ui.memory.AbstractTableRendering#getString(java.lang.String, java.math.BigInteger, org.eclipse.debug.core.model.MemoryByte[]) */ public String getString(String dataType, BigInteger address, MemoryByte[] data) { try { - String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugPreferenceConstants.PREF_PADDED_STR); + String paddedStr = DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR); if(fCodePage == null) return ""; //$NON-NLS-1$ |