Search in sources :

Example 21 with MessageDialogBox

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

the class SchedulesPanel method editJob.

private void editJob(JsJob editJob) {
    final String url = GWT.getHostPageBaseURL() + "api/scheduler/jobinfo?jobId=" + URL.encodeQueryString(editJob.getJobId());
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("accept", "application/json");
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    final JsJob jsJob = parseJsonJob(JsonUtils.escapeJsonForEval(response.getText()));
                    // check email is setup
                    RequestBuilder emailValidRequest = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/emailconfig/isValid");
                    emailValidRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                    emailValidRequest.setHeader("accept", "text/plain");
                    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());
                                    final NewScheduleDialog schedDialog = new NewScheduleDialog(jsJob, scheduleDialogCallback, isEmailConfValid);
                                    schedDialog.center();
                                }
                            }
                        });
                    } catch (RequestException e) {
                    // showError(e);
                    }
                } 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) {
    // 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) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException) NewScheduleDialog(org.pentaho.mantle.client.dialogs.scheduling.NewScheduleDialog)

Example 22 with MessageDialogBox

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

the class MantleApplication method showMessage.

/**
 * This method is used by things to show a 'mantle' looking alert dialog instead of a standard alert dialog.
 *
 * @param title
 * @param message
 */
private void showMessage(String title, String message) {
    MessageDialogBox dialog = new MessageDialogBox(title, message, true, false, true);
    dialog.center();
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)

Example 23 with MessageDialogBox

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

the class MantleApplication method onMantleSettingsLoaded.

public void onMantleSettingsLoaded(MantleSettingsLoadedEvent event) {
    final HashMap<String, String> settings = event.getSettings();
    final boolean showOnlyPerspective = Boolean.parseBoolean(StringUtils.isEmpty(Window.Location.getParameter("showOnlyPerspective")) ? settings.get("showOnlyPerspective") : Window.Location.getParameter("showOnlyPerspective"));
    final String startupPerspective = StringUtils.isEmpty(Window.Location.getParameter("startupPerspective")) ? settings.get("startupPerspective") : Window.Location.getParameter("startupPerspective");
    mantleRevisionOverride = settings.get("user-console-revision");
    RootPanel.get("pucMenuBar").add(MantleXul.getInstance().getMenubar());
    RootPanel.get("pucPerspectives").add(PerspectiveManager.getInstance());
    RootPanel.get("pucToolBar").add(MantleXul.getInstance().getToolbar());
    RootPanel.get("pucUserDropDown").add(new UserDropDown());
    if (showOnlyPerspective && !StringUtils.isEmpty(startupPerspective)) {
        RootPanel.get("pucHeader").setVisible(false);
        RootPanel.get("pucContent").getElement().getStyle().setTop(0, Unit.PX);
    }
    // update supported file types
    PluginOptionsHelper.buildEnabledOptionsList(settings);
    // show stuff we've created/configured
    contentDeck.add(new Label());
    contentDeck.showWidget(0);
    contentDeck.add(SolutionBrowserPanel.getInstance());
    if (showOnlyPerspective && !StringUtils.isEmpty(startupPerspective)) {
        SolutionBrowserPanel.getInstance().setVisible(false);
    }
    contentDeck.getElement().setId("applicationShell");
    contentDeck.setStyleName("applicationShell");
    // menubar=no,location=no,resizable=yes,scrollbars=no,status=no,width=1200,height=800
    try {
        RootPanel.get("pucContent").add(contentDeck);
    } catch (Throwable t) {
    // onLoad of something is causing problems
    }
    RootPanel.get().add(WaitPopup.getInstance());
    // Add in the overlay panel
    overlayPanel.setVisible(false);
    overlayPanel.setHeight("100%");
    overlayPanel.setWidth("100%");
    overlayPanel.getElement().getStyle().setProperty("zIndex", "1000");
    overlayPanel.getElement().getStyle().setProperty("position", "absolute");
    RootPanel.get().add(overlayPanel, 0, 0);
    String submitOnEnterSetting = settings.get("submit-on-enter-key");
    submitOnEnter = submitOnEnterSetting == null ? submitOnEnter : Boolean.parseBoolean(submitOnEnterSetting);
    try {
        // $NON-NLS-1$
        String restUrl = GWT.getHostPageBaseURL() + "api/repo/files/canAdminister";
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, restUrl);
        requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.sendRequest(null, new RequestCallback() {

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

            @Override
            public void onResponseReceived(Request arg0, Response response) {
                Boolean isAdministrator = Boolean.parseBoolean(response.getText());
                SolutionBrowserPanel.getInstance().setAdministrator(isAdministrator);
                try {
                    // $NON-NLS-1$
                    String restUrl2 = GWT.getHostPageBaseURL() + "api/scheduler/canSchedule";
                    RequestBuilder requestBuilder2 = new RequestBuilder(RequestBuilder.GET, restUrl2);
                    requestBuilder2.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                    requestBuilder2.sendRequest(null, new RequestCallback() {

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

                        public void onResponseReceived(Request arg0, Response response) {
                            Boolean isScheduler = Boolean.parseBoolean(response.getText());
                            SolutionBrowserPanel.getInstance().setScheduler(isScheduler);
                            String numStartupURLsSetting = settings.get("num-startup-urls");
                            if (numStartupURLsSetting != null) {
                                // $NON-NLS-1$
                                int numStartupURLs = Integer.parseInt(numStartupURLsSetting);
                                for (int i = 0; i < numStartupURLs; i++) {
                                    // $NON-NLS-1$
                                    String url = settings.get("startup-url-" + (i + 1));
                                    // $NON-NLS-1$
                                    String name = settings.get("startup-name-" + (i + 1));
                                    if (StringUtils.isEmpty(url) == false) {
                                        // $NON-NLS-1$
                                        url = URL.decodeQueryString(url);
                                        name = URL.decodeQueryString(name);
                                        SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(name != null ? name : url, url, url, false);
                                    }
                                }
                            }
                            if (SolutionBrowserPanel.getInstance().getContentTabPanel().getWidgetCount() > 0) {
                                SolutionBrowserPanel.getInstance().getContentTabPanel().selectTab(0);
                            }
                            // startup-url on the URL for the app, wins over settings
                            // $NON-NLS-1$
                            String startupURL = Window.Location.getParameter("startup-url");
                            if (startupURL != null && !"".equals(startupURL)) {
                                // $NON-NLS-1$
                                // Spaces were double encoded so that they wouldn't be replaced with '+' when creating a deep
                                // link so when following a deep link we need to replace '%20' with a space even after decoding
                                // $NON-NLS-1$
                                String title = Window.Location.getParameter("name").replaceAll("%20", " ");
                                SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(title, title, startupURL, false);
                            }
                        }
                    });
                } catch (RequestException e) {
                    MessageDialogBox dialogBox = // $NON-NLS-1$
                    new MessageDialogBox(Messages.getString("error"), e.getLocalizedMessage(), false, false, true);
                    dialogBox.center();
                }
            }
        });
    } catch (RequestException e) {
        MessageDialogBox dialogBox = // $NON-NLS-1$
        new MessageDialogBox(Messages.getString("error"), e.getLocalizedMessage(), false, false, true);
        dialogBox.center();
    }
    if (!StringUtils.isEmpty(startupPerspective)) {
        if (PerspectiveManager.getInstance().isLoaded()) {
            PerspectiveManager.getInstance().setPerspective(startupPerspective);
        } else {
            EventBusUtil.EVENT_BUS.addHandler(PerspectivesLoadedEvent.TYPE, new PerspectivesLoadedEventHandler() {

                public void onPerspectivesLoaded(PerspectivesLoadedEvent event) {
                    PerspectiveManager.getInstance().setPerspective(startupPerspective);
                }
            });
        }
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) PerspectivesLoadedEventHandler(org.pentaho.mantle.client.events.PerspectivesLoadedEventHandler) Label(com.google.gwt.user.client.ui.Label) Request(com.google.gwt.http.client.Request) UserDropDown(org.pentaho.mantle.client.ui.UserDropDown) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) PerspectivesLoadedEvent(org.pentaho.mantle.client.events.PerspectivesLoadedEvent) RequestCallback(com.google.gwt.http.client.RequestCallback)

