Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dsdp-tm-dev] create rse connections programmatically.


Hi Wei,

Once you have a basic menu in place (standard jface context menu), you'll need to populate it.  For an example of how RSE populated the menu for both popup-menu extensions and the adapter-contributed actions, see SystemScratchPadView.fillContextMenu().

____________________________________
David McKnight    
Phone:   905-413-3902 , T/L:  969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail:       D1/YFY/8200/TOR
____________________________________



Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>

23/03/2007 10:14 AM

To
David McKnight/Toronto/IBM@IBMCA
cc
Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>, "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
Subject
Re: [dsdp-tm-dev] create rse connections programmatically.





hi david,

i was so stupid and your last 2 mails were in fact not necessary at all. it works now. the treeview and the connections in it look good.

i've still got my last question here for you: in this view there's still no popup menu. how to build in all the standard rse popup menus for all the rse objects inside this tree?

regard,wei.



----- Original Message ----
From: David McKnight <dmcknigh@xxxxxxxxxx>
To: Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>
Cc: Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>; "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
Sent: Thursday, March 22, 2007 11:34:37 PM
Subject: Re: [dsdp-tm-dev] create rse connections programmatically.


1) & 2) You should use SystemViewConnectionAdapter to display the label, icon and children of an IHost.  You don't need new code for that.

3) & 4) Your model would consist of the folders that contain existing RSE objects.  The objects contained in the folders (i.e. hosts) are existing RSE objects.  In the code I gave you, you'd replace IRemoteFile with whatever object your "connection folder" is (i.e.  IConnectionFolder).  You'd replace SystemViewFileAdapterFactory with something like SystemViewConnectionFolderAdapterFactory.


____________________________________
David McKnight    
Phone:   905-413-3902 , T/L:  969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail:       D1/YFY/8200/TOR
____________________________________



Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>

22/03/2007 03:44 PM


To
David McKnight/Toronto/IBM@IBMCA
cc
Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>, "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
Subject
Re: [dsdp-tm-dev] create rse connections programmatically.







am i right here?

1)
SystemViewConnectionAdapter stays intact.

2) so i've been wrong to let my tree node model class extend SystemViewConnectionAdapter. it should implement IHost.  now i still need to let it implement
IAdaptable.

3) in your code below replace IRemoteFile with IHost and replace SystemViewRemoteFileAdapter with
SystemViewConnectionAdapter and replace SystemViewFileAdapterFactory with a class name i like i.e. HolySystemViewHostAdapterFactory.

4) in your code below replace
SystemViewFileAdapterFactory with HolySystemViewHostAdapterFactor.

regard,wei.



----- Original Message ----
From: David McKnight <dmcknigh@xxxxxxxxxx>
To: Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>
Cc: Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>; "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
Sent: Thursday, March 22, 2007 8:00:26 PM
Subject: Re: [dsdp-tm-dev] create rse connections programmatically.


The shortcut for implementing ISystemViewElementAdapter is to extend AbstractSystemViewElementAdapter, which provides much of the generic implementation.


SystemViewConnectionAdapter is the correct adapter for IHost.  IHost is what you want.


When you provide your own adapter for your own model objects, you need to register it.  To do that, you need to provide the following:


1) You implementation of ISystemViewElementAdapter

2) Your model object needs to implement IAdaptable.  Typically you'd implement getAdapter() as follows:

     

 
public Object getAdapter(Class adapterType)
  {

             
return Platform.getAdapterManager().getAdapter(this, adapterType);        
  }    



3) You should provide an adapter factory class.  Here's an example of what we do for mapping IRemoteFile to SystemViewRemoteFileAdapter where:


IRemoteFile is the model object type

SystemViewRemoteFileAdapter is the ISystemViewElementAdapter


/**

*
This factory maps requests for an adapter object from a given
*
 element object. This is for the universal file system.
*/

