2009-03-06 21 views
2

私はEclipseプラグインを作成しています。何らかのアクションに応答して、一連の操作を開始するのは面白いです(別のジョブ内で)。これらの操作の1つは、JFace JDialogを使用してファイル名を指定することをユーザーに要求することです。Eclipseプラグイン内のJFace FileDialogをモードレスで使用する方法は?

しかし、私はモードレスな方法でこれを行う方法が明確ではありません。たとえば、ディスプレイとシェルはどこで入手できますか?開発者がダイアログ内の内容を編集できる間にUIが確実に機能するようにするにはどうすればよいですか?

答えて

4

は、あなたは、Eclipse自体がそれをしない方法を見ることができるかもしれませ:

FindAndReplaceDialog.java

/** 
    * Creates a new dialog with the given shell as parent. 
    * @param parentShell the parent shell 
    */ 
public FindReplaceDialog(Shell parentShell) { 
    super(parentShell); 

    fParentShell= null; 

    [...] 

    readConfiguration(); 

    setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE | SWT.RESIZE); 
    setBlockOnOpen(false); 
} 

/** 
    * Returns this dialog's parent shell. 
    * @return the dialog's parent shell 
    */ 
public Shell getParentShell() { 
    return super.getParentShell(); 
} 

/** 
* Sets the parent shell of this dialog to be the given shell. 
* 
* @param shell the new parent shell 
*/ 
public void setParentShell(Shell shell) { 
    if (shell != fParentShell) { 

     if (fParentShell != null) 
      fParentShell.removeShellListener(fActivationListener); 

     fParentShell= shell; 
     fParentShell.addShellListener(fActivationListener); 
    } 

    fActiveShell= shell; 
} 

それはダイアログの焦点に応じて、その親シェルを管理しません。

/** 
    * Updates the find replace dialog on activation changes. 
    */ 
class ActivationListener extends ShellAdapter { 
    /* 
     * @see ShellListener#shellActivated(ShellEvent) 
     */ 
    public void shellActivated(ShellEvent e) { 
     fActiveShell= (Shell)e.widget; 
     updateButtonState(); 

     if (fGiveFocusToFindField && getShell() == fActiveShell && 
       okToUse(fFindField)) 
      fFindField.setFocus(); 

    } 

    /* 
     * @see ShellListener#shellDeactivated(ShellEvent) 
     */ 
    public void shellDeactivated(ShellEvent e) { 
     fGiveFocusToFindField= false; 

     storeSettings(); 

     [...] 

     fActiveShell= null; 
     updateButtonState(); 
    } 
} 

ShellAdapterされShellの状態の変化に対処する方法を提供ShellListenerインターフェースによって記載された方法のためのデフォルトの実装を提供します。

0

インポートするのは、スタイル値にSWT.MODELESSを含めることです。

スティール値のためにロットを制御して初期化できるので、スタイルはSWTで最も重要なものの1つです。

関連する問題