Search in sources :

Example 1 with IDialogCallback

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

the class MantleApplication method showConfirmationDialog.

/**
 * This method is used by things to show a 'mantle' looking confirmation dialog instead of a standard alert.
 *
 * @param title
 * @param message
 */
private void showConfirmationDialog(String title, String message, String okText, String cancelText, final JavaScriptObject callback) {
    MessageDialogBox dialog = new MessageDialogBox(title, message, true, false, true, okText, null, cancelText);
    dialog.setCallback(new IDialogCallback() {

        @Override
        public void okPressed() {
            notifyDialogCallbackOk(callback);
        }

        @Override
        public void cancelPressed() {
            notifyDialogCallbackCancel(callback);
        }
    });
    dialog.center();
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)

Example 2 with IDialogCallback

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

the class DeleteFileCommand method performOperation.

protected void performOperation(boolean feedback) {
    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction(this.getClass().getName());
    String temp = "";
    String names = "";
    // Convert to a comma delimted list for rest call
    for (SolutionBrowserFile file : filesToDelete) {
        // $NON-NLS-1$
        temp += file.getId() + ",";
        // $NON-NLS-1$
        names += file.getName() + ",";
    }
    // remove trailing ","
    temp = temp.substring(0, temp.length() - 1);
    names = names.substring(0, names.length() - 1);
    final String filesList = temp;
    if (feedback) {
        final HTML messageTextBox;
        if (filesToDelete.size() > 1) {
            messageTextBox = new HTML(Messages.getString("moveAllToTrashQuestionFile"));
        } else {
            messageTextBox = new HTML(Messages.getString("moveToTrashQuestionFile", names));
        }
        final PromptDialogBox fileMoveToTrashWarningDialogBox = new PromptDialogBox(Messages.getString("moveToTrash"), Messages.getString("yesMoveToTrash"), Messages.getString("no"), true, true);
        fileMoveToTrashWarningDialogBox.setContent(messageTextBox);
        final IDialogCallback callback = new IDialogCallback() {

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

            public void okPressed() {
                doDelete(filesList, event);
            }
        };
        fileMoveToTrashWarningDialogBox.setCallback(callback);
        fileMoveToTrashWarningDialogBox.center();
    } else {
        doDelete(filesList, event);
    }
}
Also used : SolutionBrowserFile(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserFile) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) HTML(com.google.gwt.user.client.ui.HTML) SolutionFileActionEvent(org.pentaho.mantle.client.events.SolutionFileActionEvent) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)

Example 3 with IDialogCallback

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

the class RestoreFileCommand method performRestoreToHomeFolder.

private void performRestoreToHomeFolder(final String filesList, final int restoreResponseStatusCode, final String userHomeFolderPath, final SolutionFileActionEvent event) {
    final String encodedUserHomeFolderPath = SolutionBrowserPanel.pathToId(userHomeFolderPath);
    String fileListDescription = "files";
    // if there is one file
    if (filesList.split(",").length == 1) {
        fileListDescription = "file";
    }
    HTML messageTextBox = new HTML();
    String cannotRestoreToOrigFolder = Messages.getString("cannotRestoreToOriginFolder", fileListDescription);
    String restoreToHomeFolder = Messages.getString("restoreToHomeFolder", userHomeFolderPath);
    messageTextBox.setHTML(cannotRestoreToOrigFolder + "<br> <br>" + restoreToHomeFolder + "<br>");
    final PromptDialogBox restoreFileWarningDialogBox = new PromptDialogBox(Messages.getString("couldNotWriteToFolder"), "Restore File", "Cancel", true, true);
    restoreFileWarningDialogBox.setContent(messageTextBox);
    final IDialogCallback callback = new IDialogCallback() {

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

        public void okPressed() {
            // files in homeFolder with same names
            if (restoreResponseStatusCode == Response.SC_CONFLICT) {
                final OverwritePromptDialog overwriteDialog = new OverwritePromptDialog();
                final IDialogCallback callback = new IDialogCallback() {

                    public void cancelPressed() {
                        event.setMessage("Cancel");
                        overwriteDialog.hide();
                    }

                    public void okPressed() {
                        // $NON-NLS-1$
                        String restoreFilesUrl = contextURL + "api/repo/files/restore?overwriteMode=" + overwriteDialog.getOverwriteMode();
                        RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, restoreFilesUrl);
                        try {
                            builder.sendRequest(filesList, new RequestCallback() {

                                @Override
                                public void onResponseReceived(Request request, Response response) {
                                    if (response.getStatusCode() == Response.SC_OK) {
                                        new RefreshRepositoryCommand().execute(false);
                                        event.setMessage("Success");
                                        EventBusUtil.EVENT_BUS.fireEvent(event);
                                    } else {
                                        showErrorDialogBox(event);
                                    }
                                }

                                @Override
                                public void onError(Request request, Throwable exception) {
                                    showErrorDialogBox(event);
                                }
                            });
                        } catch (RequestException e) {
                            showErrorDialogBox(event);
                        }
                    }
                };
                overwriteDialog.setCallback(callback);
                overwriteDialog.center();
            } else if (restoreResponseStatusCode == Response.SC_NOT_ACCEPTABLE) {
                String moveFilesURL = contextURL + "api/repo/files/" + encodedUserHomeFolderPath + "/move";
                RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, moveFilesURL);
                try {
                    builder.sendRequest(filesList, new RequestCallback() {

                        @Override
                        public void onResponseReceived(Request request, Response response) {
                            new RefreshRepositoryCommand().execute(false);
                            event.setMessage("Success");
                            EventBusUtil.EVENT_BUS.fireEvent(event);
                        }

                        @Override
                        public void onError(Request request, Throwable exception) {
                            showErrorDialogBox(event);
                        }
                    });
                } catch (RequestException e) {
                    showErrorDialogBox(event);
                }
            }
        }
    };
    restoreFileWarningDialogBox.setCallback(callback);
    restoreFileWarningDialogBox.center();
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Request(com.google.gwt.http.client.Request) HTML(com.google.gwt.user.client.ui.HTML) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback) OverwritePromptDialog(org.pentaho.mantle.client.dialogs.OverwritePromptDialog)

