Author: fbricon
Date: 2011-07-11 10:59:24 -0400 (Mon, 11 Jul 2011)
New Revision: 32819
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/profiles/
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/profiles/handlers/
Removed:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/IProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileManager.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/handlers/
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java
trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties
Log:
JBIDE-8969 : Refactored Maven Profile Management logic to the core plugin.
Added a source column to the profile selection UI
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF 2011-07-11
14:44:53 UTC (rev 32818)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF 2011-07-11
14:59:24 UTC (rev 32819)
@@ -30,4 +30,5 @@
Export-Package: org.jboss.tools.maven.core,
org.jboss.tools.maven.core.internal.project.facet,
org.jboss.tools.maven.core.libprov,
+ org.jboss.tools.maven.core.profiles,
org.jboss.tools.maven.core.xpl
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java 2011-07-11
14:44:53 UTC (rev 32818)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -70,6 +70,8 @@
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+import org.jboss.tools.maven.core.internal.profiles.ProfileManager;
+import org.jboss.tools.maven.core.profiles.IProfileManager;
import org.osgi.framework.BundleContext;
/**
@@ -92,6 +94,8 @@
public static final List<LibraryProviderOperationConfig>
libraryProviderOperationConfigs = new ArrayList<LibraryProviderOperationConfig>();
+ private IProfileManager profileManager;
+
// The shared instance
private static MavenCoreActivator plugin;
@@ -110,6 +114,7 @@
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ profileManager = new ProfileManager();
}
/*
@@ -762,4 +767,8 @@
IMavenConstants.PLUGIN_ID, -1, msg, ex));
}
}
+
+ public IProfileManager getProfileManager() {
+ return profileManager;
+ }
}
Copied:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java
(from rev 32782,
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileManager.java)
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -0,0 +1,120 @@
+package org.jboss.tools.maven.core.internal.profiles;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.Profile;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.SettingsUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.IProjectConfigurationManager;
+import org.eclipse.m2e.core.project.MavenUpdateRequest;
+import org.eclipse.m2e.core.project.ResolverConfiguration;
+import org.jboss.tools.maven.core.profiles.IProfileManager;
+
+public class ProfileManager implements IProfileManager {
+
+ public void updateActiveProfiles(final IMavenProjectFacade mavenProjectFacade,
+ final List<String> profiles,
+ final boolean isOffline,
+ final boolean isForceUpdate,
+ IProgressMonitor monitor) throws CoreException {
+
+ final IProjectConfigurationManager configurationManager =
MavenPlugin.getProjectConfigurationManager();
+ final ResolverConfiguration configuration =configurationManager
+ .getResolverConfiguration(mavenProjectFacade.getProject());
+
+ final String profilesAsString = getAsString(profiles);
+ if (profilesAsString.equals(configuration.getActiveProfiles())) {
+ //Nothing changed
+ return;
+ }
+
+ IProject project = mavenProjectFacade.getProject();
+
+ configuration.setActiveProfiles(profilesAsString);
+ boolean isSet = configurationManager.setResolverConfiguration(project, configuration);
+ if (isSet) {
+ MavenUpdateRequest request = new MavenUpdateRequest(project, isOffline,
isForceUpdate);
+ configurationManager.updateProjectConfiguration(request, monitor);
+ }
+
+ }
+
+ private String getAsString(List<String> profiles) {
+ StringBuilder sb = new StringBuilder();
+ boolean addComma = false;
+ if (profiles != null){
+ for (String p : profiles) {
+ if (addComma) {
+ sb.append(", "); //$NON-NLS-1$
+ }
+ sb.append(p);
+ addComma = true;
+ }
+ }
+ return sb.toString();
+ }
+
+ public Map<Profile, Boolean> getAvailableProfiles(IMavenProjectFacade facade)
throws CoreException {
+ if (facade == null) {
+ return Collections.emptyMap();
+ }
+ List<Profile> modelProfiles = facade.getMavenProject().getModel().getProfiles();
+ if (modelProfiles == null || modelProfiles.isEmpty()) {
+ return Collections.emptyMap();
+ }
+
+ ResolverConfiguration resolverConfiguration =
MavenPlugin.getProjectConfigurationManager()
+ .getResolverConfiguration(facade.getProject());
+
+ Map<Profile, Boolean> projectProfiles = new LinkedHashMap<Profile,
Boolean>(modelProfiles.size());
+ List<Profile> activeProfiles = facade.getMavenProject().getActiveProfiles();
+
+ for (Profile p : modelProfiles) {
+ boolean isAutomaticallyActivated = isActive(p, activeProfiles)
+ && !resolverConfiguration.getActiveProfileList().contains(p.getId());
+ projectProfiles.put(p, isAutomaticallyActivated);
+ }
+ return Collections.unmodifiableMap(projectProfiles);
+ }
+
+
+ public Map<Profile, Boolean> getAvailableSettingProfiles() throws CoreException {
+ Map<Profile, Boolean> settingsProfiles = new LinkedHashMap<Profile,
Boolean>();
+ Settings settings = MavenPlugin.getMaven().getSettings();
+ List<String> activeProfiles = settings.getActiveProfiles();
+
+ for (org.apache.maven.settings.Profile sp : settings.getProfiles()) {
+ Profile p = SettingsUtils.convertFromSettingsProfile(sp);
+ boolean isAutomaticallyActivated = isActive2(p, activeProfiles);
+ settingsProfiles.put(p, isAutomaticallyActivated);
+ }
+ return Collections.unmodifiableMap(settingsProfiles);
+ }
+
+ private boolean isActive(Profile p, List<Profile> activeProfiles) {
+ for (Profile activeProfile : activeProfiles) {
+ if (activeProfile.getId().equals(p.getId())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isActive2(Profile p, List<String> activeProfiles) {
+ for (String activeProfile : activeProfiles) {
+ if (activeProfile.equals(p.getId())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Copied:
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java
(from rev 32782,
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/IProfileManager.java)
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/profiles/IProfileManager.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -0,0 +1,49 @@
+package org.jboss.tools.maven.core.profiles;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.Profile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+/**
+ * Retrieves and updates Maven profile informations for Maven projects
+ *
+ * @author Fred Bricon
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IProfileManager {
+
+ /**
+ * Returns an unmodifiable Map of all the available profiles for a given project.
+ * The value of each Map.Entry indicates if the profile is active.
+ * @param mavenProjectFacade a facade of the maven project
+ * @return an unmodifiable Map of all the available profiles for a given project.
+ * @throws CoreException
+ */
+ Map<Profile, Boolean> getAvailableProfiles(IMavenProjectFacade mavenProjectFacade)
throws CoreException;
+
+ /**
+ * Returns an unmodifiable Map of all the available profiles defined in the
+ * Maven settings.xml file.<br/>
+ * The value of each Map.Entry indicates if the profile is active.
+ * @return an unmodifiable Map of all the available profiles for a given project.
+ * @throws CoreException
+ */
+ Map<Profile, Boolean> getAvailableSettingProfiles() throws CoreException;
+
+ /**
+ * Update the profiles of the resolver configuration of a IMavenProjectFacade
synchronously.
+ * @param mavenProjectFacade a facade of the maven project
+ * @param profiles the profile ids to use in the project's resolver configuration
+ * @param isOffline indicates if the maven request must be executed offline
+ * @param isForceUpdate indicates if a check for updated releases and snapshots on
remote repositories must be forced.
+ * @param monitor a progress monitor
+ * @throws CoreException
+ */
+ void updateActiveProfiles(IMavenProjectFacade mavenProjectFacade,
+ List<String> profiles, boolean isOffline, boolean isForceUpdate,
IProgressMonitor monitor)
+ throws CoreException;
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml 2011-07-11 14:44:53 UTC (rev
32818)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml 2011-07-11 14:59:24 UTC (rev
32819)
@@ -46,7 +46,7 @@
<extension
point="org.eclipse.ui.handlers">
<handler
-
class="org.jboss.tools.maven.ui.internal.profiles.handlers.ProfileSelectionHandler"
+
class="org.jboss.tools.maven.ui.internal.profiles.ProfileSelectionHandler"
commandId="org.jboss.tools.maven.ui.commands.selectMavenProfileCommand">
</handler>
</extension>
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java 2011-07-11
14:44:53 UTC (rev 32818)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Messages.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -65,6 +65,8 @@
public static String SelectProfilesDialog_Force_update;
public static String SelectProfilesDialog_Maven_profile_selection;
public static String SelectProfilesDialog_Offline;
+ public static String SelectProfilesDialog_Profile_id_header;
+ public static String SelectProfilesDialog_Profile_source_header;
public static String SelectProfilesDialog_Project_has_no_available_profiles;
public static String SelectProfilesDialog_Select_Maven_profiles;
public static String SelectProfilesDialog_Select_the_active_Maven_profiles;
Deleted:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/IProfileManager.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/IProfileManager.java 2011-07-11
14:44:53 UTC (rev 32818)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/IProfileManager.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -1,19 +0,0 @@
-package org.jboss.tools.maven.ui.internal.profiles;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.model.Profile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.m2e.core.project.IMavenProjectFacade;
-
-public interface IProfileManager {
-
- Map<Profile, Boolean> getAvailableProfiles(IMavenProjectFacade project) throws
CoreException;
-
- Map<Profile, Boolean> getAvailableSettingProfiles() throws CoreException;
-
- void updateActiveProfiles(IMavenProjectFacade mavenProjectFacade,
- List<String> profiles, boolean isOffline, boolean isForceUpdate)
- throws CoreException;
-}
Deleted:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileManager.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileManager.java 2011-07-11
14:44:53 UTC (rev 32818)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileManager.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -1,136 +0,0 @@
-package org.jboss.tools.maven.ui.internal.profiles;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.model.Profile;
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.SettingsUtils;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.m2e.core.project.IProjectConfigurationManager;
-import org.eclipse.m2e.core.project.MavenUpdateRequest;
-import org.eclipse.m2e.core.project.ResolverConfiguration;
-import org.jboss.tools.maven.ui.Messages;
-
-public class ProfileManager implements IProfileManager {
-
- public void updateActiveProfiles(final IMavenProjectFacade mavenProjectFacade,
- final List<String> profiles,
- final boolean isOffline,
- final boolean isForceUpdate) throws CoreException {
-
- final IProjectConfigurationManager configurationManager =
MavenPlugin.getProjectConfigurationManager();
- final ResolverConfiguration configuration =configurationManager
- .getResolverConfiguration(mavenProjectFacade.getProject());
-
- final String profilesAsString = getAsString(profiles);
- if (profilesAsString.equals(configuration.getActiveProfiles())) {
- //Nothing changed
- return;
- }
-
- WorkspaceJob job = new WorkspaceJob(Messages.ProfileManager_Updating_maven_profiles) {
-
- public IStatus runInWorkspace(IProgressMonitor monitor) {
- try {
-
- IProject project = mavenProjectFacade.getProject();
-
- configuration.setActiveProfiles(profilesAsString);
- boolean isSet = configurationManager.setResolverConfiguration(project,
configuration);
- if (isSet) {
- MavenUpdateRequest request = new MavenUpdateRequest(project, isOffline,
isForceUpdate);
- configurationManager.updateProjectConfiguration(request, monitor);
- }
-
- } catch (CoreException ex) {
- return ex.getStatus();
- }
- return Status.OK_STATUS;
- }
- };
- job.setRule(configurationManager.getRule());
- job.schedule();
- }
-
- private String getAsString(List<String> profiles) {
- StringBuilder sb = new StringBuilder();
- boolean addComma = false;
- if (profiles != null){
- for (String p : profiles) {
- if (addComma) {
- sb.append(", "); //$NON-NLS-1$
- }
- sb.append(p);
- addComma = true;
- }
- }
- return sb.toString();
- }
-
- public Map<Profile, Boolean> getAvailableProfiles(IMavenProjectFacade facade)
throws CoreException {
- if (facade == null) {
- return Collections.emptyMap();
- }
- List<Profile> modelProfiles = facade.getMavenProject().getModel().getProfiles();
- if (modelProfiles == null || modelProfiles.isEmpty()) {
- return Collections.emptyMap();
- }
-
- ResolverConfiguration resolverConfiguration =
MavenPlugin.getProjectConfigurationManager()
- .getResolverConfiguration(facade.getProject());
-
- Map<Profile, Boolean> projectProfiles = new LinkedHashMap<Profile,
Boolean>(modelProfiles.size());
- List<Profile> activeProfiles = facade.getMavenProject().getActiveProfiles();
-
- for (Profile p : modelProfiles) {
- boolean isAutomaticallyActivated = isActive(p, activeProfiles)
- && !resolverConfiguration.getActiveProfileList().contains(p.getId());
- projectProfiles.put(p, isAutomaticallyActivated);
- }
- System.err.println(projectProfiles);
- return Collections.unmodifiableMap(projectProfiles);
- }
-
-
- public Map<Profile, Boolean> getAvailableSettingProfiles() throws CoreException {
- Map<Profile, Boolean> settingsProfiles = new LinkedHashMap<Profile,
Boolean>();
- Settings settings = MavenPlugin.getMaven().getSettings();
- List<String> activeProfiles = settings.getActiveProfiles();
-
- for (org.apache.maven.settings.Profile sp : settings.getProfiles()) {
- Profile p = SettingsUtils.convertFromSettingsProfile(sp);
- boolean isAutomaticallyActivated = isActive2(p, activeProfiles);
- settingsProfiles.put(p, isAutomaticallyActivated);
- }
- return Collections.unmodifiableMap(settingsProfiles);
- }
-
- private boolean isActive(Profile p, List<Profile> activeProfiles) {
- for (Profile activeProfile : activeProfiles) {
- if (activeProfile.getId().equals(p.getId())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isActive2(Profile p, List<String> activeProfiles) {
- for (String activeProfile : activeProfiles) {
- if (activeProfile.equals(p.getId())) {
- return true;
- }
- }
- return false;
- }
-
-}
Copied:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java
(from rev 32782,
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/handlers/ProfileSelectionHandler.java)
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java
(rev 0)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/ProfileSelectionHandler.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -0,0 +1,120 @@
+package org.jboss.tools.maven.ui.internal.profiles;
+
+import java.util.Map;
+
+import org.apache.maven.model.Profile;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.jboss.tools.maven.core.MavenCoreActivator;
+import org.jboss.tools.maven.core.profiles.IProfileManager;
+import org.jboss.tools.maven.ui.Activator;
+import org.jboss.tools.maven.ui.Messages;
+
+/**
+ * Handles profile selection commands.
+ */
+public class ProfileSelectionHandler extends AbstractHandler {
+
+ /**
+ * Opens the Maven profile selection Dialog window.
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+ final IMavenProjectFacade facade = getSelectedMavenProject(event);
+ if (facade != null) {
+
+ final IProfileManager profileManager =
MavenCoreActivator.getDefault().getProfileManager();
+
+ Map<Profile, Boolean> availableProfiles;
+ Map<Profile, Boolean> availableSettingsProfiles;
+ facade.getMavenProject().getActiveProfiles();
+ try {
+ availableProfiles = profileManager.getAvailableProfiles(facade);
+
+ availableSettingsProfiles = profileManager.getAvailableSettingProfiles();
+
+ } catch (CoreException e) {
+ throw new ExecutionException("Unable to open the Maven Profile selection
dialog", e);
+ }
+ final SelectProfilesDialog dialog = new SelectProfilesDialog(window.getShell(),
+ facade,
+ availableProfiles,
+ availableSettingsProfiles);
+ if(dialog.open() == Window.OK) {
+ WorkspaceJob job = new WorkspaceJob(Messages.ProfileManager_Updating_maven_profiles)
{
+
+ public IStatus runInWorkspace(IProgressMonitor monitor) {
+ try {
+
+ profileManager.updateActiveProfiles(facade, dialog.getSelectedProfiles(),
+ dialog.isOffline(), dialog.isForceUpdate(), monitor);
+ } catch (CoreException ex) {
+ Activator.log(ex);
+ return ex.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setRule( MavenPlugin.getProjectConfigurationManager().getRule());
+ job.schedule();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns an IMavenProjectFacade from the selected IResource, or from the active editor
+ * @param event
+ * @return the selected IMavenProjectFacade
+ */
+ private IMavenProjectFacade getSelectedMavenProject(ExecutionEvent event) {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ IProject project = getSelectedProject(selection);
+ try {
+ if (project == null) {
+ IEditorInput input = HandlerUtil.getActiveEditorInput(event);
+ if(input instanceof IFileEditorInput) {
+ IFileEditorInput fileInput = (IFileEditorInput) input;
+ project = fileInput.getFile().getProject();
+ }
+ }
+ if (project != null && project.hasNature(IMavenConstants.NATURE_ID)) {
+ return MavenPlugin.getMavenProjectRegistry().getProject(project);
+ }
+ } catch (CoreException e) {
+ Activator.log(e);
+ }
+
+ return null;
+ }
+
+ private IProject getSelectedProject(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object firstElement = structuredSelection.getFirstElement();
+ if (firstElement instanceof IResource) {
+ return ((IResource) firstElement).getProject();
+ }
+ }
+ return null;
+ }
+
+}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java 2011-07-11
14:44:53 UTC (rev 32818)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java 2011-07-11
14:59:24 UTC (rev 32819)
@@ -28,18 +28,21 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableColorProvider;
import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IProjectConfigurationManager;
import org.eclipse.m2e.core.project.ResolverConfiguration;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -49,335 +52,351 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
import org.jboss.tools.maven.ui.Messages;
-public class SelectProfilesDialog extends TitleAreaDialog implements IMenuListener {
+public class SelectProfilesDialog extends TitleAreaDialog implements
+ IMenuListener {
- private CheckboxTableViewer profileTableViewer;
+ private static int PROFILE_ID_COLUMN = 0;
+ private static int SOURCE_COLUMN = 1;
- private Button offlineModeBtn;
+ private CheckboxTableViewer profileTableViewer;
+ private Button offlineModeBtn;
+ private Button forceUpdateBtn;
- private Button forceUpdateBtn;
+ private final IMavenProjectFacade facade;
- private final IMavenProjectFacade facade;
+ private List<Map.Entry<Profile, Boolean>> availableProfiles;
+ private List<String> initialInactiveProfileIds = new ArrayList<String>();
+ private List<String> initialActiveProfileIds = new ArrayList<String>();
+ private List<String> inactiveProfileIds = new ArrayList<String>();
+ private List<String> selectedProfiles;
- private List<Map.Entry<Profile, Boolean>> availableProfiles;
-
- private List<String> initialInactiveProfileIds = new ArrayList<String>();
- private List<String> initialActiveProfileIds = new ArrayList<String>();
- private List<String> inactiveProfileIds = new ArrayList<String>();
-
- private List<String> selectedProfiles;
-
- private boolean offlineMode;
+ private boolean offlineMode ;
+ private boolean forceUpdate;
- private boolean forceUpdate;
+ public SelectProfilesDialog(Shell parentShell, IMavenProjectFacade facade,
+ Map<Profile, Boolean> availableProjectProfiles,
+ Map<Profile, Boolean> availableSettingsProfiles) {
+ super(parentShell);
+ this.facade = facade;
- public SelectProfilesDialog(Shell parentShell, IMavenProjectFacade facade,
- Map<Profile, Boolean> availableProjectProfiles,
- Map<Profile, Boolean> availableSettingsProfiles) {
- super(parentShell);
- this.facade = facade;
+ availableProfiles = new ArrayList<Map.Entry<Profile,
Boolean>>(availableProjectProfiles.entrySet());
+ availableProfiles.addAll(availableSettingsProfiles.entrySet());
- availableProfiles = new
ArrayList<Map.Entry<Profile,Boolean>>(availableProjectProfiles.entrySet());
- availableProfiles.addAll(availableSettingsProfiles.entrySet());
-
- offlineMode = MavenPlugin.getMavenConfiguration().isOffline();
- forceUpdate = false;
-
- final IProjectConfigurationManager configurationManager =
MavenPlugin.getProjectConfigurationManager();
- final ResolverConfiguration configuration
=configurationManager.getResolverConfiguration(facade.getProject());
- for (String p : configuration.getActiveProfileList()) {
- if (p.startsWith("!")) { //$NON-NLS-1$
- initialInactiveProfileIds.add(p.substring(1));
- } else {
- initialActiveProfileIds.add(p);
+ offlineMode = MavenPlugin.getMavenConfiguration().isOffline();
+
+ final IProjectConfigurationManager configurationManager = MavenPlugin
+ .getProjectConfigurationManager();
+ final ResolverConfiguration configuration = configurationManager
+ .getResolverConfiguration(facade.getProject());
+ for (String p : configuration.getActiveProfileList()) {
+ if (p.startsWith("!")) { //$NON-NLS-1$
+ initialInactiveProfileIds.add(p.substring(1));
+ } else {
+ initialActiveProfileIds.add(p);
+ }
}
+ inactiveProfileIds.addAll(initialInactiveProfileIds);
}
- inactiveProfileIds.addAll(initialInactiveProfileIds);
- }
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(Messages.SelectProfilesDialog_Select_Maven_profiles);
- }
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(Messages.SelectProfilesDialog_Select_Maven_profiles);
+ }
- /**
- * Create contents of the dialog.
- * @param parent
- */
- @Override
- @SuppressWarnings("rawtypes")
- protected Control createDialogArea(Composite parent) {
- Composite area = (Composite) super.createDialogArea(parent);
- Composite container = new Composite(area, SWT.NONE);
-
- GridLayout layout = new GridLayout(2, false);
- layout.marginLeft = 12;
- container.setLayout(layout);
- container.setLayoutData(new GridData(GridData.FILL_BOTH));
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite area = (Composite) super.createDialogArea(parent);
+ Composite container = new Composite(area, SWT.NONE);
- setTitle(Messages.SelectProfilesDialog_Maven_profile_selection);
-
setMessage(Messages.SelectProfilesDialog_Select_the_active_Maven_profiles+facade.getProject().getName());
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginLeft = 12;
+ container.setLayout(layout);
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
- boolean hasProfiles = !availableProfiles.isEmpty();
- Label lblAvailable = new Label(container, SWT.NONE);
- if (hasProfiles) {
- lblAvailable.setText(Messages.SelectProfilesDialog_Available_profiles);
- } else {
-
lblAvailable.setText(Messages.SelectProfilesDialog_Project_has_no_available_profiles+facade.getProject().getName()
+"' has no available profiles"); //$NON-NLS-2$
- }
- lblAvailable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ setTitle(Messages.SelectProfilesDialog_Maven_profile_selection);
+ setMessage(NLS.bind(
+ Messages.SelectProfilesDialog_Select_the_active_Maven_profiles,
+ facade.getProject().getName()));
- if (hasProfiles) {
- profileTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER);
- profileTableViewer.setContentProvider(new IStructuredContentProvider() {
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // nothing to do
- }
-
- public void dispose() {
- // nothing to do
- }
-
- public Object[] getElements(Object input) {
- if(input instanceof Collection) {
- return ((Collection) input).toArray();
- }
- return null;
- }
- });
-
- profileTableViewer.setLabelProvider(new ProfileLabelProvider(this));
+ boolean hasProfiles = !availableProfiles.isEmpty();
+ Label lblAvailable = new Label(container, SWT.NONE);
+ String textLabel;
+ if (hasProfiles) {
+ textLabel = Messages.SelectProfilesDialog_Available_profiles;
+ } else {
+ textLabel = Messages.SelectProfilesDialog_Project_has_no_available_profiles;
+ }
+ lblAvailable.setText(NLS.bind(textLabel, facade.getProject().getName()));
+ lblAvailable.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true,
+ false, 2, 1));
- profileTableViewer.setInput(availableProfiles);
+ if (hasProfiles) {
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4);
- gd.heightHint = 200;
- gd.widthHint = 200;
- profileTableViewer.getTable().setLayoutData(gd);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4);
+ gd.heightHint = 150;
+ gd.widthHint = 500;
- Button selectAllBtn = new Button(container, SWT.NONE);
- selectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1,
1));
- selectAllBtn.setText(Messages.SelectProfilesDialog_SelectAll);
- selectAllBtn.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- for(Map.Entry<Profile, Boolean> entry: availableProfiles) {
- profileTableViewer.setChecked(entry, true);
- }
- }
+ profileTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER);
+ Table table = profileTableViewer.getTable();
+ table.setLayoutData(gd);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
- public void widgetDefaultSelected(SelectionEvent e) {
+ TableColumn profileColumn = new TableColumn(table, SWT.NONE);
+ profileColumn.setText(Messages.SelectProfilesDialog_Profile_id_header);
+ profileColumn.setWidth(350);
- }
- });
+ TableColumn sourceColumn = new TableColumn(table, SWT.NONE);
+ sourceColumn.setText(Messages.SelectProfilesDialog_Profile_source_header);
+ sourceColumn.setWidth(120);
- Button deselectAllBtn = new Button(container, SWT.NONE);
- deselectAllBtn.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1,
1));
- deselectAllBtn.setText(Messages.SelectProfilesDialog_DeselectAll);
- deselectAllBtn.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- for(Map.Entry<Profile, Boolean> entry: availableProfiles) {
- profileTableViewer.setChecked(entry, false);
- }
- }
+ profileTableViewer
+ .setContentProvider(new IStructuredContentProvider() {
- public void widgetDefaultSelected(SelectionEvent e) {
+ public void inputChanged(Viewer viewer,
+ Object oldInput, Object newInput) {
+ // nothing to do
+ }
- }
- });
+ public void dispose() {
+ // nothing to do
+ }
- offlineModeBtn = new Button(container, SWT.CHECK);
- offlineModeBtn.setText(Messages.SelectProfilesDialog_Offline);
- offlineModeBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2,
1));
- offlineModeBtn.setSelection(offlineMode);
+ @SuppressWarnings("rawtypes")
+ public Object[] getElements(Object input) {
+ if (input instanceof Collection) {
+ return ((Collection) input).toArray();
+ }
+ return null;
+ }
+ });
- forceUpdateBtn = new Button(container, SWT.CHECK);
- forceUpdateBtn.setText(Messages.SelectProfilesDialog_Force_update);
- forceUpdateBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2,
1));
- forceUpdateBtn.setSelection(forceUpdate);
+ profileTableViewer.setLabelProvider(new ProfileLabelProvider(parent
+ .getFont()));
- createMenu();
+ profileTableViewer.setInput(availableProfiles);
- }
+ addSelectionButton(container, Messages.SelectProfilesDialog_SelectAll, true);
- return area;
- }
+ addSelectionButton(container, Messages.SelectProfilesDialog_DeselectAll, true);
-
- private class ProfileLabelProvider extends LabelProvider implements ITableFontProvider,
ITableColorProvider{
-
- private final SelectProfilesDialog selectProfilesDialog;
+ offlineModeBtn = addCheckButton(container, Messages.SelectProfilesDialog_Offline,
offlineMode);
- private Font implicitActivationFont;
-
- private Color inactiveColor;
-
- public ProfileLabelProvider(SelectProfilesDialog selectProfilesDialog) {
- this.selectProfilesDialog = selectProfilesDialog;
+ forceUpdateBtn = addCheckButton(container, Messages.SelectProfilesDialog_Force_update,
forceUpdate);
- Font defaultFont = selectProfilesDialog.profileTableViewer.getTable().getFont();
- FontData[] fds = defaultFont.getFontData();
- for(FontData fd : fds) {
- fd.setStyle(SWT.ITALIC);
+ createMenu();
+
}
- implicitActivationFont = new Font(defaultFont.getDevice(), fds);
- inactiveColor = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
+
+ return area;
}
- public String getText(Object element) {
- Entry<Profile, Boolean> entry = getEntry(element);
- StringBuilder text = new StringBuilder();
- if (entry!= null) {
- boolean isDeactivated = isDeactivated(entry);
- Profile profile = entry.getKey();
- text.append(profile.getId());
- if (isDeactivated) {
- text.append(Messages.SelectProfilesDialog_deactivated);
- } else if (Boolean.TRUE.equals(entry.getValue())) {
- text.append(Messages.SelectProfilesDialog_autoactivated);
- }
- }
- return text.toString();
- }
-
-
-
- public Font getFont(Object element, int columnIndex) {
- Entry<Profile, Boolean> entry = getEntry(element);
- Font font = null;
- if (entry!=null && Boolean.TRUE.equals(entry.getValue())) {
- font = implicitActivationFont;
- }
- return font;
+ private Button addCheckButton(Composite container, String label, boolean selected) {
+ Button checkBtn = new Button(container, SWT.CHECK);
+ checkBtn.setText(label);
+ checkBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER,
+ true, false, 2, 1));
+ checkBtn.setSelection(selected);
+ return checkBtn;
}
-
- public Color getForeground(Object element, int columnIndex) {
- Entry<Profile, Boolean> entry = getEntry(element);
- if (isDeactivated(entry)) {
- return inactiveColor;
- }
- return null;
+
+ private Button addSelectionButton(Composite container, String label, final boolean
ischecked) {
+ Button button = new Button(container, SWT.NONE);
+ button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
+ false, false, 1, 1));
+ button.setText(label);
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ for (Map.Entry<Profile, Boolean> entry : availableProfiles) {
+ profileTableViewer.setChecked(entry, ischecked);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ return button;
}
- public Color getBackground(Object element, int columnIndex) {
- return null;
- }
-
- }
-
- private Map.Entry<Profile, Boolean> getEntry(Object o) {
- if (o instanceof Map.Entry<?,?>) {
- return (Map.Entry<Profile, Boolean> )o;
+ @SuppressWarnings("unchecked")
+ private Map.Entry<Profile, Boolean> getEntry(Object o) {
+ if (o instanceof Map.Entry<?, ?>) {
+ return (Map.Entry<Profile, Boolean>) o;
}
return null;
}
-
+
private boolean isDeactivated(Entry<Profile, Boolean> entry) {
- return entry != null && inactiveProfileIds.contains(entry.getKey().getId());
+ return entry != null
+ && inactiveProfileIds.contains(entry.getKey().getId());
}
-
- /**
- * Create contents of the button bar.
- * @param parent
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- if (profileTableViewer != null) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- }
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false);
- }
- protected void okPressed() {
- if (profileTableViewer != null) {
- Object[] obj = profileTableViewer.getCheckedElements();
- List<String> selectedProfiles = new ArrayList<String>(obj.length);
- for(int i = 0; i < obj.length; i++ ) {
- Map.Entry<Profile, Boolean> entry = (Map.Entry<Profile, Boolean>)
obj[i];
- String id = entry.getKey().getId();
- if (isDeactivated(entry)) {
- selectedProfiles.add("!"+id); //$NON-NLS-1$
- } else {
- selectedProfiles.add(id);
- }
- }
- this.selectedProfiles = selectedProfiles;
-
- offlineMode = offlineModeBtn.getSelection();
- forceUpdate = forceUpdateBtn.getSelection();
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ if (profileTableViewer != null) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ }
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false);
}
- super.okPressed();
- }
- public List<String> getSelectedProfiles() {
- return selectedProfiles;
- }
+ @Override
+ protected void okPressed() {
+ if (profileTableViewer != null) {
+ Object[] obj = profileTableViewer.getCheckedElements();
+ List<String> selectedProfiles = new ArrayList<String>(obj.length);
+ for (int i = 0; i < obj.length; i++) {
+ @SuppressWarnings("unchecked")
+ Map.Entry<Profile, Boolean> entry = (Map.Entry<Profile, Boolean>)
obj[i];
+ String id = entry.getKey().getId();
+ if (isDeactivated(entry)) {
+ selectedProfiles.add("!" + id); //$NON-NLS-1$
+ } else {
+ selectedProfiles.add(id);
+ }
+ }
+ this.selectedProfiles = selectedProfiles;
- public boolean isOffline() {
- return offlineMode;
- }
+ offlineMode = offlineModeBtn.getSelection();
+ forceUpdate = forceUpdateBtn.getSelection();
+ }
+ super.okPressed();
+ }
- public boolean isForceUpdate() {
- return forceUpdate;
- }
+ private void createMenu() {
+ MenuManager menuMgr = new MenuManager();
+ Menu contextMenu = menuMgr.createContextMenu(profileTableViewer
+ .getControl());
+ menuMgr.addMenuListener(this);
+ profileTableViewer.getControl().setMenu(contextMenu);
+ menuMgr.setRemoveAllWhenShown(true);
- private void createMenu() {
- MenuManager menuMgr = new MenuManager();
- Menu contextMenu = menuMgr.createContextMenu(profileTableViewer.getControl());
- menuMgr.addMenuListener(this);
- profileTableViewer.getControl().setMenu(contextMenu);
- menuMgr.setRemoveAllWhenShown(true);
+ for (Map.Entry<Profile, Boolean> entry : availableProfiles) {
+ String id = entry.getKey().getId();
+ boolean isSelected = initialActiveProfileIds.contains(id)
+ || inactiveProfileIds.contains(id);
+ profileTableViewer.setChecked(entry, isSelected);
+ }
+ }
- for(Map.Entry<Profile, Boolean> entry: availableProfiles) {
- String id = entry.getKey().getId();
- boolean isSelected = initialActiveProfileIds.contains(id) ||
inactiveProfileIds.contains(id);
- profileTableViewer.setChecked(entry, isSelected);
- }
- }
-
- final Action activationAction = new Action("") { //$NON-NLS-1$
+ final Action activationAction = new Action("") { //$NON-NLS-1$
@Override
public void run() {
- IStructuredSelection selection = (IStructuredSelection)
profileTableViewer.getSelection();
- if (!selection.isEmpty()) {
- final Map.Entry<Profile, Boolean> entry =
getEntry(selection.getFirstElement());
- final boolean isDeactivated = isDeactivated(entry);
+ IStructuredSelection selection = (IStructuredSelection) profileTableViewer
+ .getSelection();
+ if (!selection.isEmpty()) {
+ final Map.Entry<Profile, Boolean> entry =
getEntry(selection.getFirstElement());
+ final boolean isDeactivated = isDeactivated(entry);
- if (isDeactivated) {
- inactiveProfileIds.remove(entry.getKey().getId());
- } else {
- inactiveProfileIds.add(entry.getKey().getId());
- profileTableViewer.setChecked(entry, true);
+ if (isDeactivated) {
+ inactiveProfileIds.remove(entry.getKey().getId());
+ } else {
+ inactiveProfileIds.add(entry.getKey().getId());
+ profileTableViewer.setChecked(entry, true);
+ }
+ profileTableViewer.refresh();
}
- profileTableViewer.refresh();
- }
super.run();
}
- };
-
-
- /* (non-Javadoc)
- * @see
org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- public void menuAboutToShow(IMenuManager manager) {
-
- IStructuredSelection selection = (IStructuredSelection)
profileTableViewer.getSelection();
+ };
+
+ public void menuAboutToShow(IMenuManager manager) {
+
+ IStructuredSelection selection = (IStructuredSelection) profileTableViewer
+ .getSelection();
if (!selection.isEmpty()) {
- final Map.Entry<Profile, Boolean> entry =
getEntry(selection.getFirstElement());
+ final Map.Entry<Profile, Boolean> entry = getEntry(selection
+ .getFirstElement());
final boolean isDeactivated = isDeactivated(entry);
+ String text;
if (isDeactivated) {
- activationAction.setText(Messages.SelectProfilesDialog_Activate_menu+
entry.getKey().getId());
+ text = Messages.SelectProfilesDialog_Activate_menu;
} else {
- activationAction.setText(Messages.SelectProfilesDialog_Deactivate_menu+
entry.getKey().getId());
+ text = Messages.SelectProfilesDialog_Deactivate_menu;
}
+ activationAction.setText(NLS.bind(text, entry.getKey().getId()));
manager.add(activationAction);
}
-
- }
-
-
+ }
+ public List<String> getSelectedProfiles() {
+ return selectedProfiles;
+ }
+
+ public boolean isOffline() {
+ return offlineMode;
+ }
+
+ public boolean isForceUpdate() {
+ return forceUpdate;
+ }
+
+ private class ProfileLabelProvider extends LabelProvider implements
+ ITableLabelProvider, ITableFontProvider, ITableColorProvider {
+
+ private Font implicitActivationFont;
+
+ private Color inactiveColor;
+
+ public ProfileLabelProvider(Font defaultFont) {
+ FontData[] fds = defaultFont.getFontData();
+ for (FontData fd : fds) {
+ fd.setStyle(SWT.ITALIC);
+ }
+ implicitActivationFont = new Font(defaultFont.getDevice(), fds);
+ inactiveColor = Display.getCurrent().getSystemColor(SWT.COLOR_GRAY);
+ }
+
+ public Font getFont(Object element, int columnIndex) {
+ Entry<Profile, Boolean> entry = getEntry(element);
+ Font font = null;
+ if (entry != null && Boolean.TRUE.equals(entry.getValue())
+ && PROFILE_ID_COLUMN == columnIndex) {
+ font = implicitActivationFont;
+ }
+ return font;
+ }
+
+ public Color getForeground(Object element, int columnIndex) {
+ Entry<Profile, Boolean> entry = getEntry(element);
+ if (isDeactivated(entry)) {
+ return inactiveColor;
+ }
+ return null;
+ }
+
+ public Color getBackground(Object element, int columnIndex) {
+ return null;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ Entry<Profile, Boolean> entry = getEntry(element);
+ StringBuilder text = new StringBuilder();
+ if (entry != null) {
+ boolean isDeactivated = isDeactivated(entry);
+ Profile profile = entry.getKey();
+ if (columnIndex == PROFILE_ID_COLUMN) {
+ text.append(profile.getId());
+ if (isDeactivated) {
+ text.append(Messages.SelectProfilesDialog_deactivated);
+ } else if (Boolean.TRUE.equals(entry.getValue())) {
+ text.append(Messages.SelectProfilesDialog_autoactivated);
+ }
+ } else if (columnIndex == SOURCE_COLUMN) {
+ text.append(profile.getSource());
+ }
+ }
+ return text.toString();
+ }
+ }
}
Modified:
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties 2011-07-11
14:44:53 UTC (rev 32818)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/messages.properties 2011-07-11
14:59:24 UTC (rev 32819)
@@ -35,16 +35,18 @@
ConfiguratorPreferencePage_When_importing_Maven_projects_configure_the_following=When
importing Maven projects configure the following:
ProfileManager_Updating_maven_profiles=Updating maven profiles
-SelectProfilesDialog_Activate_menu=Activate
+SelectProfilesDialog_Activate_menu=Activate {0}
SelectProfilesDialog_autoactivated=\ (auto activated)
SelectProfilesDialog_Available_profiles=Available profiles
-SelectProfilesDialog_Deactivate_menu=Deactivate
+SelectProfilesDialog_Deactivate_menu=Deactivate {0}
SelectProfilesDialog_deactivated=\ (deactivated)
SelectProfilesDialog_DeselectAll=Deselect all
SelectProfilesDialog_Force_update=Force update
SelectProfilesDialog_Maven_profile_selection=Maven Profile selection
SelectProfilesDialog_Offline=Offline
-SelectProfilesDialog_Project_has_no_available_profiles=Project '
+SelectProfilesDialog_Profile_id_header=Profile id
+SelectProfilesDialog_Profile_source_header=Source
+SelectProfilesDialog_Project_has_no_available_profiles=Project {0} has no available
profiles
SelectProfilesDialog_Select_Maven_profiles=Select Maven profiles
-SelectProfilesDialog_Select_the_active_Maven_profiles=Select the active Maven profiles
for
+SelectProfilesDialog_Select_the_active_Maven_profiles=Select the active Maven profiles
for project {0}. Right-click to (de)activate a profile.
SelectProfilesDialog_SelectAll=Select All