Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

m
m
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.
+
  
As a plug-in writer, you will be interested mostly in  
+
As a plug-in writer, you will be interested mostly in <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>.
<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>.
+
  
<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 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.
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>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 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.
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  
+
<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.
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%3F]]
+
*[[FAQ Does the platform have support for concurrency?]]
 
*[[FAQ What are IWorkspaceRunnable, IRunnableWithProgress, and WorkspaceModifyOperation?]]
 
*[[FAQ What are IWorkspaceRunnable, IRunnableWithProgress, and WorkspaceModifyOperation?]]
  
 
<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 15:53, 17 June 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&#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 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.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.