Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2004-11-24 21:36:49 +0000
committerDarin Wright2004-11-24 21:36:49 +0000
commit31b5add74b9a0b69b0fb557f017621bb1b13603c (patch)
tree99610a18e0e982d65826dc2be128fcd7e644fd19
parent4b72b628ae66e1d31a50a2a714488c413db8a8db (diff)
downloadeclipse.platform.debug-31b5add74b9a0b69b0fb557f017621bb1b13603c.tar.gz
eclipse.platform.debug-31b5add74b9a0b69b0fb557f017621bb1b13603c.tar.xz
eclipse.platform.debug-31b5add74b9a0b69b0fb557f017621bb1b13603c.zip
Bug 79255 - Enhancements to Memory View
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java54
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java61
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryAction.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java26
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java104
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java9
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/BigEndianAction.java16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CreateRenderingTab.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryBlockModelPresentation.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingManager.java71
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryViewPane.java78
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMultipaneMemoryView.java15
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IRenderingViewPane.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingListener.java)27
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/LittleEndianAction.java16
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryRenderingManager.java347
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java172
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewPane.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java129
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTabLabelProvider.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java48
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java97
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SignedIntegerRenderer.java11
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/UnsignedIntegerRenderer.java14
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java352
25 files changed, 926 insertions, 767 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java
index 466c71653..062f67a6f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java
@@ -11,6 +11,7 @@
package org.eclipse.debug.internal.ui;
+import java.math.BigInteger;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -25,10 +26,13 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation;
+import org.eclipse.debug.internal.ui.views.memory.IMemoryRenderingType;
import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
import org.eclipse.debug.ui.IDebugEditorPresentation;
import org.eclipse.debug.ui.IDebugModelPresentation;
@@ -51,7 +55,7 @@ import org.eclipse.ui.IEditorPart;
* asked to render an object from a debug model, this presentation delegates
* to the extension registered for that debug model.
*/
-public class DelegatingModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider {
+public class DelegatingModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider, IMemoryBlockModelPresentation {
/**
* A mapping of attribute ids to their values
@@ -383,4 +387,52 @@ public class DelegatingModelPresentation implements IDebugModelPresentation, IDe
}
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getTabLabel(org.eclipse.debug.core.model.IMemoryBlock, java.lang.String)
+ */
+ public String getTabLabel(IMemoryBlock blk, String renderingId) {
+ IDebugModelPresentation modelPresentation = getConfiguredPresentation(blk);
+ if (modelPresentation instanceof IMemoryBlockModelPresentation)
+ {
+ return ((IMemoryBlockModelPresentation)modelPresentation).getTabLabel(blk, renderingId);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getColumnLabels(org.eclipse.debug.core.model.IMemoryBlock, int, int)
+ */
+ public String[] getColumnLabels(IMemoryBlock blk, int bytesPerLine, int columnSize) {
+ IDebugModelPresentation modelPresentation = getConfiguredPresentation(blk);
+ if (modelPresentation instanceof IMemoryBlockModelPresentation)
+ {
+ return ((IMemoryBlockModelPresentation)modelPresentation).getColumnLabels(blk, bytesPerLine, columnSize);
+ }
+ return new String[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getAddressPresentation(org.eclipse.debug.core.model.IMemoryBlock, java.math.BigInteger)
+ */
+ public String getAddressPresentation(IMemoryBlock blk, BigInteger address) {
+ IDebugModelPresentation modelPresentation = getConfiguredPresentation(blk);
+ if (modelPresentation instanceof IMemoryBlockModelPresentation)
+ {
+ return ((IMemoryBlockModelPresentation)modelPresentation).getAddressPresentation(blk, address);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getViewPaneIdForDefault(org.eclipse.debug.internal.ui.views.memory.IMemoryRenderingType)
+ */
+ public String getViewPaneIdForDefault(IMemoryBlock blk, IMemoryRenderingType renderingType) {
+ IDebugModelPresentation modelPresentation = getConfiguredPresentation(blk);
+ if (modelPresentation instanceof IMemoryBlockModelPresentation)
+ {
+ return ((IMemoryBlockModelPresentation)modelPresentation).getViewPaneIdForDefault(blk, renderingType);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java
index a9f6299e2..b59c5e37b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java
@@ -11,16 +11,20 @@
package org.eclipse.debug.internal.ui;
+import java.math.BigInteger;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.internal.core.ListenerList;
+import org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation;
+import org.eclipse.debug.internal.ui.views.memory.IMemoryRenderingType;
import org.eclipse.debug.ui.IDebugEditorPresentation;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IValueDetailListener;
@@ -39,7 +43,7 @@ import org.eclipse.ui.IEditorPart;
* when it is needed.
*/
-public class LazyModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider {
+public class LazyModelPresentation implements IDebugModelPresentation, IDebugEditorPresentation, IColorProvider, IFontProvider, IMemoryBlockModelPresentation {
/**
* A temporary mapping of attribute ids to their values
@@ -289,5 +293,58 @@ public class LazyModelPresentation implements IDebugModelPresentation, IDebugEdi
return fontProvider.getFont(element);
}
return null;
- }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getTabLabel(org.eclipse.debug.core.model.IMemoryBlock, java.lang.String)
+ */
+ public String getTabLabel(IMemoryBlock blk, String renderingId) {
+
+ IDebugModelPresentation presentation = getPresentation();
+ if (presentation instanceof IMemoryBlockModelPresentation)
+ {
+ IMemoryBlockModelPresentation mbp = (IMemoryBlockModelPresentation)presentation;
+ return mbp.getTabLabel(blk, renderingId);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getColumnLabels(org.eclipse.debug.core.model.IMemoryBlock, int, int)
+ */
+ public String[] getColumnLabels(IMemoryBlock blk, int bytesPerLine, int columnSize) {
+ IDebugModelPresentation presentation = getPresentation();
+ if (presentation instanceof IMemoryBlockModelPresentation)
+ {
+ IMemoryBlockModelPresentation mbp = (IMemoryBlockModelPresentation)presentation;
+ return mbp.getColumnLabels(blk, bytesPerLine, columnSize);
+ }
+ return new String[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getAddressPresentation(org.eclipse.debug.core.model.IMemoryBlock, java.math.BigInteger)
+ */
+ public String getAddressPresentation(IMemoryBlock blk, BigInteger address) {
+ IDebugModelPresentation presentation = getPresentation();
+ if (presentation instanceof IMemoryBlockModelPresentation)
+ {
+ IMemoryBlockModelPresentation mbp = (IMemoryBlockModelPresentation)presentation;
+ return mbp.getAddressPresentation(blk, address);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMemoryBlockModelPresentation#getViewPaneIdForDefault(org.eclipse.debug.core.model.IMemoryBlock, org.eclipse.debug.internal.ui.views.memory.IMemoryRenderingType)
+ */
+ public String getViewPaneIdForDefault(IMemoryBlock blk, IMemoryRenderingType renderingType) {
+ IDebugModelPresentation presentation = getPresentation();
+ if (presentation instanceof IMemoryBlockModelPresentation)
+ {
+ IMemoryBlockModelPresentation mbp = (IMemoryBlockModelPresentation)presentation;
+ return mbp.getViewPaneIdForDefault(blk, renderingType);
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryAction.java
index 6448b0255..cc46906a7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryAction.java
@@ -82,9 +82,13 @@ abstract public class AbstractMemoryAction extends Action
if (view instanceof IMultipaneMemoryView)
{
- IMemoryViewTab topTap = ((IMultipaneMemoryView)view).getTopMemoryTab(MemoryViewPane.MEMORY_VIEW_PANE_ID);
-
- return topTap;
+ IMemoryViewPane viewPane = ((IMultipaneMemoryView)view).getViewPane(MemoryViewPane.MEMORY_VIEW_PANE_ID);
+ if (viewPane != null && viewPane instanceof IMemoryView)
+ {
+ IMemoryViewTab topTab = ((IMemoryView)viewPane).getTopMemoryTab();
+ return topTab;
+ }
+ return null;
}
else if (view instanceof IMemoryView)
{
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java
index e52fa2299..8847b681a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java
@@ -49,7 +49,7 @@ import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.help.WorkbenchHelp;
-public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, ISelectionListener, SelectionListener, IMemoryView, ISelectionChangedListener{
+public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, ISelectionListener, SelectionListener, IMemoryView, ISelectionChangedListener, IMemoryViewPane{
private static final String VIEW_TAB_FACTORY = "viewTabFactory"; //$NON-NLS-1$
@@ -57,7 +57,7 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
protected Composite fViewPaneCanvas;
protected StackLayout fStackLayout;
- private ViewTabEnablementManager fViewTabEnablementManager;
+ protected ViewTabEnablementManager fViewTabEnablementManager;
protected TabFolder fEmptyTabFolder;
protected Hashtable fTabFolderForDebugView;
protected Hashtable fMenuMgr;
@@ -65,7 +65,8 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
protected Hashtable fRenderingInfoTable;
protected IMemoryBlockRetrieval fKey; // store the key for current tab folder
protected ViewPaneSelectionProvider fSelectionProvider;
- private IViewPart fParent;
+ protected IViewPart fParent;
+ protected String fPaneId;
public AbstractMemoryViewPane(IViewPart parent)
{
@@ -78,11 +79,11 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
* @param parent
* @return the control of the view pane
*/
- public Control createViewPane(Composite parent)
+ public Control createViewPane(Composite parent, String paneId)
{
WorkbenchHelp.setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".MemoryView_context"); //$NON-NLS-1$
fSelectionProvider = new ViewPaneSelectionProvider();
-
+ fPaneId = paneId;
// view pane overall canvas
Composite canvas = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
@@ -466,6 +467,14 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
fSelectionProvider.setSelection(selection);
}
+ /**
+ * @return the unique identifier of the view pane
+ */
+ public String getPaneId()
+ {
+ return fPaneId;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.memory.IMemoryBlockListener#MemoryBlockAdded(org.eclipse.debug.core.model.IMemoryBlock)
*/
@@ -487,11 +496,6 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
abstract public Object getCurrentSelection();
/**
- * @return the unique identifier of the view pane
- */
- abstract public String getPaneId();
-
- /**
* retore the view pane based on current selection from the debug view
* and the memory blocks and renderings currently exist
*/
@@ -500,5 +504,5 @@ public abstract class AbstractMemoryViewPane implements IMemoryBlockListener, IS
/**
* @return actions to be contributed to the view pane's toolbar
*/
- abstract IAction[] getActions();
+ abstract public IAction[] getActions();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java
index b41f398f7..5e4671539 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java
@@ -30,6 +30,7 @@ import org.eclipse.debug.internal.ui.DebugPluginImages;
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.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
@@ -60,35 +61,29 @@ public class AddMemoryBlockAction extends Action implements ISelectionListener,
protected ISelection currentSelection = null;
protected IMemoryBlock fLastMemoryBlock;
private boolean fAddDefaultRenderings = true;
+ protected IMemoryViewPane fViewPane;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#setEnabled(boolean)
- */
- public void setEnabled(boolean enabled) {
-
- super.setEnabled(enabled);
- }
-
- public AddMemoryBlockAction()
+
+ public AddMemoryBlockAction(IMemoryViewPane viewPane)
{
- initialize();
+ initialize(viewPane);
}
/**
* @param addDefaultRenderings - specify if the action should add
* default renderings for the new memory block when it is run
*/
- AddMemoryBlockAction(boolean addDefaultRenderings)
+ AddMemoryBlockAction(IMemoryViewPane viewPane, boolean addDefaultRenderings)
{
- initialize();
+ initialize(viewPane);
fAddDefaultRenderings = addDefaultRenderings;
}
/**
*
*/
- private void initialize() {
+ private void initialize(IMemoryViewPane viewPane) {
+ fViewPane = viewPane;
setText(DebugUIMessages.getString(TITLE));
setToolTipText(DebugUIMessages.getString(TOOLTIP));
@@ -341,25 +336,31 @@ public class AddMemoryBlockAction extends Action implements ISelectionListener,
if (view instanceof IMultipaneMemoryView)
{
- IMemoryViewTab topTap = ((IMultipaneMemoryView)view).getTopMemoryTab(IInternalDebugUIConstants.ID_MEMORY_VIEW_PANE);
+ IMemoryViewPane viewPane = ((IMultipaneMemoryView)view).getViewPane(fViewPane.getPaneId());
- if (topTap.getMemoryBlock() != memoryBlock)
+ if (viewPane != null && viewPane instanceof IMemoryView)
{
- IMemoryViewTab[] allTabs = ((IMultipaneMemoryView)view).getAllViewTabs(IInternalDebugUIConstants.ID_MEMORY_VIEW_PANE);
- IMemoryViewTab moveToTop = null;
-
- for (int i=0; i<allTabs.length; i++)
+ IMemoryView memoryView = (IMemoryView)viewPane;
+ IMemoryViewTab topTap = memoryView.getTopMemoryTab();
+
+ if (topTap != null && topTap.getMemoryBlock() != memoryBlock)
{
- if (allTabs[i].getMemoryBlock() == memoryBlock)
+ IMemoryViewTab[] allTabs = memoryView.getAllViewTabs();
+ IMemoryViewTab moveToTop = null;
+
+ for (int i=0; i<allTabs.length; i++)
{
- moveToTop = allTabs[i];
- break;
+ if (allTabs[i].getMemoryBlock() == memoryBlock)
+ {
+ moveToTop = allTabs[i];
+ break;
+ }
+ }
+
+ if (moveToTop != null)
+ {
+ memoryView.moveToTop(moveToTop);
}
- }
-
- if (moveToTop != null)
- {
- ((IMultipaneMemoryView)view).moveToTop(IInternalDebugUIConstants.ID_MEMORY_VIEW_PANE, moveToTop);
}
}
}
@@ -378,12 +379,12 @@ public class AddMemoryBlockAction extends Action implements ISelectionListener,
for (int i=0; i<renderingTypes.length; i++)
{
try {
- // make sure the defaut supports the rendering view
+ // make sure the default supports the rendering view
String[] viewIds = renderingTypes[i].getSupportedViewIds();
boolean viewSupported = false;
for (int j=0; j<viewIds.length; j++)
{
- if (viewIds[j].equals(IInternalDebugUIConstants.ID_RENDERING_VIEW_PANE))
+ if (viewIds[j].startsWith(IInternalDebugUIConstants.ID_RENDERING_VIEW_PANE))
{
viewSupported = true;
break;
@@ -391,7 +392,27 @@ public class AddMemoryBlockAction extends Action implements ISelectionListener,
}
if (viewSupported)
- MemoryRenderingManager.getMemoryRenderingManager().addMemoryBlockRendering(memoryBlock, renderingTypes[i].getRenderingId());
+ {
+ String paneId = null;
+ IDebugModelPresentation modelPresentation = DebugUIPlugin.getModelPresentation();
+ if (modelPresentation instanceof IMemoryBlockModelPresentation)
+ {
+ paneId= ((IMemoryBlockModelPresentation)modelPresentation).getViewPaneIdForDefault(memoryBlock, renderingTypes[i]);
+ }
+
+ if (paneId == null)
+ paneId = IInternalDebugUIConstants.ID_RENDERING_VIEW_PANE;
+
+ IMemoryRendering rendering = MemoryRenderingManager.getMemoryRenderingManager().createRendering(memoryBlock, renderingTypes[i].getRenderingId());
+
+ if (rendering != null)
+ {
+ IMemoryViewPane viewPane = getDefualtViewPane(paneId);
+
+ if (viewPane != null && viewPane instanceof IRenderingViewPane)
+ ((IRenderingViewPane)viewPane).addMemoryRendering(rendering);
+ }
+ }
} catch (DebugException e) {
// catch error silently
@@ -400,4 +421,25 @@ public class AddMemoryBlockAction extends Action implements ISelectionListener,
}
}
}
+
+ private IMemoryViewPane getDefualtViewPane(String paneId)
+ {
+ // open a new view if necessary
+ IWorkbenchPage p= DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (p == null) {
+ return null;
+ }
+
+ IViewPart view = null;
+ view= p.findView(IInternalDebugUIConstants.ID_MEMORY_VIEW);
+
+ if (view != null && view instanceof IMultipaneMemoryView)
+ {
+ IMemoryViewPane viewPane = ((IMultipaneMemoryView)view).getViewPane(paneId);
+
+ return viewPane;
+ }
+
+ return null;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java
index df31a0a32..9016bbcb6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java
@@ -32,11 +32,12 @@ public class AddMemoryRenderingAction extends AddMemoryBlockAction {
public static final String ADD_RENDERING_FAILED = PREFIX + "add_rendering_failed"; //$NON-NLS-1$
public static final String FAILED_TO_ADD_THE_SELECTED_RENDERING = PREFIX + "failed_to_add_the_selected_rendering"; //$NON-NLS-1$
- public AddMemoryRenderingAction()
+ public AddMemoryRenderingAction(IMemoryViewPane viewPane)
{
super(DebugUIMessages.getString("AddMemoryRenderingAction.Add_renderings"), AS_PUSH_BUTTON); //$NON-NLS-1$
setToolTipText(DebugUIMessages.getString("AddMemoryRenderingAction.Add_renderings")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, DebugUIPlugin.getUniqueIdentifier() + ".AddRenderingContextAction_context"); //$NON-NLS-1$
+ fViewPane = viewPane;
}
/* (non-Javadoc)
@@ -51,7 +52,7 @@ public class AddMemoryRenderingAction extends AddMemoryBlockAction {
if (elem != null)
{
- AddMemoryRenderingDialog dialog = new AddMemoryRenderingDialog(shell);
+ AddMemoryRenderingDialog dialog = new AddMemoryRenderingDialog(shell, fViewPane);
dialog.open();
// get a list of renderings to create
@@ -81,7 +82,9 @@ public class AddMemoryRenderingAction extends AddMemoryBlockAction {
{
String id = ((IMemoryRenderingType)renderings[i]).getRenderingId();
try {
- MemoryRenderingManager.getMemoryRenderingManager().addMemoryBlockRendering(blk, id );
+ IMemoryRendering rendering = MemoryRenderingManager.getMemoryRenderingManager().createRendering(blk, id);
+ if (rendering != null && fViewPane instanceof IRenderingViewPane)
+ ((IRenderingViewPane)fViewPane).addMemoryRendering(rendering);
} catch (DebugException e) {
MemoryViewUtil.openError(DebugUIMessages.getString("AddMemoryRenderingAction.Add_rendering_failed"), DebugUIMessages.getString("AddMemoryRenderingAction.Unable_to_add_selected_renderings"), null); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java
index 9f70f10e7..0a492cbe3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java
@@ -62,6 +62,7 @@ public class AddMemoryRenderingDialog extends SelectionDialog {
ISelectionChangedListener fSelectionChangedListener;
MouseListener fMouseListener;
SelectionListener fSelectionListener;
+ private IMemoryViewPane fViewPane;
class MemoryRenderingLabelProvider implements ILabelProvider
{
@@ -243,7 +244,7 @@ public class AddMemoryRenderingDialog extends SelectionDialog {
fMouseListener =new MouseAdapter() {
public void mouseUp(MouseEvent e) {
- AddMemoryBlockAction action = new AddMemoryBlockAction(false);
+ AddMemoryBlockAction action = new AddMemoryBlockAction(fViewPane, false);
action.run();
populateDialog(memoryBlock, fViewer, action.getLastMemoryBlock());
@@ -316,11 +317,12 @@ public class AddMemoryRenderingDialog extends SelectionDialog {
return composite;
}
- public AddMemoryRenderingDialog(Shell parent) {
+ public AddMemoryRenderingDialog(Shell parent, IMemoryViewPane viewPane) {
super(parent);
super.setTitle(DebugUIMessages.getString("AddMemoryRenderingDialog.Add_memory_rendering")); //$NON-NLS-1$
WorkbenchHelp.setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$
setShellStyle(getShellStyle() | SWT.RESIZE);
+ fViewPane = viewPane;
}
private void populateDialog(Combo combo, ListViewer viewer, IMemoryBlock lastAdded)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/BigEndianAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/BigEndianAction.java
index 037fbea9d..8ded0c974 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/BigEndianAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/BigEndianAction.java
@@ -53,8 +53,20 @@ public class BigEndianAction implements IObjectActionDelegate {
}
else if (fTargetPart instanceof IMultipaneMemoryView)
{
- IMemoryViewTab top = ((IMultipaneMemoryView)fTargetPart).getTopMemoryTab(RenderingViewPane.RENDERING_VIEW_PANE_ID);
- top.refresh();
+ IMemoryViewPane[] viewPanes = ((IMultipaneMemoryView)fTargetPart).getViewPanes();
+
+ for (int i=0; i<viewPanes.length; i++)
+ {
+ IMemoryViewPane viewPane = viewPanes[i];
+ if (viewPane != null && viewPane instanceof IMemoryView)
+ {
+ IMemoryView memoryView = (IMemoryView)viewPane;
+ IMemoryViewTab top = memoryView.getTopMemoryTab();
+
+ if (top != null && top.getRendering() == fRendering)
+ top.refresh();
+ }
+ }
}
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CreateRenderingTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CreateRenderingTab.java
index 6f4357c95..75a3a865b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CreateRenderingTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CreateRenderingTab.java
@@ -61,6 +61,7 @@ public class CreateRenderingTab implements IMemoryViewTab, IDebugEventSetListene
private Label fMemoryBlockLabel;
private CreateRendering fRendering = new CreateRendering();
private DisposeListener fDisposeListener;
+ private IRenderingViewPane fViewPane;
class MemoryRenderingLabelProvider implements ILabelProvider
{
@@ -154,10 +155,11 @@ public class CreateRenderingTab implements IMemoryViewTab, IDebugEventSetListene
}
}
- public CreateRenderingTab(IMemoryBlock memBlock, TabItem tabItem)
+ public CreateRenderingTab(IMemoryBlock memBlock, TabItem tabItem, IRenderingViewPane viewPane)
{
fMemoryBlock = memBlock;
fTabItem = tabItem;
+ fViewPane = viewPane;
Control control = createPartControl(tabItem.getParent());
fTabItem.setControl(control);
fTabItem.setData(this);
@@ -328,7 +330,9 @@ public class CreateRenderingTab implements IMemoryViewTab, IDebugEventSetListene
{
String id = ((IMemoryRenderingType)renderings[i]).getRenderingId();
try {
- MemoryRenderingManager.getMemoryRenderingManager().addMemoryBlockRendering(fMemoryBlock, id );
+ IMemoryRendering rendering = MemoryRenderingManager.getMemoryRenderingManager().createRendering(fMemoryBlock, id);
+ if (rendering != null)
+ fViewPane.addMemoryRendering(rendering);
} catch (DebugException e) {
DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), DebugUIMessages.getString("CreateRenderingTab.3"), DebugUIMessages.getString("CreateRenderingTab.4"), e); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryBlockModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryBlockModelPresentation.java
index aae1fcb14..4dd73dba6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryBlockModelPresentation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryBlockModelPresentation.java
@@ -54,4 +54,14 @@ public interface IMemoryBlockModelPresentation extends IDebugModelPresentation
* Return null if default address presentation is to be used.
*/
public String getAddressPresentation(IMemoryBlock blk, BigInteger address);
+
+ /**
+ * A default rendering is being created for the memory block. Return the pane
+ * id of the view pane where this rendering is to be created.
+ * @param blk
+ * @param renderingType
+ * @return the pane id of the view pane where this rendering is to be created.
+ * Return null if the default view pane is to be used.
+ */
+ public String getViewPaneIdForDefault(IMemoryBlock blk, IMemoryRenderingType renderingType);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingManager.java
index 86db1bc9d..b8aafe960 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingManager.java
@@ -13,7 +13,6 @@
package org.eclipse.debug.internal.ui.views.memory;
import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IMemoryBlock;
@@ -23,72 +22,16 @@ import org.eclipse.debug.core.model.IMemoryBlock;
*/
public interface IMemoryRenderingManager
{
+
/**
- * Tell the manager to add a new memory rendering
- * @param mem
- * @param renderingId
- * @return the IMemoryRendering object created
- */
- public IMemoryRendering addMemoryBlockRendering(IMemoryBlock mem, String renderingId) throws DebugException;
-
-
- /**
- * Tell the manager that a memory rendering has been removed.
- * Remove all renderings with that same memory block and rendering ids
- * @param mem
- */
- public void removeMemoryBlockRendering(IMemoryBlock mem, String renderingId);
-
- /**
- * Add the specified rendering from the manager and notify listeners
- * @param rendering
- */
- public void addMemoryBlockRendering(IMemoryRendering rendering) throws DebugException;
-
- /**
- * Remove the specified rendering from the manager and notify listeners
- * @param rendering
- */
- public void removeMemoryBlockRendering(IMemoryRendering rendering);
-
- /**
- * Add a listener to the memory rendering manager.
- * @param listener
- */
- public void addListener(IMemoryRenderingListener listener);
-
-
- /**
- * Remove a listener from the memory rendering manager.
- * @param listener
- */
- public void removeListener(IMemoryRenderingListener listener);
-
- /**
- * Get renderings based on given memory block and rendering id.
- * Return all renderings related to the memory block if renderingId
- * is null.
- * Return an empty array if the rendering cannot be found.
+ * Create and return an IMemoryRendering based on the given memory block and rendering
+ * Id.
* @param mem
* @param renderingId
+ * @return memory rendering created, null if the rendering cannot be created. Throws a debug
+ * exception if there is a problem creating the rendering.
*/
- public IMemoryRendering[] getRenderings(IMemoryBlock mem, String renderingId);
-
- /**
- * Get all memory renderings from the given debug target
- * Return an empty array if nothing can be found for the debug target.
- * @param target
- * @return all memory renderings from the given debug target
- */
- public IMemoryRendering[] getRenderingsFromDebugTarget(IDebugTarget target);
-
- /**
- * Get all memory renderings from the given memory block
- * Return an empty array if nothing can be found for the memory block.
- * @param block
- * @return all memory renderings from the given memory block
- */
- public IMemoryRendering[] getRenderingsFromMemoryBlock(IMemoryBlock block);
+ public IMemoryRendering createRendering(IMemoryBlock mem, String renderingId) throws DebugException;
/**
* @param renderingId
@@ -111,7 +54,7 @@ public interface IMemoryRenderingManager
/**
* @param obj
- * @return default renderings' ids for the given object
+ * @return default rendering type for the given object
*/
public IMemoryRenderingType[] getDefaultRenderingTypes(Object obj);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryViewPane.java
new file mode 100644
index 000000000..e01135d42
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryViewPane.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.views.memory;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+/**
+ * Represent a view pane in the memory view.
+ * @since 3.1
+ */
+public interface IMemoryViewPane {
+
+ /**
+ * Create the view pane with the given parent composite, and pane
+ * id.
+ * @param parent
+ * @param paneId
+ * @return the control of the view pane
+ */
+ public Control createViewPane(Composite parent, String paneId);
+
+ /**
+ * Restore view pane based on current selection from the debug view.
+ * Create memory blocks or renderings that currently exist in the debug
+ * session.
+ */
+ public void restoreViewPane();
+
+ /**
+ * Dispose the view pane
+ */
+ public void dispose();
+
+ /**
+ * @return unique identifier of the view pane
+ */
+ public String getPaneId();
+
+ /**
+ * @return array of actions to be contributed to the view pane's
+ * acition bar.
+ */
+ public IAction[] getActions();
+
+ /**
+ * Add the given selection listener to the view pane. The selection
+ * listener gets notified when the selection from the view pane
+ * has changed.
+ * @param listener
+ */
+ public void addSelectionListener(ISelectionChangedListener listener);
+
+ /**
+ * Remove the selection listener from the view pane. The listener
+ * will no longer get notified when selection is changed.
+ * @param listener
+ */
+ public void removeSelctionListener(ISelectionChangedListener listener);
+
+ /**
+ * @return the selection provider of the view pane
+ */
+ public ISelectionProvider getSelectionProvider();
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMultipaneMemoryView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMultipaneMemoryView.java
index 1b0fd51d2..e524299dc 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMultipaneMemoryView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMultipaneMemoryView.java
@@ -11,19 +11,16 @@
package org.eclipse.debug.internal.ui.views.memory;
public interface IMultipaneMemoryView {
- /**
- * @return the top view tab from the Memory View from the specified pane
- */
- public IMemoryViewTab getTopMemoryTab(String paneId);
/**
- * @return all view tabs from current tab folder from the specified pane
+ * @param paneId
+ * @return the memory pane with the specified pane id
+ * Return null if the specified view pane cannot be found.
*/
- public IMemoryViewTab[] getAllViewTabs(String paneId);
+ public IMemoryViewPane getViewPane(String paneId);
/**
- * Move specified view tab to the top in the specified pane
- * @param viewTab
+ * @return all view panes from the memory view
*/
- public void moveToTop(String paneId, IMemoryViewTab viewTab);
+ public IMemoryViewPane[] getViewPanes();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IRenderingViewPane.java
index dd3cde84d..697a64e3d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IMemoryRenderingListener.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/IRenderingViewPane.java
@@ -8,28 +8,25 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-
package org.eclipse.debug.internal.ui.views.memory;
-
-
-
/**
- * Rendering listeners listen for add/removal events from IMemoryRenderingManager.
- * Implementors should add itself to IMemoryRenderingManager
+ * Represents a view pane in the Memory View. The view pane allows
+ * cliens to add and remove renderings.
* @since 3.1
*/
-public interface IMemoryRenderingListener
-{
+public interface IRenderingViewPane extends IMemoryViewPane{
+
/**
- * This function is called when a new rendering is added.
- * @param rendering
+ * Add the given rendering to the view pane.
+ * @param rendering to add
*/
- void MemoryBlockRenderingAdded(IMemoryRendering rendering);
-
+ public void addMemoryRendering(IMemoryRendering rendering);
+
/**
- * Fired when a memory rendering is removed.
- * @param rendering
+ * Remove the given rendering from the view pane.
+ * @param rendering rendering to remove
*/
- void MemoryBlockRenderingRemoved(IMemoryRendering rendering);
+ public void removeMemoryRendering(IMemoryRendering rendering);
+
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/LittleEndianAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/LittleEndianAction.java
index 06bbf27d8..d1c5e5575 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/LittleEndianAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/LittleEndianAction.java
@@ -52,8 +52,20 @@ public class LittleEndianAction implements IObjectActionDelegate {
}
else if (fTargetPart instanceof IMultipaneMemoryView)
{
- IMemoryViewTab top = ((IMultipaneMemoryView)fTargetPart).getTopMemoryTab(RenderingViewPane.RENDERING_VIEW_PANE_ID);
- top.refresh();
+ IMemoryViewPane[] viewPanes = ((IMultipaneMemoryView)fTargetPart).getViewPanes();
+
+ for (int i=0; i<viewPanes.length; i++)
+ {
+ IMemoryViewPane viewPane = viewPanes[i];
+ if (viewPane != null && viewPane instanceof IMemoryView)
+ {
+ IMemoryView memoryView = (IMemoryView)viewPane;
+ IMemoryViewTab top = memoryView.getTopMemoryTab();
+
+ if (top != null && top.getRendering() == fRendering)
+ top.refresh();
+ }
+ }
}
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryRenderingManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryRenderingManager.java
index 89d44c7e3..f691a05fe 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryRenderingManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryRenderingManager.java
@@ -26,16 +26,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.IMemoryBlockListener;
-import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.internal.core.DebugCoreMessages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
@@ -44,10 +39,8 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin;
* @since 3.1
*/
-public class MemoryRenderingManager implements IMemoryRenderingManager, IDebugEventSetListener, IMemoryBlockListener
+public class MemoryRenderingManager implements IMemoryRenderingManager
{
- private ArrayList listeners = new ArrayList();
- private ArrayList fRenderings = new ArrayList();
private Hashtable fMemoryRenderingTypes = new Hashtable();
private ArrayList fRenderingTypesOrderList = new ArrayList();
private Hashtable fDynamicRenderingMap = new Hashtable();
@@ -55,9 +48,6 @@ public class MemoryRenderingManager implements IMemoryRenderingManager, IDebugEv
private Hashtable fRenderingsEnablement = new Hashtable();
private Hashtable fDefaultsEnablement = new Hashtable();
- private static final int ADDED = 0;
- private static final int REMOVED = 1;
-
private static final String RENDERING_EXT = "memoryRenderingTypes"; //$NON-NLS-1$
private static final String RENDERING_ELEMENT = "rendering"; //$NON-NLS-1$
private static final String RENDERING_PROPERTY_ELEMENT = "renderingProperty"; //$NON-NLS-1$
@@ -77,58 +67,9 @@ public class MemoryRenderingManager implements IMemoryRenderingManager, IDebugEv
* The singleton memory rendering manager.
*/
private static MemoryRenderingManager fgMemoryRenderingManager;
-
- /**
- * Notifies a memory block listener in a safe runnable to
- * handle exceptions.
- */
- class MemoryRenderingManagerNotifier implements ISafeRunnable {
-
- private IMemoryRenderingListener fListener;
- private int fType;
- private IMemoryRendering fRendering;
-
- /**
- * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
- */
- public void handleException(Throwable exception) {
- DebugUIPlugin.log(exception);
- }
-
- /**
- * @see org.eclipse.core.runtime.ISafeRunnable#run()
- */
- public void run() throws Exception {
- switch (fType) {
- case ADDED:
- fListener.MemoryBlockRenderingAdded(fRendering);
- break;
- case REMOVED:
- fListener.MemoryBlockRenderingRemoved(fRendering);
- break;
- }
- }
-
- /**
- * Notfied listeners of added/removed rendering events
- */
- public void notify(int update, IMemoryRendering rendering) {
- if (listeners != null) {
- fType = update;
- fRendering = rendering;
- Object[] copiedListeners= listeners.toArray(new IMemoryRenderingListener[listeners.size()]);
- for (int i= 0; i < copiedListeners.length; i++) {
- fListener = (IMemoryRenderingListener)copiedListeners[i];
- Platform.run(this);
- }
- }
- fListener = null;
- }
- }
public MemoryRenderingManager()
{
- DebugPlugin.getDefault().getMemoryBlockManager().addListener(this);
buildMemoryRenderingTypes();
}
@@ -474,42 +415,6 @@ public class MemoryRenderingManager implements IMemoryRenderingManager, IDebugEv
}
return returnedArray;
}
-
- private MemoryRenderingManagerNotifier getMemoryBlockNotifier() {
- return new MemoryRenderingManagerNotifier();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#addMemoryBlockRendering(org.eclipse.debug.core.model.IMemoryBlock, java.lang.String)
- */
- public IMemoryRendering addMemoryBlockRendering(IMemoryBlock mem, String renderingId) throws DebugException
- {
- if (fRenderings == null)
- return null;
-
- IMemoryRendering newRendering = createRendering(mem, renderingId);
-
- // if an error has occurred, or if user has canceled
- if (newRendering == null)
- return newRendering;
-
- if (fRenderings.contains(newRendering))
- return newRendering;
-
- fRenderings.add(newRendering);
-
- // add listener for the first memory block added
- if (fRenderings.size() == 1)
- {
- DebugPlugin.getDefault().addDebugEventListener(this);
- }
-
- notifyListeners(ADDED, newRendering);
-
- return newRendering;
-
- }
-
/**
* @param mem
* @param renderingId
@@ -576,242 +481,6 @@ public class MemoryRenderingManager implements IMemoryRenderingManager, IDebugEv
}
/* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#removeMemoryBlockRendering(org.eclipse.debug.core.model.IMemoryBlock, java.lang.String)
- */
- public void removeMemoryBlockRendering(IMemoryBlock mem, String renderingId)
- {
- if(fRenderings == null)
- return;
-
- IMemoryRendering[] toRemove = getRenderings(mem, renderingId);
-
- for (int i=0; i<toRemove.length; i++)
- {
- fRenderings.remove(toRemove[i]);
-
- // remove listener after the last memory block has been removed
- if (fRenderings.size() == 0)
- {
- DebugPlugin.getDefault().removeDebugEventListener(this);
- }
-
- notifyListeners(REMOVED, toRemove[i]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#addMemoryBlockRendering(org.eclipse.debug.ui.IMemoryRendering)
- */
- public void addMemoryBlockRendering(IMemoryRendering rendering) throws DebugException{
-
- // do not allow duplicated objects
- if (fRenderings.contains(rendering))
- return;
-
- fRenderings.add(rendering);
-
- // add listener for the first memory block added
- if (fRenderings.size() == 1)
- {
- DebugPlugin.getDefault().addDebugEventListener(this);
- }
-
- notifyListeners(ADDED, rendering);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#removeMemoryBlockRendering(org.eclipse.debug.ui.IMemoryRendering)
- */
- public void removeMemoryBlockRendering(IMemoryRendering rendering) {
- if(rendering == null)
- return;
-
- if(!fRenderings.contains(rendering))
- return;
-
- fRenderings.remove(rendering);
-
- // remove listener after the last memory block has been removed
- if (fRenderings.size() == 0)
- {
- DebugPlugin.getDefault().removeDebugEventListener(this);
- }
-
- notifyListeners(REMOVED, rendering);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#getRenderings(org.eclipse.debug.core.model.IMemoryBlock, java.lang.String)
- */
- public IMemoryRendering[] getRenderings(IMemoryBlock mem, String renderingId)
- {
- if (renderingId == null)
- {
- return getRenderingsFromMemoryBlock(mem);
- }
-
- ArrayList ret = new ArrayList();
- for (int i=0; i<fRenderings.size(); i++)
- {
- if (fRenderings.get(i) instanceof IMemoryRendering)
- {
- IMemoryRendering rendering = (IMemoryRendering)fRenderings.get(i);
- if (rendering.getBlock() == mem && renderingId.equals(rendering.getRenderingId()))
- {
- ret.add(rendering);
- }
- }
- }
-
- return (IMemoryRendering[])ret.toArray(new IMemoryRendering[ret.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#getRenderingsFromDebugTarget(org.eclipse.debug.core.model.IDebugTarget)
- */
- public IMemoryRendering[] getRenderingsFromDebugTarget(IDebugTarget target)
- {
- ArrayList ret = new ArrayList();
- for (int i=0; i<fRenderings.size(); i++)
- {
- if (fRenderings.get(i) instanceof IMemoryRendering)
- {
- IMemoryRendering rendering = (IMemoryRendering)fRenderings.get(i);
- if (rendering.getBlock().getDebugTarget() == target)
- {
- ret.add(rendering);
- }
- }
- }
-
- return (IMemoryRendering[])ret.toArray(new IMemoryRendering[ret.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#getRenderingsFromMemoryBlock(org.eclipse.debug.core.model.IMemoryBlock)
- */
- public IMemoryRendering[] getRenderingsFromMemoryBlock(IMemoryBlock block)
- {
- ArrayList ret = new ArrayList();
- for (int i=0; i<fRenderings.size(); i++)
- {
- if (fRenderings.get(i) instanceof IMemoryRendering)
- {
- IMemoryRendering rendering = (IMemoryRendering)fRenderings.get(i);
- if (rendering.getBlock() == block)
- {
- ret.add(rendering);
- }
- }
- }
-
- return (IMemoryRendering[])ret.toArray(new IMemoryRendering[ret.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#addListener(org.eclipse.debug.ui.IMemoryBlockListener)
- */
- public void addListener(IMemoryRenderingListener listener)
- {
- if(listeners == null)
- return;
-
- if(listener == null){
- DebugUIPlugin.logErrorMessage("Null argument passed into IMemoryRenderingManager.addListener"); //$NON-NLS-1$
- return;
- }
-
- if (!listeners.contains(listener))
- listeners.add(listener);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryRenderingManager#removeListener(org.eclipse.debug.ui.IMemoryBlockListener)
- */
- public void removeListener(IMemoryRenderingListener listener)
- {
- if(listeners == null)
- return;
-
- if(listener == null){
- DebugUIPlugin.logErrorMessage("Null argument passed into IMemoryRenderingManager.removeListener"); //$NON-NLS-1$
- return;
- }
-
- if (listeners.contains(listener))
- listeners.remove(listener);
-
- }
-
- private void notifyListeners(int update, IMemoryRendering rendering)
- {
- getMemoryBlockNotifier().notify(update, rendering);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
- */
- public void handleDebugEvents(DebugEvent[] events) {
-
- for (int i=0; i < events.length; i++)
- handleDebugEvent(events[i]);
-
- }
-
- public void handleDebugEvent(DebugEvent event) {
- Object obj = event.getSource();
- IDebugTarget dt = null;
-
- if (event.getKind() == DebugEvent.TERMINATE)
- {
- // a terminate event could happen from an IThread or IDebugTarget
- // Only handle terminate event from debug target
- if (obj instanceof IDebugTarget)
- {
- dt = ((IDebugTarget)obj);
- }
-
- // returns empty array if dt == null
- IMemoryRendering[] deletedrendering = getRenderingsFromDebugTarget(dt);
-
- for (int i=0; i<deletedrendering.length; i++)
- {
- removeMemoryBlockRendering(deletedrendering[i].getBlock(), deletedrendering[i].getRenderingId());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryBlockListener#MemoryBlockAdded(org.eclipse.debug.core.model.IMemoryBlock)
- */
- public void memoryBlocksAdded(IMemoryBlock[] memoryBlocks)
- {
- // do nothing when memory blocks are added
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryBlockListener#MemoryBlockRemoved(org.eclipse.debug.core.model.IMemoryBlock)
- */
- public void memoryBlocksRemoved(IMemoryBlock[] memoryBlocks)
- {
- for (int j=0; j<memoryBlocks.length; j++)
- {
- IMemoryBlock memory = memoryBlocks[j];
- // remove all renderings related to the deleted memory block
- IMemoryRendering[] renderings = getRenderingsFromMemoryBlock(memory);
-
- for (int i=0; i<renderings.length; i++)
- {
- removeMemoryBlockRendering(renderings[i].getBlock(), renderings[i].getRenderingId());
- }
- }
- }
-
-
-
- /* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.views.memory.IMemoryRenderingManager#getRenderingTypeById(java.lang.String)
*/
public IMemoryRenderingType getRenderingTypeById(String renderingId)
@@ -1110,18 +779,6 @@ public class MemoryRenderingManager implements IMemoryRenderingManager, IDebugEv
*/
public void shutdown()
{
- // clean up
- if (listeners != null)
- {
- listeners.clear();
- listeners = null;
- }
-
- if (fRenderings != null)
- {
- fRenderings.clear();
- fRenderings = null;
- }
if (fMemoryRenderingTypes != null)
{
@@ -1147,8 +804,6 @@ public class MemoryRenderingManager implements IMemoryRenderingManager, IDebugEv
fDynamicRenderingFactory = null;
}
- // remove listener
- DebugPlugin.getDefault().getMemoryBlockManager().removeListener(this);
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java
index 296bed928..cbcad87c5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java
@@ -11,6 +11,8 @@
package org.eclipse.debug.internal.ui.views.memory;
import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.ui.IDebugUIConstants;
@@ -46,9 +48,8 @@ public class MemoryView extends ViewPart implements IMultipaneMemoryView {
private MemoryViewPartListener fPartListener;
private SashForm fSashForm;
- private AbstractMemoryViewPane fMemoryViewPane;
- private AbstractMemoryViewPane fRenderingPane;
-
+ private Hashtable fViewPanes = new Hashtable();
+
class MemoryViewSelectionProvider implements ISelectionProvider, ISelectionChangedListener
{
ArrayList fListeners = new ArrayList();
@@ -171,9 +172,7 @@ public class MemoryView extends ViewPart implements IMultipaneMemoryView {
if (part == fView)
{
- setVisible(true);
- fMemoryViewPane.restoreViewPane();
- fRenderingPane.restoreViewPane();
+ restoreView();
}
}
@@ -196,18 +195,45 @@ public class MemoryView extends ViewPart implements IMultipaneMemoryView {
WorkbenchHelp.setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".MemoryView_context"); //$NON-NLS-1$
fSashForm = new SashForm(parent, SWT.HORIZONTAL);
+ fSelectionProvider = new MemoryViewSelectionProvider();
// create memory view pane
- fMemoryViewPane = new MemoryViewPane(this);
+ createMemoryViewPane();
+
+ createRenderingViewPane(RenderingViewPane.RENDERING_VIEW_PANE_ID);
+
+ setVisible(true);
+
+ fSashForm.layout();
+
+ // set up selection provider and listeners
+
+ getSite().setSelectionProvider(fSelectionProvider);
+ contributeToActionBars();
+
+ fPartListener = new MemoryViewPartListener(this);
+ getSite().getPage().addPartListener(fPartListener);
+
+ // restore view pane after finishing creating all the view panes
+ restoreView();
+
+ }
+
+ /**
+ *
+ */
+ private void createMemoryViewPane() {
+ IAction[] actions;
+
+ MemoryViewPane memoryViewPane = new MemoryViewPane(this);
+ fViewPanes.put(MemoryViewPane.MEMORY_VIEW_PANE_ID, memoryViewPane);
ViewForm memoryViewForm = new ViewForm(fSashForm, SWT.FLAT);
- Control memoryControl = fMemoryViewPane.createViewPane(memoryViewForm);
+ Control memoryControl = memoryViewPane.createViewPane(memoryViewForm, MemoryViewPane.MEMORY_VIEW_PANE_ID);
memoryViewForm.setContent(memoryControl);
-
- fSelectionProvider = new MemoryViewSelectionProvider();
- fMemoryViewPane.addSelectionListener(fSelectionProvider);
+ memoryViewPane.addSelectionListener(fSelectionProvider);
ToolBarManager memoryViewMgr = new ToolBarManager(SWT.FLAT);
- IAction[] actions = fMemoryViewPane.getActions();
+ actions = memoryViewPane.getActions();
for (int i=0; i<actions.length; i++)
{
memoryViewMgr.add(actions[i]);
@@ -218,16 +244,23 @@ public class MemoryView extends ViewPart implements IMultipaneMemoryView {
Label memoryLabel = new Label(memoryViewForm, SWT.WRAP);
memoryLabel.setText(DebugUIMessages.getString("MemoryView.Memory_monitors")); //$NON-NLS-1$
memoryViewForm.setTopLeft(memoryLabel);
-
- // create rendering view pane
- fRenderingPane = new RenderingViewPane(this);
+ }
+
+
+ /**
+ * Create rendering view pane with specified pane id.
+ * @param paneId
+ */
+ public void createRenderingViewPane(String paneId) {
+ RenderingViewPane renderingPane = new RenderingViewPane(this); //$NON-NLS-1$
+ fViewPanes.put(paneId, renderingPane);
ViewForm renderingViewForm = new ViewForm(fSashForm, SWT.FLAT);
- Control renderingControl = fRenderingPane.createViewPane(renderingViewForm);
+ Control renderingControl = renderingPane.createViewPane(renderingViewForm, paneId);
renderingViewForm.setContent(renderingControl);
- fRenderingPane.addSelectionListener(fSelectionProvider);
+ renderingPane.addSelectionListener(fSelectionProvider);
ToolBarManager renderingViewMgr = new ToolBarManager(SWT.FLAT);
- IAction[] renderingActions = fRenderingPane.getActions();
+ IAction[] renderingActions = renderingPane.getActions();
for (int i=0; i<renderingActions.length; i++)
{
renderingViewMgr.add(renderingActions[i]);
@@ -239,24 +272,14 @@ public class MemoryView extends ViewPart implements IMultipaneMemoryView {
renderingLabel.setText(DebugUIMessages.getString("MemoryView.Memory_renderings")); //$NON-NLS-1$
renderingViewForm.setTopLeft(renderingLabel);
- // set up selection provider and listeners
-
- getSite().setSelectionProvider(fSelectionProvider);
- contributeToActionBars();
-
- fPartListener = new MemoryViewPartListener(this);
- getSite().getPage().addPartListener(fPartListener);
-
- setVisible(true);
+
}
-
+
private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
- bars.getMenuManager().add(new SetDefaultColumnSizePrefAction());
- bars.updateActionBars();
-
+ bars.getMenuManager().add(new SetDefaultColumnSizePrefAction());
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
@@ -265,59 +288,68 @@ public class MemoryView extends ViewPart implements IMultipaneMemoryView {
public void dispose() {
- fMemoryViewPane.dispose();
- fRenderingPane.dispose();
+ Enumeration enumeration = fViewPanes.elements();
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.memory.IMultipaneMemoryView#getTopMemoryTab(java.lang.String)
- */
- public IMemoryViewTab getTopMemoryTab(String paneId) {
- if (paneId.equals(fMemoryViewPane.getPaneId()))
+ while (enumeration.hasMoreElements())
{
- return fMemoryViewPane.getTopMemoryTab();
+ Object element = enumeration.nextElement();
+ if (element instanceof IMemoryViewPane)
+ {
+ ((IMemoryViewPane)element).dispose();
+ }
}
- else if (paneId.equals(fRenderingPane.getPaneId()))
+
+ super.dispose();
+ }
+
+ private void setVisible(boolean visible)
+ {
+ IMemoryViewPane[] viewPanes = getViewPanes();
+
+ for (int i=0; i<viewPanes.length; i++)
{
- return fRenderingPane.getTopMemoryTab();
+ if (viewPanes[i] instanceof AbstractMemoryViewPane)
+ {
+ ((AbstractMemoryViewPane)viewPanes[i]).setVisible(visible);
+ }
}
- return null;
}
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.memory.IMultipaneMemoryView#getAllViewTabs(java.lang.String)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMultipaneMemoryView#getViewPane(java.lang.String)
*/
- public IMemoryViewTab[] getAllViewTabs(String paneId) {
- if (paneId.equals(fMemoryViewPane.getPaneId()))
- {
- return fMemoryViewPane.getAllViewTabs();
- }
- else if (paneId.equals(fRenderingPane.getPaneId()))
- {
- return fRenderingPane.getAllViewTabs();
- }
- return new IMemoryViewTab[0];
- }
+ public IMemoryViewPane getViewPane(String paneId) {
+ return (IMemoryViewPane)fViewPanes.get(paneId);
+ }
+
/* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.memory.IMultipaneMemoryView#moveToTop(java.lang.String, org.eclipse.debug.internal.ui.views.memory.IMemoryViewTab)
+ * @see org.eclipse.debug.internal.ui.views.memory.IMultipaneMemoryView#getViewPanes()
*/
- public void moveToTop(String paneId, IMemoryViewTab viewTab) {
- if (paneId.equals(fMemoryViewPane.getPaneId()))
+ public IMemoryViewPane[] getViewPanes() {
+ IMemoryViewPane[] viewPanes = new IMemoryViewPane[fViewPanes.size()];
+
+ Enumeration enumeration = fViewPanes.elements();
+ int i=0;
+ while (enumeration.hasMoreElements())
{
- fMemoryViewPane.moveToTop(viewTab);
+ viewPanes[i] = (IMemoryViewPane)enumeration.nextElement();
+ i++;
}
- else if (paneId.equals(fRenderingPane.getPaneId()))
+
+ return viewPanes;
+ }
+
+ /**
+ * Restore each view pane from the memory view based on current
+ * debug selection
+ */
+ private void restoreView() {
+ setVisible(true);
+ IMemoryViewPane[] viewPanes = getViewPanes();
+ for (int i=0; i<viewPanes.length; i++)
{
- fRenderingPane.moveToTop(viewTab);
+ viewPanes[i].restoreViewPane();
}
}
-
- private void setVisible(boolean visible)
- {
- fMemoryViewPane.setVisible(visible);
- fRenderingPane.setVisible(visible);
- }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewPane.java
index 562b8e6d8..d3c66f579 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewPane.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewPane.java
@@ -485,12 +485,6 @@ public class MemoryViewPane extends AbstractMemoryViewPane {
}
}
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.memory.AbstractMemoryViewPane#getPaneId()
- */
- public String getPaneId() {
- return MEMORY_VIEW_PANE_ID;
- }
public void restoreViewPane() {
@@ -553,11 +547,11 @@ public class MemoryViewPane extends AbstractMemoryViewPane {
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.views.memory.AbstractMemoryViewPane#getActions()
*/
- IAction[] getActions() {
+ public IAction[] getActions() {
ArrayList actions = new ArrayList();
if (fAddMemoryBlockAction == null)
- fAddMemoryBlockAction = new AddMemoryBlockAction();
+ fAddMemoryBlockAction = new AddMemoryBlockAction(this);
actions.add(fAddMemoryBlockAction);
if (fRemoveMemoryBlockAction == null)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java
index e9a532658..c46ff0dd9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java
@@ -13,20 +13,14 @@ package org.eclipse.debug.internal.ui.views.memory;
import java.math.BigInteger;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
-import org.eclipse.debug.internal.ui.LazyModelPresentation;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
@@ -92,8 +86,6 @@ public class MemoryViewTab extends AbstractMemoryViewTab implements SelectionLis
private boolean fEnabled;
private ViewTabCursorManager fCursorManager;
- private IMemoryBlockModelPresentation fMemoryBlockPresentation;
- private boolean fNoPresentation = false;
private boolean fShowAddressColumn = true;
public int TABLE_PREBUFFER = 20;
@@ -207,84 +199,6 @@ public class MemoryViewTab extends AbstractMemoryViewTab implements SelectionLis
}
}
}
-
- // ** Referring to internal class: DelegatingModelPresentation and LazyModelPresentation
- // ** This should be ok when Memory View is contributed to Eclipse platform?
- class MemoryViewDelegatingModelPresentation extends DelegatingModelPresentation
- {
-
- MemoryViewDelegatingModelPresentation()
- {
- IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.ID_DEBUG_MODEL_PRESENTATION);
- if (point != null) {
- IExtension[] extensions= point.getExtensions();
- for (int i= 0; i < extensions.length; i++) {
- IExtension extension= extensions[i];
- IConfigurationElement[] configElements= extension.getConfigurationElements();
- for (int j= 0; j < configElements.length; j++) {
- IConfigurationElement elt= configElements[j];
- String id= elt.getAttribute("id"); //$NON-NLS-1$
- if (id != null) {
- IDebugModelPresentation lp= new MemoryViewLazyModelPresentation(elt);
- getLabelProviders().put(id, lp);
- }
- }
- }
- }
- }
-
- }
-
- class MemoryViewLazyModelPresentation extends LazyModelPresentation implements IMemoryBlockModelPresentation
- {
-
- MemoryViewLazyModelPresentation(IConfigurationElement element)
- {
- super(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryBlockModelPresentation#getTabLabel(org.eclipse.debug.core.model.IMemoryBlock)
- */
- public String getTabLabel(IMemoryBlock blk, String renderingId)
- {
- IDebugModelPresentation presentation = getPresentation();
-
- if (presentation instanceof IMemoryBlockModelPresentation)
- {
- return ((IMemoryBlockModelPresentation)presentation).getTabLabel(blk, getRenderingId());
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryBlockModelPresentation#getColumnLabels(org.eclipse.debug.core.model.IMemoryBlock, int, int)
- */
- public String[] getColumnLabels(IMemoryBlock blk, int bytesPerLine, int columnSize)
- {
- IDebugModelPresentation presentation = getPresentation();
-
- if (presentation instanceof IMemoryBlockModelPresentation)
- {
- return ((IMemoryBlockModelPresentation)presentation).getColumnLabels(blk, bytesPerLine, columnSize);
- }
- return new String[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.IMemoryBlockModelPresentation#getAddressPresentation(org.eclipse.debug.core.model.IMemoryBlock, java.math.BigInteger)
- */
- public String getAddressPresentation(IMemoryBlock blk, BigInteger address)
- {
- IDebugModelPresentation presentation = getPresentation();
-
- if (presentation instanceof IMemoryBlockModelPresentation)
- {
- return ((IMemoryBlockModelPresentation)presentation).getAddressPresentation(blk, address);
- }
- return null;
- }
- }
public MemoryViewTab(IMemoryBlock newMemory, TabItem newTab, MenuManager menuMgr, IMemoryRendering rendering, AbstractMemoryRenderer renderer) {
super(newMemory, newTab, menuMgr, rendering);
@@ -403,8 +317,9 @@ public class MemoryViewTab extends AbstractMemoryViewTab implements SelectionLis
String tabName = null;
- if (getMemoryBlockPresentation() != null)
- tabName = getMemoryBlockPresentation().getTabLabel(newMemory, getRenderingId());
+ IDebugModelPresentation presentation = DebugUIPlugin.getModelPresentation();
+ if (presentation instanceof IMemoryBlockModelPresentation)
+ tabName = ((IMemoryBlockModelPresentation)presentation).getTabLabel(newMemory, getRenderingId());
if (tabName == null)
{
@@ -713,8 +628,13 @@ public class MemoryViewTab extends AbstractMemoryViewTab implements SelectionLis
TableColumn [] byteColumns = new TableColumn[bytesPerLine/columnSize];
String[] columnLabels = new String[0];
- if (getMemoryBlockPresentation() != null)
- columnLabels = getMemoryBlockPresentation().getColumnLabels(getMemoryBlock(), bytesPerLine, columnSize);
+ IDebugModelPresentation presentation = DebugUIPlugin.getModelPresentation();
+ if (presentation instanceof IMemoryBlockModelPresentation)
+ columnLabels = ((IMemoryBlockModelPresentation)presentation).getColumnLabels(getMemoryBlock(), bytesPerLine, columnSize);
+
+ // check that column labels are not null
+ if (columnLabels == null)
+ columnLabels = new String[0];
for (int i=0;i<byteColumns.length; i++)
{
@@ -800,8 +720,13 @@ public class MemoryViewTab extends AbstractMemoryViewTab implements SelectionLis
{
String[] columnLabels = new String[0];
- if (getMemoryBlockPresentation() != null)
- columnLabels = getMemoryBlockPresentation().getColumnLabels(getMemoryBlock(), fBytePerLine, fColumnSize);
+ IDebugModelPresentation presentation = DebugUIPlugin.getModelPresentation();
+ if (presentation instanceof IMemoryBlockModelPresentation)
+ columnLabels = ((IMemoryBlockModelPresentation)presentation).getColumnLabels(getMemoryBlock(), fBytePerLine, fColumnSize);
+
+ // check that column labels returned are not null
+ if (columnLabels == null)
+ columnLabels = new String[0];
int numByteColumns = fBytePerLine/fColumnSize;
@@ -1989,26 +1914,6 @@ public class MemoryViewTab extends AbstractMemoryViewTab implements SelectionLis
// update table cursor and force redraw
updateCursorPosition();
}
-
- /**
- * @return memory block presentation to allow for customization
- */
- protected IMemoryBlockModelPresentation getMemoryBlockPresentation()
- {
- // only try to create a model presentation once
- if (fMemoryBlockPresentation == null && !fNoPresentation)
- {
- // create model presentation for memory block
- DelegatingModelPresentation presentation = new MemoryViewDelegatingModelPresentation();
- String id = fMemoryBlock.getModelIdentifier();
- fMemoryBlockPresentation = (MemoryViewLazyModelPresentation)presentation.getPresentation(id);
-
- // if a memory block presentation cannot be retrieved
- if (fMemoryBlockPresentation == null)
- fNoPresentation = true;
- }
- return fMemoryBlockPresentation;
- }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IMemoryViewTab#setTabLabel(java.lang.String)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTabLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTabLabelProvider.java
index e6f137e0b..9ac8f4197 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTabLabelProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTabLabelProvider.java
@@ -48,7 +48,7 @@ public class MemoryViewTabLabelProvider
if (fViewTab instanceof MemoryViewTab)
{
// get model presentation
- IDebugModelPresentation presentation = ((MemoryViewTab)fViewTab).getMemoryBlockPresentation();
+ IDebugModelPresentation presentation = DebugUIPlugin.getModelPresentation();
if (presentation instanceof IMemoryBlockModelPresentation)
{
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java
index 95176985d..7c9a4694f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java
@@ -13,12 +13,7 @@ package org.eclipse.debug.internal.ui.views.memory;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.DebugUIMessages;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
/**
@@ -32,7 +27,8 @@ import org.eclipse.ui.PartInitException;
*/
public class RemoveMemoryRenderingAction extends AbstractMemoryAction
{
- public RemoveMemoryRenderingAction()
+ private IMemoryViewPane fViewPane;
+ public RemoveMemoryRenderingAction(IMemoryViewPane viewPane)
{
// create action as drop down
super(DebugUIMessages.getString("RemoveMemoryRenderingAction.Remove_rendering"), AS_PUSH_BUTTON); //$NON-NLS-1$
@@ -43,6 +39,7 @@ public class RemoveMemoryRenderingAction extends AbstractMemoryAction
setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_REMOVE_MEMORY));
setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_REMOVE_MEMORY));
setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_REMOVE_MEMORY));
+ fViewPane = viewPane;
}
/* (non-Javadoc)
@@ -60,7 +57,8 @@ public class RemoveMemoryRenderingAction extends AbstractMemoryAction
if (rendering != null)
{
// remove from Memory Rendering Manager
- MemoryRenderingManager.getMemoryRenderingManager().removeMemoryBlockRendering(rendering);
+ if (fViewPane instanceof IRenderingViewPane)
+ ((IRenderingViewPane)fViewPane).removeMemoryRendering(rendering);
}
}
}
@@ -69,40 +67,10 @@ public class RemoveMemoryRenderingAction extends AbstractMemoryAction
* @see com.ibm.debug.defaultrenderings.internal.actions.AbstractMemoryAction#getViewTab()
*/
IMemoryViewTab getViewTab() {
- String viewId = IInternalDebugUIConstants.ID_MEMORY_VIEW;
- // open a new view if necessary
- IWorkbenchPage p= DebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (p == null) {
- return null;
- }
- IViewPart view = null;
- view= p.findView(viewId);
-
- if (view == null) {
- try {
- IWorkbenchPart activePart= p.getActivePart();
- view= p.showView(viewId);
- p.activate(activePart);
- } catch (PartInitException e) {
- return null;
- }
-
- }
-
- if (view instanceof IMultipaneMemoryView)
- {
- IMemoryViewTab topTap = ((IMultipaneMemoryView)view).getTopMemoryTab(RenderingViewPane.RENDERING_VIEW_PANE_ID);
-
- return topTap;
- }
- else if (view instanceof IMemoryView)
- {
- IMemoryViewTab topTap = ((IMemoryView)view).getTopMemoryTab();
- return topTap;
- }
- else
+ if (fViewPane instanceof IMemoryView)
{
- return null;
+ return ((IMemoryView)fViewPane).getTopMemoryTab();
}
+ return null;
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
index 95f9d2558..7b92ba404 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java
@@ -47,7 +47,7 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.help.WorkbenchHelp;
-public class RenderingViewPane extends AbstractMemoryViewPane implements IMemoryRenderingListener{
+public class RenderingViewPane extends AbstractMemoryViewPane implements IRenderingViewPane{
public static final String RENDERING_VIEW_PANE_ID = DebugUIPlugin.getUniqueIdentifier() + ".MemoryView.RenderingViewPane"; //$NON-NLS-1$
@@ -61,9 +61,25 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
private IAction fAddMemoryBlockAction;
private IAction fRemoveMemoryRenderingAction;
+ private ViewPaneRenderingMgr fRenderingMgr;
/**
- * @param parent
+ * @param parent is the view hosting this view pane
+ * @param paneId is the identifier assigned by the Memory View
+ *
+ * Pane id is assigned with the following format.
+ * Rendering view pane created has its id assigned to
+ * org.eclipse.debug.ui.MemoryView.RenderingViewPane.#.
+ * # is a number indicating the order of which the rendering view
+ * pane is created. First rendering view pane created will have its
+ * id assigned to org.eclipse.debug.ui.MemoryView.RenderingViewPane.1.
+ * Second rendering view pane created will have its id assigned to
+ * org.eclipse.debug.ui.MemoryView.RenderingViewPane.2. and so on.
+ * View pane are created from left to right by the Memory View.
+ *
+ * Note: Currently, there is only one rendering view pane with id
+ * org.eclipse.debug.ui.MemoryView.RenderingViewPane.1. Memory View is
+ * equipped to host more than one rendering view pane.
*/
public RenderingViewPane(IViewPart parent) {
super(parent);
@@ -88,7 +104,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
TabFolder folder = new TabFolder(fViewPaneCanvas, SWT.NULL);
TabItem newItem = new TabItem(folder, SWT.NULL);
- CreateRenderingTab createTab = new CreateRenderingTab(memory, newItem);
+ CreateRenderingTab createTab = new CreateRenderingTab(memory, newItem, getInstance());
folder.setSelection(0);
@@ -140,11 +156,11 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
}
// get all renderings from this memroy block and remove them from the view
- IMemoryRendering[] renderings = MemoryRenderingManager.getMemoryRenderingManager().getRenderingsFromMemoryBlock(memory);
+ IMemoryRendering[] renderings = fRenderingMgr.getRenderingsFromMemoryBlock(memory);
for (int k=0; k<renderings.length; k++)
{
- MemoryBlockRenderingRemoved(renderings[k]);
+ removeMemoryRendering(renderings[k]);
}
// remove a the tab folder if the memory block is removed
@@ -389,7 +405,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
}
// restore view tabs
- IMemoryRendering[] renderings = MemoryRenderingManager.getMemoryRenderingManager().getRenderingsFromMemoryBlock(memBlock);
+ IMemoryRendering[] renderings = fRenderingMgr.getRenderingsFromMemoryBlock(memBlock);
TabFolder toDisplay = (TabFolder)fStackLayout.topControl;
// remember tab folder for current debug target
@@ -428,7 +444,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
if (viewTab == null)
{
TabItem newItem = new TabItem(toDisplay, SWT.NULL);
- CreateRenderingTab createTab = new CreateRenderingTab(memBlock, newItem);
+ CreateRenderingTab createTab = new CreateRenderingTab(memBlock, newItem, getInstance());
setRenderingSelection(createTab);
}
@@ -441,7 +457,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.memory.IMemoryRenderingListener#MemoryBlockRenderingAdded(org.eclipse.debug.internal.core.memory.IMemoryRendering)
*/
- public void MemoryBlockRenderingAdded(IMemoryRendering rendering) {
+ public void memoryBlockRenderingAdded(IMemoryRendering rendering) {
String renderingId = rendering.getRenderingId();
IMemoryBlock memoryblk = rendering.getBlock();
@@ -531,7 +547,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
// remove the rendering if view tab factory is not defined
// otherwise, we will keep getting the error
- MemoryRenderingManager.getMemoryRenderingManager().removeMemoryBlockRendering(rendering.getBlock(), rendering.getRenderingId());
+ fRenderingMgr.removeMemoryBlockRendering(rendering.getBlock(), rendering.getRenderingId());
}
updateToolBarActionsEnablement();
@@ -540,7 +556,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
/* (non-Javadoc)
* @see org.eclipse.debug.internal.core.memory.IMemoryRenderingListener#MemoryBlockRenderingRemoved(org.eclipse.debug.internal.core.memory.IMemoryRendering)
*/
- public void MemoryBlockRenderingRemoved(final IMemoryRendering rendering) {
+ public void memoryBlockRenderingRemoved(final IMemoryRendering rendering) {
final IMemoryBlock memory = rendering.getBlock();
// need to run the following code on the UI Thread to avoid invalid thread access exception
@@ -610,7 +626,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
if (tabFolder != fEmptyTabFolder)
{
TabItem newItem = new TabItem(tabFolder, SWT.NULL);
- CreateRenderingTab createTab = new CreateRenderingTab(memory, newItem);
+ CreateRenderingTab createTab = new CreateRenderingTab(memory, newItem, getInstance());
tabFolder.setSelection(0);
setRenderingSelection(createTab);
}
@@ -720,7 +736,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
{
for (int i=0; i<renderings.length; i++)
{
- MemoryBlockRenderingAdded(renderings[i]);
+ memoryBlockRenderingAdded(renderings[i]);
// // disable after done
// if (renderings[i].getBlock() instanceof IMemoryBlockExtension)
@@ -844,11 +860,9 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
protected void addListeners() {
super.addListeners();
- MemoryRenderingManager.getMemoryRenderingManager().addListener(this);
}
protected void removeListeners() {
super.removeListeners();
- MemoryRenderingManager.getMemoryRenderingManager().removeListener(this);
}
/* (non-Javadoc)
@@ -932,12 +946,6 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
}
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.views.memory.AbstractMemoryViewPane#getPaneId()
- */
- public String getPaneId() {
- return RENDERING_VIEW_PANE_ID;
- }
public void restoreViewPane() {
IMemoryBlock memoryBlock = null;
@@ -981,7 +989,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
fViewPaneCanvas.layout();
// restore view tabs
- IMemoryRendering[] renderings = MemoryRenderingManager.getMemoryRenderingManager().getRenderingsFromMemoryBlock(memoryBlock);
+ IMemoryRendering[] renderings = fRenderingMgr.getRenderingsFromMemoryBlock(memoryBlock);
if (toDisplay.getItemCount() == 0)
{
@@ -1005,7 +1013,7 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
{
TabFolder folder = (TabFolder)fStackLayout.topControl;
TabItem newItem = new TabItem(folder, SWT.NULL);
- new CreateRenderingTab(memoryBlock, newItem);
+ new CreateRenderingTab(memoryBlock, newItem, getInstance());
folder.setSelection(0);
}
}
@@ -1019,23 +1027,27 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
fMemoryBlockFromTabFolder.clear();
fMemoryBlockFromTabFolder = null;
+
+ fRenderingMgr.dispose();
+ fRenderingMgr = null;
}
- public Control createViewPane(Composite parent) {
- Control control = super.createViewPane(parent);
+ public Control createViewPane(Composite parent, String paneId) {
+ Control control = super.createViewPane(parent, paneId);
+ fRenderingMgr = new ViewPaneRenderingMgr(this);
WorkbenchHelp.setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".MemoryRenderingView_context"); //$NON-NLS-1$
return control;
}
- IAction[] getActions() {
+ public IAction[] getActions() {
ArrayList actions = new ArrayList();
if (fAddMemoryBlockAction == null)
- fAddMemoryBlockAction = new AddMemoryRenderingAction();
+ fAddMemoryBlockAction = new AddMemoryRenderingAction(this);
actions.add(fAddMemoryBlockAction);
if (fRemoveMemoryRenderingAction == null)
- fRemoveMemoryRenderingAction = new RemoveMemoryRenderingAction();
+ fRemoveMemoryRenderingAction = new RemoveMemoryRenderingAction(this);
fRemoveMemoryRenderingAction.setEnabled(false);
actions.add(fRemoveMemoryRenderingAction);
@@ -1088,4 +1100,35 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory
updateToolBarActionsEnablement();
fSelectionProvider.setSelection(new StructuredSelection(new Object[0]));
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IRenderingViewPane#addMemoryRendering(org.eclipse.debug.internal.ui.views.memory.IMemoryRendering)
+ */
+ public void addMemoryRendering(IMemoryRendering rendering) {
+
+ if (rendering == null)
+ return;
+
+ memoryBlockRenderingAdded(rendering);
+ fRenderingMgr.addMemoryBlockRendering(rendering);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.views.memory.IRenderingViewPane#removeMemoryRendering(org.eclipse.debug.internal.ui.views.memory.IMemoryRendering)
+ */
+ public void removeMemoryRendering(IMemoryRendering rendering) {
+
+ if (rendering == null)
+ return;
+
+ memoryBlockRenderingRemoved(rendering);
+ fRenderingMgr.removeMemoryBlockRendering(rendering);
+
+ }
+
+ private RenderingViewPane getInstance()
+ {
+ return this;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SignedIntegerRenderer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SignedIntegerRenderer.java
index 5b3cc6734..078a27b50 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SignedIntegerRenderer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SignedIntegerRenderer.java
@@ -114,13 +114,10 @@ public class SignedIntegerRenderer
int endianess = RendererUtil.BIG_ENDIAN;
// Check current state of the rendering
- IMemoryRendering[] renderings = MemoryRenderingManager.getMemoryRenderingManager().getRenderings(fViewTab.getMemoryBlock(), fViewTab.getRenderingId());
-
- if (renderings.length > 0){
- if (renderings[0] instanceof IntegerRendering)
- {
- endianess = ((IntegerRendering)renderings[0]).getCurrentEndianess();
- }
+ IMemoryRendering rendering = fTableViewTab.getRendering();
+ if (rendering instanceof IntegerRendering)
+ {
+ endianess = ((IntegerRendering)rendering).getCurrentEndianess();
}
return endianess;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/UnsignedIntegerRenderer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/UnsignedIntegerRenderer.java
index eee3baa85..1c09c0be3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/UnsignedIntegerRenderer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/UnsignedIntegerRenderer.java
@@ -117,16 +117,12 @@ public class UnsignedIntegerRenderer extends AbstractMemoryRenderer {
// default to Big Endian in case the endianess cannot be determined
int endianess = RendererUtil.BIG_ENDIAN;
- // if it's IMemoryBlock
- // Check current state of the rendering
- IMemoryRendering[] renderings = MemoryRenderingManager.getMemoryRenderingManager().getRenderings(fViewTab.getMemoryBlock(), fViewTab.getRenderingId());
-
- if (renderings.length > 0){
- if (renderings[0] instanceof IntegerRendering)
- {
- endianess = ((IntegerRendering)renderings[0]).getCurrentEndianess();
- }
+ IMemoryRendering rendering = fTableViewTab.getRendering();
+ if (rendering instanceof IntegerRendering)
+ {
+ endianess = ((IntegerRendering)rendering).getCurrentEndianess();
}
+
return endianess;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java
new file mode 100644
index 000000000..1f678d39a
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.views.memory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.internal.core.LaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A View Pane Rendering Manager manages all the rendering from a view pane.
+ * It is responsible for handling debug events and removing renderings
+ * from the view pane as a debug session is terminated.
+ * In addition, the rendering manager is responsible for persisting memory renderings.
+ * Renderings need to be persisted when the memory view is disposed. If the view is
+ * opened again, the same set of renderings will be created in the view pane if
+ * the renderings are still valid.
+ * @since 3.1
+ */
+public class ViewPaneRenderingMgr implements IDebugEventSetListener{
+
+ private ArrayList fRenderings = new ArrayList();
+ private IRenderingViewPane fViewPane;
+
+ private static final String RENDERINGS_TAG = "persistedMemoryRenderings"; //$NON-NLS-1$
+ private static final String MEMORY_RENDERING_TAG = "memoryRendering"; //$NON-NLS-1$
+ private static final String MEMORY_BLOCK = "memoryBlock"; //$NON-NLS-1$
+ private static final String RENDERING_ID = "renderingId"; //$NON-NLS-1$
+
+ public ViewPaneRenderingMgr(IRenderingViewPane viewPane)
+ {
+ fViewPane = viewPane;
+ loadPersistedRenderings();
+ }
+
+
+ public IMemoryRendering addMemoryBlockRendering(IMemoryBlock mem, String renderingId) throws DebugException
+ {
+ if (fRenderings == null)
+ return null;
+
+ IMemoryRendering newRendering = MemoryRenderingManager.getMemoryRenderingManager().createRendering(mem, renderingId);
+
+ // if an error has occurred, or if user has canceled
+ if (newRendering == null)
+ return newRendering;
+
+ if (fRenderings.contains(newRendering))
+ return newRendering;
+
+ fRenderings.add(newRendering);
+
+ // add listener for the first memory block added
+ if (fRenderings.size() == 1)
+ {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+
+ storeRenderings();
+
+ return newRendering;
+
+ }
+
+ public void removeMemoryBlockRendering(IMemoryBlock mem, String renderingId)
+ {
+ if(fRenderings == null)
+ return;
+
+ IMemoryRendering[] toRemove = getRenderings(mem, renderingId);
+
+ for (int i=0; i<toRemove.length; i++)
+ {
+ fRenderings.remove(toRemove[i]);
+
+ // remove listener after the last memory block has been removed
+ if (fRenderings.size() == 0)
+ {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+ }
+
+ storeRenderings();
+ }
+
+
+ public void addMemoryBlockRendering(IMemoryRendering rendering) {
+
+ // do not allow duplicated objects
+ if (fRenderings.contains(rendering))
+ return;
+
+ fRenderings.add(rendering);
+
+ // add listener for the first memory block added
+ if (fRenderings.size() == 1)
+ {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+
+ storeRenderings();
+ }
+
+
+ public void removeMemoryBlockRendering(IMemoryRendering rendering) {
+ if(rendering == null)
+ return;
+
+ if(!fRenderings.contains(rendering))
+ return;
+
+ fRenderings.remove(rendering);
+
+ // remove listener after the last memory block has been removed
+ if (fRenderings.size() == 0)
+ {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+
+ storeRenderings();
+ }
+
+ public IMemoryRendering[] getRenderings(IMemoryBlock mem, String renderingId)
+ {
+ if (renderingId == null)
+ {
+ return getRenderingsFromMemoryBlock(mem);
+ }
+
+ ArrayList ret = new ArrayList();
+ for (int i=0; i<fRenderings.size(); i++)
+ {
+ if (fRenderings.get(i) instanceof IMemoryRendering)
+ {
+ IMemoryRendering rendering = (IMemoryRendering)fRenderings.get(i);
+ if (rendering.getBlock() == mem && renderingId.equals(rendering.getRenderingId()))
+ {
+ ret.add(rendering);
+ }
+ }
+ }
+
+ return (IMemoryRendering[])ret.toArray(new IMemoryRendering[ret.size()]);
+ }
+
+
+ public IMemoryRendering[] getRenderingsFromDebugTarget(IDebugTarget target)
+ {
+ ArrayList ret = new ArrayList();
+ for (int i=0; i<fRenderings.size(); i++)
+ {
+ if (fRenderings.get(i) instanceof IMemoryRendering)
+ {
+ IMemoryRendering rendering = (IMemoryRendering)fRenderings.get(i);
+ if (rendering.getBlock().getDebugTarget() == target)
+ {
+ ret.add(rendering);
+ }
+ }
+ }
+
+ return (IMemoryRendering[])ret.toArray(new IMemoryRendering[ret.size()]);
+ }
+
+
+ public IMemoryRendering[] getRenderingsFromMemoryBlock(IMemoryBlock block)
+ {
+ ArrayList ret = new ArrayList();
+ for (int i=0; i<fRenderings.size(); i++)
+ {
+ if (fRenderings.get(i) instanceof IMemoryRendering)
+ {
+ IMemoryRendering rendering = (IMemoryRendering)fRenderings.get(i);
+ if (rendering.getBlock() == block)
+ {
+ ret.add(rendering);
+ }
+ }
+ }
+
+ return (IMemoryRendering[])ret.toArray(new IMemoryRendering[ret.size()]);
+ }
+
+
+
+ public void handleDebugEvents(DebugEvent[] events) {
+
+ for (int i=0; i < events.length; i++)
+ handleDebugEvent(events[i]);
+
+ }
+
+ public void handleDebugEvent(DebugEvent event) {
+ Object obj = event.getSource();
+ IDebugTarget dt = null;
+
+ if (event.getKind() == DebugEvent.TERMINATE)
+ {
+ // a terminate event could happen from an IThread or IDebugTarget
+ // Only handle terminate event from debug target
+ if (obj instanceof IDebugTarget)
+ {
+ dt = ((IDebugTarget)obj);
+
+ // returns empty array if dt == null
+ IMemoryRendering[] deletedrendering = getRenderingsFromDebugTarget(dt);
+
+ for (int i=0; i<deletedrendering.length; i++)
+ {
+ removeMemoryBlockRendering(deletedrendering[i].getBlock(), deletedrendering[i].getRenderingId());
+ fViewPane.removeMemoryRendering(deletedrendering[i]);
+ }
+ }
+ }
+ }
+
+ public void dispose()
+ {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+
+ /**
+ * Store renderings as preferences. If renderings are stored, renderings
+ * can be persisted even after the memory view is closed.
+ */
+ private void storeRenderings()
+ {
+ Preferences prefs = DebugUIPlugin.getDefault().getPluginPreferences();
+ String renderingsStr= ""; //$NON-NLS-1$
+ try {
+ renderingsStr= getRenderingsAsXML();
+ } catch (IOException e) {
+ DebugUIPlugin.log(e);
+ } catch (ParserConfigurationException e) {
+ DebugUIPlugin.log(e);
+ } catch (TransformerException e) {
+ DebugUIPlugin.log(e);
+ }
+ prefs.setValue(fViewPane.getPaneId(), renderingsStr);
+ DebugUIPlugin.getDefault().savePluginPreferences();
+ }
+
+ /**
+ * Convert renderings to xml text
+ * @return
+ * @throws IOException
+ * @throws ParserConfigurationException
+ * @throws TransformerException
+ */
+ private String getRenderingsAsXML() throws IOException, ParserConfigurationException, TransformerException {
+ IMemoryRendering[] renderings= (IMemoryRendering[])fRenderings.toArray(new IMemoryRendering[fRenderings.size()]);
+ Document document= LaunchManager.getDocument();
+ Element rootElement= document.createElement(RENDERINGS_TAG);
+ document.appendChild(rootElement);
+ for (int i = 0; i < renderings.length; i++) {
+ IMemoryRendering rendering= renderings[i];
+ Element element= document.createElement(MEMORY_RENDERING_TAG);
+ element.setAttribute(MEMORY_BLOCK, Integer.toString(rendering.getBlock().hashCode()));
+ element.setAttribute(RENDERING_ID, rendering.getRenderingId());
+ rootElement.appendChild(element);
+ }
+ return LaunchManager.serializeDocument(document);
+ }
+
+ /**
+ * Load renderings currently stored.
+ */
+ private void loadPersistedRenderings() {
+ String renderingsStr= DebugUIPlugin.getDefault().getPluginPreferences().getString(fViewPane.getPaneId());
+ if (renderingsStr.length() == 0) {
+ return;
+ }
+ Element root;
+ try {
+ root = DebugPlugin.parseDocument(renderingsStr);
+ } catch (CoreException e) {
+ DebugUIPlugin.logErrorMessage("An exception occurred while loading memory renderings."); //$NON-NLS-1$
+ return;
+ }
+ if (!root.getNodeName().equals(RENDERINGS_TAG)) {
+ DebugUIPlugin.logErrorMessage("Invalid format encountered while loading memory renderings."); //$NON-NLS-1$
+ return;
+ }
+ NodeList list= root.getChildNodes();
+ boolean renderingsAdded= false;
+ for (int i= 0, numItems= list.getLength(); i < numItems; i++) {
+ Node node= list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element element= (Element) node;
+ if (!element.getNodeName().equals(MEMORY_RENDERING_TAG)) {
+ DebugUIPlugin.logErrorMessage("Invalid XML element encountered while loading memory rendering."); //$NON-NLS-1$
+ continue;
+ }
+ String memoryBlockHashCode= element.getAttribute(MEMORY_BLOCK);
+ String renderingId = element.getAttribute(RENDERING_ID);
+
+ IMemoryBlock[] memoryBlocks = DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks();
+ IMemoryBlock memoryBlock = null;
+ for (int j=0; j<memoryBlocks.length; j++)
+ {
+ if (Integer.toString(memoryBlocks[j].hashCode()).equals(memoryBlockHashCode))
+ memoryBlock = memoryBlocks[j];
+ }
+
+ // if memory block is not found, the rendering is no longer valid
+ // simply ignore the rendering
+ if (memoryBlock != null)
+ {
+ try {
+ IMemoryRendering rendering = MemoryRenderingManager.getMemoryRenderingManager().createRendering(memoryBlock, renderingId);
+ if (rendering != null)
+ {
+ if (!fRenderings.contains(rendering))
+ {
+ fRenderings.add(rendering);
+ renderingsAdded= true;
+ }
+ }
+ } catch (DebugException e1) {
+ }
+ }
+ }
+ }
+ if (renderingsAdded) {
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+ }
+}

Back to the top