use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class GenericResourceBundlePathService method computeRoots.
public final List<Path> computeRoots(IProject project) {
if (project == null) {
return new ArrayList<>();
}
List<Path> roots = new ArrayList<>();
IClasspathEntry[] cpEntries = CoreUtil.getClasspathEntries(project);
for (IClasspathEntry iClasspathEntry : cpEntries) {
if (IClasspathEntry.CPE_SOURCE == iClasspathEntry.getEntryKind()) {
IFolder folder = CoreUtil.getWorkspaceRoot().getFolder(iClasspathEntry.getPath());
IPath entryPath = folder.getLocation();
String fullPath = entryPath.toOSString();
Path sapphirePath = new Path(fullPath);
roots.add(sapphirePath);
}
}
return roots;
}
use of org.eclipse.sapphire.modeling.Path 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.modeling.Path 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;
}
use of org.eclipse.sapphire.modeling.Path 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;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class CustomJspPossibleValuesService method compute.
@Override
protected void compute(final Set<String> values) {
if (_possibleValues == null) {
IProject project = project();
ILiferayProject liferayProject = LiferayCore.create(project);
if (liferayProject != null) {
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
_portalDir = new Path(portal.getAppServerPortalDir().toPortableString());
if (_portalDir != null) {
File portalDirFile = _portalDir.toFile();
File htmlDirFile = new File(portalDirFile, "html");
List<File> fileValues = new LinkedList<>();
if (FileUtil.exists(htmlDirFile)) {
_findJSPFiles(new File[] { htmlDirFile }, fileValues);
} else {
File[] files = portalDirFile.listFiles(_jspfilter);
_findJSPFiles(files, fileValues);
}
_possibleValues = fileValues.toArray(new File[0]);
}
}
}
}
if (_possibleValues != null) {
for (File file : _possibleValues) {
values.add(new Path(file.getAbsolutePath()).makeRelativeTo(_portalDir).toPortableString());
}
}
}
Aggregations