Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-debug-dev] Implementing View in Debugger


Hi!

I followed an advice and wrote code in my class ModelViewEventHandler which catches the DebugEvent.CREATE event by such snippet of code

case DebugEvent.CREATE :
                            if ( event.getSource() instanceof CDebugTarget )                                
                             {        
                                     ModelManager fModelManager = new ModelManager( (CDebugTarget)event.getSource() );
                             }
So,  my class ModelView,  registered as a listener by fragment  getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); in createViewer(...) function, reacts on SelectionChanged in function
        public void selectionChanged( IWorkbenchPart part, ISelection selection )
        {
                if ( selection instanceof IStructuredSelection )
                {
                        setViewerInput( (IStructuredSelection)selection );
                }
        }        , and we can see that ModelView calls function setViewerInput(...) which look like this:

        protected void setViewerInput( IStructuredSelection ssel )
        {
               
                ModelManager mm = null;
                if ( ssel != null && ssel.size() == 1 )
                {
                        Object input = ssel.getFirstElement();
                        if ( input instanceof IDebugElement )
                        {
                                mm = (ModelManager)((IDebugElement)input).getDebugTarget().getAdapter( ModelManager.class );
                        }
                }

                Object current = getViewer().getInput();
                if ( current != null && current.equals( mm ) )
                {
                        return;
                }
                showViewer();
                getViewer().setInput( mm );
        }        
 
All those functions created, using as an example structure of Memory Manager classes and function as it can be seen.  

First problem I met is how to replace the string  mm = (ModelManager)((IDebugElement)input).getDebugTarget().getAdapter( ModelManager.class ). As long as I decided not to change CDT code I can't keep this string as it is now. So how can I get ModelManager object in my situation, without any intervention in source code of CDT?

And another one. I've noticed that SelectionChanged event is fired after CMemoryManager creating and my ModelView reacts on it and value of  
 input instanceof IDebugElement is TRUE. But my ModelManager has not created yet! It will be created later after calling of fireCreationEvent() function, which triggers DebugEvent.CREATE. What should I do in this case?

By the way, I don't quite understand mission of following strings:

                if ( ssel != null && ssel.size() == 1 )
                {
                        Object input = ssel.getFirstElement();
                        if ( input instanceof IDebugElement )
                        {
                                mm = (ModelManager)((IDebugElement)input).getDebugTarget().getAdapter( ModelManager.class );
                        }
                }

                Object current = getViewer().getInput();
                if ( current != null && current.equals( mm ) )
                {
                        return;
                }

I have a suggestion that they allow to manage view using event's type, but I don't clearly understand how they work. Moreover RegistersView.setViewerInput() constructed similar to above examples. Please tell me about it a little.




Great Thanks in Advance,

 Igor S. Zamyatin
 Interstron Ltd.
----------------------------------------
email:  isz@xxxxxxxxxxxxx
tel:    +7 (095) 269-4713
cell:   +7 (902) 659-5838
www:    http://www.interstron.ru

 



"Mikhail Khodjaiants" <mikhailk@xxxxxxx>
Sent by: cdt-debug-dev-admin@xxxxxxxxxxx

18.11.2002 19:31
Please respond to cdt-debug-dev

       
        To:        <cdt-debug-dev@xxxxxxxxxxx>
        cc:        
        Subject:        Re: [cdt-debug-dev] Implementing View in Debugger



If you want to associate an instance of your class (ModelManager) with CDebugTarget you should catch the creation of CDebugTarget (CREATE type of DebugEvent) and create an association.
 
Mikhail
----- Original Message -----
From: Igor S Zamjatin
To: cdt-debug-dev@xxxxxxxxxxx
Sent: Friday, November 15, 2002 10:27 AM
Subject: Re: [cdt-debug-dev] Implementing View in Debugger


Hi!!!


My problem is overpassed!  ModelManager recieves notification from Debugger! Thanks a lot.


But I have another question  :)


While solving my problem I had to add some code into CDebugTarget.java.



In particular I added in function initialize() such a string         initializeModelManager();

and function                


       
protected void initializeModelManager()
       {

               fModelManager =
new ModelManager( this );
       }

Also I added in function getAdapter() following strings


     
if ( adapter.equals( ModelManager.class ) )
             
return getModelManager();        
and function getModelManager() and so on.


Can I somehow avoid this situation?  I don't want to correct or add something in source files. May be I do something wrong...



Igor S. Zamyatin


Interstron Ltd.
----------------------------------------
email:  isz@xxxxxxxxxxxxx
tel:    +7 (095) 269-4713
cell:   +7 (902) 659-5838
www:    http://www.interstron.ru





Back to the top