天天看點

eclipse dialog 對話框 大全

TwoPaneElementSelector  d=new  TwoPaneElementSelector(window.getShell(), new LabelProvider(), new LabelProvider());

d.setElements(new String[]{"aaa","bb","cc"});

d.setTitle("選擇對話框");

d.open();

eclipse dialog 對話框 大全

ElementTreeSelectionDialog  d=new  ElementTreeSelectionDialog(window.getShell(), new LabelProvider(), new TreeNodeContentProvider());

TreeNode  input=new TreeNode("root");

TreeNode  node1=new TreeNode("node1");

TreeNode  node2=new TreeNode("node2");

input.setChildren(new TreeNode[]{node1,node2});

d.setInput(new TreeNode[]{input}); 

d.open();

這裡标簽提供者我沒有進行擴充。所有就展現為下面這樣了。

eclipse dialog 對話框 大全

ElementListSelectionDialog  d=new  ElementListSelectionDialog(window.getShell(), new LabelProvider());

d.setElements(new String[]{"aaa","bb","cc"});

d.setTitle("選擇對話框");

d.open();

eclipse dialog 對話框 大全

 TitleAreaDialog   

可以對該對話框 進行擴充,在上面實作自己的控件。

eclipse dialog 對話框 大全

Dialog  d=new Dialog(window.getShell()) {

};

d.open();

這是最基本的對話框 ,隻有一個ok  cancel

eclipse  dialog基本上提供了所有常用的對話框,如:帶樹的、帶表格的、帶有搜尋選擇的等等。

基本上都提供了封裝。

可以參考一下代碼,為自己的系統封裝一下常用的dialog

MessageDialog.openConfirm(window.getShell(), "title", "message");

eclipse dialog 對話框 大全

MessageDialog.openInformation(window.getShell(), "title", "message");

eclipse dialog 對話框 大全

 MessageDialog.openError(window.getShell(), "title", "message");

eclipse dialog 對話框 大全
eclipse dialog 對話框 大全

 MessageDialog.openConfirm(window.getShell(), "title", "message");

MessageDialog.openInformation(window.getShell(), "title", "message"); MessageDialog.openError(window.getShell(), "title", "message"); MessageDialog.openQuestion(window.getShell(), "title", "message"); MessageDialog.openWarning(window.getShell(), "title", "message");     EditorSelectionDialog  d=new EditorSelectionDialog(window.getShell()); d.open();    

PreferenceManager  pm=  window.getWorkbench().getPreferenceManager();

PreferenceDialog  d=new PreferenceDialog(window.getShell(), pm);

d.open();

帶有複選框的選擇。。。

ListSelectionDialog dlg =

  new ListSelectionDialog(

      window.getShell(),

      null,

      new BaseWorkbenchContentProvider(),

new WorkbenchLabelProvider(),

"Select the resources to save:");

///dlg.setInitialSelections(dirtyEditors);

dlg.setTitle("Save Resources");

dlg.open();