public
class SystemViewFileAdapterFactory extends AbstractSystemRemoteAdapterFactory
{

     
private SystemViewRemoteFileAdapter fileAdapter = new SystemViewRemoteFileAdapter();
     
     
/**
       
* Called by our plugin's startup method to register our adaptable object types
       
* with the platform. We prefer to do it here to isolate/encapsulate all factory
       
* logic in this one place.
       
*/
     
public void registerWithManager(IAdapterManager manager)
      {

          manager.registerAdapters(
this, IRemoteFile.class);
      }

     
/**
       
* @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
       
*/
     
public Object getAdapter(Object adaptableObject, Class adapterType)
      {

          Object adapter =
null;
         
if (adaptableObject instanceof IRemoteFile)
            adapter =
fileAdapter;

         
if ((adapter != null) && (adapterType == IPropertySource.class))
          {        

              ((ISystemViewElementAdapter)adapter).setPropertySourceInput(adaptableObject);

          }                              
             
return adapter;
      }        

}



4) Finally, you need to register the adapter factory  (for example, in your Activator at startup).  Here's how we do it for the files:


          IAdapterManager manager = Platform.getAdapterManager();

         
         
svfaf = new SystemViewFileAdapterFactory();        
         
svfaf.registerWithManager(manager);        

____________________________________
David McKnight    
Phone:   905-413-3902 , T/L:  969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail:       D1/YFY/8200/TOR
____________________________________


Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>

22/03/2007 02:25 PM


To
David McKnight/Toronto/IBM@IBMCA
cc
Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>, "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
Subject
Re: [dsdp-tm-dev] create rse connections programmatically.









of course thanks. i've got the last problem i think. you said "
Or you may choose to create an ISystemViewElementAdapter for your object.". yes i need to do this but there are 63 methods to implement for ISystemViewElementAdapter. is there any shortcut to create a connection like                
---------------------------------
         host = registry.createHost(

                                         
"SSH Only",        //System Type Name        //$NON-NLS-1$
                                         hostName,        
//Connection name
                                         hostName,        
//IP Address                
                                         
"Connection to Eclipse build site"); //description //$NON-NLS-1$
---------------------------------------
but IHost is not what we want, is it?
i tried to let my tree node model class extend SystemViewConnectionAdapter. but it does not seem to work and i never run into this bracket:
--------------------------------------

                   {

                             result.setPropertySourceInput(object);

                             result.setViewer(
_view);
                             
return result;
                     }

--------------------------------------
please let me know what you would do here! regard,wei.


----- Original Message ----
From: David McKnight <dmcknigh@xxxxxxxxxx>
To: Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>
Cc: Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>; "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
Sent: Thursday, March 22, 2007 5:25:50 PM
Subject: Re: [dsdp-tm-dev] create rse connections programmatically.



With your own view, you probably already have a content provider and a label provider.  If you want to reuse the existing RSE model objects (i.e. connections, subsystems, filters, etc) there are adapters that can help out the provider.  The interface that these adapters implement is ISystemViewElementAdapter.  The interface has code to allow for getting the icon, label and children of a particular node, as well as other things, such as action contributions and properties.


The reason I point to the ScratchpadViewProvider, is that it's a good example of a content and label provider that makes use of the ISystemViewelementAdapter.  Here's code from the provider that allows you to get at a ISystemViewElementAdapter from a model object:


     
protected ISystemViewElementAdapter getAdapterFor(Object object)
     {

             
if (object instanceof IContextObject)
             {

                     object = ((IContextObject)object).getModelObject();

             }

         
if  (object instanceof IAdaptable)
         {

                 IAdaptable adapt = (IAdaptable) object;

                     ISystemViewElementAdapter result = (ISystemViewElementAdapter) adapt.getAdapter(ISystemViewElementAdapter.
class);
                     
if (result != null)
                     {

                             result.setPropertySourceInput(object);

                             result.setViewer(
_view);
                             
return result;
                     }

         }

             
return null;
     }


Once you have a way to get at the adapter, you can use it to implement the methods of the content provider and label provider as follows:


     
public boolean hasChildren(Object object)
     {

                                     
             ISystemViewElementAdapter adapter = getAdapterFor(object);

             
if (adapter != null)
             {

                     
if (object instanceof IContextObject)
                     {

                             
return adapter.hasChildren((IContextObject)object);
                     }

                     
else
                     {

                             
return adapter.hasChildren((IAdaptable)object);
                     }

             }

             ...

             
return false;
     }



     
