Bug 248486 - [Memory View] Need a way to set default memory view format for a particular renderer
Summary: [Memory View] Need a way to set default memory view format for a particular r...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Samantha Chan CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-09-24 14:44 EDT by Chris Genly CLA
Modified: 2009-10-25 17:11 EDT (History)
2 users (show)

See Also:


Attachments
Fix the behaviour of "Restore Defaults" button (18.03 KB, patch)
2009-09-09 07:37 EDT, Radu Farcas CLA
r88781: review?
Details | Diff
Correct previouse (1.85 KB, patch)
2009-10-05 03:13 EDT, Teodor Madan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Genly CLA 2008-09-24 14:44:50 EDT
I’m working on a machine with word addresses.  So I want the memory block address in the memory view to be words,  not bytes.  So I’ve set getAddressableSize() to 4 for IMemoryBlockExtension.

  public class AmbricExtendedMemory 
      extends AmbricDebugElement 
      implements IMemoryBlockExtension, ILabelDecorator {

      ...

      public int getAddressableSize() throws DebugException {
            return 4;
      }
      ....
}

 

The problem when I do this is the memory view tries to concatenate four words together in one column of the memory view when using the hex integer renderer.  This is very hard to read.  I can right click on the memory view and select the format menu item to set the column size to 1, and the row size to 8 to make things display reasonably.  My problem is that I want to be able to do this programmatically.  For my memory type I want the default format to be as I have described: rowSize 8, column size 1.  But I can not find any APIs which are public.

For example going through the eclipse debugger source I found IPersistableDebugElement dictates the format of a memory block.

  package org.eclipse.debug.internal.ui.memory;

  public interface IPersistableDebugElement {
    public Object getProperty(Object context, String propertyId)
  }

 
This interface will allow me to set the row and column size.  The problem is that it is in an internal package.  The property ID is also internal.  

Further it is in a UI project, while my memory block implementation, AmbricExtendedMemory, is in ambric.debug.core project.   It would be inappropriate for the AmbricExtendedMemory to use IPersistableDebugElement which is in a UI package.

I tried to solve the modularity problem by having the ambric ui declare an adapter using the org.eclipse.core.runtime.adapaters extension, but it doesn’t work.  The eclipse debug code for getting the format via IPersistibleDebugElement does not use the adapter manager.

Ken_Dyck@amis.com sent me a reply on the mailing list suggesting I use plugin_customizations.ini and add the following lines.

org.eclipse.debug.ui/org.eclipse.debug.ui.memory.rowSize\:com.ambric.debug.ui=8 
org.eclipse.debug.ui/org.eclipse.debug.ui.memory.columnSize\:com.ambric.debug.ui=1 

This has not worked for me either.  Reading the eclipse code I have not been able to salvage this method.  This would be a fine solution if it worked.
Comment 1 Samantha Chan CLA 2008-09-24 15:20:18 EDT
Does your model object extend from PlatformObject?  And if it does, does #getAdapter call super if your model object cannot find an adapter?

I believe that if your model object extends from PlatformObject, when the platform makes a #getAdapter call it will eventually get to the adapter manager.  PlatformObject will call the adapter manager to find an adapter.
Comment 2 Chris Genly CLA 2008-09-24 19:45:50 EDT
I had scrapped my original implementation.   But I wanted to try some things for this bug report so I reimplemented it.  AmbricExtendedMemory did and does extend PlatformObject.  Things are now working as expected so I must have made a mistake before.

As before I am using internal classes:
  IPersistableDebugElement
  IDebugPreferenceConstants.PREF_ROW_SIZE_BY_MODEL
  IDebugPreferenceConstants.PREF_COL_SIZE_BY_MODEL

When I right click on the memory view and select the format menu item the format dialog box presents a 'save as defaults' button.   Pressing it causes IPersistableDebugElement.setProperty() to be called.  That's pretty cool.  When I select 'restore defaults' it restores the values to the eclipse defaults, what I really want is to restore them to my defaults.

I'm using IPersistableDebugElement because that was what was available.   All I really want to do is supply defaults to a renderer.  For me this might be better if the platform supplied an extension point which let me specify the defaults I want for my IMemoryBlockExtension implementation.
Comment 3 Radu Farcas CLA 2009-07-06 09:00:13 EDT
I have a similar problem with the one described here, only that my model doesn't extend from PlatformObject (actually I'm using CDI) so I can't use IPersistableDebugElement. 
Is there a way to specify the rendering default using pluginCustomization file? 

I've tried the obvious by adding the following entry in my file:

org.eclipse.debug.ui/org.eclipse.debug.ui.memory.columnSize\:org.eclipse.cdt.debug.core=1

but it seems that this kind of command line default ([plugin]/[key]:[model]=[value]) doesn't get applied correctly. The problem seems to be somewhere in 
org.eclipse.core.internal.preferences.applyDefaults(). 

Is there another way to specify this kind of defaults in plugin customization file? 
Or, is there another alternative for setting this kind of defaults (besides IPersistableDebugElement)?

Comment 4 Radu Farcas CLA 2009-09-09 07:37:26 EDT
Created attachment 146736 [details]
Fix the behaviour of "Restore Defaults" button

restoreDefaults() method must check for an IPersistableDebugElement adapter before getting the defaultRowSize and defaultColSize.
Comment 5 Teodor Madan CLA 2009-10-05 03:13:25 EDT
Created attachment 148736 [details]
Correct previouse 

Correcting patch format for the previous attached file. 
Values for defaults will be used in the following search order: IPersistableDebugElement, workspace preference, plugin defaults.
Comment 6 Samantha Chan CLA 2009-10-05 08:59:59 EDT
Thanks... I will review patch.
Comment 7 Samantha Chan CLA 2009-10-25 16:52:40 EDT
(In reply to comment #2)
> I had scrapped my original implementation.   But I wanted to try some things
> for this bug report so I reimplemented it.  AmbricExtendedMemory did and does
> extend PlatformObject.  Things are now working as expected so I must have made
> a mistake before.
> 
> As before I am using internal classes:
>   IPersistableDebugElement
>   IDebugPreferenceConstants.PREF_ROW_SIZE_BY_MODEL
>   IDebugPreferenceConstants.PREF_COL_SIZE_BY_MODEL
> 
> When I right click on the memory view and select the format menu item the
> format dialog box presents a 'save as defaults' button.   Pressing it causes
> IPersistableDebugElement.setProperty() to be called.  That's pretty cool.  When
> I select 'restore defaults' it restores the values to the eclipse defaults,
> what I really want is to restore them to my defaults.
> 
> I'm using IPersistableDebugElement because that was what was available.   All I
> really want to do is supply defaults to a renderer.  For me this might be
> better if the platform supplied an extension point which let me specify the
> defaults I want for my IMemoryBlockExtension implementation.

IPersistableDebugElement and related classes are internal because they are experimental interfaces.  We have looked at allowing the debug model to persist preferences before, but were not able to come up with a solution that we think we can support in the long run.  This is a bigger problem for the debug platform that it needs to allow the debug model to save and restore preferences and options.
Comment 8 Samantha Chan CLA 2009-10-25 17:10:58 EDT
Applied patch.
Comment 9 Samantha Chan CLA 2009-10-25 17:11:15 EDT
Verified