2010-12-07 13 views
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 
} 
+1

コードスニペットが書式設定されたコードとして表示されるように質問を再フォーマットできますか?私はCTRL + kはあなたのためにこれを行うことができると思います。 –

答えて

0

を克服するか、なぜあなたは一つの場所でアクションを経由して別の場所でのコマンドでそれをやっていますか?単純に1つのコマンドを使用して、両方の場所でコマンドの投稿を追加できないのはなぜですか?

関連する問題