Package org.eclipse.team.ui
Class TeamOperation
java.lang.Object
org.eclipse.core.runtime.jobs.JobChangeAdapter
org.eclipse.team.ui.TeamOperation
- All Implemented Interfaces:
IJobChangeListener
,IRunnableWithProgress
- Direct Known Subclasses:
ModelOperation
,SynchronizationOperation
,SynchronizeModelOperation
An operation that can be configured to run in the foreground using
the
IProgressService
or the background
as a Job
. The execution context is determined
by what is returned by the canRunAsJob()
hint which may be overridden by subclasses.
Subclass must override the run(IProgressMonitor)
method to perform
the behavior of the operation in the desired execution context.
If this operation is run as a job, it is registered with the job as a
IJobChangeListener
and is scheduled with
the part of this operation if it is not null
.
Subclasses can override the methods of this interface to receive job change notifications.
- Since:
- 3.0
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
TeamOperation
(IRunnableContext context) Create an team operation that will run in the given context.protected
TeamOperation
(IWorkbenchPart part) Create an team operation associated with the given part.protected
TeamOperation
(IWorkbenchPart part, IRunnableContext context) Create an team operation associated with the given part that will run in the given context. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return whether the job that is running this operation should be considered a member member of the given family.protected boolean
If this operation can safely be run in the background, then subclasses can override this method and returntrue
.protected IAction
This method is called to allow subclasses to configure an action that could be run to show the results of the action to the user.protected String
Return the job name to be used if the action can run as a job.protected boolean
This method is called to allow subclasses to have the results of the operation remain available to the user in the progress service even after the job is done.protected URL
This method is called to allow subclasses to configure an icon to show when running this operation.getPart()
Return the part that is associated with this operation.protected ISchedulingRule
Returns the scheduling rule that is to be obtained before this operation is executed by its context ornull
if no scheduling rule is to be obtained.protected Shell
getShell()
Return a shell that can be used by the operation to display dialogs, etc.boolean
This method is similar togetKeepOperation
but will only keep one entry of a particular type available.protected boolean
Return whether the auto-build should be postponed until after the operation is complete.protected boolean
isSameFamilyAs
(TeamOperation operation) Return whether this Team operation belongs to the same family as the given operation for the purpose of showing only one operation of the same type in the progress service whenisKeepOneProgressServiceEntry
is overridden to returntrue
.boolean
Indicates whether the operation was user initiated.final void
run()
Run the operation in a context that is determined by thecanRunAsJob()
hint.protected boolean
This method is invoked from therun()
method before the operation is run in the operation's context.Methods inherited from class org.eclipse.core.runtime.jobs.JobChangeAdapter
aboutToRun, awake, done, running, scheduled, sleeping
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jface.operation.IRunnableWithProgress
run
-
Constructor Details
-
TeamOperation
Create an team operation associated with the given part.- Parameters:
part
- the part the operation is associated with ornull
if the operation is to be run without a part.
-
TeamOperation
Create an team operation that will run in the given context.- Parameters:
context
- a runnable context
-
TeamOperation
Create an team operation associated with the given part that will run in the given context.- Parameters:
part
- the part the operation is associated with ornull
context
- a runnable context
-
-
Method Details
-
getPart
Return the part that is associated with this operation.- Returns:
- Returns the part or
null
-
run
Run the operation in a context that is determined by thecanRunAsJob()
hint. If this operation can run as a job then it will be run in a background thread. Otherwise it will run in the foreground and block the caller. -
shouldRun
protected boolean shouldRun()This method is invoked from therun()
method before the operation is run in the operation's context. Subclasses may override in order to perform pre-checks to determine if the operation should run. This may include prompting the user for information, etc.- Returns:
- whether the operation should be run.
-
getSchedulingRule
Returns the scheduling rule that is to be obtained before this operation is executed by its context ornull
if no scheduling rule is to be obtained. If the operation is run as a job, the scheduling rule is used as the scheduling rule of the job. Otherwise, it is obtained before execution of the operation occurs.By default, no scheduling rule is obtained. Subclasses can override in order to obtain a scheduling rule or can obtain scheduling rules within their operation if finer grained scheduling is desired.
- Returns:
- the scheduling rule to be obtained by this operation
or
null
.
-
isPostponeAutobuild
protected boolean isPostponeAutobuild()Return whether the auto-build should be postponed until after the operation is complete. The default is to postpone the auto-build. subclasses can override.- Returns:
- whether to postpone the auto-build while the operation is executing.
-
canRunAsJob
protected boolean canRunAsJob()If this operation can safely be run in the background, then subclasses can override this method and returntrue
. This will make their action run in aJob
. Subclass that override this method should also override thegetJobName()
method.- Returns:
true
if this action can be run in the background andfalse
otherwise.
-
getJobName
Return the job name to be used if the action can run as a job. (i.e. ifcanRunAsJob()
returnstrue
).- Returns:
- the string to be used as the job name
-
getGotoAction
This method is called to allow subclasses to configure an action that could be run to show the results of the action to the user. Default is to return null.- Returns:
- an action that could be run to see the results of this operation
-
getOperationIcon
This method is called to allow subclasses to configure an icon to show when running this operation.- Returns:
- an URL to an icon
-
getKeepOperation
protected boolean getKeepOperation()This method is called to allow subclasses to have the results of the operation remain available to the user in the progress service even after the job is done. This method is only relevant if the operation is run as a job (i.e.,canRunAsJob
returnstrue
).- Returns:
true
to keep the operation andfalse
otherwise.
-
isKeepOneProgressServiceEntry
public boolean isKeepOneProgressServiceEntry()This method is similar togetKeepOperation
but will only keep one entry of a particular type available. This method is only relevant if the operation is run as a job (i.e.,canRunAsJob
returnstrue
). Subclasses that override this method should also overrideisSameFamilyAs
in order to match operations of the same type.- Returns:
true
to keep the operation andfalse
otherwise.- Since:
- 3.1
-
isSameFamilyAs
Return whether this Team operation belongs to the same family as the given operation for the purpose of showing only one operation of the same type in the progress service whenisKeepOneProgressServiceEntry
is overridden to returntrue
. By default,false
is returned. Subclasses may override.- Parameters:
operation
- a team operation- Since:
- 3.1
-
belongsTo
Return whether the job that is running this operation should be considered a member member of the given family. Subclasses can override this method in order to support the family based functionality provided by theIJobManager
. By default,false
is always returned. Subclasses that override theisKeepOneProgressServiceEntry
method do not need to override this method, but instead should overrideisSameFamilyAs
.- Parameters:
family
- the family being tested.- Returns:
- whether the job that is running this operation should be considered a member member of the given family.
- Since:
- 3.1
-
isUserInitiated
public boolean isUserInitiated()Indicates whether the operation was user initiated. The progress for user initiated jobs may be presented differently than non-user initiated operations if they are run as jobs.- Returns:
- whether the operation is user initiated
- Since:
- 3.1
-
getShell
Return a shell that can be used by the operation to display dialogs, etc.- Returns:
- a shell
-