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;
}
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;
}
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;
}
Aggregations