2014-03-12 2 views
0

dialog.open() 후 폐쇄에서 JFace는 대화를 중지하고 이것이 내가 개방 해요 어떻게하기 : 컨트롤이 경우 블록에 가면하는 방법은 JFace의 대화를

SampleDialog dialog = new SampleDialog(shell); 
if(Window.OK == dialog.open()) 
{ 
    // do something 
    if(condition) 
    { 
    MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK| SWT.CANCEL); 
    dialog.setText("Sample"); 
    dialog.setMessage("Some problem in processing"); 
    } 
    else 
    { 
    // do something 
    } 
} 

, 내가 원하는 해달라고 대화 상자가 닫힙니다. 이것을 달성하는 방법?

+1

가되면'()'라는 한 후 대화 상자가 열릴 것입니다 dialog.open 다음 JFace는 Dialogclose() 방법을 재정의

public class SampleDialog extends Dialog { @Override protected void okPressed() { if (condition) { // TODO show your message box } else { // Allow the dialog to close super.okPressed(); } } } 

답변

0

그것을 해결의 또 다른 방법입니다. 사용자가 대화 상자에서 닫기 (X), 확인 또는 취소 버튼을 클릭하지 않는 한 컨트롤은 절대로 if 문으로 이동하지 않습니다. 게시물을 업데이트하여이 행동이 필요한 이유 또는 정확히 달성하고자하는 목표를 업데이트하십시오.
4

대화 상자에서 okPressed 메서드를 재정 의하여 검사 및 메시지 상자를 표시해야합니다.

@Override 
public boolean close() 
{ 
    if(condition) 
    { 
     if(this.getReturnCode() == OK) 
     { 
      MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK|     SWT.CANCEL); 
      dialog.setText("Sample"); 
      dialog.setMessage("Some problem in processing"); 

      return false; 
     } 
    } 
    return super.close(); 
}