0
ポップアップメニューとメニュー項目から同じプラグインを実行する2つのクラスのプラグインがあります。しかし、それらのうちの1つが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
}
コードスニペットが書式設定されたコードとして表示されるように質問を再フォーマットできますか?私はCTRL + kはあなたのためにこれを行うことができると思います。 –