Example 24 with MessageDialogBox

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

the class ContentCleanerPanel method activate.

public void activate() {
    clear();
    String moduleBaseURL = GWT.getModuleBaseURL();
    String moduleName = GWT.getModuleName();
    String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, contextURL + "api/scheduler/getContentCleanerJob?cb=" + System.currentTimeMillis());
    scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    // $NON-NLS-1$//$NON-NLS-2$
    scheduleFileRequestBuilder.setHeader("Content-Type", "application/json");
    // $NON-NLS-1$//$NON-NLS-2$
    scheduleFileRequestBuilder.setHeader("accept", "application/json");
    try {
        scheduleFileRequestBuilder.sendRequest("", new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                final TextBox nowTextBox = new TextBox();
                nowTextBox.setWidth("24px");
                nowTextBox.getElement().getStyle().setPadding(5, Unit.PX);
                nowTextBox.getElement().getStyle().setMarginLeft(5, Unit.PX);
                nowTextBox.getElement().getStyle().setMarginRight(5, Unit.PX);
                final TextBox scheduleTextBox = new TextBox();
                scheduleTextBox.setVisibleLength(4);
                JsJob tmpJsJob = parseJsonJob(JsonUtils.escapeJsonForEval(response.getText()));
                boolean fakeJob = false;
                if (tmpJsJob == null) {
                    tmpJsJob = createJsJob();
                    fakeJob = true;
                }
                final JsJob jsJob = tmpJsJob;
                if (jsJob != null) {
                    scheduleTextBox.setValue("" + (Long.parseLong(jsJob.getJobParamValue("age")) / 86400L));
                } else {
                    scheduleTextBox.setText("180");
                }
                scheduleTextBox.addChangeHandler(new ChangeHandler() {

                    public void onChange(ChangeEvent event) {
                        if (jsJob != null) {
                            JsArray<JsJobParam> params = jsJob.getJobParams();
                            for (int i = 0; i < params.length(); i++) {
                                if (params.get(i).getName().equals("age")) {
                                    params.get(i).setValue("" + (Long.parseLong(scheduleTextBox.getText()) * 86400L));
                                    break;
                                }
                            }
                        }
                    }
                });
                Label settingsLabel = new Label(Messages.getString("settings"));
                settingsLabel.setStyleName("pentaho-fieldgroup-major");
                add(settingsLabel, DockPanel.NORTH);
                VerticalPanel nowPanelWrapper = new VerticalPanel();
                Label deleteNowLabel = new Label(Messages.getString("deleteGeneratedFilesNow"));
                deleteNowLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
                deleteNowLabel.setStyleName("pentaho-fieldgroup-minor");
                nowPanelWrapper.add(deleteNowLabel);
                HorizontalPanel nowLabelPanel = new HorizontalPanel();
                nowLabelPanel.getElement().getStyle().setPaddingTop(10, Unit.PX);
                nowLabelPanel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
                Label deleteGeneratedFilesOlderThan = new Label(Messages.getString("deleteGeneratedFilesOlderThan"));
                deleteGeneratedFilesOlderThan.getElement().getStyle().setPaddingTop(7, Unit.PX);
                nowLabelPanel.add(deleteGeneratedFilesOlderThan);
                nowLabelPanel.add(nowTextBox);
                nowTextBox.setText("180");
                Label days = new Label(Messages.getString("daysDot"));
                days.getElement().getStyle().setPaddingTop(7, Unit.PX);
                nowLabelPanel.add(days);
                Button deleteNowButton = new Button(Messages.getString("deleteNow"));
                deleteNowButton.setStylePrimaryName("pentaho-button");
                deleteNowButton.addStyleName("first");
                deleteNowButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        MessageDialogBox warning = new MessageDialogBox(Messages.getString("deleteNow"), Messages.getString("confirmDeleteGeneratedContentNow"), false, false, true, Messages.getString("yes"), null, Messages.getString("no"));
                        warning.setCallback(new IDialogCallback() {

                            @Override
                            public void okPressed() {
                                deleteContentNow(Long.parseLong(nowTextBox.getValue()) * 86400L);
                            }

                            @Override
                            public void cancelPressed() {
                            }
                        });
                        warning.center();
                    }
                });
                nowPanelWrapper.add(nowLabelPanel);
                nowPanelWrapper.add(deleteNowButton);
                add(nowPanelWrapper, DockPanel.NORTH);
                // scheduled
                VerticalPanel scheduledPanel = new VerticalPanel();
                Label deleteScheduleLabel = new Label(Messages.getString("scheduleDeletionOfGeneratedFiles"));
                deleteScheduleLabel.setStyleName("pentaho-fieldgroup-minor");
                deleteScheduleLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
                scheduledPanel.add(deleteScheduleLabel);
                Label descLabel;
                if (!fakeJob) {
                    String desc = jsJob.getJobTrigger().getDescription();
                    descLabel = new Label(desc);
                    scheduledPanel.add(descLabel);
                } else {
                    descLabel = new Label(Messages.getString("generatedFilesAreNotScheduledToBeDeleted"));
                    scheduledPanel.add(descLabel);
                }
                descLabel.getElement().getStyle().setPaddingTop(10, Unit.PX);
                descLabel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
                Button editScheduleButton = new Button(Messages.getString("edit"));
                if (fakeJob) {
                    editScheduleButton.setText(Messages.getString("scheduleDeletion"));
                }
                Button deleteScheduleButton = new Button(Messages.getString("cancelSchedule"));
                deleteScheduleButton.setStylePrimaryName("pentaho-button");
                deleteScheduleButton.addStyleName("last");
                deleteScheduleButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        deleteContentCleaner(jsJob);
                    }
                });
                editScheduleButton.setStylePrimaryName("pentaho-button");
                editScheduleButton.addStyleName("first");
                editScheduleButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        IDialogCallback callback = new IDialogCallback() {

                            public void okPressed() {
                                deleteContentCleaner(jsJob);
                            }

                            public void cancelPressed() {
                            }
                        };
                        HorizontalPanel scheduleLabelPanel = new HorizontalPanel();
                        scheduleLabelPanel.add(new Label(Messages.getString("deleteGeneratedFilesOlderThan"), false));
                        scheduleLabelPanel.add(scheduleTextBox);
                        scheduleLabelPanel.add(new Label(Messages.getString("daysUsingTheFollowingRules"), false));
                        ScheduleRecurrenceDialog editSchedule = new ScheduleRecurrenceDialog(null, jsJob, callback, false, false, AbstractWizardDialog.ScheduleDialogType.SCHEDULER);
                        editSchedule.setShowSuccessDialog(false);
                        editSchedule.addCustomPanel(scheduleLabelPanel, DockPanel.NORTH);
                        editSchedule.center();
                    }
                });
                HorizontalPanel scheduleButtonPanel = new HorizontalPanel();
                scheduleButtonPanel.add(editScheduleButton);
                if (!fakeJob) {
                    scheduleButtonPanel.add(deleteScheduleButton);
                }
                scheduledPanel.add(scheduleButtonPanel);
                add(scheduledPanel, DockPanel.NORTH);
                VerticalPanel fillPanel = new VerticalPanel();
                add(fillPanel, DockPanel.NORTH);
                fillPanel.getElement().getParentElement().getStyle().setHeight(100, Unit.PCT);
            }
        });
    } catch (RequestException re) {
    // ignored
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Request(com.google.gwt.http.client.Request) Label(com.google.gwt.user.client.ui.Label) JsJobParam(org.pentaho.mantle.client.workspace.JsJobParam) JSONString(com.google.gwt.json.client.JSONString) TextBox(com.google.gwt.user.client.ui.TextBox) 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) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RequestCallback(com.google.gwt.http.client.RequestCallback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(com.google.gwt.user.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) JsJob(org.pentaho.mantle.client.workspace.JsJob) ScheduleRecurrenceDialog(org.pentaho.mantle.client.dialogs.scheduling.ScheduleRecurrenceDialog)

Example 25 with MessageDialogBox

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

the class EmailAdminPanelController method passivate.

public void passivate(final AsyncCallback<Boolean> callback) {
    if (isDirty) {
        MessageDialogBox messageBox = new MessageDialogBox(Messages.getString("confirm"), Messages.getString("dirtyStateMessage"), false, false, true, Messages.getString("yes"), null, Messages.getString("no"));
        messageBox.setCallback(new IDialogCallback() {

            @Override
            public void okPressed() {
                if (isPortValid(portTextBox.getValue())) {
                    setEmailConfig();
                    callback.onSuccess(true);
                    setDirty(false);
                } else {
                    new MessageDialogBox(Messages.getString("error"), Messages.getString("portValidationLength"), false, false, true).center();
                }
            }

            @Override
            public void cancelPressed() {
                callback.onSuccess(true);
                setDirty(false);
            }
        });
        messageBox.center();
    } else {
        callback.onSuccess(true);
    }
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)

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