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;
}
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);
}
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());
}
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();
}
}
}
Aggregations