Search in sources :

Example 6 with StringTokenizer

use of org.pentaho.gwt.widgets.client.utils.string.StringTokenizer in project pentaho-platform by pentaho.

the class DeleteFileCommand method performOperation.

protected void performOperation() {
    if (this.getSolutionPath() != null && this.getFileNames() != null && this.getFileIds() != null) {
        StringTokenizer pathTk = new StringTokenizer(this.getSolutionPath(), "\n");
        StringTokenizer nameTk = new StringTokenizer(this.getFileNames(), "\n");
        StringTokenizer idTk = new StringTokenizer(this.getFileIds(), "\n");
        // Build Arrays since we cannot pass complex objects from the js bus
        for (int i = 0; i < pathTk.countTokens(); i++) {
            filesToDelete.add(new SolutionBrowserFile(idTk.tokenAt(i), nameTk.tokenAt(i), pathTk.tokenAt(i)));
        }
        performOperation(true);
    } else {
        performOperation(true);
    }
}
Also used : SolutionBrowserFile(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserFile) StringTokenizer(org.pentaho.gwt.widgets.client.utils.string.StringTokenizer)

Example 7 with StringTokenizer

use of org.pentaho.gwt.widgets.client.utils.string.StringTokenizer in project pentaho-platform by pentaho.

the class MantleController method executeAdminContent.

private void executeAdminContent() {
    try {
        RequestCallback internalCallback = new RequestCallback() {

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

            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
                }
                if (jsSettings == null) {
                    return;
                }
                for (int i = 0; i < jsSettings.length(); i++) {
                    String content = jsSettings.get(i).getValue();
                    // $NON-NLS-1$
                    StringTokenizer nameValuePairs = new StringTokenizer(content, ";");
                    String perspective = null, content_panel_id = null, content_url = null;
                    for (int j = 0; j < nameValuePairs.countTokens(); j++) {
                        String currentToken = nameValuePairs.tokenAt(j).trim();
                        if (currentToken.startsWith("perspective=")) {
                            // $NON-NLS-1$
                            // $NON-NLS-1$
                            perspective = currentToken.substring("perspective=".length());
                        }
                        if (currentToken.startsWith("content-panel-id=")) {
                            // $NON-NLS-1$
                            // $NON-NLS-1$
                            content_panel_id = currentToken.substring("content-panel-id=".length());
                        }
                        if (currentToken.startsWith("content-url=")) {
                            // $NON-NLS-1$
                            // $NON-NLS-1$
                            content_url = currentToken.substring("content-url=".length());
                        }
                    }
                    if (content_panel_id != null && content_url != null) {
                        overrideContentPanelId = content_panel_id;
                        overrideContentUrl = content_url;
                    }
                    if (perspective != null) {
                        PerspectiveManager.getInstance().setPerspective(perspective);
                    }
                    if (perspective == null && content_panel_id == null && content_url == null) {
                        GwtMessageBox warning = new GwtMessageBox();
                        // $NON-NLS-1$
                        warning.setTitle(Messages.getString("warning"));
                        warning.setMessage(content);
                        warning.setButtons(new Object[GwtMessageBox.ACCEPT]);
                        // $NON-NLS-1$
                        warning.setAcceptLabel(Messages.getString("close"));
                        warning.show();
                    }
                }
            }
        };
        RequestBuilder builder = // $NON-NLS-1$
        new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/mantle/getAdminContent");
        builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        // $NON-NLS-1$ //$NON-NLS-2$
        builder.setHeader("accept", "application/json");
        builder.sendRequest(null, internalCallback);
    // TO DO Reset the menuItem click for browser and workspace here?
    } catch (RequestException e) {
    // ignore
    }
}
Also used : Response(com.google.gwt.http.client.Response) JsSetting(org.pentaho.mantle.client.usersettings.JsSetting) StringTokenizer(org.pentaho.gwt.widgets.client.utils.string.StringTokenizer) RequestCallback(com.google.gwt.http.client.RequestCallback) RequestBuilder(com.google.gwt.http.client.RequestBuilder) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) GwtMessageBox(org.pentaho.ui.xul.gwt.tags.GwtMessageBox)

Example 8 with StringTokenizer

use of org.pentaho.gwt.widgets.client.utils.string.StringTokenizer in project pentaho-platform by pentaho.

the class SolutionTree method select.

public void select(String path) {
    this.selectedPath = path;
    ArrayList<String> pathSegments = new ArrayList<String>();
    if (path != null) {
        if (path.startsWith("/")) {
            // $NON-NLS-1$
            path = path.substring(1);
        }
        StringTokenizer st = new StringTokenizer(path, '/');
        for (int i = 0; i < st.countTokens(); i++) {
            String token = st.tokenAt(i);
            pathSegments.add(token);
        }
    }
    TreeItem item = getTreeItem(pathSegments);
    selectedItem = item;
    ArrayList<TreeItem> parents = new ArrayList<TreeItem>();
    if (item != null) {
        this.setSelectedItem(item, false);
        parents.add(item);
        item = item.getParentItem();
        while (item != null) {
            parents.add(item);
            item = item.getParentItem();
        }
        Collections.reverse(parents);
        selectFromList(parents);
    // this.setSelectedItem(selectedItem, false);
    // selectedItem.setSelected(true);
    }
}
Also used : StringTokenizer(org.pentaho.gwt.widgets.client.utils.string.StringTokenizer) TreeItem(com.google.gwt.user.client.ui.TreeItem) ArrayList(java.util.ArrayList)

Example 9 with StringTokenizer

use of org.pentaho.gwt.widgets.client.utils.string.StringTokenizer in project pentaho-platform by pentaho.

the class JsCreateNewConfig method getActionUrl.

public final String getActionUrl() {
    String value = getValue();
    StringTokenizer st = new StringTokenizer(value, ',');
    return st.tokenAt(3).trim();
}
Also used : StringTokenizer(org.pentaho.gwt.widgets.client.utils.string.StringTokenizer)

Example 10 with StringTokenizer

use of org.pentaho.gwt.widgets.client.utils.string.StringTokenizer in project pentaho-platform by pentaho.

the class JsCreateNewConfig method getEnabledUrl.

public final String getEnabledUrl() {
    String value = getValue();
    StringTokenizer st = new StringTokenizer(value, ',');
    if (st.countTokens() < 5) {
        return null;
    } else {
        return st.tokenAt(4).trim();
    }
}
Also used : StringTokenizer(org.pentaho.gwt.widgets.client.utils.string.StringTokenizer)

Aggregations

StringTokenizer (org.pentaho.gwt.widgets.client.utils.string.StringTokenizer)11 SolutionBrowserFile (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserFile)3 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 TreeItem (com.google.gwt.user.client.ui.TreeItem)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 JsSetting (org.pentaho.mantle.client.usersettings.JsSetting)1 GwtMessageBox (org.pentaho.ui.xul.gwt.tags.GwtMessageBox)1