Search in sources :

Example 46 with Path

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ArrayList(java.util.ArrayList) IFolder(org.eclipse.core.resources.IFolder)

Example 47 with Path

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;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) RelativePathService(org.eclipse.sapphire.services.RelativePathService) Value(org.eclipse.sapphire.Value)

Example 48 with Path

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;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) IWebProject(com.liferay.ide.core.IWebProject) Element(org.eclipse.sapphire.Element) RelativePathService(org.eclipse.sapphire.services.RelativePathService) CustomJspDir(com.liferay.ide.hook.core.model.CustomJspDir) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 49 with Path

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;
}
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 50 with Path

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());
        }
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) File(java.io.File) IFile(org.eclipse.core.resources.IFile) IProject(org.eclipse.core.resources.IProject) LinkedList(java.util.LinkedList)

Aggregations

Path (org.eclipse.sapphire.modeling.Path)71 IPath (org.eclipse.core.runtime.IPath)37 IStatus (org.eclipse.core.runtime.IStatus)18 Status (org.eclipse.sapphire.modeling.Status)18 IProject (org.eclipse.core.resources.IProject)17 SDK (com.liferay.ide.sdk.core.SDK)16 CoreException (org.eclipse.core.runtime.CoreException)16 IFile (org.eclipse.core.resources.IFile)12 File (java.io.File)9 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)8 ArrayList (java.util.ArrayList)8 IFolder (org.eclipse.core.resources.IFolder)8 Hook (com.liferay.ide.hook.core.model.Hook)6 Element (org.eclipse.sapphire.Element)6 CustomJspDir (com.liferay.ide.hook.core.model.CustomJspDir)5 IWebProject (com.liferay.ide.core.IWebProject)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 ValueProperty (org.eclipse.sapphire.ValueProperty)3 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)2