Search in sources :

Example 16 with Path

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

the class SDKImportVersionDerivedValueService method compute.

@Override
protected String compute() {
    String retVal = null;
    SDKProjectsImportOp op = _op();
    Value<Path> sdkLocation = op.getSdkLocation();
    if ((sdkLocation != null) && (sdkLocation.content() != null) && !sdkLocation.content().isEmpty()) {
        Path sdkPath = sdkLocation.content();
        IStatus status = ProjectImportUtil.validateSDKPath(sdkLocation.content().toPortableString());
        if (status.isOK()) {
            SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkPath));
            retVal = sdk.getVersion();
        }
    }
    return retVal;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) SDKProjectsImportOp(com.liferay.ide.project.core.model.SDKProjectsImportOp) SDK(com.liferay.ide.sdk.core.SDK)

Example 17 with Path

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

the class SDKLocationListener method updateLocation.

public static void updateLocation(NewLiferayPluginProjectOp op) {
    Path newLocationBase = null;
    Path sdkLocation = op.getSdkLocation().content(true);
    if (sdkLocation == null) {
        return;
    }
    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
    op.setImportProjectStatus(false);
    if (sdk == null) {
        return;
    }
    switch(op.getPluginType().content(true)) {
        case portlet:
        case servicebuilder:
            newLocationBase = sdkLocation.append("portlets");
            break;
        case ext:
            newLocationBase = sdkLocation.append("ext");
            break;
        case hook:
            newLocationBase = sdkLocation.append("hooks");
            break;
        case layouttpl:
            newLocationBase = sdkLocation.append("layouttpl");
            break;
        case theme:
            newLocationBase = sdkLocation.append("themes");
            break;
        case web:
            newLocationBase = sdkLocation.append("webs");
            break;
    }
    if (newLocationBase != null) {
        NewLiferayPluginProjectOpMethods.updateLocation(op, newLocationBase);
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) SDK(com.liferay.ide.sdk.core.SDK)

Example 18 with Path

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

the class AbstractProjectLocationValidationService method compute.

@Override
protected Status compute() {
    BaseModuleOp op = op();
    Status retval = Status.createOkStatus();
    String currentProjectName = op.getProjectName().content();
    Path currentProjectLocation = op.getLocation().content();
    Boolean userDefaultLocation = op.getUseDefaultLocation().content();
    /*
		 * Location won't be validated if the UseDefaultLocation has an error.
		 * Get the validation of the property might not work as excepted,
		 * let's use call the validation service manually.
		 */
    if (userDefaultLocation) {
        return retval;
    }
    /*
		 * IDE-1150, instead of using annotation "@Required",use this service to
		 * validate the custom project location must be specified, let the wizard
		 * display the error of project name when project name and location are both
		 * null.
		 */
    if (currentProjectName == null) {
        return retval;
    }
    if (currentProjectLocation == null) {
        return Status.createErrorStatus("Location must be specified.");
    }
    String currentPath = currentProjectLocation.toOSString();
    if (!org.eclipse.core.runtime.Path.EMPTY.isValidPath(currentPath)) {
        return Status.createErrorStatus("\"" + currentPath + "\" is not a valid path.");
    } else {
        IPath osPath = org.eclipse.core.runtime.Path.fromOSString(currentPath);
        if (!osPath.toFile().isAbsolute()) {
            retval = Status.createErrorStatus("\"" + currentPath + "\" is not an absolute path.");
        } else {
            if (FileUtil.notExists(osPath)) {
                if (!_canCreate(osPath.toFile())) {
                    retval = Status.createErrorStatus("Cannot create project content at \"" + currentPath + "\"");
                }
            }
            NewLiferayProjectProvider<BaseModuleOp> provider = op.getProjectProvider().content();
            IStatus locationStatus = provider.validateProjectLocation(currentProjectName, osPath);
            if (!locationStatus.isOK()) {
                retval = Status.createErrorStatus(locationStatus.getMessage());
            }
        }
    }
    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)

Example 19 with Path

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

the class ModuleProjectNameListener method updateLocation.

public static void updateLocation(NewLiferayModuleProjectOp op) {
    String currentProjectName = op.getProjectName().content(true);
    if ((currentProjectName == null) || CoreUtil.isNullOrEmpty(currentProjectName.trim())) {
        return;
    }
    boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
    if (useDefaultLocation) {
        Path newLocationBase = null;
        boolean hasLiferayWorkspace = false;
        boolean hasGradleWorkspace = false;
        boolean hasMavenWorkspace = false;
        try {
            hasLiferayWorkspace = LiferayWorkspaceUtil.hasWorkspace();
            hasGradleWorkspace = LiferayWorkspaceUtil.hasGradleWorkspace();
            hasMavenWorkspace = LiferayWorkspaceUtil.hasMavenWorkspace();
        } catch (Exception e) {
            ProjectCore.logError("Failed to check LiferayWorkspace project.");
        }
        if (!hasLiferayWorkspace) {
            newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRootLocation());
        } else {
            boolean gradleModule = false;
            boolean mavenModule = false;
            ILiferayProjectProvider provider = op.getProjectProvider().content();
            if (provider != null) {
                String shortName = provider.getShortName();
                if (!CoreUtil.empty(shortName) && shortName.startsWith("gradle")) {
                    gradleModule = true;
                } else {
                    mavenModule = true;
                }
            }
            boolean themeProject = false;
            if (op instanceof NewLiferayModuleProjectOp) {
                NewLiferayModuleProjectOp moduleProjectOp = (NewLiferayModuleProjectOp) op;
                String projectTemplateName = moduleProjectOp.getProjectTemplateName().content();
                for (String projectType : _WAR_TYPE_PROJECT) {
                    if (projectType.equals(projectTemplateName)) {
                        themeProject = true;
                    }
                }
            }
            if ((gradleModule && hasGradleWorkspace) || (mavenModule && hasMavenWorkspace)) {
                IProject liferayWorkspaceProject = LiferayWorkspaceUtil.getWorkspaceProject();
                if (FileUtil.exists(liferayWorkspaceProject)) {
                    if (themeProject) {
                        String[] warsNames = LiferayWorkspaceUtil.getWarsDirs(liferayWorkspaceProject);
                        // use the first configured wars fodle name
                        newLocationBase = PathBridge.create(liferayWorkspaceProject.getLocation().append(warsNames[0]));
                    } else {
                        String folder = LiferayWorkspaceUtil.getModulesDir(liferayWorkspaceProject);
                        if (folder != null) {
                            IPath appendPath = liferayWorkspaceProject.getLocation().append(folder);
                            newLocationBase = PathBridge.create(appendPath);
                        }
                    }
                }
            } else {
                newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
            }
        }
        if (newLocationBase != null) {
            op.setLocation(newLocationBase);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IPath(org.eclipse.core.runtime.IPath) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider) IProject(org.eclipse.core.resources.IProject)

Example 20 with Path

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

the class ImportModuleProjectBuildTypeDerivedValueService method compute.

@Override
protected String compute() {
    String retVal = null;
    ImportLiferayModuleProjectOp op = _op();
    if (op.getLocation() == null) {
        return retVal;
    }
    Path path = op.getLocation().content();
    if ((path != null) && !path.isEmpty()) {
        String location = path.toOSString();
        IStatus status = ImportLiferayModuleProjectOpMethods.getBuildType(location);
        if (status.isOK()) {
            retVal = status.getMessage();
        } else if (status.getSeverity() == IStatus.WARNING) {
            retVal = "gradle";
        } else {
            retVal = "";
        }
    }
    return retVal;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus)

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