Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2013-10-11 08:46:13 -0400
committerIgor Fedorenko2013-10-11 16:36:08 -0400
commit44caa378b65b905f4d27e48a968b0a5802fb5fb7 (patch)
tree28175048d34b747eaecf7773898cc0144e8ab7d5
parent03101f71c4944e504683fb71ef06ff8389b91e49 (diff)
downloadm2e-core-44caa378b65b905f4d27e48a968b0a5802fb5fb7.tar.gz
m2e-core-44caa378b65b905f4d27e48a968b0a5802fb5fb7.tar.xz
m2e-core-44caa378b65b905f4d27e48a968b0a5802fb5fb7.zip
417466 AssignWorkingSetDialog usability improvements
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/WorkingSets.java133
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java6
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java1
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java110
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties3
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractCreateMavenProjectsOperation.java25
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java15
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java23
9 files changed, 200 insertions, 118 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
index ca0781de..7908260d 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
@@ -897,6 +897,8 @@ public class Messages extends NLS {
public static String AssignWorkingSetDialog_btnFilterClosedProjects_text;
+ public static String AssignWorkingSetDialog_lblWorkingSet;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/WorkingSets.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/WorkingSets.java
new file mode 100644
index 00000000..44ebbb40
--- /dev/null
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/WorkingSets.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Igor Fedorenko
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Igor Fedorenko - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.ui.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Helpers to query and manipulate workbench working sets.
+ *
+ * @since 1.5
+ */
+public class WorkingSets {
+
+ /**
+ * Returns all visible workbench working sets.
+ *
+ * @since 1.5
+ */
+ public static String[] getWorkingSets() {
+ List<String> workingSets = new ArrayList<String>();
+ IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ for(IWorkingSet workingSet : workingSetManager.getWorkingSets()) {
+ if(workingSet.isVisible()) {
+ workingSets.add(workingSet.getName());
+ }
+ }
+ return workingSets.toArray(new String[workingSets.size()]);
+ }
+
+ /**
+ * Returns existing or creates new workbench working set with the given name
+ *
+ * @since 1.5
+ */
+ public static IWorkingSet getOrCreateWorkingSet(String workingSetName) {
+ IWorkingSetManager wsm = PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSet workingSet = wsm.getWorkingSet(workingSetName);
+ if(workingSet == null) {
+ workingSet = wsm.createWorkingSet(workingSetName, new IAdaptable[0]);
+ // TODO is there a constant we should be setting here?
+ workingSet.setId("org.eclipse.ui.resourceWorkingSetPage");
+ wsm.addWorkingSet(workingSet);
+ }
+ return workingSet;
+ }
+
+ /**
+ * Adds given projects to workbench working set with the given name. Creates new working set if workbench working set
+ * with given name does not already exist.
+ *
+ * @since 1.5
+ */
+ public static void addToWorkingSet(IProject[] projects, String workingSetName) {
+ IWorkingSet[] workingSets = new IWorkingSet[] {getOrCreateWorkingSet(workingSetName)};
+ IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
+ for(IProject project : projects) {
+ manager.addToWorkingSets(project, workingSets);
+ }
+ }
+
+ /**
+ * Adds given projects to given workbench working sets.
+ *
+ * @since 1.5
+ */
+ public static void addToWorkingSets(IProject[] projects, List<IWorkingSet> workingSets) {
+ // PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(project, new IWorkingSet[] {workingSet});
+ if(projects != null && projects.length > 0 && workingSets != null && !workingSets.isEmpty()) {
+ for(IWorkingSet workingSet : workingSets) {
+ if(workingSet != null) {
+ IAdaptable[] oldElements = workingSet.getElements();
+ IAdaptable[] newElements = new IAdaptable[oldElements.length + projects.length];
+ System.arraycopy(oldElements, 0, newElements, 0, oldElements.length);
+ System.arraycopy(newElements, oldElements.length, projects, 0, projects.length);
+ workingSet.setElements(newElements);
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds given projects to given workbench working sets.
+ *
+ * @since 1.5
+ */
+ public static void addToWorkingSets(Collection<IProject> projects, List<IWorkingSet> workingSets) {
+ addToWorkingSets(projects.toArray(new IProject[projects.size()]), workingSets);
+ }
+
+ /**
+ * Returns all projects that belong to workbench working sets.
+ *
+ * @since 1.5
+ */
+ public static Set<IProject> getProjects() {
+ Set<IProject> projects = new HashSet<IProject>();
+ IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
+ for(IWorkingSet workingSet : manager.getAllWorkingSets()) {
+ try {
+ for(IAdaptable element : workingSet.getElements()) {
+ IProject project = (IProject) element.getAdapter(IProject.class);
+ if(project != null) {
+ projects.add(project);
+ }
+ }
+ } catch(IllegalStateException ignored) {
+ // ignore bad/misconfigured working sets
+ }
+ }
+ return projects;
+ }
+
+}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java
index b3ea56a2..1f6f7bb4 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/NestedProjectsComposite.java
@@ -356,7 +356,7 @@ public class NestedProjectsComposite extends Composite implements IMenuListener
}
};
- IProject getSelection() {
+ public IProject getSelection() {
ISelection selection = codebaseViewer.getSelection();
if(selection instanceof IStructuredSelection) {
return (IProject) ((IStructuredSelection) selection).getFirstElement();
@@ -391,4 +391,8 @@ public class NestedProjectsComposite extends Composite implements IMenuListener
codebaseViewer.setSubtreeChecked(project, false);
}
}
+
+ public void addSelectionChangeListener(ISelectionChangedListener listener) {
+ codebaseViewer.addSelectionChangedListener(listener);
+ }
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java
index 20d475ff..b8c604c2 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/components/WorkingSetGroup.java
@@ -56,6 +56,7 @@ import org.eclipse.m2e.core.ui.internal.Messages;
*
* @author Eugene Kuleshov
*/
+// TODO reconcile with WorkingSets
public class WorkingSetGroup {
static final List<String> WORKING_SET_IDS = Arrays.asList( //
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java
index 3acd4bee..d862a46c 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/AssignWorkingSetDialog.java
@@ -11,33 +11,33 @@
package org.eclipse.m2e.core.ui.internal.dialogs;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.ui.internal.Messages;
+import org.eclipse.m2e.core.ui.internal.WorkingSets;
import org.eclipse.m2e.core.ui.internal.components.NestedProjectsComposite;
-import org.eclipse.m2e.core.ui.internal.components.WorkingSetGroup;
/**
@@ -50,35 +50,17 @@ public class AssignWorkingSetDialog extends TitleAreaDialog {
NestedProjectsComposite selectedProjects;
- private List<IWorkingSet> workingSets = new ArrayList<IWorkingSet>();
+ Set<IProject> allWorkingSetProjects = new HashSet<IProject>(WorkingSets.getProjects());
- Set<IProject> allWorkingSetProjects = getAllWorkingSetProjects();
+ Combo workingSetCombo;
- WorkingSetGroup workingSetGroup;
+ String workingSetName;
public AssignWorkingSetDialog(Shell parentShell, IProject[] initialSelection) {
super(parentShell);
this.initialSelection = initialSelection;
}
- private static Set<IProject> getAllWorkingSetProjects() {
- Set<IProject> projects = new HashSet<IProject>();
- IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
- for(IWorkingSet workingSet : manager.getAllWorkingSets()) {
- try {
- for(IAdaptable element : workingSet.getElements()) {
- IProject project = (IProject) element.getAdapter(IProject.class);
- if(project != null) {
- projects.add(project);
- }
- }
- } catch(IllegalStateException ignored) {
- // ignore bad/misconfigured working sets
- }
- }
- return projects;
- }
-
protected Control createDialogArea(Composite parent) {
setTitle(Messages.AssignWorkingSetDialog_title);
@@ -128,47 +110,55 @@ public class AssignWorkingSetDialog extends TitleAreaDialog {
}
return !btnFilterAssignedProjects.getSelection() || !allWorkingSetProjects.contains(project);
}
-
- @Override
- protected void createButtons(Composite selectionActionComposite) {
- super.createButtons(selectionActionComposite);
-
- Label label = new Label(selectionActionComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
-
- Button btnAssign = new Button(selectionActionComposite, SWT.NONE);
- btnAssign.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
- btnAssign.setText(Messages.AssignWorkingSetDialog_btnAssign_text);
- btnAssign.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- assignWorkingSets();
- reset();
- }
- });
- }
};
selectedProjects.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
- this.workingSetGroup = new WorkingSetGroup(composite, workingSets, getShell());
+ Composite workingSetComposite = new Composite(composite, SWT.NONE);
+ workingSetComposite.setLayout(new GridLayout(3, false));
+ workingSetComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 3, 1));
- return area;
- }
+ Label lblNewLabel = new Label(workingSetComposite, SWT.NONE);
+ lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ lblNewLabel.setText(Messages.AssignWorkingSetDialog_lblWorkingSet);
- public IWorkingSet[] getWorkingSets() {
- return workingSets.toArray(new IWorkingSet[workingSets.size()]);
- }
+ workingSetCombo = new Combo(workingSetComposite, SWT.BORDER);
+ workingSetCombo.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ workingSetName = workingSetCombo.getText();
+ }
+ });
+ GridData gd_workingSetName = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
+ gd_workingSetName.horizontalIndent = 10;
+ workingSetCombo.setLayoutData(gd_workingSetName);
+ workingSetCombo.setItems(WorkingSets.getWorkingSets());
+
+ selectedProjects.addSelectionChangeListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IProject selection = selectedProjects.getSelection();
+ if(selection != null && workingSetCombo.getSelectionIndex() < 0) {
+ workingSetCombo.setText(selection.getName());
+ }
+ }
+ });
- public IProject[] getSelectedProjects() {
- return selectedProjects.getSelectedProjects();
+ Button btnAssign = new Button(workingSetComposite, SWT.NONE);
+ btnAssign.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ btnAssign.setText(Messages.AssignWorkingSetDialog_btnAssign_text);
+ btnAssign.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ assignWorkingSets();
+ selectedProjects.reset();
+ }
+ });
+
+ return area;
}
public void assignWorkingSets() {
- IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
- IWorkingSet[] workingSets = getWorkingSets();
- for(IProject project : getSelectedProjects()) {
- manager.addToWorkingSets(project, workingSets);
- allWorkingSetProjects.add(project);
+ IProject[] projects = selectedProjects.getSelectedProjects();
+ if(projects != null && projects.length > 0 && workingSetName != null && !workingSetName.isEmpty()) {
+ WorkingSets.addToWorkingSet(projects, workingSetName);
+ allWorkingSetProjects.addAll(Arrays.asList(projects));
}
}
-
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
index dca7ef29..b7d8ad9f 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
@@ -1,5 +1,5 @@
#Eclipse modern messages class
-#Tue Oct 01 21:35:50 EDT 2013
+#Thu Oct 10 22:33:49 EDT 2013
AddDependencyAction_error_msg=Can't add dependency to {0}
AddDependencyAction_error_title=Add Dependency
AddDependencyAction_searchDialog_title=Add Dependency
@@ -13,6 +13,7 @@ AddPluginAction_searchDialog_title=Add Plugin
AssignWorkingSetDialog_btnAssign_text=Assign
AssignWorkingSetDialog_btnFilterAssignedProjects_text=Filter assigned projects
AssignWorkingSetDialog_btnFilterClosedProjects_text=Filter closed projects
+AssignWorkingSetDialog_lblWorkingSet=Working set
AssignWorkingSetDialog_title=Add projects to working sets
BuildDebugView_actionClear=Clear
BuildDebugView_actionCollapseAll=Collapse All
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractCreateMavenProjectsOperation.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractCreateMavenProjectsOperation.java
index 7fba9572..81d3cfcd 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractCreateMavenProjectsOperation.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/AbstractCreateMavenProjectsOperation.java
@@ -19,7 +19,6 @@ import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -30,6 +29,7 @@ import org.eclipse.ui.IWorkingSet;
import org.eclipse.m2e.core.project.IMavenProjectImportResult;
import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
+import org.eclipse.m2e.core.ui.internal.WorkingSets;
public abstract class AbstractCreateMavenProjectsOperation implements IRunnableWithProgress {
@@ -44,23 +44,6 @@ public abstract class AbstractCreateMavenProjectsOperation implements IRunnableW
protected abstract List<IProject> doCreateMavenProjects(IProgressMonitor monitor) throws CoreException;
- // PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(project, new IWorkingSet[] {workingSet});
- public static void addToWorkingSets(IProject project, List<IWorkingSet> workingSets) {
- if(workingSets != null && !workingSets.isEmpty()) {
- // IAdaptable[] elements = workingSet.adaptElements(new IAdaptable[] {project});
- // if(elements.length == 1) {
- for(IWorkingSet workingSet : workingSets) {
- if(workingSet != null) {
- IAdaptable[] oldElements = workingSet.getElements();
- IAdaptable[] newElements = new IAdaptable[oldElements.length + 1];
- System.arraycopy(oldElements, 0, newElements, 0, oldElements.length);
- newElements[oldElements.length] = project;
- workingSet.setElements(newElements);
- }
- }
- }
- }
-
protected static ArrayList<IProject> toProjects(List<IMavenProjectImportResult> results) {
ArrayList<IProject> projects = new ArrayList<IProject>();
for(IMavenProjectImportResult result : results) {
@@ -77,11 +60,7 @@ public abstract class AbstractCreateMavenProjectsOperation implements IRunnableW
try {
try {
this.createdProjects = doCreateMavenProjects(monitor);
- if(createdProjects != null && workingSets != null && !workingSets.isEmpty()) {
- for(IProject project : createdProjects) {
- addToWorkingSets(project, workingSets);
- }
- }
+ WorkingSets.addToWorkingSets(createdProjects, workingSets);
} catch(CoreException e) {
throw new InvocationTargetException(e);
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java
index 8b2429b4..44c6445d 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java
@@ -16,19 +16,17 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.Messages;
+import org.eclipse.m2e.core.ui.internal.WorkingSets;
import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
@@ -37,7 +35,6 @@ import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
*
* @author Eugene Kuleshov
*/
-@SuppressWarnings("restriction")
public class MavenImportWizard extends AbstractMavenProjectWizard implements IImportWizard {
//private static final Logger LOG = LoggerFactory.getLogger(MavenImportWizard.class);
@@ -103,15 +100,7 @@ public class MavenImportWizard extends AbstractMavenProjectWizard implements IIm
Collection<MavenProjectInfo> projects = getProjects();
if(page.shouldCreateWorkingSet() && !projects.isEmpty()) {
- String workingSetName = page.getWorkingSetName();
- IWorkingSetManager wsm = PlatformUI.getWorkbench().getWorkingSetManager();
- IWorkingSet workingSet = wsm.getWorkingSet(workingSetName);
- if(workingSet == null) {
- workingSet = wsm.createWorkingSet(workingSetName, new IAdaptable[0]);
- // TODO is there a constant we should be setting here?
- workingSet.setId("org.eclipse.ui.resourceWorkingSetPage");
- wsm.addWorkingSet(workingSet);
- }
+ IWorkingSet workingSet = WorkingSets.getOrCreateWorkingSet(page.getWorkingSetName());
if(!workingSets.contains(workingSet)) {
workingSets.add(workingSet);
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
index 5b48b274..1d294d3e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
@@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
@@ -66,9 +67,6 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PlatformUI;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
@@ -80,6 +78,7 @@ import org.eclipse.m2e.core.project.LocalProjectScanner;
import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.Messages;
+import org.eclipse.m2e.core.ui.internal.WorkingSets;
/**
@@ -116,8 +115,6 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
private Combo workingSetName;
- private Set<String> existingWorkingSets;
-
public MavenImportWizardPage(ProjectImportConfiguration importConfiguration) {
super("MavenProjectImportWizardPage", importConfiguration); //$NON-NLS-1$
setTitle(org.eclipse.m2e.core.ui.internal.Messages.MavenImportWizardPage_title);
@@ -420,7 +417,6 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
}
public void dispose() {
- existingWorkingSets = null;
super.dispose();
}
@@ -468,7 +464,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
} else {
name = "";//$NON-NLS-1$
}
- workingSetNames.addAll(getExistingWorkingSets());
+ workingSetNames.addAll(Arrays.asList(WorkingSets.getWorkingSets()));
String[] workingSetNameArray = new String[workingSetNames.size()];
workingSetName.setItems(workingSetNames.toArray(workingSetNameArray));
@@ -611,19 +607,6 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
return workingSetName.getText();
}
- private Collection<String> getExistingWorkingSets() {
- if(existingWorkingSets == null) {
- existingWorkingSets = new LinkedHashSet<String>();
- IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
- for(IWorkingSet workingSet : workingSetManager.getWorkingSets()) {
- if(workingSet.isVisible()) {
- existingWorkingSets.add(workingSet.getName());
- }
- }
- }
- return existingWorkingSets;
- }
-
protected AbstractProjectScanner<MavenProjectInfo> getProjectScanner() {
File root = workspaceRoot.getLocation().toFile();
MavenModelManager modelManager = MavenPlugin.getMavenModelManager();

Back to the top