Search in sources :

Example 1 with DefaultPluginPerspective

use of org.pentaho.platform.plugin.services.pluginmgr.perspective.pojo.DefaultPluginPerspective in project pentaho-platform by pentaho.

the class PerspectiveManager method setupPerspectiveManager.

private void setupPerspectiveManager() {
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/plugin-manager/perspectives?ts=" + System.currentTimeMillis();
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    // $NON-NLS-1$//$NON-NLS-2$
    builder.setHeader("Content-Type", "application/json");
    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        builder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                Window.alert("getPluginPerpectives fail: " + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                JsArray<JsPerspective> jsperspectives = JsPerspective.parseJson(JsonUtils.escapeJsonForEval(response.getText()));
                ArrayList<IPluginPerspective> perspectives = new ArrayList<IPluginPerspective>();
                for (int i = 0; i < jsperspectives.length(); i++) {
                    JsPerspective jsperspective = jsperspectives.get(i);
                    // Don't include schedules if user doesn't have schedule permissions
                    if ("${schedules}".equals(jsperspective.getTitle()) && !canSchedule) {
                        continue;
                    }
                    DefaultPluginPerspective perspective = new DefaultPluginPerspective();
                    perspective.setContentUrl(jsperspective.getContentUrl());
                    perspective.setId(jsperspective.getId());
                    perspective.setLayoutPriority(Integer.parseInt(jsperspective.getLayoutPriority()));
                    ArrayList<String> requiredSecurityActions = new ArrayList<String>();
                    if (jsperspective.getRequiredSecurityActions() != null) {
                        for (int j = 0; j < jsperspective.getRequiredSecurityActions().length(); j++) {
                            requiredSecurityActions.add(jsperspective.getRequiredSecurityActions().get(j));
                        }
                    }
                    // will need to iterate over jsoverlays and convert to MantleXulOverlay
                    ArrayList<XulOverlay> overlays = new ArrayList<XulOverlay>();
                    if (jsperspective.getOverlays() != null) {
                        for (int j = 0; j < jsperspective.getOverlays().length(); j++) {
                            JsXulOverlay o = jsperspective.getOverlays().get(j);
                            MantleXulOverlay overlay = new MantleXulOverlay(o.getId(), o.getOverlayUri(), o.getSource(), o.getResourceBundleUri());
                            overlays.add(overlay);
                        }
                    }
                    perspective.setOverlays(overlays);
                    perspective.setRequiredSecurityActions(requiredSecurityActions);
                    perspective.setResourceBundleUri(jsperspective.getResourceBundleUri());
                    perspective.setTitle(jsperspective.getTitle());
                    perspectives.add(perspective);
                }
                setPluginPerspectives(perspectives);
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
    registerFunctions(this);
}
Also used : JsArray(com.google.gwt.core.client.JsArray) RequestBuilder(com.google.gwt.http.client.RequestBuilder) DefaultPluginPerspective(org.pentaho.platform.plugin.services.pluginmgr.perspective.pojo.DefaultPluginPerspective) Request(com.google.gwt.http.client.Request) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString) JsXulOverlay(org.pentaho.mantle.client.ui.xul.JsXulOverlay) RequestException(com.google.gwt.http.client.RequestException) JsPerspective(org.pentaho.mantle.client.ui.xul.JsPerspective) Response(com.google.gwt.http.client.Response) XulOverlay(org.pentaho.ui.xul.XulOverlay) JsXulOverlay(org.pentaho.mantle.client.ui.xul.JsXulOverlay) MantleXulOverlay(org.pentaho.mantle.client.objects.MantleXulOverlay) RequestCallback(com.google.gwt.http.client.RequestCallback) MantleXulOverlay(org.pentaho.mantle.client.objects.MantleXulOverlay) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective)

Example 2 with DefaultPluginPerspective

use of org.pentaho.platform.plugin.services.pluginmgr.perspective.pojo.DefaultPluginPerspective in project pentaho-platform by pentaho.

