Search in sources :

Example 36 with MessageDialogBox

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

the class RestoreFileCommand method showErrorDialogBox.

public void showErrorDialogBox(SolutionFileActionEvent event) {
    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("restoreError"), false, false, true);
    dialogBox.center();
    event.setMessage(Messages.getString("restoreError"));
    EventBusUtil.EVENT_BUS.fireEvent(event);
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)

Example 37 with MessageDialogBox

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

the class RunInBackgroundCommand method showDialog.

protected void showDialog(final boolean feedback) {
    final ScheduleOutputLocationDialog outputLocationDialog = new ScheduleOutputLocationDialog(solutionPath) {

        @Override
        protected void onSelect(final String name, final String outputLocationPath, final String useWorkerNodes, final boolean overwriteFile, final String dateFormat) {
            setOutputName(name);
            setOutputLocationPath(outputLocationPath);
            setUseWorkerNodes(useWorkerNodes);
            setOverwriteFile(String.valueOf(overwriteFile));
            setDateFormat(dateFormat);
            performOperation(feedback);
        }
    };
    final String filePath = solutionPath;
    String urlPath = NameUtils.URLEncode(NameUtils.encodeRepositoryPath(filePath));
    RequestBuilder scheduleFileRequestBuilder = createParametersChecker(urlPath);
    final boolean isXAction = isXAction(urlPath);
    try {
        scheduleFileRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                MessageDialogBox dialogBox = // $NON-NLS-1$
                new MessageDialogBox(Messages.getString("error"), exception.toString(), false, false, true);
                dialogBox.center();
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    String responseMessage = response.getText();
                    boolean hasParams = hasParameters(responseMessage, isXAction);
                    if (!hasParams) {
                        outputLocationDialog.setOkButtonText(Messages.getString("ok"));
                    }
                    outputLocationDialog.center();
                } else {
                    MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("serverErrorColon") + " " + response.getStatusCode(), false, false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                    true);
                    dialogBox.center();
                }
            }
        });
    } catch (RequestException e) {
        MessageDialogBox dialogBox = // $NON-NLS-1$
        new MessageDialogBox(Messages.getString("error"), e.toString(), false, false, true);
        dialogBox.center();
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) ScheduleOutputLocationDialog(org.pentaho.mantle.client.dialogs.scheduling.ScheduleOutputLocationDialog) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException)

Example 38 with MessageDialogBox

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

the class RunInBackgroundCommand method performOperation.

