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

From Eclipsepedia

Jump to: navigation, search
 
m
Line 3: Line 3:
 
among others.  Here is a high- level view of the terms to help you keep
 
among others.  Here is a high- level view of the terms to help you keep
 
things straight.
 
things straight.
 
  
 
As a plug-in writer, you will be interested mostly in  
 
As a plug-in writer, you will be interested mostly in  
Line 13: Line 12:
 
are contributed to the workbench declaratively in <tt>plugin.xml</tt>  
 
are contributed to the workbench declaratively in <tt>plugin.xml</tt>  
 
defer the actual work to an <i>action delegate</i>.
 
defer the actual work to an <i>action delegate</i>.
 
  
 
<i>Commands</i> are a meta-level glue that the platform uses to manage
 
<i>Commands</i> are a meta-level glue that the platform uses to manage
Line 20: Line 18:
 
point to define key bindings for your actions and to group your actions
 
point to define key bindings for your actions and to group your actions
 
into configurations and contexts.
 
into configurations and contexts.
 
  
 
<i>Operations</i> aren&#146;t an official part of the workbench API, but
 
<i>Operations</i> aren&#146;t an official part of the workbench API, but
Line 32: Line 29:
 
that the UI stays alive and painting.  The context provides progress feedback  
 
that the UI stays alive and painting.  The context provides progress feedback  
 
to the user and support for cancellation.
 
to the user and support for cancellation.
 
  
 
<i>Jobs</i>, introduced in Eclipse 3.0, are operations that run  
 
<i>Jobs</i>, introduced in Eclipse 3.0, are operations that run  
Line 40: Line 36:
 
to live at a lower level in the plug-in architecture to make them usable by  
 
to live at a lower level in the plug-in architecture to make them usable by  
 
non-UI components.
 
non-UI components.
 
  
 
== See Also: ==
 
== See Also: ==
 
+
*[[FAQ_Does_the_platform_have_support_for_concurrency%3F]]
[[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 22:12, 29 May 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.

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.

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 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, 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.