У меня есть два класса плагина, которые отвечают за запуск одного и того же плагина во всплывающем меню и пункте меню.Но так как один из них имеет метод run (), я не могу использовать событие выполнения для создания оболочки.Как мне преодолеть эту проблему
public class ConvertConstantsToEnumHandler extends AbstractHandler {
//execution of the plugin
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = HandlerUtil.getCurrentSelectionChecked(event);
RefactoringMenuAction menuitem= new RefactoringMenuAction();
menuitem.setEvent(event);
List selectedFields = getSelectedFields(currentSelection);
Shell shell = HandlerUtil.getActiveShellChecked(event);
//get the selected Fields to do the convertion
IField[] fields = (IField[]) selectedFields.toArray(new IField[] {});
try {
ConvertConstantsToEnumWizard.startConvertConstantsToEnumRefactoring(fields, shell);
} catch (JavaModelException e) {
e.printStackTrace();
}
return null;
}
public class RefactoringMenuAction implements IWorkbenchWindowActionDelegate {
public IWorkbenchWindow window;
public RefactoringMenuAction() {
}
public void run(IAction action) {
RefactoringPlugin rp = new RefactoringPlugin();
try {
rp.start(rp.getTheBundle()); // get the current context of the eclipse
} catch (CoreException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
// here I need to find a way to access or create a shell to compile same as the above class
}