public Object[] getChildren(Object object)
     {

             
return getElements(object);
     }

     
     
public Object[] getElements(Object object)
     {

             Object[] results =
null;

             Object element = object;

             
if (object instanceof IContextObject)
                 {

                         element = ((IContextObject)object).getModelObject();

                 }

             
if (element instanceof IAdaptable)
             {                                

                     ISystemViewElementAdapter adapter = getAdapterFor(element);

                     
if (adapter != null && adapter.hasChildren((IAdaptable)element))
                     {

                               
if (object instanceof IContextObject)
                           {

                                   results = adapter.getChildren(
new NullProgressMonitor(), (IContextObject)object);
                           }

                           
else
                           {

                                   results = adapter.getChildren(
new NullProgressMonitor(), (IAdaptable)object);
                           }

                     }

                     ...

             }

             
if (results == null)
             {

                     
return new Object[0];
             }


             
return results;
     }


     
public String getText(Object object)
     {

             ISystemViewElementAdapter adapter = getAdapterFor(object);

             
if (adapter != null)
             {

                     
return adapter.getText(object);
             }

             ...

             
return object.toString();
     }


     
public Image getImage(Object object)
     {

             Image image =
null;
             ISystemViewElementAdapter adapter = getAdapterFor(object);

             
if (adapter != null)
             {

                     ImageDescriptor descriptor = adapter.getImageDescriptor(object);

     
                     
                     
if (descriptor != null)
                     {

                             Object iobj =
imageTable.get(descriptor);
                             
if (iobj == null)
                             {

                                     image = descriptor.createImage();

                                     
imageTable.put(descriptor, image);
                             }

                             
else
                             {

                                     image = (Image) iobj;

                             }

                     }

                     
return image;
             }

             ...

             
return null;
     }



Once you have the content provider setup properly, then you just need to make sure you populate the initial nodes of the tree as you wish (wiht you connection folder objects).   You might either hardcode the provider to deal with your objects:


             if (object instanceof MyConnectionFolder)

             {

                     ...

             }


Or you may choose to create an ISystemViewElementAdapter for your object.


Does this help?
____________________________________
David McKnight    
Phone:   905-413-3902 , T/L:  969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail:       D1/YFY/8200/TOR
____________________________________

Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>

22/03/2007 11:29 AM


To
David McKnight/Toronto/IBM@IBMCA, "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
cc
Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>
Subject
Re: [dsdp-tm-dev] create rse connections programmatically.











hi, now i'll have to do this alone. could you please explain your mail below a little bit more in detail? regard,wei.


----- Original Message ----
From: David McKnight <dmcknigh@xxxxxxxxxx>
To: "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
Cc: Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>; Wei Zhang <zhangwei_2000_2000@xxxxxxxxx>
Sent: Wednesday, March 21, 2007 6:41:34 PM
Subject: RE: [dsdp-tm-dev] create rse connections programmatically.



Hi Wei,


For what you want to do, the current Remote Systems view will not work.  You could write your own view and reuse much of the RSE functionality.  In particular, you could have the label and content provider make use of the SystemView adapters for the RSE model objects which you use.


For a simple example, you could take a look at:
SystemScratchpadViewProvider.   This is what the scratchpad view does to display the same sorts of things that the Remote Systems view displays.  In this case, you'd need to provide a new model object for these "connection folders" as well as it's corresponding adapter.

____________________________________
David McKnight    
Phone:   905-413-3902 , T/L:  969-3902
Internet: dmcknigh@xxxxxxxxxx
Mail:       D1/YFY/8200/TOR
____________________________________
"Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>

21/03/2007 01:21 PM


To
"Wei Zhang" <zhangwei_2000_2000@xxxxxxxxx>, David McKnight/Toronto/IBM@IBMCA
cc
"Target Management developer discussions" <dsdp-tm-dev@xxxxxxxxxxx>
Subject
RE: [dsdp-tm-dev] create rse connections programmatically.













Hello Wei,

I'm afraid that what you want to do is not possible
with our official API. It may be possible by deriving
from RSE SystemView, and implementing a custom
SystemViewContentProvider.

