Search in sources :

Example 1 with NewLiferayProfileOp

use of com.liferay.ide.maven.core.model.NewLiferayProfileOp in project liferay-ide by liferay.

the class AbstractProjectMarkerResolution method run.

public void run(IMarker marker) {
    IProject project = marker.getResource().getProject();
    IProjectConfigurationManager projectManager = MavenPlugin.getProjectConfigurationManager();
    ResolverConfiguration configuration = projectManager.getResolverConfiguration(project);
    List<String> currentProfiles = configuration.getActiveProfileList();
    NewLiferayProfileOp op = NewLiferayProfileOp.TYPE.instantiate();
    ElementList<Profile> selectedProfiles = op.getSelectedProfiles();
    for (String currentProfile : currentProfiles) {
        selectedProfiles.insert().setId(currentProfile);
    }
    int result = promptUser(project, op);
    if (result == SapphireDialog.OK) {
        configuration.setSelectedProfiles(op.getActiveProfilesValue().content());
        boolean changed = projectManager.setResolverConfiguration(project, configuration);
        if (changed) {
            WorkspaceJob job = new WorkspaceJob("Updating project " + project.getName()) {

                public IStatus runInWorkspace(IProgressMonitor monitor) {
                    try {
                        MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, monitor);
                    } catch (CoreException ce) {
                        return ce.getStatus();
                    }
                    return Status.OK_STATUS;
                }
            };
            job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
            job.schedule();
        }
    }
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IProjectConfigurationManager(org.eclipse.m2e.core.project.IProjectConfigurationManager) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IProject(org.eclipse.core.resources.IProject) Profile(com.liferay.ide.project.core.model.Profile) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) NewLiferayProfileOp(com.liferay.ide.maven.core.model.NewLiferayProfileOp)

Aggregations

NewLiferayProfileOp (com.liferay.ide.maven.core.model.NewLiferayProfileOp)1 Profile (com.liferay.ide.project.core.model.Profile)1 IProject (org.eclipse.core.resources.IProject)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IProjectConfigurationManager (org.eclipse.m2e.core.project.IProjectConfigurationManager)1 ResolverConfiguration (org.eclipse.m2e.core.project.ResolverConfiguration)1