Search in sources :

Example 1 with MultiStatusBuilder

use of com.liferay.ide.core.util.MultiStatusBuilder 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 2 with MultiStatusBuilder

use of com.liferay.ide.core.util.MultiStatusBuilder in project liferay-ide by liferay.

the class MavenProjectBuilder method execGoals.

public IStatus execGoals(List<String> goals, IProgressMonitor monitor) throws CoreException {
    IStatus retval = null;
    IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), monitor);
    ICallable<IStatus> callable = new ICallable<IStatus>() {

        public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
            IStatus execStatus = MavenUtil.executeGoals(facade, context, goals, monitor);
            MavenSession session = context.getSession();
            List<Throwable> exceptions = session.getResult().getExceptions();
            MultiStatusBuilder multiStatusBuilder = LiferayMavenCore.newMultiStatus();
            multiStatusBuilder.add(execStatus);
            multiStatusBuilder.addAll(exceptions);
            return multiStatusBuilder.retval();
        }
    };
    retval = executeMaven(facade, callable, monitor);
    return retval;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MultiStatusBuilder(com.liferay.ide.core.util.MultiStatusBuilder) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Aggregations

MultiStatusBuilder (com.liferay.ide.core.util.MultiStatusBuilder)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 MavenSession (org.apache.maven.execution.MavenSession)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 ICallable (org.eclipse.m2e.core.embedder.ICallable)1 IMavenExecutionContext (org.eclipse.m2e.core.embedder.IMavenExecutionContext)1 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)1 Path (org.eclipse.sapphire.modeling.Path)1 Status (org.eclipse.sapphire.modeling.Status)1