Search in sources :

Example 1 with PortletStyleElement

use of com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement in project liferay-ide by liferay.

the class PortletStyleValidationService method compute.

@Override
protected Status compute() {
    Element modelElement = context(Element.class);
    if (!modelElement.disposed() && modelElement instanceof PortletStyleElement) {
        Path path = (Path) modelElement.property(context(ValueProperty.class)).content();
        if (path != null) {
            String name = path.lastSegment();
            IProject project = modelElement.adapt(IProject.class);
            boolean fileExisted = new FileCheckVisitor().checkFiles(project, name);
            if (!fileExisted) {
                return Status.createErrorStatus("File " + path.toPortableString() + " is not existed");
            }
        } else {
            return Status.createErrorStatus("Can not set empty value");
        }
    }
    return Status.createOkStatus();
}
Also used : Path(org.eclipse.sapphire.modeling.Path) PortletStyleElement(com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement) Element(org.eclipse.sapphire.Element) PortletStyleElement(com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement) ValueProperty(org.eclipse.sapphire.ValueProperty) IProject(org.eclipse.core.resources.IProject)

Example 2 with PortletStyleElement

use of com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement in project liferay-ide by liferay.

the class LiferayPortletXmlTest method testLiferayScriptPossibleValuesService.

@Test
public void testLiferayScriptPossibleValuesService() throws Exception {
    if (shouldSkipBundleTests())
        return;
    NewLiferayPluginProjectOp newProjectOp = NewLiferayPluginProjectOp.TYPE.instantiate();
    newProjectOp.setProjectName("test-script");
    newProjectOp.setPluginType(PluginType.portlet);
    newProjectOp.setIncludeSampleCode(true);
    newProjectOp.setPortletFramework("mvc");
    newProjectOp.setPortletName("testPortlet");
    final IProject testProject = createAntProject(newProjectOp);
    LiferayPortletXml liferayPortletApp = op(testProject);
    for (LiferayPortlet liferayPortlet : liferayPortletApp.getPortlets()) {
        ElementList<PortletStyleElement> portletCsses = liferayPortlet.getHeaderPortletCsses();
        {
            for (PortletStyleElement portletCss : portletCsses) {
                final PossibleValuesService scriptService = portletCss.getValue().service(PossibleValuesService.class);
                assertEquals(true, scriptService.values().contains("/css/main.css"));
            }
        }
    }
}
Also used : PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) LiferayPortletXml(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) PortletStyleElement(com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement) LiferayPortlet(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 3 with PortletStyleElement

use of com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement in project liferay-ide by liferay.

the class LiferayPortletXmlTest method testPortletXmlRead.

@Test
public void testPortletXmlRead() throws Exception {
    final LiferayPortletXml portletApp = op(PORTLET_XML);
    assertNotNull(portletApp);
    final ElementList<LiferayPortlet> portlets = portletApp.getPortlets();
    assertNotNull(portlets);
    assertEquals(1, portlets.size());
    final LiferayPortlet portlet = portlets.get(0);
    assertNotNull(portlet);
    assertEquals("new", portlet.getPortletName().content());
    assertEquals("/icon.png", portlet.getIcon().content().toPortableString());
    assertEquals("/testStrutsPath", portlet.getStrutsPath().content());
    assertEquals("com.test.configuration.Test", portlet.getConfigurationActionClass().content().toString());
    String[] indexerClassNames = { "com.test.index.Test1", "com.test.index.Test2", "com.test.index.Test3" };
    final ElementList<IndexerClass> indexerClasses = portlet.getIndexerClasses();
    assertNotNull(indexerClasses);
    for (IndexerClass indexer : indexerClasses) {
        assertEquals(true, Arrays.asList(indexerClassNames).contains(indexer.getValue().toString()));
    }
    String[] schedulerEntryDescriptions = { "scheduler cron entry test", "scheduler simple entry test" };
    String[] schedulerEntryClasses = { "com.test.schedulerEntry.TestScheduler1", "com.test.schedulerEntry.TestScheduler2" };
    final ElementList<SchedulerEntry> schedulerEntris = portlet.getSchedulerEntries();
    assertNotNull(schedulerEntris);
    for (SchedulerEntry schedulerEntry : schedulerEntris) {
        assertEquals(true, Arrays.asList(schedulerEntryDescriptions).contains(schedulerEntry.getSchedulerDescription().content()));
        assertEquals(true, Arrays.asList(schedulerEntryClasses).contains(schedulerEntry.getSchedulerEventListenerClass().toString()));
        ElementHandle<ITrigger> trigger = schedulerEntry.getPortletTrigger();
        if (trigger.content() instanceof CronTrigger) {
            CronTrigger cronTrigger = (CronTrigger) (trigger.content());
            ElementHandle<ICronTrigger> cronTriggerDetail = cronTrigger.getCronTrigger();
            if (cronTriggerDetail.content() instanceof PropertyCronTrigger) {
                PropertyCronTrigger propertyTrigger = (PropertyCronTrigger) cronTriggerDetail.content();
                assertEquals("cron", propertyTrigger.getPropertyKey().content());
            } else if (cronTriggerDetail.content() instanceof CronTriggerValueTrigger) {
                CronTriggerValueTrigger valueTrigger = (CronTriggerValueTrigger) cronTriggerDetail.content();
                assertEquals("15", valueTrigger.getCronTriggerValue().content());
            }
        } else {
            SimpleTrigger simpleTrigger = (SimpleTrigger) (trigger.content());
            ElementHandle<ISimpleTrigger> simpleTriggerDetail = simpleTrigger.getSimpleTrigger();
            if (simpleTriggerDetail.content() instanceof PropertySimpleTrigger) {
                PropertySimpleTrigger propertyTrigger = (PropertySimpleTrigger) simpleTriggerDetail.content();
                assertEquals("simple", propertyTrigger.getPropertyKey().content());
            } else if (simpleTriggerDetail.content() instanceof SimpleTriggerValueTrigger) {
                SimpleTriggerValueTrigger valueTrigger = (SimpleTriggerValueTrigger) simpleTriggerDetail.content();
                assertEquals("15", valueTrigger.getSimpleTriggerValue().content());
            }
            assertEquals("minute", simpleTrigger.getTimeUnit().content());
        }
    }
    assertEquals("com.test.friendUrlMapper.Test", portlet.getFriendlyURLMapperClass().content().toString());
    assertEquals("test", portlet.getFriendlyURLMapping().toString());
    assertEquals("test", portlet.getFriendlyURLRoutes().toString());
    assertEquals("com.test.portletDataHandler.Test", portlet.getPortletDataHandlerClass().content().toString());
    final ElementList<StagedModelDataHandlerClass> stageHandlers = portlet.getStagedModelDataHandlerClasses();
    assertNotNull(stageHandlers);
    String[] stageHandlersValue = { "com.test.stagedModelDataHandler.Test1", "com.test.stagedModelDataHandler.Test2", "com.test.stagedModelDataHandler.Test3" };
    for (StagedModelDataHandlerClass stageHandler : stageHandlers) {
        assertEquals(true, Arrays.asList(stageHandlersValue).contains(stageHandler.getValue().content().toString()));
    }
    final ElementList<SocialActivityInterpreterClass> socialActivities = portlet.getSocialActivityInterpreterClasses();
    assertNotNull(socialActivities);
    String[] socialActivityValues = { "com.test.socialActivityListener.Test1", "com.test.socialActivityListener.Test2", "com.test.socialActivityListener.Test3" };
    for (SocialActivityInterpreterClass socialActivity : socialActivities) {
        assertEquals(true, Arrays.asList(socialActivityValues).contains(socialActivity.getValue().content().toString()));
    }
    assertEquals("my", portlet.getControlPanelEntryCategory().content());
    assertEquals(new Double(1.5), portlet.getControlPanelEntryWeight().content());
    assertEquals("com.test.NewPortletControlPanelEntry", portlet.getControlPanelEntryClass().content().toString());
    final ElementList<AssetRendererFactory> assetHandlers = portlet.getAssetRendererFactories();
    assertNotNull(assetHandlers);
    String[] assetHandlersValues = { "com.test.assetRenderFactory.Test1", "com.test.assetRenderFactory.Test2", "com.test.assetRenderFactory.Test3" };
    for (AssetRendererFactory assetHandler : assetHandlers) {
        assertEquals(true, Arrays.asList(assetHandlersValues).contains(assetHandler.getValue().content().toString()));
    }
    final ElementList<TrashHandler> trashHanlders = portlet.getTrashHandlers();
    assertNotNull(trashHanlders);
    String[] trashHanldersValues = { "com.test.trashHandler.Test1", "com.test.trashHandler.Test2", "com.test.trashHandler.Test3" };
    for (TrashHandler trashHanlder : trashHanlders) {
        assertEquals(true, Arrays.asList(trashHanldersValues).contains(trashHanlder.getValue().content().toString()));
    }
    // workflow test
    final ElementList<PortletStyleElement> headerPortletCsses = portlet.getHeaderPortletCsses();
    assertNotNull(headerPortletCsses);
    String[] headerPortletCssesValues = { "/css/portlet1.css", "/css/portlet2.css", "/css/portlet3.css" };
    for (PortletStyleElement headerPortalCss : headerPortletCsses) {
        assertEquals(true, Arrays.asList(headerPortletCssesValues).contains(headerPortalCss.getValue().content().toPortableString()));
    }
    final ElementList<PortletStyleElement> headerPortletJses = portlet.getHeaderPortletJavascripts();
    assertNotNull(headerPortletJses);
    String[] headerPortletJsesValues = { "/js/portlet1.js", "/js/portlet2.js", "/js/portlet3.js" };
    for (PortletStyleElement headerPortletJs : headerPortletJses) {
        assertEquals(true, Arrays.asList(headerPortletJsesValues).contains(headerPortletJs.getValue().content().toPortableString()));
    }
    final ElementList<PortletStyleElement> footerPortletJses = portlet.getFooterPortletJavascripts();
    assertNotNull(footerPortletJses);
    String[] footerPortletJsesValues = { "/js/portlet1.js", "/js/portlet2.js", "/js/portlet3.js" };
    for (PortletStyleElement footerPortletJs : footerPortletJses) {
        assertEquals(true, Arrays.asList(footerPortletJsesValues).contains(footerPortletJs.getValue().content().toPortableString()));
    }
    assertEquals("test", portlet.getCssClassWrapper().toString());
    assertEquals("test", portlet.getCssClassWrapper().content());
    final ElementList<SecurityRoleRef> roleMappers = portletApp.getRoleMappers();
    assertNotNull(roleMappers);
    String[] roleMapperNameValues = { "administrator", "guest", "power-user", "user" };
    String[] roleMapperLinkValues = { "Administrator", "Guest", "Power User", "User" };
    for (SecurityRoleRef roleMapper : roleMappers) {
        assertEquals(true, Arrays.asList(roleMapperNameValues).contains(roleMapper.getRoleName().content()));
        assertEquals(true, Arrays.asList(roleMapperLinkValues).contains(roleMapper.getRoleLink().content()));
    }
    final ElementList<CustomUserAttribute> userAttributes = portletApp.getCustomUserAttributes();
    assertNotNull(userAttributes);
    String[] attributeNameValues = { "tag1", "tag2", "tag3" };
    String[] attributeClassValues = { "com.test.customUserAttribute.Test1" };
    for (CustomUserAttribute attribute : userAttributes) {
        ElementList<CutomUserAttributeName> attributeNames = attribute.getCustomUserAttributeNames();
        assertNotNull(attributeNames);
        for (CutomUserAttributeName attributeName : attributeNames) {
            assertEquals(true, Arrays.asList(attributeNameValues).contains(attributeName.getValue().content()));
        }
        assertEquals(true, Arrays.asList(attributeClassValues).contains(attribute.getCustomClass().toString()));
    }
}
Also used : ISimpleTrigger(com.liferay.ide.portlet.core.lfportlet.model.ISimpleTrigger) SimpleTriggerValueTrigger(com.liferay.ide.portlet.core.lfportlet.model.SimpleTriggerValueTrigger) SecurityRoleRef(com.liferay.ide.portlet.core.model.SecurityRoleRef) LiferayPortlet(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet) AssetRendererFactory(com.liferay.ide.portlet.core.lfportlet.model.AssetRendererFactory) LiferayPortletXml(com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml) SocialActivityInterpreterClass(com.liferay.ide.portlet.core.lfportlet.model.SocialActivityInterpreterClass) PropertySimpleTrigger(com.liferay.ide.portlet.core.lfportlet.model.PropertySimpleTrigger) SchedulerEntry(com.liferay.ide.portlet.core.lfportlet.model.SchedulerEntry) StagedModelDataHandlerClass(com.liferay.ide.portlet.core.lfportlet.model.StagedModelDataHandlerClass) ISimpleTrigger(com.liferay.ide.portlet.core.lfportlet.model.ISimpleTrigger) SimpleTrigger(com.liferay.ide.portlet.core.lfportlet.model.SimpleTrigger) PropertySimpleTrigger(com.liferay.ide.portlet.core.lfportlet.model.PropertySimpleTrigger) CronTrigger(com.liferay.ide.portlet.core.lfportlet.model.CronTrigger) ICronTrigger(com.liferay.ide.portlet.core.lfportlet.model.ICronTrigger) PropertyCronTrigger(com.liferay.ide.portlet.core.lfportlet.model.PropertyCronTrigger) TrashHandler(com.liferay.ide.portlet.core.lfportlet.model.TrashHandler) CutomUserAttributeName(com.liferay.ide.portlet.core.lfportlet.model.CutomUserAttributeName) CronTriggerValueTrigger(com.liferay.ide.portlet.core.lfportlet.model.CronTriggerValueTrigger) PortletStyleElement(com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement) ITrigger(com.liferay.ide.portlet.core.lfportlet.model.ITrigger) ICronTrigger(com.liferay.ide.portlet.core.lfportlet.model.ICronTrigger) IndexerClass(com.liferay.ide.portlet.core.lfportlet.model.IndexerClass) CustomUserAttribute(com.liferay.ide.portlet.core.lfportlet.model.CustomUserAttribute) PropertyCronTrigger(com.liferay.ide.portlet.core.lfportlet.model.PropertyCronTrigger) Test(org.junit.Test)

Aggregations

PortletStyleElement (com.liferay.ide.portlet.core.lfportlet.model.PortletStyleElement)3 LiferayPortlet (com.liferay.ide.portlet.core.lfportlet.model.LiferayPortlet)2 LiferayPortletXml (com.liferay.ide.portlet.core.lfportlet.model.LiferayPortletXml)2 IProject (org.eclipse.core.resources.IProject)2 Test (org.junit.Test)2 AssetRendererFactory (com.liferay.ide.portlet.core.lfportlet.model.AssetRendererFactory)1 CronTrigger (com.liferay.ide.portlet.core.lfportlet.model.CronTrigger)1 CronTriggerValueTrigger (com.liferay.ide.portlet.core.lfportlet.model.CronTriggerValueTrigger)1 CustomUserAttribute (com.liferay.ide.portlet.core.lfportlet.model.CustomUserAttribute)1 CutomUserAttributeName (com.liferay.ide.portlet.core.lfportlet.model.CutomUserAttributeName)1 ICronTrigger (com.liferay.ide.portlet.core.lfportlet.model.ICronTrigger)1 ISimpleTrigger (com.liferay.ide.portlet.core.lfportlet.model.ISimpleTrigger)1 ITrigger (com.liferay.ide.portlet.core.lfportlet.model.ITrigger)1 IndexerClass (com.liferay.ide.portlet.core.lfportlet.model.IndexerClass)1 PropertyCronTrigger (com.liferay.ide.portlet.core.lfportlet.model.PropertyCronTrigger)1 PropertySimpleTrigger (com.liferay.ide.portlet.core.lfportlet.model.PropertySimpleTrigger)1 SchedulerEntry (com.liferay.ide.portlet.core.lfportlet.model.SchedulerEntry)1 SimpleTrigger (com.liferay.ide.portlet.core.lfportlet.model.SimpleTrigger)1 SimpleTriggerValueTrigger (com.liferay.ide.portlet.core.lfportlet.model.SimpleTriggerValueTrigger)1 SocialActivityInterpreterClass (com.liferay.ide.portlet.core.lfportlet.model.SocialActivityInterpreterClass)1