Search in sources :

Example 21 with RepositoryFile

use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile 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)

Example 22 with RepositoryFile

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

the class NewFolderCommand method performOperation.

protected void performOperation() {
    if (this.getSolutionPath() != null) {
        final SolutionBrowserPanel sbp = SolutionBrowserPanel.getInstance();
        if (callback == null) {
            setCallback(new ICallback<String>() {

                public void onHandle(String path) {
                    sbp.getSolutionTree().select(path);
                }
            });
        }
        sbp.getFile(this.getSolutionPath(), new SolutionFileHandler() {

            @Override
            public void handle(RepositoryFile repositoryFile) {
                NewFolderCommand.this.parentFolder = repositoryFile;
                performOperation(true);
            }
        });
    } else {
        performOperation(true);
    }
}
Also used : SolutionFileHandler(org.pentaho.mantle.client.events.SolutionFileHandler) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)

Example 23 with RepositoryFile

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

the class OpenFileCommand method performOperation.

protected void performOperation(boolean feedback) {
    final IPluginPerspective activePerspective = PerspectiveManager.getInstance().getActivePerspective();
    final SolutionBrowserPanel solutionBrowserPerspective = SolutionBrowserPanel.getInstance();
    boolean forceReload = false;
    if (FileChooserDialog.getIsDirty()) {
        forceReload = true;
        WaitPopup.getInstance().setVisibleById(true, spinnerId);
        FileChooserDialog.setIsDirty(Boolean.FALSE);
    }
    RepositoryFileTreeManager.getInstance().fetchRepositoryFileTree(new AsyncCallback<RepositoryFileTree>() {

        public void onFailure(Throwable caught) {
        }

        public void onSuccess(RepositoryFileTree tree) {
            // TODO Uncomment the line below and delete the line after that once gwtwidets have been branched
            WaitPopup.getInstance().setVisibleById(false, spinnerId);
            final FileChooserDialog dialog = new FileChooserDialog(FileChooserMode.OPEN, lastPath, tree, false, true, solutionBrowserPerspective.getSolutionTree().isShowHiddenFiles());
            dialog.setSubmitOnEnter(MantleApplication.submitOnEnter);
            dialog.addFileChooserListener(new FileChooserListener() {

                public void dialogCanceled() {
                    // retain current active perspective
                    PerspectiveManager.getInstance().setPerspective(activePerspective.getId());
                }

                @Override
                public void fileSelected(RepositoryFile repositoryFile, String filePath, String fileName, String title) {
                    dialog.hide();
                    solutionBrowserPerspective.openFile(repositoryFile, openMethod);
                }

                @Override
                public void fileSelectionChanged(RepositoryFile repositoryFile, String filePath, String fileName, String title) {
                // TODO Auto-generated method stub
                }
            });
            dialog.center();
        }
    }, forceReload, null, null, SolutionBrowserPanel.getInstance().getSolutionTree().isShowHiddenFiles());
}
Also used : FileChooserListener(org.pentaho.gwt.widgets.client.filechooser.FileChooserListener) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel) RepositoryFileTree(org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree) FileChooserDialog(org.pentaho.gwt.widgets.client.filechooser.FileChooserDialog)

Aggregations

RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)23 SolutionBrowserPanel (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)7 Request (com.google.gwt.http.client.Request)6 RequestBuilder (com.google.gwt.http.client.RequestBuilder)6 RequestCallback (com.google.gwt.http.client.RequestCallback)6 RequestException (com.google.gwt.http.client.RequestException)6 Response (com.google.gwt.http.client.Response)6 RepositoryFileTree (org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree)6 JsArrayString (com.google.gwt.core.client.JsArrayString)5 ArrayList (java.util.ArrayList)4 SolutionFileHandler (org.pentaho.mantle.client.events.SolutionFileHandler)4 FileChooserDialog (org.pentaho.gwt.widgets.client.filechooser.FileChooserDialog)3 FileChooserListener (org.pentaho.gwt.widgets.client.filechooser.FileChooserListener)3 SolutionFileActionEvent (org.pentaho.mantle.client.events.SolutionFileActionEvent)3 JSONObject (com.google.gwt.json.client.JSONObject)2 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)2 TreeItemComparator (org.pentaho.gwt.widgets.client.filechooser.TreeItemComparator)2 PentahoTabPanel (org.pentaho.gwt.widgets.client.tabs.PentahoTabPanel)2 EmptyRequestCallback (org.pentaho.mantle.client.EmptyRequestCallback)2 ContentTypePlugin (org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)2