我有一個ElementListSelectionDialog的基本實現,如下所示。重用Eclipse 4上的ElementListSelectionDialog RCP應用程序
ElementListSelectionDialog dialog =
new ElementListSelectionDialog(shell, new LabelProvider());
dialog.setElements(new String[] { "Linux", "Mac", "Windows" });
dialog.setTitle("Which operating system are you using");
dialog.open();
對話框打開狀態良好,但列表爲空,當我們在搜索字段中鍵入內容時,什麼也沒有發生。
我沒有任何異常,我在Eclipse中Kepeler 4.3
我讀的地方,選擇對話框中的後4.2發佈日食直接重用。
我深入研究了ElementListSelectionDialog類,並且發現問題來自FiltredList而不是繪製通過LabelProvider提供的元素。
FilteredList list = new FilteredList(workArea,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,new LabelProvider(),false,true,true);
list.setLayoutData(new GridData(GridData.FILL,
GridData.BEGINNING, true, false, 1, 1));
list.setFilter(""); //$NON-NLS-1$
list.setElements(new Object[] {"Item 1","Item 2","Item 3","Item"});
我不知道爲什麼它不適合我的工作,但有一點我可以肯定的是,它在Eclipse IDE中工作正常。
我想我也沒辦法,我必須基於一個TableViewer中定義自己的對話框
有沒有人成功地在Eclipse 4運行ElementListSelectionDialog,因爲這將是一種恥辱不使用它,這是一個對話框來作爲立場使用