Search in sources :

Example 71 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class NewMavenJSFModuleProjectProvider method validateProjectLocation.

@Override
public IStatus validateProjectLocation(String projectName, IPath path) {
    IStatus retval = Status.OK_STATUS;
    Path currentProjectLocation = PathBridge.create(path);
    boolean liferayWorkspace = false;
    if (currentProjectLocation != null) {
        liferayWorkspace = LiferayWorkspaceUtil.isValidWorkspaceLocation(currentProjectLocation.toOSString());
    }
    if (LiferayWorkspaceUtil.isValidWorkspaceLocation(currentProjectLocation.toOSString())) {
        retval = LiferayMavenCore.createErrorStatus("Can't set WorkspaceProject root folder as project directory.");
    }
    if (liferayWorkspace) {
        File workspaceDir = LiferayWorkspaceUtil.getWorkspaceDir(currentProjectLocation.toFile());
        if (FileUtil.notExists(workspaceDir)) {
            return LiferayCore.createErrorStatus("The project location of Liferay Workspace shoule be existed.");
        }
        String[] folders = LiferayWorkspaceUtil.getLiferayWorkspaceProjectWarsDirs(workspaceDir.getAbsolutePath());
        if (folders != null) {
            boolean appendWarFolder = false;
            IPath projectLocation = PathBridge.create(currentProjectLocation);
            for (String folder : folders) {
                if (projectLocation.lastSegment().endsWith(folder)) {
                    appendWarFolder = true;
                    break;
                }
            }
            if (appendWarFolder == false) {
                return LiferayMavenCore.createErrorStatus("The project location should be wars folder of Liferay workspace.");
            }
        } else {
            return LiferayMavenCore.createErrorStatus("The Liferay Workspace wasn't defined wars folder path.");
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) File(java.io.File)

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