Example 4 with IDialogCallback

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

the class SwitchThemeCommand method performOperation.

protected void performOperation(boolean feedback) {
    final HTML messageTextBox = new HTML(Messages.getString("confirmSwitchTheme.message"));
    final PromptDialogBox fileMoveToTrashWarningDialogBox = new PromptDialogBox(Messages.getString("confirmSwitchTheme.title"), Messages.getString("confirmSwitchTheme.ok"), Messages.getString("confirmSwitchTheme.cancel"), true, true);
    fileMoveToTrashWarningDialogBox.setContent(messageTextBox);
    final IDialogCallback callback = new IDialogCallback() {

        public void cancelPressed() {
        }

        public void okPressed() {
            // $NON-NLS-1$
            final String url = GWT.getHostPageBaseURL() + "api/theme/set";
            RequestBuilder setThemeRequestBuilder = new RequestBuilder(RequestBuilder.POST, url);
            setThemeRequestBuilder.setHeader("accept", "text/plain");
            setThemeRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            try {
                setThemeRequestBuilder.sendRequest(theme, new RequestCallback() {

                    public void onError(Request request, Throwable exception) {
                    // showError(exception);
                    }

                    public void onResponseReceived(Request request, Response response) {
                        // forcing a setTimeout to fix a problem in IE BISERVER-6385
                        Scheduler.get().scheduleDeferred(new Command() {

                            public void execute() {
                                Window.Location.reload();
                            }
                        });
                    }
                });
            } catch (RequestException e) {
                Window.alert(e.getMessage());
            // showError(e);
            }
        }
    };
    fileMoveToTrashWarningDialogBox.setCallback(callback);
    fileMoveToTrashWarningDialogBox.center();
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Command(com.google.gwt.user.client.Command) Request(com.google.gwt.http.client.Request) HTML(com.google.gwt.user.client.ui.HTML) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) RequestException(com.google.gwt.http.client.RequestException)

Example 5 with IDialogCallback

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

the class ImportFileCommand method performOperation.

protected void performOperation(boolean feedback) {
    // delete file
    importDialog = new ImportDialog(repositoryFile, SolutionBrowserPanel.getInstance().isAdministrator());
    importDialog.getForm().addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent sce) {
            new RefreshRepositoryCommand().execute(false);
        }
    });
    final IDialogCallback callback = new IDialogCallback() {

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

        public void okPressed() {
            importDialog.getForm().submit();
        }
    };
    importDialog.setCallback(callback);
    importDialog.center();
}
Also used : ImportDialog(org.pentaho.mantle.client.dialogs.ImportDialog) SubmitCompleteEvent(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent) SubmitCompleteHandler(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)

Aggregations

IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)21 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)11 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)9 Request (com.google.gwt.http.client.Request)8 RequestBuilder (com.google.gwt.http.client.RequestBuilder)8 RequestCallback (com.google.gwt.http.client.RequestCallback)8 RequestException (com.google.gwt.http.client.RequestException)8 Response (com.google.gwt.http.client.Response)8 Label (com.google.gwt.user.client.ui.Label)7 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)7 HTML (com.google.gwt.user.client.ui.HTML)6 TextBox (com.google.gwt.user.client.ui.TextBox)3 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)3 JSONString (com.google.gwt.json.client.JSONString)2 Command (com.google.gwt.user.client.Command)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 OverwritePromptDialog (org.pentaho.mantle.client.dialogs.OverwritePromptDialog)2 SolutionBrowserFile (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserFile)2