use of org.eclipse.linuxtools.vagrant.core.EnumVMStatus in project linuxtools by eclipse.
the class VagrantToolBarContributionItem method getApplicableActions.
private List<IAction> getApplicableActions(IVagrantVM vm) {
final EnumVMStatus containerStatus = EnumVMStatus.fromStatusMessage(vm.state());
List<IAction> list = new ArrayList<>();
if (containerStatus == EnumVMStatus.RUNNING) {
list.add(createAction(Messages.VagrantToolBarContributionItem_stop, // $NON-NLS-1$
"org.eclipse.linuxtools.vagrant.ui.commands.stopVM", SWTImagesFactory.DESC_STOP, vm));
list.add(createAction(Messages.VagrantToolBarContributionItem_destroy, // $NON-NLS-1$
"org.eclipse.linuxtools.vagrant.ui.commands.destroyVM", SWTImagesFactory.DESC_REMOVE, vm));
list.add(createAction(Messages.VagrantToolBarContributionItem_ssh, // $NON-NLS-1$
"org.eclipse.linuxtools.vagrant.ui.commands.sshVM", SWTImagesFactory.DESC_CONSOLE, vm));
} else {
list.add(createAction(Messages.VagrantToolBarContributionItem_start, // $NON-NLS-1$
"org.eclipse.linuxtools.vagrant.ui.commands.startVM", SWTImagesFactory.DESC_START, vm));
}
list.add(createAction(Messages.VagrantToolBarContributionItem_package, // $NON-NLS-1$
"org.eclipse.linuxtools.vagrant.ui.commands.packageVM", SWTImagesFactory.DESC_BUILD, vm));
list.add(createAction(Messages.VagrantToolBarContributionItem_open, // $NON-NLS-1$
"org.eclipse.linuxtools.vagrant.ui.commands.openVFile", SWTImagesFactory.DESC_FILE, vm));
return list;
}
use of org.eclipse.linuxtools.vagrant.core.EnumVMStatus in project linuxtools by eclipse.
the class VagrantToolBarContributionItem method fill.
@Override
public void fill(Menu menu, int index) {
// Ignore it, get the parent IMenuManager and create the structure
if (getParent() instanceof IMenuManager) {
IMenuManager mm = (IMenuManager) getParent();
IContributionItem v = mm.find(getId());
// Menu manager contributions get aggregated so remove them first
mm.removeAll();
// dynamic menu contribution ensures fill() gets called
mm.add(v);
for (IVagrantVM vm : vms) {
EnumVMStatus containerStatus = EnumVMStatus.fromStatusMessage(vm.state());
ImageDescriptor img = (containerStatus == EnumVMStatus.RUNNING) ? SWTImagesFactory.DESC_CONTAINER_STARTED : SWTImagesFactory.DESC_CONTAINER_STOPPED;
IMenuManager vmM = new MenuManager(vm.name(), img, null);
for (IAction act : getApplicableActions(vm)) {
vmM.add(act);
}
mm.add(vmM);
}
}
}
Aggregations