use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class BaseContainersCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<IDockerContainer> selectedContainers = getSelectedContainers(activePart);
final IDockerConnection connection = getCurrentConnection(activePart);
if (connection == null || selectedContainers.isEmpty()) {
return null;
}
final Job job = new Job(getJobName(selectedContainers)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
if (confirmed(selectedContainers)) {
monitor.beginTask(getJobName(selectedContainers), selectedContainers.size());
for (final IDockerContainer container : selectedContainers) {
monitor.setTaskName(getTaskName(container));
executeInJob(container, connection);
monitor.worked(1);
}
}
monitor.done();
return Status.OK_STATUS;
}
};
// job.setPriority(Job.LONG);
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class RefreshCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<Job> jobs = getRefreshJobs(activePart);
for (Job job : jobs) {
job.setPriority(Job.LONG);
job.setUser(true);
job.schedule();
}
return null;
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class RefreshCommandHandler method getRefreshContainersJob.
private Job getRefreshContainersJob(final IDockerConnection connection) {
if (connection == null) {
return null;
}
final Job job = new Job(DVMessages.getString(CONTAINERS_REFRESH_MSG)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
monitor.beginTask(DVMessages.getString(CONTAINERS_REFRESH_MSG), 1);
connection.getContainers(true);
monitor.worked(1);
monitor.done();
return Status.OK_STATUS;
}
};
return job;
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class RefreshConnectionHandler method getRefreshContainersJob.
private Job getRefreshContainersJob(final IDockerConnection connection) {
if (connection == null) {
return null;
}
final Job job = new Job(DVMessages.getString(CONTAINERS_REFRESH_MSG)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
monitor.beginTask(DVMessages.getString(CONTAINERS_REFRESH_MSG), 1);
connection.getContainers(true);
monitor.worked(1);
monitor.done();
return Status.OK_STATUS;
}
};
return job;
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class ShowInSystemExplorerCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<DockerContainerVolume> volumes = CommandUtils.getSelectedVolumes(activePart);
if (volumes == null || volumes.isEmpty()) {
return null;
}
final DockerContainerVolume selectedVolume = volumes.get(0);
final File hostFile = new File(selectedVolume.getHostPath());
final String launchCmd = getShowInSystemExplorerCommand(hostFile);
if (launchCmd == null) {
return null;
}
final Job job = new Job(CommandMessages.getString("command.showIn.systemExplorer")) {
// $NON-NLS-1$
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
final Process p = getLaunchProcess(launchCmd, hostFile);
final int retCode = p.waitFor();
if (retCode != 0 && !Util.isWindows()) {
Activator.log(new DockerException(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure.command.execute", launchCmd, Integer.toString(retCode))));
}
} catch (IOException | InterruptedException e) {
Activator.logErrorMessage(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure", launchCmd), e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return null;
}
Aggregations