Search in sources :

Example 46 with Status

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

the class ThemeFrameworkValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayPluginProjectOp op = _op();
    String currentThemeFramework = op.getThemeFramework().content();
    if (currentThemeFramework.equals("JSP")) {
        retval = Status.createWarningStatus("For advanced theme developers only.");
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Example 47 with Status

use of org.eclipse.sapphire.modeling.Status 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 48 with Status

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

the class NewLiferayModuleProjectOpMethods method execute.

public static final Status execute(NewLiferayModuleProjectOp op, ProgressMonitor pm) {
    IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
    monitor.beginTask("Creating Liferay module project (this process may take several minutes)", 100);
    Status retval = null;
    try {
        NewLiferayProjectProvider<BaseModuleOp> projectProvider = op.getProjectProvider().content(true);
        IStatus status = projectProvider.createNewProject(op, monitor);
        retval = StatusBridge.create(status);
        String projectName = op.getProjectName().content();
        IPath location = PathBridge.create(op.getLocation().content());
        IPath projectLocation = location;
        String lastSegment = location.lastSegment();
        if ((location != null) && (location.segmentCount() > 0) && !lastSegment.equals(projectName)) {
            projectLocation = location.append(projectName);
        }
        List<IPath> finalClassPaths = _getClassFilePath(projectLocation);
        for (IPath classFilePath : finalClassPaths) {
            File finalClassFile = classFilePath.toFile();
            if (FileUtil.exists(finalClassFile)) {
                ElementList<PropertyKey> propertyKeys = op.getPropertyKeys();
                List<String> properties = new ArrayList<>();
                for (PropertyKey propertyKey : propertyKeys) {
                    properties.add(propertyKey.getName().content(true) + "=" + propertyKey.getValue().content(true));
                }
                if (addProperties(finalClassFile, properties)) {
                    IProject project = CoreUtil.getProject(op.getProjectName().content());
                    project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                }
            }
        }
        if (retval.ok()) {
            _updateBuildPrefs(op);
        }
    } catch (Exception e) {
        String msg = "Error creating Liferay module project.";
        ProjectCore.logError(msg, e);
        return Status.createErrorStatus(msg + " " + e.getMessage(), e);
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) File(java.io.File)

Example 49 with Status

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

the class PackageNameValidationService method compute.

@Override
protected Status compute() {
    NewLiferayModuleProjectOp op = _op();
    String packageName = op.getPackageName().content(true);
    Status retval = Status.createOkStatus();
    int packageNameStatus = IStatus.OK;
    if (!CoreUtil.isNullOrEmpty(packageName)) {
        IStatus status = JavaConventions.validatePackageName(packageName, CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7);
        packageNameStatus = status.getSeverity();
        if (packageNameStatus == IStatus.ERROR) {
            retval = Status.createErrorStatus("Invalid package name");
        }
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) IStatus(org.eclipse.core.runtime.IStatus)

Example 50 with Status

use of org.eclipse.sapphire.modeling.Status 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)

Aggregations

Status (org.eclipse.sapphire.modeling.Status)83 IProject (org.eclipse.core.resources.IProject)33 Test (org.junit.Test)31 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)29 IStatus (org.eclipse.core.runtime.IStatus)25 Path (org.eclipse.sapphire.modeling.Path)18 CoreException (org.eclipse.core.runtime.CoreException)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 NewLiferayJSFModuleProjectOp (com.liferay.ide.project.core.jsf.NewLiferayJSFModuleProjectOp)14 IFile (org.eclipse.core.resources.IFile)12 IPath (org.eclipse.core.runtime.IPath)11 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)10 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)9 SDK (com.liferay.ide.sdk.core.SDK)9 File (java.io.File)6 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)5 IRuntime (org.eclipse.wst.server.core.IRuntime)5 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)3 ArrayList (java.util.ArrayList)3