Search in sources :

Example 1 with FileFilter

use of org.pentaho.gwt.widgets.client.filechooser.FileFilter in project pentaho-platform by pentaho.

the class FileDialog method show.

public void show() {
    String pathToShow = (path != null) ? path : FileDialog.lastPath;
    final SolutionBrowserPanel solutionBrowserPerspective = SolutionBrowserPanel.getInstance();
    final FileChooserDialog dialog = new FileChooserDialog(FileChooserMode.OPEN, pathToShow, repositoryFileTree, false, true, title, okText, solutionBrowserPerspective.getSolutionTree().isShowHiddenFiles()) {

        @Override
        public void hide() {
            super.hide();
            GlassPane.getInstance().hide();
        }
    };
    dialog.setSubmitOnEnter(MantleApplication.submitOnEnter);
    dialog.addFileChooserListener(new FileChooserListener() {

        public void fileSelected(RepositoryFile file, String filePath, String fileName, String title) {
            dialog.hide();
            for (FileChooserListener listener : listeners) {
                listener.fileSelected(file, filePath, fileName, title);
            }
        }

        public void fileSelectionChanged(RepositoryFile file, String filePath, String fileName, String title) {
        }

        public void dialogCanceled() {
        }
    });
    dialog.setFileFilter(new FileFilter() {

        public boolean accept(String name, boolean isDirectory, boolean isVisible) {
            if (isDirectory && isVisible) {
                return true;
            }
            if (name.indexOf(".") == -1) {
                return false;
            }
            String extension = name.substring(name.lastIndexOf(".") + 1);
            for (int i = 0; i < fileTypes.length; i++) {
                if (fileTypes[i].trim().equalsIgnoreCase(extension) && isVisible) {
                    return true;
                }
            }
            return false;
        }
    });
    GlassPane.getInstance().show();
    dialog.center();
}
Also used : FileChooserListener(org.pentaho.gwt.widgets.client.filechooser.FileChooserListener) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) FileFilter(org.pentaho.gwt.widgets.client.filechooser.FileFilter) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel) FileChooserDialog(org.pentaho.gwt.widgets.client.filechooser.FileChooserDialog)

Aggregations

FileChooserDialog (org.pentaho.gwt.widgets.client.filechooser.FileChooserDialog)1 FileChooserListener (org.pentaho.gwt.widgets.client.filechooser.FileChooserListener)1 FileFilter (org.pentaho.gwt.widgets.client.filechooser.FileFilter)1 RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)1 SolutionBrowserPanel (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)1