Search in sources :

Example 56 with Path

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

the class SDKLocationValidationService method compute.

@Override
protected Status compute() {
    NewLiferayPluginProjectOp op = _op();
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
    if (!provider.getShortName().equals("ant")) {
        return Status.createOkStatus();
    }
    int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
    if (countPossibleWorkspaceSDKProjects > 1) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK."));
    }
    Path sdkLocation = op.getSdkLocation().content(true);
    if ((sdkLocation == null) || sdkLocation.isEmpty()) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is empty."));
    }
    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
    if (sdk != null) {
        IStatus status = sdk.validate(true);
        if (!status.isOK()) {
            return StatusBridge.create(status);
        }
    } else {
        return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is not correct."));
    }
    Path projectLocation = op.getLocation().content();
    String projectName = op.getProjectName().content();
    IPath projectPath = PathBridge.create(projectLocation);
    if (FileUtil.exists(projectPath)) {
        return StatusBridge.create(ProjectCore.createErrorStatus("Project(" + projectName + ") is existed in sdk folder, please set new project name."));
    }
    PluginType pluginType = op.getPluginType().content();
    if (pluginType.equals(PluginType.web) && !supportsTypePlugin(op, "web")) {
        StringBuilder sb = new StringBuilder();
        sb.append("The selected Plugins SDK does not support creating new web type plugins. ");
        sb.append("");
        sb.append("Please configure version 7.0 or greater.");
        return Status.createErrorStatus(sb.toString());
    } else if (pluginType.equals(PluginType.theme) && !supportsTypePlugin(op, "theme")) {
        StringBuilder sb = new StringBuilder();
        sb.append("The selected Plugins SDK does not support creating theme type plugins. ");
        sb.append("");
        sb.append("Please configure version 6.2 or less or using gulp way.");
        return Status.createErrorStatus(sb.toString());
    } else if (pluginType.equals(PluginType.portlet)) {
        IPortletFramework portletFramework = op.getPortletFramework().content();
        Version requiredVersion = new Version(portletFramework.getRequiredSDKVersion());
        Version sdkVersion = new Version(sdk.getVersion());
        if (CoreUtil.compareVersions(requiredVersion, sdkVersion) > 0) {
            StringBuilder sb = new StringBuilder();
            sb.append("Selected portlet framework requires SDK version at least ");
            sb.append("");
            sb.append(requiredVersion);
            return Status.createErrorStatus(sb.toString());
        }
    } else if (pluginType.equals(PluginType.ext) && !supportsTypePlugin(op, "ext")) {
        StringBuilder sb = new StringBuilder();
        sb.append("The selected Plugins SDK does not support creating ext type plugins. ");
        sb.append("");
        sb.append("Please try to confirm whether sdk has ext folder.");
        return Status.createErrorStatus(sb.toString());
    }
    return Status.createOkStatus();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) IPortletFramework(com.liferay.ide.project.core.IPortletFramework) IPath(org.eclipse.core.runtime.IPath) Version(org.osgi.framework.Version) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) PluginType(com.liferay.ide.project.core.model.PluginType)

Example 57 with Path

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

the class NewLiferayPluginProjectOpMethods method execute.

public static final Status execute(NewLiferayPluginProjectOp op, ProgressMonitor pm) {
    IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
    monitor.beginTask("Creating Liferay plugin project (this process may take several minutes)", 100);
    Status retval = null;
    try {
        NewLiferayProjectProvider<NewLiferayPluginProjectOp> projectProvider = op.getProjectProvider().content(true);
        // IDE-1306 If the user types too quickly all the model changes may not have propagated
        Path projectLocation = op.getLocation().content();
        updateLocation(op, projectLocation);
        IStatus status = projectProvider.createNewProject(op, monitor);
        if (status.isOK()) {
            _updateProjectPrefs(op);
            _removeSampleCodeAndFiles(op);
            op.setImportProjectStatus(true);
        }
        retval = StatusBridge.create(status);
    } catch (Exception e) {
        String msg = "Error creating Liferay plugin project.";
        ProjectCore.logError(msg, e);
        return Status.createErrorStatus(msg + " Please see Eclipse error log for more details.", e);
    }
    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) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException)

Example 58 with Path

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

the class FragmentProjectNameListener method updateLocation.

public static void updateLocation(NewModuleFragmentOp 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.getWorkspaceRoot().getLocation());
        } else {
            boolean gradleModule = false;
            boolean mavenModule = false;
            ILiferayProjectProvider iProvider = op.getProjectProvider().content();
            if (iProvider != null) {
                String shortName = iProvider.getShortName();
                if (!CoreUtil.empty(shortName) && shortName.startsWith("gradle")) {
                    gradleModule = true;
                } else {
                    mavenModule = true;
                }
            }
            if ((gradleModule && hasGradleWorkspace) || (mavenModule && hasMavenWorkspace)) {
                IProject liferayWorkspaceProject = LiferayWorkspaceUtil.getWorkspaceProject();
                if (FileUtil.exists(liferayWorkspaceProject)) {
                    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 59 with Path

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

the class ModuleProjectArtifactVersionDefaultValueService method compute.

@Override
protected String compute() {
    String data = null;
    NewLiferayModuleProjectOp 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();
        data = NewLiferayModuleProjectOpMethods.getMavenParentPomVersion(op, projectName, parentProjectOsPath);
    }
    if (data == null) {
        data = "1.0.0-SNAPSHOT";
    }
    return data;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IPath(org.eclipse.core.runtime.IPath)

Example 60 with Path

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

the class ModuleProjectGroupIdDefaultValueService method compute.

@Override
protected String compute() {
    NewLiferayModuleProjectOp op = _op();
    String groupId = null;
    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 = NewLiferayModuleProjectOpMethods.getMavenParentPomGroupId(op, projectName, parentProjectOsPath);
    }
    if (groupId == null) {
        groupId = _getDefaultMavenGroupId();
        if (CoreUtil.isNullOrEmpty(groupId)) {
            groupId = op.getPackageName().content();
        }
    }
    return groupId;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IPath(org.eclipse.core.runtime.IPath)

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