protected void performOperation(boolean feedback) {
    final String filePath = (this.getSolutionPath() != null) ? this.getSolutionPath() : repositoryFile.getPath();
    String urlPath = NameUtils.URLEncode(NameUtils.encodeRepositoryPath(filePath));
    RequestBuilder scheduleFileRequestBuilder = createParametersChecker(urlPath);
    final boolean isXAction = isXAction(urlPath);
    try {
        scheduleFileRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                MessageDialogBox dialogBox = // $NON-NLS-1$
                new MessageDialogBox(Messages.getString("error"), exception.toString(), false, false, true);
                dialogBox.center();
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    final JSONObject scheduleRequest = new JSONObject();
                    // $NON-NLS-1$
                    scheduleRequest.put("inputFile", new JSONString(filePath));
                    // Set date format to append to filename
                    if (StringUtils.isEmpty(getDateFormat())) {
                        // $NON-NLS-1$
                        scheduleRequest.put("appendDateFormat", JSONNull.getInstance());
                    } else {
                        // $NON-NLS-1$
                        scheduleRequest.put("appendDateFormat", new JSONString(getDateFormat()));
                    }
                    // Set whether to overwrite the file
                    if (StringUtils.isEmpty(getOverwriteFile())) {
                        // $NON-NLS-1$
                        scheduleRequest.put("overwriteFile", JSONNull.getInstance());
                    } else {
                        // $NON-NLS-1$
                        scheduleRequest.put("overwriteFile", new JSONString(getOverwriteFile()));
                    }
                    // Set job name
                    if (StringUtils.isEmpty(getOutputName())) {
                        // $NON-NLS-1$
                        scheduleRequest.put("jobName", JSONNull.getInstance());
                    } else {
                        // $NON-NLS-1$
                        scheduleRequest.put("jobName", new JSONString(getOutputName()));
                    }
                    // Set output path location
                    if (StringUtils.isEmpty(getOutputLocationPath())) {
                        // $NON-NLS-1$
                        scheduleRequest.put("outputFile", JSONNull.getInstance());
                    } else {
                        // $NON-NLS-1$
                        scheduleRequest.put("outputFile", new JSONString(getOutputLocationPath()));
                    }
                    if (!StringUtils.isEmpty(getUseWorkerNodes())) {
                        // $NON-NLS-1$
                        scheduleRequest.put("useWorkerNodes", new JSONString(getUseWorkerNodes()));
                    }
                    // BISERVER-9321
                    scheduleRequest.put("runInBackground", JSONBoolean.getInstance(true));
                    String responseMessage = response.getText();
                    final boolean hasParams = hasParameters(responseMessage, isXAction);
                    RequestBuilder emailValidRequest = // $NON-NLS-1$
                    new RequestBuilder(RequestBuilder.GET, contextURL + "api/emailconfig/isValid");
                    // $NON-NLS-1$ //$NON-NLS-2$
                    emailValidRequest.setHeader("accept", "text/plain");
                    emailValidRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                    try {
                        emailValidRequest.sendRequest(null, new RequestCallback() {

                            public void onError(Request request, Throwable exception) {
                                MessageDialogBox dialogBox = // $NON-NLS-1$
                                new MessageDialogBox(Messages.getString("error"), exception.toString(), false, false, true);
                                dialogBox.center();
                            }

                            public void onResponseReceived(Request request, Response response) {
                                if (response.getStatusCode() == Response.SC_OK) {
                                    // final boolean isEmailConfValid = Boolean.parseBoolean(response.getText());
                                    // force false for now, I have a feeling PM is going to want this, making it easy to turn back
                                    // on
                                    final boolean isEmailConfValid = false;
                                    if (hasParams) {
                                        ScheduleParamsDialog dialog = new ScheduleParamsDialog(filePath, scheduleRequest, isEmailConfValid);
                                        dialog.center();
                                        dialog.setAfterResponseCallback(scheduleParamsDialogCallback);
                                    } else if (isEmailConfValid) {
                                        ScheduleEmailDialog scheduleEmailDialog = new ScheduleEmailDialog(null, filePath, scheduleRequest, null, null);
                                        scheduleEmailDialog.center();
                                    } else {
                                        // just run it
                                        RequestBuilder scheduleFileRequestBuilder = // $NON-NLS-1$
                                        new RequestBuilder(RequestBuilder.POST, contextURL + "api/scheduler/job");
                                        // $NON-NLS-1$//$NON-NLS-2$
                                        scheduleFileRequestBuilder.setHeader("Content-Type", "application/json");
                                        scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                                        try {
                                            scheduleFileRequestBuilder.sendRequest(scheduleRequest.toString(), new RequestCallback() {

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

                                                @Override
                                                public void onResponseReceived(Request request, Response response) {
                                                    if (response.getStatusCode() == 200) {
                                                        MessageDialogBox dialogBox = new MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                                                        Messages.getString("runInBackground"), // $NON-NLS-1$ //$NON-NLS-2$
                                                        Messages.getString("backgroundExecutionStarted"), false, false, true);
                                                        dialogBox.center();
                                                    } else {
                                                        MessageDialogBox dialogBox = new MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-2$ //$NON-NLS-3$
                                                        Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-2$ //$NON-NLS-3$
                                                        Messages.getString("serverErrorColon") + " " + response.getStatusCode(), false, false, true);
                                                        dialogBox.center();
                                                    }
                                                }
                                            });
                                        } catch (RequestException e) {
                                            MessageDialogBox dialogBox = new // $NON-NLS-1$
                                            MessageDialogBox(// $NON-NLS-1$
                                            Messages.getString("error"), // $NON-NLS-1$
                                            e.toString(), false, false, true);
                                            dialogBox.center();
                                        }
                                    }
                                }
                            }
                        });
                    } catch (RequestException e) {
                        MessageDialogBox dialogBox = // $NON-NLS-1$
                        new MessageDialogBox(Messages.getString("error"), e.toString(), false, false, true);
                        dialogBox.center();
                    }
                } else {
                    MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("serverErrorColon") + " " + response.getStatusCode(), false, false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                    true);
                    dialogBox.center();
                }
            }
        });
    } catch (RequestException e) {
        MessageDialogBox dialogBox = // $NON-NLS-1$
        new MessageDialogBox(Messages.getString("error"), e.toString(), false, false, true);
        dialogBox.center();
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) ScheduleParamsDialog(org.pentaho.mantle.client.dialogs.scheduling.ScheduleParamsDialog) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback) JSONObject(com.google.gwt.json.client.JSONObject) ScheduleEmailDialog(org.pentaho.mantle.client.dialogs.scheduling.ScheduleEmailDialog) JSONString(com.google.gwt.json.client.JSONString)

Example 39 with MessageDialogBox

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

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

the class PurgeReportingDataCacheCommand method performOperation.

protected void performOperation() {
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/system/refresh/reportingDataCache";
    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    requestBuilder.setHeader("accept", "text/plain");
    requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        requestBuilder.sendRequest(null, new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("info"), Messages.getString("reportingDataCacheFlushedSuccessfully"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
                true);
                dialogBox.center();
            }
        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)43 RequestException (com.google.gwt.http.client.RequestException)29 Request (com.google.gwt.http.client.Request)28 RequestBuilder (com.google.gwt.http.client.RequestBuilder)28 RequestCallback (com.google.gwt.http.client.RequestCallback)28 Response (com.google.gwt.http.client.Response)28 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)9 JSONString (com.google.gwt.json.client.JSONString)7 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)6 JsArrayString (com.google.gwt.core.client.JsArrayString)5 Label (com.google.gwt.user.client.ui.Label)5 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)5 HTML (com.google.gwt.user.client.ui.HTML)4 TextBox (com.google.gwt.user.client.ui.TextBox)3 Widget (com.google.gwt.user.client.ui.Widget)3 JsArray (com.google.gwt.core.client.JsArray)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 JSONObject (com.google.gwt.json.client.JSONObject)2 Button (com.google.gwt.user.client.ui.Button)2