Search in sources :

Example 1 with Profile

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

the class SelectActiveProfilesActionHandler method run.

@Override
protected Object run(Presentation context) {
    if (context instanceof SwtPresentation) {
        final SwtPresentation swt = (SwtPresentation) context;
        final NewLiferayPluginProjectOp op = getModelElement().nearest(NewLiferayPluginProjectOp.class);
        final String previousActiveProfilesValue = op.getActiveProfilesValue().content();
        // we need to rebuild the 'selected' list from what is specified in the
        // 'activeProfiles' property
        op.getSelectedProfiles().clear();
        final String activeProfiles = op.getActiveProfilesValue().content();
        if (!CoreUtil.isNullOrEmpty(activeProfiles)) {
            final String[] profileIds = activeProfiles.split(",");
            if (ListUtil.isNotEmpty(profileIds)) {
                for (String profileId : profileIds) {
                    if (!CoreUtil.isNullOrEmpty(profileId)) {
                        boolean foundExistingProfile = false;
                        for (Profile profile : op.getSelectedProfiles()) {
                            if (profileId.equals(profile.getId().content())) {
                                foundExistingProfile = true;
                                break;
                            }
                        }
                        if (!foundExistingProfile) {
                            Profile newlySelectedProfile = op.getSelectedProfiles().insert();
                            newlySelectedProfile.setId(profileId);
                        }
                    }
                }
            }
        }
        final CustomSapphireDialog dialog = new CustomSapphireDialog(swt.shell(), op, DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("SelectActiveProfiles"));
        dialog.setBlockOnOpen(true);
        final int result = dialog.open();
        if (result == SapphireDialog.CANCEL) {
            // restore previous value
            op.setActiveProfilesValue(previousActiveProfilesValue);
        } else {
            final ElementList<Profile> selectedProfiles = op.getSelectedProfiles();
            NewLiferayPluginProjectOpMethods.updateActiveProfilesValue(op, selectedProfiles);
        }
    }
    return null;
}
Also used : SwtPresentation(org.eclipse.sapphire.ui.forms.swt.SwtPresentation) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Profile(com.liferay.ide.project.core.model.Profile)

Example 2 with Profile

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

the class ProfileIdListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    NewLiferayPluginProjectOp op = event.property().nearest(NewLiferayPluginProjectOp.class);
    ElementList<Profile> selectedProfiles = op.getSelectedProfiles();
    NewLiferayPluginProjectOpMethods.updateActiveProfilesValue(op, selectedProfiles);
}
Also used : NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Profile(com.liferay.ide.project.core.model.Profile)

Example 3 with Profile

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

the class ProfilePossibleValuesTests method testActiveProfilesValue.

@Test
public void testActiveProfilesValue() throws Exception {
    final NewLiferayPluginProjectOp op = newMavenProjectOp();
    final Profile firstProfile = op.getSelectedProfiles().insert();
    final String firstProfileId = "__first_profile__";
    firstProfile.setId(firstProfileId);
    assertEquals(firstProfileId, op.getActiveProfilesValue().content());
    final Profile secondProfile = op.getSelectedProfiles().insert();
    final String secondProfileId = "__second_profile__";
    secondProfile.setId(secondProfileId);
    assertEquals(firstProfileId + ',' + secondProfileId, op.getActiveProfilesValue().content());
}
Also used : NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Profile(com.liferay.ide.project.core.model.Profile) Test(org.junit.Test)

Example 4 with Profile

use of com.liferay.ide.project.core.model.Profile 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

Profile (com.liferay.ide.project.core.model.Profile)4 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)3 NewLiferayProfileOp (com.liferay.ide.maven.core.model.NewLiferayProfileOp)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 SwtPresentation (org.eclipse.sapphire.ui.forms.swt.SwtPresentation)1 Test (org.junit.Test)1