the class PerspectiveUtil method createPerspective.

static IPluginPerspective createPerspective(Element perspectiveNode) {
    if (perspectiveNode != null) {
        // $NON-NLS-1$
        String title = perspectiveNode.attributeValue("title");
        // $NON-NLS-1$
        String id = perspectiveNode.attributeValue("id");
        // $NON-NLS-1$
        String contentUrl = perspectiveNode.attributeValue("content-url");
        // $NON-NLS-1$
        String resourceBundleUri = perspectiveNode.attributeValue("resourcebundle");
        // $NON-NLS-1$
        String layoutPriorityStr = perspectiveNode.attributeValue("layout-priority");
        int layoutPriority = DEFAULT_LAYOUT_PRIORITY;
        if (layoutPriorityStr != null && layoutPriorityStr.length() > 0) {
            try {
                layoutPriority = Integer.parseInt(layoutPriorityStr);
            } catch (Exception e) {
                layoutPriority = DEFAULT_LAYOUT_PRIORITY;
            }
        }
        String securityActionStr = perspectiveNode.attributeValue("required-security-action");
        ArrayList<String> actions = new ArrayList<String>();
        if (securityActionStr != null) {
            StringTokenizer st = new StringTokenizer(securityActionStr, ";, ");
            while (st.hasMoreTokens()) {
                String action = st.nextToken();
                actions.add(action);
            }
        }
        // $NON-NLS-1$
        ArrayList<XulOverlay> overlays = processOverlays(perspectiveNode);
        IPluginPerspective perspective = new DefaultPluginPerspective();
        perspective.setTitle(title);
        perspective.setId(id);
        perspective.setContentUrl(contentUrl);
        perspective.setLayoutPriority(layoutPriority);
        perspective.setOverlays(overlays);
        perspective.setRequiredSecurityActions(actions);
        perspective.setResourceBundleUri(resourceBundleUri);
        return perspective;
    }
    return null;
}
Also used : XulOverlay(org.pentaho.ui.xul.XulOverlay) DefaultXulOverlay(org.pentaho.ui.xul.impl.DefaultXulOverlay) StringTokenizer(java.util.StringTokenizer) DefaultPluginPerspective(org.pentaho.platform.plugin.services.pluginmgr.perspective.pojo.DefaultPluginPerspective) ArrayList(java.util.ArrayList) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective)

Example 3 with DefaultPluginPerspective

use of org.pentaho.platform.plugin.services.pluginmgr.perspective.pojo.DefaultPluginPerspective in project pentaho-platform by pentaho.

the class DefaultPluginPerspectiveManagerIT method createTestPerspective.

private IPluginPerspective createTestPerspective(final String id, final String title) {
    IPluginPerspective perspective = new DefaultPluginPerspective();
    perspective.setId(id);
    perspective.setTitle(title);
    perspective.setContentUrl("test-content-url");
    perspective.setLayoutPriority(500);
    return perspective;
}
Also used : DefaultPluginPerspective(org.pentaho.platform.plugin.services.pluginmgr.perspective.pojo.DefaultPluginPerspective) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective)

Aggregations

IPluginPerspective (org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective)3 DefaultPluginPerspective (org.pentaho.platform.plugin.services.pluginmgr.perspective.pojo.DefaultPluginPerspective)3 ArrayList (java.util.ArrayList)2 XulOverlay (org.pentaho.ui.xul.XulOverlay)2 JsArray (com.google.gwt.core.client.JsArray)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 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 StringTokenizer (java.util.StringTokenizer)1 MantleXulOverlay (org.pentaho.mantle.client.objects.MantleXulOverlay)1 JsPerspective (org.pentaho.mantle.client.ui.xul.JsPerspective)1 JsXulOverlay (org.pentaho.mantle.client.ui.xul.JsXulOverlay)1 DefaultXulOverlay (org.pentaho.ui.xul.impl.DefaultXulOverlay)1