Jump to: navigation, search

Difference between revisions of "FAQ Actions, commands, operations, jobs: What does it all mean?"

 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Many terms are thrown around in Eclipse for units of functionality or  
+
Many terms are thrown around in Eclipse for units of functionality or behavior: runnables, actions, commands, operations, and jobs, among others.  Here is a high- level view of the terms to help you keep things straight.
behavior: runnables, actions, commands, operations, and jobs,  
+
among others.  Here is a high- level view of the terms to help you keep
+
things straight.
+
  
 +
== Actions ==
 +
As a plug-in writer, you will be interested mostly in  ''actions''.  When a toolbar button or a menu item is clicked or when a defined key sequence is invoked, the <tt>run</tt> method  of some action is invoked.  Actions generally do not care about how or when they are invoked, although they often require extra context information, such as the current selection or view.  Actions that are contributed to the workbench declaratively in <tt>plugin.xml</tt>  defer the actual work to an ''action delegate''.
  
As a plug-in writer, you will be interested mostly in
+
''Note: When using action delegates, keep in mind that your implementing classes must provide a no argument constructor for RCP to hook the two together.''
<i>actions</i>.  When a toolbar button or a menu item is clicked
+
or when a defined key sequence is invoked, the <tt>run</tt> method
+
of some action is invoked.  Actions generally do not care
+
about how or when they are invoked, although they often require
+
extra context information, such as the current selection or view.  Actions that
+
are contributed to the workbench declaratively in <tt>plugin.xml</tt>
+
defer the actual work to an <i>action delegate</i>.
+
  
 +
== Commands ==
 +
''Commands'' are a meta-level glue that the platform uses to manage and organize actions.  As a plug-in writer, you will never write code for a command directly, but you will use the <tt>org.eclipse.ui.commands</tt> extension point to define key bindings for your actions and to group your actions into configurations and contexts.
  
<i>Commands</i> are a meta-level glue that the platform uses to manage
+
== Operations ==
and organize actions.  As a plug-in writer, you will never write code for a
+
''Operations'' aren&#146;t an official part of the workbench API, but the term tends to be used for a long-running unit of behavior.   Any work that might take a second or more should really be inside an operation. The official designation for operations in the API is <tt>IRunnableWithProgress</tt>, but the term ''operation'' tends to be used in its place because it is easier to say and remember. Operations are executed within an <tt>IRunnableContext</tt>. The context manages the execution of the operation in a non-UI thread so that the UI stays alive and painting.  The context provides progress feedback to the user and support for cancellation.
command directly, but you will use the <tt>org.eclipse.ui.commands</tt> extension
+
point to define key bindings for your actions and to group your actions
+
into configurations and contexts.
+
 
+
 
+
<i>Operations</i> aren&#146;t an official part of the workbench API, but
+
the term tends to be used for a long-running unit of behavior.
+
Any work that might take a second or more should really be inside an  
+
operation. The official designation for operations in the API is  
+
<tt>IRunnableWithProgress</tt>, but the term <i>operation</i> tends to
+
be used in its place because it is easier to say and remember.
+
Operations are executed within an <tt>IRunnableContext</tt>.
+
The context manages the execution of the operation in a non-UI thread so
+
that the UI stays alive and painting.  The context provides progress feedback  
+
to the user and support for cancellation.
+
 
+
 
+
<i>Jobs</i>, introduced in Eclipse 3.0, are operations that run
+
in the background.  The user is typically prevented from doing anything while
+
an operation is running but is free to continue working when a job is running.
+
Operations and jobs belong together, but jobs needed
+
to live at a lower level in the plug-in architecture to make them usable by
+
non-UI components.
+
  
 +
== Jobs ==
 +
''Jobs'', introduced in Eclipse 3.0, are operations that run  in the background.  The user is typically prevented from doing anything while an operation is running but is free to continue working when a job is running.  Operations and jobs belong together, but jobs needed  to live at a lower level in the plug-in architecture to make them usable by  non-UI components.
  
 
== See Also: ==
 
== See Also: ==
 
+
*[[FAQ Does the platform have support for concurrency?]]
[[FAQ_Does_the_platform_have_support_for_concurrency%3F]]
+
*[[FAQ What are IWorkspaceRunnable, IRunnableWithProgress, and WorkspaceModifyOperation?]]
 
+
[[FAQ_What_are_%3Ctt%3EIWorkspaceRunnable%3C%2Ftt%3E%2C_%3Ctt%3EIRunnableWithProgress%3C%2Ftt%3E%2C_and_%3Ctt%3EWorkspaceModifyOperation%3C%2Ftt%3E%3F]]
+
  
 
<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>

Revision as of 17:00, 17 August 2006

Many terms are thrown around in Eclipse for units of functionality or behavior: runnables, actions, commands, operations, and jobs, among others. Here is a high- level view of the terms to help you keep things straight.

Actions

As a plug-in writer, you will be interested mostly in actions. When a toolbar button or a menu item is clicked or when a defined key sequence is invoked, the run method of some action is invoked. Actions generally do not care about how or when they are invoked, although they often require extra context information, such as the current selection or view. Actions that are contributed to the workbench declaratively in plugin.xml defer the actual work to an action delegate.

Note: When using action delegates, keep in mind that your implementing classes must provide a no argument constructor for RCP to hook the two together.

Commands

Commands are a meta-level glue that the platform uses to manage and organize actions. As a plug-in writer, you will never write code for a command directly, but you will use the org.eclipse.ui.commands extension point to define key bindings for your actions and to group your actions into configurations and contexts.

Operations

Operations aren’t an official part of the workbench API, but the term tends to be used for a long-running unit of behavior. Any work that might take a second or more should really be inside an operation. The official designation for operations in the API is IRunnableWithProgress, but the term operation tends to be used in its place because it is easier to say and remember. Operations are executed within an IRunnableContext. The context manages the execution of the operation in a non-UI thread so that the UI stays alive and painting. The context provides progress feedback to the user and support for cancellation.

Jobs

Jobs, introduced in Eclipse 3.0, are operations that run in the background. The user is typically prevented from doing anything while an operation is running but is free to continue working when a job is running. Operations and jobs belong together, but jobs needed to live at a lower level in the plug-in architecture to make them usable by non-UI components.

See Also:


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.