/******************************************************************************* * Copyright (c) 2015 Red Hat. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Red Hat - Initial Contribution *******************************************************************************/ package org.eclipse.linuxtools.internal.vagrant.ui.commands; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.linuxtools.internal.vagrant.ui.views.DVMessages; import org.eclipse.linuxtools.vagrant.core.IVagrantConnection; import org.eclipse.linuxtools.vagrant.core.VagrantService; public class RefreshVMCommandHandler extends AbstractHandler { public static final String VM_REFRESH_MSG = "VMRefresh.msg"; //$NON-NLS-1$ @Override public Object execute(ExecutionEvent event) { final IVagrantConnection connection = VagrantService.getInstance(); if (connection == null) { return null; } final Job job = new Job(DVMessages.getString(VM_REFRESH_MSG)) { @Override protected IStatus run(final IProgressMonitor monitor) { monitor.beginTask(DVMessages.getString(VM_REFRESH_MSG), 1); connection.getVMs(true); monitor.worked(1); monitor.done(); return Status.OK_STATUS; } }; job.setPriority(Job.LONG); job.schedule(); return null; } }