Search in sources :

Example 61 with Path

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

the class ModuleProjectNameValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    BaseModuleOp op = op();
    String currentProjectName = op.getProjectName().content();
    if (!CoreUtil.empty(currentProjectName)) {
        IStatus nameStatus = CoreUtil.getWorkspace().validateName(currentProjectName, IResource.PROJECT);
        if (!nameStatus.isOK()) {
            return StatusBridge.create(nameStatus);
        }
        if (ValidationUtil.isExistingProjectName(currentProjectName)) {
            return Status.createErrorStatus("A project with that name(ignore case) already exists.");
        }
        if (!_validProjectName(currentProjectName)) {
            return Status.createErrorStatus("The project name is invalid.");
        }
        Path currentProjectLocation = op.getLocation().content();
        if (currentProjectLocation != null) {
            String currentPath = currentProjectLocation.toOSString();
            IPath osPath = org.eclipse.core.runtime.Path.fromOSString(currentPath);
            NewLiferayProjectProvider<BaseModuleOp> provider = op.getProjectProvider().content();
            IStatus projectStatus = provider.validateProjectLocation(currentProjectName, osPath);
            if (!projectStatus.isOK()) {
                return StatusBridge.create(projectStatus);
            }
            File projectFodler = osPath.append(currentProjectName).toFile();
            if (FileUtil.hasChildren(projectFodler)) {
                return StatusBridge.create(ProjectCore.createErrorStatus("Target project folder is not empty."));
            }
        }
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) 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)

Example 62 with Path

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

the class ModuleFragmentProjectGroupIdDefaultValueService method compute.

@Override
protected String compute() {
    String groupId = null;
    NewModuleFragmentOp op = _op();
    Path location = op.getLocation().content();
    if (location != null) {
        String parentProjectLocation = location.toOSString();
        IPath parentProjectOsPath = org.eclipse.core.runtime.Path.fromOSString(parentProjectLocation);
        String projectName = op.getProjectName().content();
        groupId = NewModuleFragmentOpMethods.getMavenParentPomGroupId(op, projectName, parentProjectOsPath);
    }
    if (groupId == null) {
        groupId = _getDefaultMavenGroupId();
        if (CoreUtil.isNullOrEmpty(groupId)) {
            groupId = op.getProjectName().content();
        }
    }
    return groupId;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IPath(org.eclipse.core.runtime.IPath)

Example 63 with Path

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

the class ImportLiferayModuleProjectOpMethods method execute.

public static final Status execute(ImportLiferayModuleProjectOp op, ProgressMonitor pm) {
    IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
    monitor.beginTask("Importing Module project...", 100);
    Path path = op.getLocation().content();
    String location = path.toOSString();
    ILiferayProjectImporter importer = LiferayCore.getImporter(op.getBuildType().content());
    Status retval = Status.createOkStatus();
    try {
        importer.importProjects(location, monitor);
    } catch (CoreException ce) {
        retval = Status.createErrorStatus(ce);
    }
    return retval;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ILiferayProjectImporter(com.liferay.ide.core.ILiferayProjectImporter) CoreException(org.eclipse.core.runtime.CoreException)

Example 64 with Path

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

the class ImportModuleProjectLocationValidationService method compute.

@Override
protected Status compute() {
    ImportLiferayModuleProjectOp op = _op();
    Path path = op.getLocation().content();
    if ((path == null) || path.isEmpty()) {
        return Status.createOkStatus();
    }
    String location = path.toOSString();
    Status retval = StatusBridge.create(ProjectImportUtil.validatePath(location));
    if (!retval.ok()) {
        return retval;
    }
    if (LiferayWorkspaceUtil.isValidWorkspaceLocation(location)) {
        return Status.createErrorStatus("Can't import Liferay Workspace, please use Import Liferay Workspace Project wizard.");
    }
    retval = StatusBridge.create(ImportLiferayModuleProjectOpMethods.getBuildType(location));
    if (retval.severity() == Status.Severity.ERROR) {
        return retval;
    }
    String projectName = path.lastSegment();
    if (FileUtil.exists(CoreUtil.getProject(projectName))) {
        return Status.createErrorStatus("A project with that name already exists.");
    }
    return retval;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Status(org.eclipse.sapphire.modeling.Status)

Example 65 with Path

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

the class CheckSDKLocationDerivedValueService method _checkProjects.

private void _checkProjects(CodeUpgradeOp op, SDK sdk) {
    File[] portlets = _getFiles(sdk, "portlet");
    if (portlets != null) {
        for (File file : portlets) {
            if (file.isDirectory()) {
                op.setHasPortlet("true");
                File serviceXml = new Path(file.getPath()).append("docroot/WEB-INF/service.xml").toFile();
                if (FileUtil.exists(serviceXml)) {
                    op.setHasServiceBuilder("true");
                }
            }
        }
    }
    File[] hooks = _getFiles(sdk, "hook");
    if (hooks != null) {
        for (File file : hooks) {
            if (file.isDirectory()) {
                op.setHasHook("true");
                File serviceXml = new Path(file.getPath()).append("docroot/WEB-INF/service.xml").toFile();
                if (FileUtil.exists(serviceXml)) {
                    op.setHasServiceBuilder("true");
                }
            }
        }
    }
    File[] exts = _getFiles(sdk, "ext");
    if (exts != null) {
        for (File file : exts) {
            if (file.isDirectory()) {
                op.setHasExt("true");
                break;
            }
        }
    }
    File[] layouttpls = _getFiles(sdk, "layouttpl");
    if (layouttpls != null) {
        for (File file : layouttpls) {
            if (file.isDirectory()) {
                op.setHasLayout("true");
                break;
            }
        }
    }
    File[] themes = _getFiles(sdk, "theme");
    if (themes != null) {
        for (File file : themes) {
            if (file.isDirectory()) {
                op.setHasTheme("true");
                break;
            }
        }
    }
    File[] webs = _getFiles(sdk, "web");
    if (webs != null) {
        for (File file : webs) {
            if (file.isDirectory()) {
                op.setHasWeb("true");
                break;
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) 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