Search in sources :

Example 1 with IPluginPerspectiveManager

use of org.pentaho.platform.api.engine.perspective.IPluginPerspectiveManager in project pentaho-platform by pentaho.

the class DefaultPluginPerspectiveManagerIT method testPerspectiveManager.

@Test
public void testPerspectiveManager() {
    IPluginPerspectiveManager manager = PentahoSystem.get(IPluginPerspectiveManager.class);
    assertNotNull(manager);
    IPluginPerspective testPerspective = createTestPerspective("test-perspective-id", "test-perspective-title");
    manager.addPluginPerspective(testPerspective);
    assertEquals(1, manager.getPluginPerspectives().size());
    assertEquals("test-perspective-id", manager.getPluginPerspectives().get(0).getId());
    assertEquals("test-perspective-title", manager.getPluginPerspectives().get(0).getTitle());
    assertEquals("test-content-url", manager.getPluginPerspectives().get(0).getContentUrl());
    manager.getPluginPerspectives().get(0).setContentUrl("different");
    assertEquals("different", manager.getPluginPerspectives().get(0).getContentUrl());
    manager.removePluginPerspective(testPerspective);
    assertEquals(0, manager.getPluginPerspectives().size());
    manager.addPluginPerspective(createTestPerspective("test-perspective-id-1", "test-perspective-title-1"));
    manager.addPluginPerspective(createTestPerspective("test-perspective-id-2", "test-perspective-title-2"));
    manager.addPluginPerspective(createTestPerspective("test-perspective-id-3", "test-perspective-title-3"));
    manager.addPluginPerspective(createTestPerspective("test-perspective-id-4", "test-perspective-title-4"));
    manager.addPluginPerspective(createTestPerspective("test-perspective-id-5", "test-perspective-title-5"));
    assertEquals(5, manager.getPluginPerspectives().size());
    for (int i = 0; i < 5; i++) {
        assertEquals("test-perspective-id-" + (i + 1), manager.getPluginPerspectives().get(i).getId());
        assertEquals("test-perspective-title-" + (i + 1), manager.getPluginPerspectives().get(i).getTitle());
        assertEquals(500, manager.getPluginPerspectives().get(i).getLayoutPriority());
    }
    manager.clearPluginPerspectives();
    assertEquals(0, manager.getPluginPerspectives().size());
}
Also used : IPluginPerspectiveManager(org.pentaho.platform.api.engine.perspective.IPluginPerspectiveManager) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective) Test(org.junit.Test)

Example 2 with IPluginPerspectiveManager

use of org.pentaho.platform.api.engine.perspective.IPluginPerspectiveManager in project pentaho-platform by pentaho.

the class PluginManagerResource method getPluginPerpectives.

/**
 * Retrieve the list of plugin perspective in the platform
 *
 * @return list of <code> PluginPerspective </code>
 */
@GET
@Path("/perspectives")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public ArrayList<PluginPerspective> getPluginPerpectives() {
    IPluginPerspectiveManager manager = // $NON-NLS-1$
    PentahoSystem.get(IPluginPerspectiveManager.class, PentahoSessionHolder.getSession());
    ArrayList<PluginPerspective> perspectives = new ArrayList<PluginPerspective>();
    for (IPluginPerspective perspective : manager.getPluginPerspectives()) {
        PluginPerspective pp = new PluginPerspective();
        pp.setId(perspective.getId());
        pp.setTitle(perspective.getTitle());
        pp.setContentUrl(perspective.getContentUrl());
        pp.setLayoutPriority(perspective.getLayoutPriority());
        pp.setRequiredSecurityActions(perspective.getRequiredSecurityActions());
        pp.setResourceBundleUri(perspective.getResourceBundleUri());
        if (perspective.getOverlays() != null) {
            ArrayList<Overlay> safeOverlays = new ArrayList<Overlay>();
            for (XulOverlay orig : perspective.getOverlays()) {
                Overlay tempOverlay = new Overlay(orig.getId(), orig.getOverlayUri(), orig.getSource(), orig.getResourceBundleUri(), orig.getPriority());
                safeOverlays.add(tempOverlay);
            }
            pp.setOverlays(safeOverlays);
        }
        perspectives.add(pp);
    }
    return perspectives;
}
Also used : XulOverlay(org.pentaho.ui.xul.XulOverlay) ArrayList(java.util.ArrayList) XulOverlay(org.pentaho.ui.xul.XulOverlay) IPluginPerspectiveManager(org.pentaho.platform.api.engine.perspective.IPluginPerspectiveManager) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Aggregations

IPluginPerspectiveManager (org.pentaho.platform.api.engine.perspective.IPluginPerspectiveManager)2 IPluginPerspective (org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective)2 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Facet (org.codehaus.enunciate.Facet)1 Test (org.junit.Test)1 XulOverlay (org.pentaho.ui.xul.XulOverlay)1