I'm copying the dsdp-tm-dev list. Please CC the list
for all such kinds of requests, since there might be
others who know the answer better than any individual.

DaveM, can you help?

Thanks,
--
Martin Oberhuber
Wind River Systems, Inc.
Target Management Project Lead, DSDP PMC Member

http://www.eclipse.org/dsdp/tm

> -----Original Message-----
> From: Wei Zhang [mailto:zhangwei_2000_2000@xxxxxxxxx]
> Sent: Wednesday, March 21, 2007 5:52 PM
> To: Oberhuber, Martin
> Subject: Re: [dsdp-tm-dev] create rse connections programmatically.
>
> thanks martin,
>
> my task is a little bit more than my last question. i should
> customize rse primary
>                                                      Remote Systems view so that it
> contains nothing but a tree structure and have connections as
> end tree nodes:
>
> -folder
>   -folder1
>      -connection1
>         -files
>         -shells
>      -connection2
>         -files
>
>         -shells
>   -folder2
>        -connection3
>           -files
>
>           -shells
>
> is it possible?
> regard,wei.
> ps: sorry, i'm quite new in plugin world.
>
>
>
> ----- Original Message ----
> From: "Oberhuber, Martin" <Martin.Oberhuber@xxxxxxxxxxxxx>
> To: Target Management developer discussions <dsdp-tm-dev@xxxxxxxxxxx>
> Sent: Wednesday, March 21, 2007 4:16:56 PM
> Subject: RE: [dsdp-tm-dev] create rse connections programmatically.
>
> Hello Wei,
>
> exactly this question was answered by the TM Tutorial
> at this year's EclipseCon. Tutorial materials as well
> as sample code are available. See
>
>
http://wiki.eclipse.org/index.php/TM_and_RSE_FAQ#How_can_I_lea
> rn_program
> ming_with_RSE.3F
>
> Cheers,
> --
> Martin Oberhuber
> Wind River Systems, Inc.
> Target Management Project Lead, DSDP PMC Member
>
http://www.eclipse.org/dsdp/tm
>
> > -----Original Message-----
> > From: dsdp-tm-dev-bounces@xxxxxxxxxxx
> > [mailto:dsdp-tm-dev-bounces@xxxxxxxxxxx] On Behalf Of Wei Zhang
> > Sent: Wednesday, March 21, 2007 4:09 PM
> > To: dsdp-tm-dev@xxxxxxxxxxx
> > Subject: [dsdp-tm-dev] create rse connections programmatically.
> >
> > hello there,
> >
> > i would like to extend rse and generate connections in rse
> > prospective programmatically. could anybody tell me how?
> >
> > regard,wei.
> >
> >
> >
> >  
> > ______________________________________________________________
> > ______________________
> > Food fight? Enjoy some healthy debate
> > in the Yahoo! Answers Food & Drink Q&A.
> >
http://answers.yahoo.com/dir/?link=list&sid=396545367
> > _______________________________________________
> > dsdp-tm-dev mailing list
> > dsdp-tm-dev@xxxxxxxxxxx
> >
https://dev.eclipse.org/mailman/listinfo/dsdp-tm-dev
> >
> _______________________________________________
> dsdp-tm-dev mailing list
> dsdp-tm-dev@xxxxxxxxxxx
>
https://dev.eclipse.org/mailman/listinfo/dsdp-tm-dev
>
>
>
>
>
>  
> ______________________________________________________________
> ______________________
> It's here! Your new message!  
> Get new email alerts with the free Yahoo! Toolbar.
>
http://tools.search.yahoo.com/toolbar/features/mail/
>




Sucker-punch spam with award-winning protection.
Try the
free Yahoo! Mail Beta.


Don't get soaked. Take a
quick peek at the forecast
with the
Yahoo! Search weather shortcut.


It's here! Your new message!
Get
new email alerts with the free Yahoo! Toolbar.



Food fight? Enjoy some healthy debate
in the
Yahoo! Answers Food & Drink Q&A.

Attachment: it_works.GIF
Description: GIF image


Back to the top