Search in sources :

Example 1 with EnumVMStatus

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;
}
Also used : IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) EnumVMStatus(org.eclipse.linuxtools.vagrant.core.EnumVMStatus)

Example 2 with EnumVMStatus

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);
        }
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) IContributionItem(org.eclipse.jface.action.IContributionItem) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IVagrantVM(org.eclipse.linuxtools.vagrant.core.IVagrantVM) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IMenuManager(org.eclipse.jface.action.IMenuManager) EnumVMStatus(org.eclipse.linuxtools.vagrant.core.EnumVMStatus)

Aggregations

IAction (org.eclipse.jface.action.IAction)2 EnumVMStatus (org.eclipse.linuxtools.vagrant.core.EnumVMStatus)2 ArrayList (java.util.ArrayList)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 IVagrantVM (org.eclipse.linuxtools.vagrant.core.IVagrantVM)1