Source:
public StringDirectorySelector(Composite parent, int style) { super(parent, style); ((GridLayout) getLayout()).numColumns = 5; browse = factory.createButton(this, Messages.StringFileSelector_Browse, SWT.PUSH); browse.setLayoutData(new GridData()); browseWorkspace = factory.createButton(this, Messages.StringFileSelector_BrowseWorkspace, SWT.PUSH); browseWorkspace.setLayoutData(new GridData()); browse.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { File file = FolderUtil.getFolder(text.getText()); DirectoryDialog dialog = new DirectoryDialog(getShell()); if (labelText != null) { dialog.setText(labelText); } if (null != file) { dialog.setText(file.getAbsolutePath()); } String result = dialog.open(); if (result == null) { return; } setResult(result); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); browseWorkspace.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { LabelProviderService labelProviderService = new LabelProviderServiceImpl(); try { labelProviderService.startService(); } catch (ServiceException ex) { Activator.log.error(ex); } ILabelProvider labelProvider = labelProviderService.getLabelProvider(); IFile currentFile = FileUtil.getIFile(text.getText()); TreeSelectorDialog dialog = new TreeSelectorDialog(getShell()); if (labelText != null) { dialog.setTitle(labelText); } WorkspaceContentProvider contentProvider = new WorkspaceContentProvider() { @Override public boolean isValidValue(Object element) { return isValidFolder(element); } }; dialog.setContentProvider(contentProvider); dialog.setLabelProvider(labelProvider); if (currentFile != null && currentFile.exists()) { dialog.setInitialSelections(new IFile[] { currentFile }); } int code = dialog.open(); if (code == Window.OK) { Object[] result = dialog.getResult(); if (result.length > 0) { Object file = result[0]; if (isValidFolder(result[0])) { setResult((IContainer) file); } } } } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); }

Target:
public StringDirectorySelector(Composite parent, int style) { super(parent, style); ((GridLayout) getLayout()).numColumns = 5; browse = factory.createButton(this, Messages.StringFileSelector_Browse, SWT.PUSH); browse.setLayoutData(new GridData()); browseWorkspace = factory.createButton(this, Messages.StringFileSelector_BrowseWorkspace, SWT.PUSH); browseWorkspace.setLayoutData(new GridData()); browse.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { File file = FileUtil.getFolder(text.getText()); DirectoryDialog dialog = new DirectoryDialog(getShell()); if (labelText != null) { dialog.setText(labelText); } if (null != file) { dialog.setFilterPath(file.getAbsolutePath()); } String result = dialog.open(); if (result == null) { return; } setResult(result); } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); browseWorkspace.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { LabelProviderService labelProviderService = new LabelProviderServiceImpl(); try { labelProviderService.startService(); } catch (ServiceException ex) { Activator.log.error(ex); } ILabelProvider labelProvider = labelProviderService.getLabelProvider(); IFile currentFile = FileUtil.getIFile(text.getText()); TreeSelectorDialog dialog = new TreeSelectorDialog(getShell()); if (labelText != null) { dialog.setTitle(labelText); } WorkspaceContentProvider contentProvider = new WorkspaceContentProvider() { @Override public boolean isValidValue(Object element) { return isValidFolder(element); } }; dialog.setContentProvider(contentProvider); dialog.setLabelProvider(labelProvider); if (currentFile != null && currentFile.exists()) { dialog.setInitialSelections(new IFile[] { currentFile }); } int code = dialog.open(); if (code == Window.OK) { Object[] result = dialog.getResult(); if (result.length > 0) { Object file = result[0]; if (isValidFolder(result[0])) { setResult((IContainer) file); } } } } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); }