	public Object execute(ExecutionEvent event) throws ExecutionException {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		final Set<IMavenProjectFacade> facades = getSelectedMavenProjects(event);
		if (!facades.isEmpty() ) {
			System.out.print("Select projects "+facades);
			final IProfileManager profileManager = MavenCoreActivator.getDefault().getProfileManager();
			final List<ProfileSelection> sharedProfiles;
			final Map<IMavenProjectFacade, List<ProfileStatus>> allProfiles;
			try {
				allProfiles = getAllProfiles(facades, profileManager);
				sharedProfiles = getSharedProfiles(allProfiles);
			} catch (CoreException e) {
				throw new ExecutionException("Unable to open the Maven Profile selection dialog", e);
			}
			final SelectProfilesDialog dialog = new SelectProfilesDialog(window.getShell(), 
																	facades, 
																	sharedProfiles);
		    if(dialog.open() == Window.OK) {
				WorkspaceJob job = new WorkspaceJob(Messages.ProfileManager_Updating_maven_profiles) {
					public IStatus runInWorkspace(IProgressMonitor monitor) {
						try {
							for (Map.Entry<IMavenProjectFacade, List<ProfileStatus>> entry : allProfiles.entrySet()){
								IMavenProjectFacade facade = entry.getKey();
								List<String> activeProfiles = getActiveProfiles(sharedProfiles, entry.getValue());
								profileManager.updateActiveProfiles(facade, activeProfiles, 
									dialog.isOffline(), dialog.isForceUpdate(), monitor); 
							}
						} catch (CoreException ex) {
							Activator.log(ex);
							return ex.getStatus();
						}
						return Status.OK_STATUS;
					}
					private List<String> getActiveProfiles(
							List<ProfileSelection> sharedProfiles,
							List<ProfileStatus> availableProfiles) {
						List<String> ids = new ArrayList<String>();
						for (ProfileStatus st : availableProfiles) {
							ProfileSelection selection = findSelectedProfile(st.getId(), sharedProfiles);
							String id = null;
							boolean isDisabled = false;
							if (selection == null) {
								if (st.isUserSelected()) {
									id = st.getId();
									isDisabled = st.getActivationState().equals(ProfileState.Disabled);
								}
							} else {
								if (null == selection.getSelected()) {
									if (st.isUserSelected()) {
										id = st.getId();
										isDisabled = st.getActivationState().equals(ProfileState.Disabled);
									}
								} else {
									if (Boolean.TRUE.equals(selection.getSelected())) {
										id = st.getId();
										isDisabled = st.getActivationState().equals(ProfileState.Disabled);
									}
								}
							}
							if (id != null) {
								if (isDisabled) {
									id = "!"+id;
								}
								ids.add(id);
							}
						}
						return ids;
					}
					private ProfileSelection findSelectedProfile(String id,
							List<ProfileSelection> sharedProfiles) {
						for (ProfileSelection sel : sharedProfiles) {
							if (id.equals(sel.getId())) {
								return sel;
							}
						}
						return null;
					}
				};
				job.setRule( MavenPlugin.getProjectConfigurationManager().getRule());
				job.schedule();
		    }		
		}
	    return null;
	}

	public Object execute(ExecutionEvent event) throws ExecutionException {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		final Set<IMavenProjectFacade> facades = getSelectedMavenProjects(event);
		if (!facades.isEmpty() ) {
			System.out.print("Select projects "+facades);
			final IProfileManager profileManager = MavenCoreActivator.getDefault().getProfileManager();
			final List<ProfileSelection> sharedProfiles;
			final Map<IMavenProjectFacade, List<ProfileStatus>> allProfiles;
			try {
				allProfiles = getAllProfiles(facades, profileManager);
				sharedProfiles = getSharedProfiles(allProfiles);
			} catch (CoreException e) {
				throw new ExecutionException("Unable to open the Maven Profile selection dialog", e);
			}
			final SelectProfilesDialog dialog = new SelectProfilesDialog(window.getShell(), 
																	facades, 
																	sharedProfiles);
		    if(dialog.open() == Window.OK) {
				WorkspaceJob job = new WorkspaceJob(Messages.ProfileManager_Updating_maven_profiles) {
					public IStatus runInWorkspace(IProgressMonitor monitor) {
						try {
							for (Map.Entry<IMavenProjectFacade, List<ProfileStatus>> entry : allProfiles.entrySet()){
								IMavenProjectFacade facade = entry.getKey();
								List<String> activeProfiles = getActiveProfiles(sharedProfiles, entry.getValue());
								profileManager.updateActiveProfiles(facade, activeProfiles, 
									dialog.isOffline(), dialog.isForceUpdate(), monitor); 
							}
						} catch (CoreException ex) {
							Activator.log(ex);
							return ex.getStatus();
						}
						return Status.OK_STATUS;
					}
					private List<String> getActiveProfiles(
							List<ProfileSelection> sharedProfiles,
							List<ProfileStatus> availableProfiles) {
						List<String> ids = new ArrayList<String>();
						for (ProfileStatus st : availableProfiles) {
							ProfileSelection selection = findSelectedProfile(st.getId(), sharedProfiles);
							String id = null;
							boolean isDisabled = false;
							if (selection == null) {
								if (st.isUserSelected()) {
									id = st.getId();
									isDisabled = st.getActivationState().equals(ProfileState.Disabled);
								}
							} else {
								if (null == selection.getSelected()) {
									if (st.isUserSelected()) {
										id = st.getId();
										isDisabled = st.getActivationState().equals(ProfileState.Disabled);
									}
								} else {
									if (Boolean.TRUE.equals(selection.getSelected())) {
										id = selection.getId();
										isDisabled = selection.getActivationState().equals(ProfileState.Disabled);
									}
								}
							}
							if (id != null) {
								if (isDisabled) {
									id = "!"+id;
								}
								ids.add(id);
							}
						}
						return ids;
					}
					private ProfileSelection findSelectedProfile(String id,
							List<ProfileSelection> sharedProfiles) {
						for (ProfileSelection sel : sharedProfiles) {
							if (id.equals(sel.getId())) {
								return sel;
							}
						}
						return null;
					}
				};
				job.setRule( MavenPlugin.getProjectConfigurationManager().getRule());
				job.schedule();
		    }		
		}
	    return null;
	}
