/** * View the file selection dialog.<br> * Called when the know-how of creating XML files "Browse" button is pressed.<br> * * @return File */ private IFolder folderBrowse() { String filePath = page.outputFilePath(); String filePathExcludeProjectName = page.getOutputFilePathExcludeProjectName(); if (CmnStringUtil.isEmpty(filePath)) { return null; } // Create dialog final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( PluginUtil.getActiveWorkbenchShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); // Set the resources that are displayed in the dialog // IProject project = PluginUtil.getProject(filePath); // this.page.getSelectionProject(); IProject selectionProject = this.page.getSelectionProject(); dialog.setInput(selectionProject); dialog.setMessage(getDialogMessage(this.page.getSelectionProject())); dialog.setTitle(ResourceUtil.selectOutput); dialog.setHelpAvailable(false); // Add ViewerFileter dialog.addFilter( new ViewerFilter() { /** {@inheritDoc} */ @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IFolder) { return true; } return false; } }); // dialog.getFirstResult(); // Open the dialog. if (dialog.open() == Window.OK) { Object result = dialog.getFirstResult(); if (result instanceof IFolder) { return (IFolder) result; } } return null; }
/** {@inheritDoc} */ @Override public void widgetSelected(SelectionEvent e) { BrowseFileButtonSelectionListener.LOGGER.info( MessagePropertiesUtil.getMessage(MessagePropertiesUtil.LOG_OPEN_SELECT_FILE_DOALOG)); // Specify from the browse button output destination, (file name set to // the end) create a path IFolder targetFolder = folderBrowse(); if (targetFolder != null) { StringBuilder sb = new StringBuilder(); sb.append(targetFolder.getProject().getName()); sb.append(CmnFileUtil.FILE_SEPARATOR); sb.append(targetFolder.getProjectRelativePath()); sb.append(CmnFileUtil.FILE_SEPARATOR); sb.append(page.getKnowhowFileName()); outputPlace.setText(sb.toString()); } }