Package tool.commands.checkout

Source Code of tool.commands.checkout.CheckoutHandler

package tool.commands.checkout;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;

public class CheckoutHandler extends AbstractHandler {

  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    ISelectionService selectionService = window.getSelectionService();
    ISelection selection = selectionService.getSelection();
   
    if (selection instanceof ITreeSelection && (((ITreeSelection) selection).getFirstElement() instanceof IFile)){
      ITreeSelection treeSelection = (ITreeSelection)selection;
      IFile comp = (IFile) treeSelection.getFirstElement();
      CheckoutJob runner = new CheckoutJob(comp);
      runner.setPriority(Job.INTERACTIVE);
      runner.schedule();
    }
   
    return null;
  }


}
TOP

Related Classes of tool.commands.checkout.CheckoutHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.