Author: fbricon
Date: 2011-08-08 10:24:08 -0400 (Mon, 08 Aug 2011)
New Revision: 33677
Modified:
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.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java
Log:
JBIDE-8969 Added support for right-click on multiple profile selection
Modified:
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/internal/profiles/ProfileManager.java 2011-08-08
13:15:11 UTC (rev 33676)
+++
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/profiles/ProfileManager.java 2011-08-08
14:24:08 UTC (rev 33677)
@@ -37,6 +37,8 @@
public class ProfileManager implements IProfileManager {
+ private static final String ARTIFACT_SEPARATOR = ":"; //$NON-NLS-1$
+
public void updateActiveProfiles(final IMavenProjectFacade mavenProjectFacade,
final List<String> profiles,
final boolean isOffline,
@@ -183,18 +185,21 @@
private String findSource(Profile profile, List<Model> modelHierarchy) {
if (profile != null) {
- if ("settings.xml".equals(profile.getSource())) {
+ if ("settings.xml".equals(profile.getSource())) { //$NON-NLS-1$
return profile.getSource();
}
for (Model m : modelHierarchy) {
for (Profile p : m.getProfiles()) {
if(p.equals(profile)) {
- return m.getArtifactId();
+ return //m.getGroupId()+ARTIFACT_SEPARATOR+
+ m.getArtifactId()
+ //+
(m.getVersion()==null?"":ARTIFACT_SEPARATOR+m.getVersion())//$NON-NLS-1$
+ ;
}
}
}
}
- return "undefined";
+ return "undefined"; //$NON-NLS-1$
}
protected List<Profile> collectAvailableProfiles(List<Model> models,
IProgressMonitor monitor) throws CoreException {
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-08-08
13:15:11 UTC (rev 33676)
+++
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/profiles/SelectProfilesDialog.java 2011-08-08
14:24:08 UTC (rev 33677)
@@ -299,13 +299,7 @@
ISelection s = profileTableViewer.getSelection();
if (s instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) s;
- Iterator<?> ite = sel.iterator();
- while (ite.hasNext()) {
- Object o = ite.next();
- if (o instanceof ProfileSelection) {
- setActivationState((ProfileSelection)o, state);
- }
- }
+ setActivationState(sel, state);
}
refresh();
}
@@ -360,17 +354,26 @@
IStructuredSelection selection = (IStructuredSelection) profileTableViewer
.getSelection();
if (!selection.isEmpty()) {
- final ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
- String text = ""; //$NON-NLS-1$
- ProfileState state = entry.getActivationState();
- if ( state == null || state.equals(ProfileState.Disabled)) {
+ boolean multiSelection = selection.size() > 1;
+ ProfileState state = null;
+ String selectionText;
+ String text;
+ if (multiSelection) {
+ selectionText = "selected profiles";
+ } else {
+ ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
+ state = entry.getActivationState();
+ selectionText = entry.getId();
+ }
+
+ if ( state == null || ProfileState.Disabled.equals(state)) {
text = Messages.SelectProfilesDialog_Activate_menu;
- activationAction.setText(NLS.bind(text, entry.getId()));
+ activationAction.setText(NLS.bind(text, selectionText));
manager.add(activationAction);
}
if( !ProfileState.Disabled.equals(state)) {
text = Messages.SelectProfilesDialog_Deactivate_menu;
- deActivationAction.setText(NLS.bind(text, entry.getId()));
+ deActivationAction.setText(NLS.bind(text, selectionText));
manager.add(deActivationAction);
}
}
@@ -497,12 +500,20 @@
}
*/
- private void setActivationState(final ProfileSelection profileSelection, ProfileState
state) {
- profileSelection.setActivationState(state);
- profileTableViewer.setChecked(profileSelection, true);
- profileTableViewer.setGrayed(profileSelection, false);
- if (ProfileState.Disabled.equals(state)) {
- profileSelection.setSelected(true);
+ private void setActivationState(final IStructuredSelection sel, ProfileState state) {
+ if (sel == null) return;
+ Iterator<?> ite = sel.iterator();
+ while (ite.hasNext()) {
+ Object o = ite.next();
+ if (o instanceof ProfileSelection) {
+ ProfileSelection ps = (ProfileSelection) o;
+ ps.setActivationState(state);
+ profileTableViewer.setGrayed(ps, false);
+ if (ProfileState.Disabled.equals(state)) {
+ profileTableViewer.setChecked(ps, true);
+ ps.setSelected(true);
+ }
+ }
}
}
@@ -526,8 +537,7 @@
IStructuredSelection selection = (IStructuredSelection) profileTableViewer
.getSelection();
if (!selection.isEmpty()) {
- final ProfileSelection entry = (ProfileSelection) selection.getFirstElement();
- setActivationState(entry, state);
+ setActivationState(selection, state);
refresh();
}
super.run();
Show replies by date