Search in sources :

Example 6 with Hook

use of com.liferay.ide.hook.core.model.Hook in project liferay-ide by liferay.

the class AddServletFilterMappingAction method run.

@Override
protected Object run(Presentation context) {
    Element element = context.part().getLocalModelElement();
    Hook hook = element.nearest(Hook.class);
    return hook.getServletFilterMappings().insert();
}
Also used : Hook(com.liferay.ide.hook.core.model.Hook) Element(org.eclipse.sapphire.Element)

Example 7 with Hook

use of com.liferay.ide.hook.core.model.Hook in project liferay-ide by liferay.

the class SrcFoldersRelativePathService method roots.

@Override
public List<Path> roots() {
    List<Path> roots = new ArrayList<>();
    Hook hook = context(Hook.class);
    if (hook != null) {
        IProject project = hook.adapt(IProject.class);
        List<IFolder> folders = CoreUtil.getSourceFolders(JavaCore.create(project));
        for (final IFolder folder : folders) {
            roots.add(new Path(folder.getLocation().toPortableString()));
        }
    }
    return roots;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 8 with Hook

use of com.liferay.ide.hook.core.model.Hook in project liferay-ide by liferay.

the class DocrootRelativePathService method roots.

@Override
public List<Path> roots() {
    List<Path> roots = new ArrayList<>();
    Hook hook = context(Hook.class);
    if (hook != null) {
        IProject project = hook.adapt(IProject.class);
        // IDE-110
        IWebProject lrproject = LiferayCore.create(IWebProject.class, project);
        if (lrproject != null) {
            IFolder defaultDocroot = lrproject.getDefaultDocrootFolder();
            if (FileUtil.exists(defaultDocroot)) {
                roots.add(new Path(defaultDocroot.getLocation().toPortableString()));
            }
        }
    }
    return roots;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) IWebProject(com.liferay.ide.core.IWebProject) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 9 with Hook

use of com.liferay.ide.hook.core.model.Hook in project liferay-ide by liferay.

the class LiferayHookModelTests method strutsActionPathPossibleValuesCacheService.

@Test
public void strutsActionPathPossibleValuesCacheService() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("testPossibleValuesCache");
    op.setPluginType(PluginType.hook);
    final IProject hookProject = createAntProject(op);
    final IFolder webappRoot = LiferayCore.create(IWebProject.class, hookProject).getDefaultDocrootFolder();
    assertNotNull(webappRoot);
    final IFile hookXml = webappRoot.getFile("WEB-INF/liferay-hook.xml");
    assertEquals(true, hookXml.exists());
    final Hook hook = Hook6xx.TYPE.instantiate(new RootXmlResource(new XmlResourceStore(hookXml.getContents())));
    assertNotNull(hook);
    final ILiferayProject liferayProject = LiferayCore.create(hookProject);
    final ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
    final IPath strutsConfigPath = portal.getAppServerPortalDir().append("WEB-INF/struts-config.xml");
    final StrutsAction strutsAction = hook.getStrutsActions().insert();
    final Value<String> strutsActionPath = strutsAction.getStrutsActionPath();
    final TreeSet<String> vals1 = strutsActionPath.service(StrutsActionPathPossibleValuesCacheService.class).getPossibleValuesForPath(strutsConfigPath);
    final TreeSet<String> vals2 = strutsActionPath.service(StrutsActionPathPossibleValuesCacheService.class).getPossibleValuesForPath(strutsConfigPath);
    assertTrue(vals1 == vals2);
}
Also used : Hook(com.liferay.ide.hook.core.model.Hook) IFile(org.eclipse.core.resources.IFile) StrutsActionPathPossibleValuesCacheService(com.liferay.ide.hook.core.model.internal.StrutsActionPathPossibleValuesCacheService) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) XmlResourceStore(org.eclipse.sapphire.modeling.xml.XmlResourceStore) StrutsAction(com.liferay.ide.hook.core.model.StrutsAction) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) IProject(org.eclipse.core.resources.IProject) ILiferayProject(com.liferay.ide.core.ILiferayProject) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Aggregations

Hook (com.liferay.ide.hook.core.model.Hook)9 Path (org.eclipse.sapphire.modeling.Path)6 IFolder (org.eclipse.core.resources.IFolder)5 IWebProject (com.liferay.ide.core.IWebProject)4 IProject (org.eclipse.core.resources.IProject)4 CustomJspDir (com.liferay.ide.hook.core.model.CustomJspDir)3 IFile (org.eclipse.core.resources.IFile)3 IPath (org.eclipse.core.runtime.IPath)3 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)2 ILiferayProject (com.liferay.ide.core.ILiferayProject)2 CustomJsp (com.liferay.ide.hook.core.model.CustomJsp)2 StrutsAction (com.liferay.ide.hook.core.model.StrutsAction)2 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)2 ArrayList (java.util.ArrayList)2 Property (org.eclipse.sapphire.Property)2 RootXmlResource (org.eclipse.sapphire.modeling.xml.RootXmlResource)2 XmlResourceStore (org.eclipse.sapphire.modeling.xml.XmlResourceStore)2 Test (org.junit.Test)2 PortalPropertiesFile (com.liferay.ide.hook.core.model.PortalPropertiesFile)1 StrutsActionPathPossibleValuesCacheService (com.liferay.ide.hook.core.model.internal.StrutsActionPathPossibleValuesCacheService)1