Package no.hal.jex.editor.actions

Source Code of no.hal.jex.editor.actions.CreateExerciseFromTestAnnotationsAction

package no.hal.jex.editor.actions;

import java.util.Collection;

import no.hal.jex.Exercise;
import no.hal.jex.editor.commands.CreateExerciseFromTestAnnotationsCommand;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.action.StaticSelectionCommandAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;

public class CreateExerciseFromTestAnnotationsAction extends StaticSelectionCommandAction {

  public CreateExerciseFromTestAnnotationsAction(IWorkbenchPart workbenchPart, ISelection selection) {
    super(workbenchPart);
    configureAction(selection);
  }
 
  @Override
  protected Command createActionCommand(EditingDomain editingDomain, Collection selection) {
    if (selection.size() == 1) {
      Object owner = selection.iterator().next();
      if (owner instanceof Exercise) {
        return new CreateExerciseFromTestAnnotationsCommand((Exercise)owner, "tests");
      }
    }
    return UnexecutableCommand.INSTANCE;
  }
}
TOP

Related Classes of no.hal.jex.editor.actions.CreateExerciseFromTestAnnotationsAction

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.