Search in sources :

Example 6 with SolutionBrowserPanel

use of org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel in project pentaho-platform by pentaho.

the class CollapseBrowserCommand method performOperation.

protected void performOperation(boolean feedback) {
    final SolutionBrowserPanel solutionBrowserPerspective = SolutionBrowserPanel.getInstance();
    if (!solutionBrowserPerspective.isNavigatorShowing()) {
        PerspectiveManager.getInstance().setPerspective(PerspectiveManager.OPENED_PERSPECTIVE);
    }
    solutionBrowserPerspective.setNavigatorShowing(false);
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/user-settings/MANTLE_SHOW_NAVIGATOR";
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);
    try {
        builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        builder.sendRequest("false", EmptyRequestCallback.getInstance());
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestException(com.google.gwt.http.client.RequestException) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)

Example 7 with SolutionBrowserPanel

use of org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel in project pentaho-platform by pentaho.

the class SaveCommand method performOperation.

protected void performOperation(boolean feedback) {
    final SolutionBrowserPanel navigatorPerspective = SolutionBrowserPanel.getInstance();
    retrieveCachedValues(navigatorPerspective.getContentTabPanel().getCurrentFrame());
    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) {
            retrieveCachedValues(navigatorPerspective.getContentTabPanel().getCurrentFrame());
            if (isSaveAs || name == null) {
                String fileDir = "";
                if (path != null && !StringUtils.isEmpty(path)) {
                    // If has extension
                    if (path.endsWith(name)) {
                        fileDir = path.substring(0, path.lastIndexOf("/"));
                    } else {
                        fileDir = path;
                    }
                }
                WaitPopup.getInstance().setVisibleById(false, spinnerId);
                final FileChooserDialog dialog = new FileChooserDialog(FileChooserMode.SAVE, fileDir, tree, false, true, Messages.getString("save"), Messages.getString("save"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                navigatorPerspective.getSolutionTree().isShowHiddenFiles());
                dialog.setSubmitOnEnter(MantleApplication.submitOnEnter);
                if (isSaveAs) {
                    // $NON-NLS-1$
                    dialog.setTitle(Messages.getString("saveAs"));
                    // $NON-NLS-1$
                    dialog.setText(Messages.getString("saveAs"));
                } else {
                    // $NON-NLS-1$
                    dialog.setTitle(Messages.getString("save"));
                    // $NON-NLS-1$
                    dialog.setText(Messages.getString("save"));
                }
                // TODO Uncomment the line below and delete the line after that once gwtwidets have been branched
                dialog.addFileChooserListener(new FileChooserListener() {

                    public void dialogCanceled() {
                    }

                    @Override
                    public void fileSelected(final RepositoryFile file, String filePath, String fileName, String title) {
                        SaveCommand.this.type = SolutionFileInfo.Type.XACTION;
                        SaveCommand.this.name = fileName;
                        SaveCommand.this.path = filePath;
                        tabName = name;
                        if (tabName.indexOf("analysisview.xaction") != -1) {
                            // trim off the analysisview.xaction from the localized-name
                            tabName = tabName.substring(0, tabName.indexOf("analysisview.xaction") - 1);
                        }
                        JsArrayString extensions = getPossibleExtensions(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId());
                        final String fileExtension = extensions.length() == 1 ? extensions.get(0) : null;
                        if (dialog.doesSelectedFileExist(fileExtension)) {
                            dialog.hide();
                            PromptDialogBox overWriteDialog = new PromptDialogBox(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                            Messages.getString("question"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                            Messages.getString("yes"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                            Messages.getString("no"), false, true);
                            // $NON-NLS-1$
                            overWriteDialog.setContent(new Label(Messages.getString("fileExistsOverwrite"), false));
                            overWriteDialog.setCallback(new IDialogCallback() {

                                public void okPressed() {
                                    if (fileExtension != null && tabName.endsWith(fileExtension)) {
                                        tabName = tabName.substring(0, tabName.lastIndexOf(fileExtension));
                                    }
                                    doSaveAs(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId(), name, path, type, true);
                                    // $NON-NLS-1$ //$NON-NLS-2$
                                    Window.setTitle(Messages.getString("productName") + " - " + name);
                                    FileChooserDialog.setIsDirty(Boolean.TRUE);
                                    persistFileInfoInFrame();
                                }

                                public void cancelPressed() {
                                    dialog.show();
                                }
                            });
                            overWriteDialog.center();
                        } else {
                            // [Fix for PIR-833]
                            if (file != null && !file.isFolder() && !fileName.equals(title) && filePath.endsWith(file.getName())) {
                                SaveCommand.this.path = filePath.substring(0, filePath.lastIndexOf("/" + file.getName()));
                            }
                            doSaveAs(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId(), name, path, type, true);
                            // $NON-NLS-1$ //$NON-NLS-2$
                            Window.setTitle(Messages.getString("productName") + " - " + name);
                            persistFileInfoInFrame();
                            // navigatorPerspective.addRecent(fullPathWithName, name);
                            clearValues();
                        }
                    }

                    @Override
                    public void fileSelectionChanged(RepositoryFile file, String filePath, String fileName, String title) {
                    // TODO Auto-generated method stub
                    }
                });
                dialog.center();
            } else {
                doSaveAs(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId(), name, path, type, true);
                clearValues();
            }
            WaitPopup.getInstance().setVisibleById(false, spinnerId);
        }
    }, forceReload, null, null, SolutionBrowserPanel.getInstance().getSolutionTree().isShowHiddenFiles());
}
Also used : PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Label(com.google.gwt.user.client.ui.Label) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel) RepositoryFileTree(org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree) FileChooserDialog(org.pentaho.gwt.widgets.client.filechooser.FileChooserDialog) FileChooserListener(org.pentaho.gwt.widgets.client.filechooser.FileChooserListener) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)

