Search in sources :

Example 31 with MessageDialogBox

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

the class MantleSettingsManager method getMantleSettings.

private void getMantleSettings(final AsyncCallback<HashMap<String, String>> callback) {
    final RequestCallback internalCallback = new RequestCallback() {

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

        public void onResponseReceived(Request request, Response response) {
            JsArray<JsSetting> jsSettings = null;
            try {
                jsSettings = JsSetting.parseSettingsJson(response.getText());
            } catch (Throwable t) {
            // happens when there are no settings
            }
            for (int i = 0; i < jsSettings.length(); i++) {
                settings.put(jsSettings.get(i).getName(), jsSettings.get(i).getValue());
            }
            settings.put("is-administrator", "" + isAdministrator);
            if (callback != null) {
                callback.onSuccess(settings);
            }
            EventBusUtil.EVENT_BUS.fireEvent(new MantleSettingsLoadedEvent(settings));
        }
    };
    final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/mantle/settings");
    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    builder.setHeader("accept", "application/json");
    try {
        // $NON-NLS-1$
        final String url = GWT.getHostPageBaseURL() + "api/repo/files/canAdminister";
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
        builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.setHeader("accept", "text/plain");
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable caught) {
                try {
                    builder.sendRequest(null, internalCallback);
                } catch (RequestException e) {
                // ignored
                }
                // CHECKSTYLE IGNORE Indentation FOR NEXT 1 LINES
                MantleSettingsManager.getInstance().isAdministrator = false;
            }

            public void onResponseReceived(Request request, Response response) {
                try {
                    builder.sendRequest(null, internalCallback);
                } catch (RequestException e) {
                // ignored
                }
                // CHECKSTYLE IGNORE Indentation FOR NEXT 1 LINES
                MantleSettingsManager.getInstance().isAdministrator = isAdministrator;
            }
        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) RequestBuilder(com.google.gwt.http.client.RequestBuilder) Request(com.google.gwt.http.client.Request) MantleSettingsLoadedEvent(org.pentaho.mantle.client.events.MantleSettingsLoadedEvent) RequestException(com.google.gwt.http.client.RequestException)

Example 32 with MessageDialogBox

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

the class ScheduleCallback method okPressed.

@Override
public void okPressed() {
    // $NON-NLS-1$
    String extension = "";
    if (repositoryFile.getPath().lastIndexOf(".") > 0) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        extension = repositoryFile.getPath().substring(repositoryFile.getPath().lastIndexOf(".") + 1);
    }
    if (SolutionBrowserPanel.getInstance().getExecutableFileExtensions().contains(extension)) {
        IDialogCallback callback = new IDialogCallback() {

            @Override
            public void okPressed() {
                ScheduleCreateStatusDialog dialog = new ScheduleCreateStatusDialog();
                dialog.center();
            }

            @Override
            public void cancelPressed() {
            }
        };
        ScheduleHelper.showScheduleDialog(repositoryFile.getPath(), callback);
    } else {
        final MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("open"), Messages.getString("scheduleInvalidFileType", repositoryFile.getPath()), false, false, // $NON-NLS-1$ //$NON-NLS-2$
        true);
        dialogBox.setCallback(new IDialogCallback() {

            public void cancelPressed() {
            }

            public void okPressed() {
                dialogBox.hide();
            }
        });
        dialogBox.center();
        return;
    }
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)

Example 33 with MessageDialogBox

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

the class SolutionBrowserPanel method editFile.

public void editFile(final RepositoryFile file) {
    if (file.getName().endsWith(".analysisview.xaction")) {
        // $NON-NLS-1$
        openFile(file, COMMAND.RUN);
    } else {
        // check to see if a plugin supports editing
        ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(file.getName());
        if (plugin != null && plugin.hasCommand(COMMAND.EDIT)) {
            // load the editor for this plugin
            String editUrl = getPath() + "api/repos/" + pathToId(file.getPath()) + "/" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            (plugin != null && (plugin.getCommandPerspective(COMMAND.EDIT) != null) ? plugin.getCommandPerspective(COMMAND.EDIT) : "editor");
            // See if it's already loaded
            for (int i = 0; i < contentTabPanel.getTabCount(); i++) {
                Widget w = contentTabPanel.getTab(i).getContent();
                if (w instanceof IFrameTabPanel && ((IFrameTabPanel) w).getUrl().endsWith(editUrl)) {
                    // Already up, select and exit
                    contentTabPanel.selectTab(i);
                    return;
                }
            }
            contentTabPanel.showNewURLTab(Messages.getString("editingColon") + file.getTitle(), Messages.getString("editingColon") + file.getTitle(), editUrl, // $NON-NLS-1$ //$NON-NLS-2$
            true);
        } else {
            MessageDialogBox dialogBox = new // $NON-NLS-1$
            MessageDialogBox(// $NON-NLS-1$
            Messages.getString("error"), // $NON-NLS-1$
            Messages.getString("cannotEditFileType"), true, false, true);
            dialogBox.center();
        }
    }
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) Widget(com.google.gwt.user.client.ui.Widget) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) JsArrayString(com.google.gwt.core.client.JsArrayString) ContentTypePlugin(org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)

Example 34 with MessageDialogBox

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

the class SchedulesPanel method showValidateOutputLocationError.

private void showValidateOutputLocationError() {
    String title = Messages.getString("outputLocationErrorTitle");
    String message = Messages.getString("outputLocationErrorMessage");
    MessageDialogBox dialogBox = // $NON-NLS-1$
    new MessageDialogBox(title, message, false, false, true, Messages.getString("close"), null, null);
    dialogBox.addStyleName("pentaho-dialog-small");
    dialogBox.center();
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) JSONString(com.google.gwt.json.client.JSONString)

Example 35 with MessageDialogBox

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

the class SelectUserOrRoleDialog method fetchAllUsers.

public void fetchAllUsers(final ArrayList<String> existing, final Document fileInfo) {
    try {
        // $NON-NLS-1$
        final String url = GWT.getHostPageBaseURL() + "api/userrolelist/permission-users";
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
        // This header is required to force Internet Explorer to not cache values from the GET response.
        requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.setHeader("accept", "application/json");
        requestBuilder.sendRequest(null, new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                JsArrayString users = parseUsersJson(JsonUtils.escapeJsonForEval(response.getText()));
                // filter out existing
                usersListBox.clear();
                PermissionsPanel permPanel = new PermissionsPanel(null);
                for (int i = 0; i < users.length(); i++) {
                    String user = users.get(i);
                    if (!existing.contains(user)) {
                        usersListBox.addItem(user);
                    } else {
                        if (!permPanel.getNames(fileInfo, 0).contains(user) && permPanel.getNames(fileInfo, 1).contains(user)) {
                            // we have equal user/role pair(s) and role already in existing list
                            usersListBox.addItem(user);
                        }
                    }
                }
            }
        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    }
}
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) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) RequestException(com.google.gwt.http.client.RequestException) PermissionsPanel(org.pentaho.mantle.client.solutionbrowser.fileproperties.PermissionsPanel)

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