use of org.eclipse.sapphire.services.RelativePathService in project liferay-ide by liferay.
the class LiferayPortletXmlTest method testIconRelativePathService.
@Test
public void testIconRelativePathService() throws Exception {
if (shouldSkipBundleTests())
return;
NewLiferayPluginProjectOp newProjectOp = NewLiferayPluginProjectOp.TYPE.instantiate();
newProjectOp.setProjectName("test-path");
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()) {
final RelativePathService pathService = liferayPortlet.getIcon().service(RelativePathService.class);
List<Path> iconPaths = pathService.roots();
assertEquals(true, iconPaths.size() > 0);
}
}
use of org.eclipse.sapphire.services.RelativePathService in project liferay-ide by liferay.
the class CreateDirectoryActionHandler method computeEnablementState.
@Override
protected boolean computeEnablementState() {
boolean enabled = super.computeEnablementState();
if (enabled) {
@SuppressWarnings("unchecked") Value<Path> value = (Value<Path>) getModelElement().property(property().definition());
Path path = value.content();
RelativePathService service = property().service(RelativePathService.class);
Path absolutePath = service.convertToAbsolute(path);
enabled = (absolutePath != null) && (!absolutePath.toFile().exists());
}
return enabled;
}
use of org.eclipse.sapphire.services.RelativePathService in project liferay-ide by liferay.
the class CreateDirectoryActionHandler method run.
@Override
protected Object run(Presentation context) {
try {
Element element = getModelElement();
IProject project = element.adapt(IProject.class);
CustomJspDir customJspDir = (CustomJspDir) element;
Path customJspDirValue = customJspDir.getValue().content(false);
if (customJspDirValue == null) {
customJspDirValue = customJspDir.getValue().content(true);
customJspDir.setValue(customJspDirValue);
}
customJspDir.setValue(customJspDirValue);
RelativePathService service = property().service(RelativePathService.class);
Path absolutePath = service.convertToAbsolute(customJspDirValue);
if (FileUtil.notExists(absolutePath)) {
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
IFolder customJspFolder = defaultDocroot.getFolder(new org.eclipse.core.runtime.Path(customJspDirValue.toPortableString()));
CoreUtil.makeFolders(customJspFolder);
// force a refresh of validation
customJspDir.setValue((Path) null);
customJspDir.setValue(customJspDirValue);
refreshEnablementState();
}
}
} catch (Exception e) {
HookUI.logError(e);
}
return null;
}
Aggregations