public abstract class TeamOperation extends JobChangeAdapter implements IRunnableWithProgress
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.
IProgressService
,
Job
,
ISchedulingRule
,
IJobChangeListener
Modifier | Constructor and Description |
---|---|
protected |
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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
belongsTo(Object family)
Return whether the job that is running this operation should be considered
a member member of the given family.
|
protected boolean |
canRunAsJob()
If this operation can safely be run in the background, then subclasses can
override this method and return
true . |
protected IAction |
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.
|
protected String |
getJobName()
Return the job name to be used if the action can run as a job.
|
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.
|
protected URL |
getOperationIcon()
This method is called to allow subclasses to configure an icon to show when running this
operation.
|
IWorkbenchPart |
getPart()
Return the part that is associated with this operation.
|
protected ISchedulingRule |
getSchedulingRule()
Returns the scheduling rule that is to be obtained before this
operation is executed by its context or
null 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 |
isKeepOneProgressServiceEntry()
This method is similar to
getKeepOperation but will
only keep one entry of a particular type available. |
protected boolean |
isPostponeAutobuild()
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 when
isKeepOneProgressServiceEntry is overridden to
return true . |
boolean |
isUserInitiated()
Indicates whether the operation was user initiated.
|
void |
run()
Run the operation in a context that is determined by the
canRunAsJob()
hint. |
protected boolean |
shouldRun()
This method is invoked from the
run() method before
the operation is run in the operation's context. |
aboutToRun, awake, done, running, scheduled, sleeping
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
run
protected TeamOperation(IWorkbenchPart part)
part
- the part the operation is associated with or null
if the
operation is to be run without a part.protected TeamOperation(IRunnableContext context)
context
- a runnable contextprotected TeamOperation(IWorkbenchPart part, IRunnableContext context)
part
- the part the operation is associated with or null
context
- a runnable contextpublic IWorkbenchPart getPart()
null
public final void run() throws InvocationTargetException, InterruptedException
canRunAsJob()
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.protected boolean shouldRun()
run()
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.protected ISchedulingRule getSchedulingRule()
null
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.
null
.protected boolean isPostponeAutobuild()
protected boolean canRunAsJob()
true
. This will make their
action run in a Job
.
Subclass that override this method should
also override the getJobName()
method.true
if this action can be run in the background and
false
otherwise.protected String getJobName()
canRunAsJob()
returns true
).protected IAction getGotoAction()
protected URL getOperationIcon()
protected boolean getKeepOperation()
canRunAsJob
returns true
).true
to keep the operation and false
otherwise.public boolean isKeepOneProgressServiceEntry()
getKeepOperation
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
returns true
).
Subclasses that override this method should also override
isSameFamilyAs
in order to match operations of the same type.true
to keep the operation and false
otherwise.protected boolean isSameFamilyAs(TeamOperation operation)
isKeepOneProgressServiceEntry
is overridden to
return true
. By default,
false
is returned. Subclasses may override.operation
- a team operationpublic boolean belongsTo(Object family)
IJobManager
.
By default, false
is always returned. Subclasses that override the
isKeepOneProgressServiceEntry
method do not need to override
this method, but instead should override isSameFamilyAs
.family
- the family being tested.public boolean isUserInitiated()
protected Shell getShell()
Copyright (c) 2000, 2013 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.