Search in sources :

Example 31 with Path

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

the class SDKImportProjectsOpMethods method execute.

public static final Status execute(SDKProjectsImportOp op, ProgressMonitor pm) {
    IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
    monitor.beginTask("Importing Liferay plugin projects...", 100);
    Status retval = Status.createOkStatus();
    Path projectLocation = op.getSdkLocation().content();
    if ((projectLocation == null) || projectLocation.isEmpty()) {
        return Status.createErrorStatus("Project cannot be empty");
    }
    Job job = new WorkspaceJob("Importing Liferay projects...") {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            MultiStatusBuilder statusBuilder = new MultiStatusBuilder(ProjectCore.PLUGIN_ID);
            ElementList<ProjectNamedItem> projectItems = op.getSelectedProjects();
            for (NamedItem projectNamedItem : projectItems) {
                try {
                    if (projectNamedItem instanceof ProjectNamedItem) {
                        String projectPath = ((ProjectNamedItem) projectNamedItem).getLocation().content();
                        String projectLocation = new Path(projectPath).toPortableString();
                        ProjectImportUtil.importProject(PathBridge.create(new Path(projectLocation)), new NullProgressMonitor(), null);
                    }
                } catch (Exception e) {
                    statusBuilder.add(StatusBridge.create(Status.createErrorStatus(e.getMessage())));
                }
            }
            return statusBuilder.retval();
        }
    };
    job.schedule();
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MultiStatusBuilder(com.liferay.ide.core.util.MultiStatusBuilder) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) CoreException(org.eclipse.core.runtime.CoreException)

Example 32 with Path

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

the class ArtifactVersionDefaultValueService method compute.

@Override
protected String compute() {
    String data = null;
    NewLiferayPluginProjectOp 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 = NewLiferayPluginProjectOpMethods.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) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Example 33 with Path

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

the class GroupIdDefaultValueService method compute.

@Override
protected String compute() {
    String groupId = null;
    NewLiferayPluginProjectOp 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 = NewLiferayPluginProjectOpMethods.getMavenParentPomGroupId(op, projectName, parentProjectOsPath);
    }
    if (groupId == null) {
        groupId = _getDefaultMavenGroupId();
        if (CoreUtil.isNullOrEmpty(groupId)) {
            groupId = "com.example.plugins";
        }
    }
    return groupId;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)

Example 34 with Path

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

the class JSFModuleProjectNameListener method updateLocation.

public static void updateLocation(NewLiferayJSFModuleProjectOp op) {
    String currentProjectName = op.getProjectName().content(true);
    Path newLocationBase = null;
    if ((currentProjectName == null) || CoreUtil.isNullOrEmpty(currentProjectName.trim())) {
        return;
    }
    boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
    if (useDefaultLocation) {
        newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
    } else {
        Path currentProjectLocation = op.getLocation().content(true);
        boolean hasLiferayWorkspace = false;
        if (currentProjectLocation != null) {
            hasLiferayWorkspace = LiferayWorkspaceUtil.isValidWorkspaceLocation(currentProjectLocation.toOSString());
        }
        if (hasLiferayWorkspace) {
            File workspaceDir = LiferayWorkspaceUtil.getWorkspaceDir(currentProjectLocation.toFile());
            if (FileUtil.notExists(workspaceDir)) {
                return;
            }
            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 == true) {
                    newLocationBase = PathBridge.create(projectLocation);
                } else {
                    newLocationBase = PathBridge.create(projectLocation.append(folders[0]));
                }
            } 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) File(java.io.File)

Example 35 with Path

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

the class SdkLocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
    if (countPossibleWorkspaceSDKProjects > 1) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK. "));
    }
    Value<Path> sdkLocationValue = _op().getSdkLocation();
    Path sdkLocation = sdkLocationValue.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"));
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) SDK(com.liferay.ide.sdk.core.SDK)

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