Search in sources :

Example 1 with FMStackFrame

use of com.liferay.ide.portal.core.debug.fm.FMStackFrame in project liferay-ide by liferay.

the class PortalSourceLookupParticipant method getSourceName.

public String getSourceName(Object object) throws CoreException {
    String retval = null;
    if (object instanceof FMStackFrame) {
        try {
            FMStackFrame frame = (FMStackFrame) object;
            String templateName = getTemplateName(frame);
            // if( templateName.matches( "^\\d+#\\d+#\\d+$" ) ) //$NON-NLS-1$
            // {
            // retval = templateName + ".ftl"; //$NON-NLS-1$
            // }
            // else
            // {
            // we need to figure out how to map this back to a valid project path.
            // first if it contains a path that points to an existing plugin project
            IPath templatePath = new Path(templateName);
            final String firstSegment = templatePath.segment(0);
            final String resourcePath = templatePath.removeFirstSegments(1).toPortableString();
            IProject project = ServerUtil.findProjectByContextName(firstSegment);
            final IWebProject webproject = LiferayCore.create(IWebProject.class, project);
            if (webproject != null) {
                // first lets see if we can find
                final String diffsPath = "_diffs/" + resourcePath;
                final IResource diffsResourceFile = webproject.findDocrootResource(new Path(diffsPath));
                if (diffsResourceFile.exists()) {
                    retval = diffsPath;
                } else {
                    final IResource resourceFile = webproject.findDocrootResource(new Path(resourcePath));
                    if (resourceFile.exists()) {
                        retval = resourcePath;
                    }
                }
            }
        } catch (Exception e) {
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) FMStackFrame(com.liferay.ide.portal.core.debug.fm.FMStackFrame) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException)

Example 2 with FMStackFrame

use of com.liferay.ide.portal.core.debug.fm.FMStackFrame in project liferay-ide by liferay.

the class PortalSourceLookupParticipant method findSourceElements.

@Override
public Object[] findSourceElements(Object object) throws CoreException {
    Object[] retval = null;
    final Object[] sourceElements = super.findSourceElements(object);
    if (object instanceof FMStackFrame) {
        String templateName = getTemplateName((IStackFrame) object);
        IProject project = getSourceProject(templateName);
        if (project != null) {
            // go through all containers and only include the ones in this project
            List<IResource> validSourceElements = new ArrayList<IResource>();
            for (Object sourceElement : sourceElements) {
                if (sourceElement instanceof IResource) {
                    IResource res = (IResource) sourceElement;
                    if (res.getProject().equals(project)) {
                        validSourceElements.add((IResource) sourceElement);
                    }
                }
            }
            // check for two source elements in the same project, try to weed one of them out
            if (validSourceElements.size() > 1) {
                for (Iterator<IResource> i = validSourceElements.iterator(); i.hasNext(); ) {
                    IResource res = i.next();
                    if (res.getProjectRelativePath().toPortableString().contains(// $NON-NLS-1$
                    "target/m2e-liferay/theme-resources")) {
                        i.remove();
                    }
                }
            }
            retval = validSourceElements.toArray(new Object[0]);
        }
    }
    if (retval == null) {
        retval = sourceElements;
    }
    return retval;
}
Also used : ArrayList(java.util.ArrayList) FMStackFrame(com.liferay.ide.portal.core.debug.fm.FMStackFrame) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 3 with FMStackFrame

use of com.liferay.ide.portal.core.debug.fm.FMStackFrame in project liferay-ide by liferay.

the class SuspendFreemarkerThreadHandler method getSelectedFMStackFrame.

private FMStackFrame getSelectedFMStackFrame(Object context) {
    Object selectedElement = getSelectedElement(context);
    FMThread fmThread = null;
    FMStackFrame fmStackFrame = null;
    if (selectedElement instanceof FMThread) {
        fmThread = (FMThread) selectedElement;
        if (fmThread.isSuspended()) {
            try {
                fmStackFrame = (FMStackFrame) fmThread.getTopStackFrame();
            } catch (DebugException e) {
            }
        }
    } else if (selectedElement instanceof FMStackFrame) {
        fmStackFrame = (FMStackFrame) selectedElement;
    }
    return fmStackFrame;
}
Also used : FMThread(com.liferay.ide.portal.core.debug.fm.FMThread) FMStackFrame(com.liferay.ide.portal.core.debug.fm.FMStackFrame) DebugException(org.eclipse.debug.core.DebugException)

Aggregations

FMStackFrame (com.liferay.ide.portal.core.debug.fm.FMStackFrame)3 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 DebugException (org.eclipse.debug.core.DebugException)2 IWebProject (com.liferay.ide.core.IWebProject)1 FMThread (com.liferay.ide.portal.core.debug.fm.FMThread)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1