Bug 300539 Add ability to specify filter-path to build-options that support browsing
Build Identifier: 7.0.0.I201001150805 Currently, build-options of browseType "file"/"directory"/etc allow the user to browse the file-system, but do not give integrators a way to set the default filter-path. So, the Browse dialog by default opens at the root of the file-system. The attached patch adds a new optional attribute for the <option> element - "browseFilterPath". If the attribute is specified, the Browse dialog uses the supplied value as the default filter-path. Macros in the attribute value are expanded. If the attribute is not specified, the behaviour is unchanged. Reproducible: Always Steps to Reproduce: 1. Create a new C Project. 2. Open the Settings property page, and find a build-option that has a "file" browseType (eg. libraries) or a "directory" browseType (eg. include-path). 3. Click on Add... button to add a new entry. 4. Click on Filesystem... to browse the file-system. -> The Browse dialog opens up at the root of the file-system by default.
bundles/org.eclipse.jface/src/org/eclipse/jface/preference/DirectoryFieldEditor.java
String fileName = getTextControl().getText();
        fileName = fileName.trim();
        if (fileName.length() == 0 && isEmptyStringAllowed()) {
			return true;
		}
        File file = new File(fileName);
        return file.isDirectory();
    }
    /**
     * Helper that opens the directory chooser dialog.
     * @param startingDirectory The directory the dialog will open in.
     * @return File File or <code>null</code>.
     * 
     */
    private File getDirectory(File startingDirectory) {
        DirectoryDialog fileDialog = new DirectoryDialog(getShell(), SWT.OPEN | SWT.SHEET);
        if (startingDirectory != null) {
			fileDialog.setFilterPath(startingDirectory.getPath());
		}
        String dir = fileDialog.open();
        if (dir != null) {
            dir = dir.trim();
            if (dir.length() > 0) {
				return new File(dir);
			}
        }
        return null;
    }
}