Search in sources :

Example 11 with PromptDialogBox

use of org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox in project pentaho-platform by pentaho.

the class DeletePermanentFileCommand method performOperation.

/*
 * (non-Javadoc)
 *
 * @see com.google.gwt.user.client.Command#execute()
 */
protected void performOperation(boolean feedback) {
    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction(this.getClass().getName());
    VerticalPanel vp = new VerticalPanel();
    String deleteMessage;
    final PromptDialogBox deleteConfirmDialog;
    if (mode.equals("purge")) {
        deleteMessage = Messages.getString("deleteAllQuestion");
        deleteConfirmDialog = new PromptDialogBox(Messages.getString("emptyTrash"), Messages.getString("yesEmptyTrash"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        vp);
    } else {
        if (MULTIPLE_DELETE_TYPE.equals(type)) {
            deleteMessage = Messages.getString("deleteMultiQuestion");
        } else {
            deleteMessage = Messages.getString("deleteQuestion", type);
        }
        deleteConfirmDialog = new PromptDialogBox(Messages.getString("permDelete"), Messages.getString("yesPermDelete"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        vp);
    }
    // $NON-NLS-1$
    vp.add(new HTML(deleteMessage));
    final IDialogCallback callback = new IDialogCallback() {

        public void cancelPressed() {
            deleteConfirmDialog.hide();
        }

        public void okPressed() {
            String temp = "";
            // Add js file list
            temp = temp + fileList;
            // remove trailing ","
            temp = temp.substring(0, temp.length() - 1);
            final String filesList = temp;
            // $NON-NLS-1$
            String deleteFilesURL = contextURL + "api/repo/files/deletepermanent";
            RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
            // $NON-NLS-1$//$NON-NLS-2$
            deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
            deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            try {
                deleteFilesRequestBuilder.sendRequest(filesList, new RequestCallback() {

                    @Override
                    public void onError(Request request, Throwable exception) {
                        MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                        MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                        Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                        Messages.getString("couldNotDeleteFile"), false, false, true);
                        dialogBox.center();
                        event.setMessage(Messages.getString("couldNotDeleteFile"));
                        EventBusUtil.EVENT_BUS.fireEvent(event);
                    }

                    @Override
                    public void onResponseReceived(Request request, Response response) {
                        if (response.getStatusCode() == 200) {
                            new RefreshRepositoryCommand().execute(false);
                            event.setMessage("Success");
                            FileChooserDialog.setIsDirty(Boolean.TRUE);
                            setBrowseRepoDirty(Boolean.TRUE);
                            EventBusUtil.EVENT_BUS.fireEvent(event);
                        } else {
                            event.setMessage(Messages.getString("couldNotDeleteFile"));
                            EventBusUtil.EVENT_BUS.fireEvent(event);
                        }
                    }
                });
            } catch (RequestException e) {
                MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("couldNotDeleteFile"), false, false, true);
                dialogBox.center();
                event.setMessage(Messages.getString("couldNotDeleteFile"));
                EventBusUtil.EVENT_BUS.fireEvent(event);
            }
        }
    };
    if (!feedback) {
        callback.okPressed();
    } else {
        deleteConfirmDialog.setCallback(callback);
        deleteConfirmDialog.center();
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Request(com.google.gwt.http.client.Request) HTML(com.google.gwt.user.client.ui.HTML) SolutionFileActionEvent(org.pentaho.mantle.client.events.SolutionFileActionEvent) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) RequestCallback(com.google.gwt.http.client.RequestCallback)

Example 12 with PromptDialogBox

use of org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox 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 13 with PromptDialogBox

use of org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox in project pentaho-platform by pentaho.

the class OpenURLCommand method performOperation.

protected void performOperation(boolean feedback) {
    final TextBox textBox = new TextBox();
    // $NON-NLS-1$
    textBox.setText("http://");
    // $NON-NLS-1$
    textBox.setWidth("500px");
    textBox.setVisibleLength(72);
    IDialogCallback callback = new IDialogCallback() {

        public void cancelPressed() {
        }

        public void okPressed() {
            SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(textBox.getText(), textBox.getText(), textBox.getText(), false);
        }
    };
    IDialogValidatorCallback validatorCallback = new IDialogValidatorCallback() {

        public boolean validate() {
            // $NON-NLS-1$
            boolean isValid = !"".equals(textBox.getText()) && textBox.getText() != null;
            if (!isValid) {
                MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("urlNotSpecified"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
                true);
                dialogBox.center();
            }
            return isValid;
        }
    };
    PromptDialogBox promptDialog = new PromptDialogBox(Messages.getString("enterURL"), Messages.getString("ok"), Messages.getString("cancel"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    textBox);
    promptDialog.setValidatorCallback(validatorCallback);
    promptDialog.setCallback(callback);
    // $NON-NLS-1$
    promptDialog.setWidth("500px");
    promptDialog.center();
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) TextBox(com.google.gwt.user.client.ui.TextBox) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) IDialogValidatorCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogValidatorCallback)

Example 14 with PromptDialogBox

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

Aggregations

PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)14 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)11 HTML (com.google.gwt.user.client.ui.HTML)8 Request (com.google.gwt.http.client.Request)7 RequestBuilder (com.google.gwt.http.client.RequestBuilder)7 RequestCallback (com.google.gwt.http.client.RequestCallback)7 RequestException (com.google.gwt.http.client.RequestException)7 Response (com.google.gwt.http.client.Response)7 Label (com.google.gwt.user.client.ui.Label)6 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)6 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)5 Command (com.google.gwt.user.client.Command)2 TextBox (com.google.gwt.user.client.ui.TextBox)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 SolutionBrowserPanel (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 NodeList (com.google.gwt.dom.client.NodeList)1 TableCellElement (com.google.gwt.dom.client.TableCellElement)1 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)1