Jump to: navigation, search

Difference between revisions of "FAQ Can I use the actions from the Navigator in my own plug-in?"

 
 
Line 1: Line 1:
 
''
 
''
  
Yes.  All the resource actions in the Navigator view, including  
+
Yes.  All the resource actions in the Navigator view, including '''Copy''', '''Move''', '''Delete''', '''Build''', and '''Refresh''', are available as API.  These actions are found in the
'''Copy''', '''Move''', '''Delete''', '''Build''',
+
<tt>org.eclipse.ui.actions</tt> package of the <tt>org.eclipse.ui.ide</tt> plug-in.  These actions  expect a selection of either <tt>IResource</tt> objects or  <tt>IAdaptable</tt> objects that are able to adapt to <tt>IResource</tt>. You must either install the actions as selection change listeners, such as on a <tt>TreeViewer</tt>, or supply them with the selection before running them:
and '''Refresh''', are available as API.  These actions are found in the
+
<tt>org.eclipse.ui.actions</tt> package of the <tt>org.eclipse.ui.ide</tt>
+
plug-in.  These actions  expect a selection of either <tt>IResource</tt>
+
objects or  <tt>IAdaptable</tt> objects that are able to adapt
+
to <tt>IResource</tt>. You must either install the actions as selection
+
change listeners, such as on a <tt>TreeViewer</tt>, or supply them
+
with the selection before running them:
+
 
<pre>
 
<pre>
 
   IResource r = ...;//resource to delete
 
   IResource r = ...;//resource to delete
Line 21: Line 14:
 
== See Also: ==
 
== See Also: ==
  
[[FAQ_How_do_I_use_%3Ctt%3EIAdaptable%3C%2Ftt%3E_and_%3Ctt%3EIAdapterFactory%3C%2Ftt%3E%3F]]
+
[[FAQ How do I use IAdaptable and IAdapterFactory?]]
  
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>

Latest revision as of 08:52, 26 January 2007

Yes. All the resource actions in the Navigator view, including Copy, Move, Delete, Build, and Refresh, are available as API. These actions are found in the org.eclipse.ui.actions package of the org.eclipse.ui.ide plug-in. These actions expect a selection of either IResource objects or IAdaptable objects that are able to adapt to IResource. You must either install the actions as selection change listeners, such as on a TreeViewer, or supply them with the selection before running them:

   IResource r = ...;//resource to delete
   IStructuredSelection ss = new StructuredSelection(r);
   DeleteResourceAction delete = new DeleteResourceAction(shell);
   delete.selectionChanged(ss);
   delete.run();


See Also:

FAQ How do I use IAdaptable and IAdapterFactory?


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.