Example 8 with SolutionBrowserPanel

use of org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel in project pentaho-platform by pentaho.

the class UrlCommand method performOperation.

protected void performOperation(boolean feedback) {
    if (showInDialog) {
        // $NON-NLS-1$
        String height = dialogHeight + "px";
        // $NON-NLS-1$
        String width = dialogWidth + "px";
        final Frame frame = new Frame(url);
        final PromptDialogBox dialogBox = new PromptDialogBox(title, Messages.getString("ok"), null, false, false);
        dialogBox.setStylePrimaryName("pentaho-dialog");
        dialogBox.setText(title);
        dialogBox.setContent(frame);
        frame.setSize(width, height);
        dialogBox.center();
        frame.setSize(width, height);
    } else {
        SolutionBrowserPanel navigatorPerspective = SolutionBrowserPanel.getInstance();
        // $NON-NLS-1$
        navigatorPerspective.getContentTabPanel().showNewURLTab(title, "", url, false);
    }
}
Also used : Frame(com.google.gwt.user.client.ui.Frame) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)

Example 9 with SolutionBrowserPanel

use of org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel 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 10 with SolutionBrowserPanel

use of org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel 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)

Aggregations

SolutionBrowserPanel (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)11 RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)7 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 RequestBuilder (com.google.gwt.http.client.RequestBuilder)2 RequestException (com.google.gwt.http.client.RequestException)2 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)2 RepositoryFileTree (org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 Frame (com.google.gwt.user.client.ui.Frame)1 Label (com.google.gwt.user.client.ui.Label)1 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)1 FileFilter (org.pentaho.gwt.widgets.client.filechooser.FileFilter)1 ExportFileCommand (org.pentaho.mantle.client.commands.ExportFileCommand)1 FilePropertiesCommand (org.pentaho.mantle.client.commands.FilePropertiesCommand)1 ImportFileCommand (org.pentaho.mantle.client.commands.ImportFileCommand)1 NewFolderCommand (org.pentaho.mantle.client.commands.NewFolderCommand)1 RunInBackgroundCommand (org.pentaho.mantle.client.commands.RunInBackgroundCommand)1 ShareFileCommand (org.pentaho.mantle.client.commands.ShareFileCommand)1