使用eclipse open type对话框
需要依赖jdt的相关插件(ui和core)
具体调用方法:
Shell parent= JavaPlugin.getActiveWorkbenchShell();
OpenTypeSelectionDialog dialog= new OpenTypeSelectionDialog(parent, false, PlatformUI.getWorkbench().getProgressService(),SearchEngine.createWorkspaceScope(), IJavaSearchConstants.TYPE);
dialog.setTitle(ActionMessages.OpenTypeInHierarchyAction_dialogTitle); dialog.setMessage(ActionMessages.OpenTypeInHierarchyAction_dialogMessage);
int result= dialog.open(); if (result != IDialogConstants.OK_ID) return; Object[] types= dialog.getResult(); if (types != null && types.length > 0) { IType type= (IType)types[0]; }
拿到的type就是选中的对象,类型为org.eclipse.jdt.core.IType。