我想在我的应用程序中做一个按钮,让我输入系统中的环境变量列表,如下例所示,输入文件系统
b = new Button(dialog, SWT.PUSH);
b.setText("Browse file system");
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog fileDialog = new DirectoryDialog(parent);
fileDialog.setFilterPath(pathText.getText());
String file = fileDialog.open();
if (file != null) {
File workspace = ResourcesPlugin.getWorkspace().getRoot()
.getLocation().toFile().getAbsoluteFile();
String workspacePath = workspace.toString();
if (file.contains(workspacePath))
file = file.replace(workspacePath, "$WORKSPACE")
.replace("\\", "/");
pathText.setText(file);
}
super.widgetSelected(e);
}
});
谁能帮帮我??