包选择对话框
效果如上
代码
:
public static void getPkgDialog() {
try {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IJavaModel jModel = JavaCore.create(root);
IJavaProject jProject[];
jProject = jModel.getJavaProjects();
SelectionDialog dialog = null;
dialog.setDefaultImage(ImageProvider.complieImage);
try {
dialog = JavaUI.createPackageDialog(new Shell(), jProject[0],
IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS);
dialog.setTitle("包选择器");
dialog.setMessage("选择一个包路径");
} catch (JavaModelException e1) {
// ExceptionHandler.handleExceptionAndAbort(e1);
}
if (dialog.open() != Window.OK) {
return;
}
IPackageFragment pck = (IPackageFragment) dialog.getResult()[0];
System.err.println(pck.getPath());
} catch (JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
系统文件目录
/***
*
* 通过浏览选择文件目录,并把目录名返回给输入框
*
* @return 选择 目录/jfids_demo/resources/service/helloworld_ws_ref/src/com/sunsheen/jfids/system/base
*/
public static String getSysFileDialog() {
DirectoryDialog dlg = new DirectoryDialog(new Shell());
dlg.setFilterPath(StringUtil.getProjectPath());
dlg.setText("系统文件目录");
dlg.setMessage("选择一个编译路径");
return dlg.open();
}