Search in sources :

Example 1 with PromptDialogBox

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

the class AboutCommand method showAboutDialog.

private void showAboutDialog(String version) {
    @SuppressWarnings("deprecation") String licenseInfo = Messages.getString("licenseInfo", "" + ((new Date()).getYear() + 1900));
    String releaseLabel = Messages.getString("release");
    PromptDialogBox dialogBox = // $NON-NLS-1$
    new PromptDialogBox(Messages.getString("aboutDialogTitle"), Messages.getString("ok"), null, false, true);
    VerticalPanel aboutContent = new VerticalPanel();
    aboutContent.add(new Label(releaseLabel + " " + version));
    aboutContent.add(new HTML(licenseInfo));
    dialogBox.setContent(aboutContent);
    dialogBox.center();
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Label(com.google.gwt.user.client.ui.Label) HTML(com.google.gwt.user.client.ui.HTML) Date(java.util.Date)

Example 2 with PromptDialogBox

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

the class CheckForSoftwareUpdatesCommand method performOperation.

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

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

            public void onResponseReceived(Request request, Response response) {
                Document doc = XMLParser.parse(response.getText());
                // $NON-NLS-1$
                NodeList updates = doc.getElementsByTagName("update");
                if (updates.getLength() > 0) {
                    FlexTable updateTable = new FlexTable();
                    // $NON-NLS-1$
                    updateTable.setStyleName("backgroundContentTable");
                    // $NON-NLS-1$
                    updateTable.setWidget(0, 0, new Label(Messages.getString("version")));
                    // $NON-NLS-1$
                    updateTable.setWidget(0, 1, new Label(Messages.getString("type")));
                    // $NON-NLS-1$
                    updateTable.setWidget(0, 2, new Label(Messages.getString("os")));
                    // $NON-NLS-1$
                    updateTable.setWidget(0, 3, new Label(Messages.getString("link")));
                    // $NON-NLS-1$
                    updateTable.getCellFormatter().setStyleName(0, 0, "backgroundContentHeaderTableCell");
                    // $NON-NLS-1$
                    updateTable.getCellFormatter().setStyleName(0, 1, "backgroundContentHeaderTableCell");
                    // $NON-NLS-1$
                    updateTable.getCellFormatter().setStyleName(0, 2, "backgroundContentHeaderTableCell");
                    // $NON-NLS-1$
                    updateTable.getCellFormatter().setStyleName(0, 3, "backgroundContentHeaderTableCellRight");
                    for (int i = 0; i < updates.getLength(); i++) {
                        Element updateElement = (Element) updates.item(i);
                        // $NON-NLS-1$
                        String version = updateElement.getAttribute("version");
                        // $NON-NLS-1$
                        String type = updateElement.getAttribute("type");
                        // $NON-NLS-1$
                        String os = updateElement.getAttribute("os");
                        // String title = updateElement.getAttribute("title");
                        // $NON-NLS-1$
                        String downloadURL = updateElement.getElementsByTagName("downloadurl").item(0).toString();
                        // $NON-NLS-1$ //$NON-NLS-2$
                        downloadURL = downloadURL.substring(downloadURL.indexOf("http"), downloadURL.indexOf("]"));
                        updateTable.setWidget(i + 1, 0, new Label(version));
                        updateTable.setWidget(i + 1, 1, new Label(type));
                        updateTable.setWidget(i + 1, 2, new Label(os));
                        updateTable.setWidget(i + 1, 3, new HTML("<A HREF=\"" + downloadURL + "\" target=\"_blank\" title=\"" + downloadURL + "\">" + Messages.getString("download") + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                        "</A>"));
                        // $NON-NLS-1$
                        updateTable.getCellFormatter().setStyleName(i + 1, 0, "backgroundContentTableCell");
                        // $NON-NLS-1$
                        updateTable.getCellFormatter().setStyleName(i + 1, 1, "backgroundContentTableCell");
                        // $NON-NLS-1$
                        updateTable.getCellFormatter().setStyleName(i + 1, 2, "backgroundContentTableCell");
                        // $NON-NLS-1$
                        updateTable.getCellFormatter().setStyleName(i + 1, 3, "backgroundContentTableCellRight");
                        if (i == updates.getLength() - 1) {
                            // last
                            // $NON-NLS-1$
                            updateTable.getCellFormatter().setStyleName(i + 1, 0, "backgroundContentTableCellBottom");
                            // $NON-NLS-1$
                            updateTable.getCellFormatter().setStyleName(i + 1, 1, "backgroundContentTableCellBottom");
                            // $NON-NLS-1$
                            updateTable.getCellFormatter().setStyleName(i + 1, 2, "backgroundContentTableCellBottom");
                            // $NON-NLS-1$
                            updateTable.getCellFormatter().setStyleName(i + 1, 3, "backgroundContentTableCellBottomRight");
                        }
                    }
                    PromptDialogBox versionPromptDialog = new PromptDialogBox(Messages.getString("softwareUpdateAvailable"), Messages.getString("ok"), null, false, true, // $NON-NLS-1$ //$NON-NLS-2$
                    updateTable);
                    versionPromptDialog.center();
                } else {
                    MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("softwareUpdates"), Messages.getString("noUpdatesAvailable"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
                    true);
                    dialogBox.center();
                }
            }
        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    // showError(e);
    }
}
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) NodeList(com.google.gwt.xml.client.NodeList) Element(com.google.gwt.xml.client.Element) Request(com.google.gwt.http.client.Request) FlexTable(com.google.gwt.user.client.ui.FlexTable) Label(com.google.gwt.user.client.ui.Label) HTML(com.google.gwt.user.client.ui.HTML) Document(com.google.gwt.xml.client.Document) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback)

Example 3 with PromptDialogBox

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

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

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

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