Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2013-10-07 11:36:25 +0000
committerFred Bricon2013-10-07 11:36:25 +0000
commita9a6c841e0fa5f648e284c32919c0066a9d58c74 (patch)
tree006b3166c19d91548a8bf8247c5b2358ea5177e7
parentadfe1dc17d699d4483bce84149f2be3c5ea1d007 (diff)
downloadm2e-core-a9a6c841e0fa5f648e284c32919c0066a9d58c74.tar.gz
m2e-core-a9a6c841e0fa5f648e284c32919c0066a9d58c74.tar.xz
m2e-core-a9a6c841e0fa5f648e284c32919c0066a9d58c74.zip
418801 : restore import project to existing working set
The feature is partially restored in that it can only add the imported projects to one workingset, instead of several previously. But I thing it's a fair compromise. Bug 418801 Signed-off-by: Fred Bricon <fbricon@gmail.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java40
1 files changed, 35 insertions, 5 deletions
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 e13ea245..5b48b274 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
@@ -18,7 +18,9 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,8 +65,10 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Text;
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;
@@ -110,7 +114,9 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
private Button createWorkingSet;
- private Text workingSetName;
+ private Combo workingSetName;
+
+ private Set<String> existingWorkingSets;
public MavenImportWizardPage(ProjectImportConfiguration importConfiguration) {
super("MavenProjectImportWizardPage", importConfiguration); //$NON-NLS-1$
@@ -385,7 +391,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
}
});
- workingSetName = new Text(composite, SWT.BORDER);
+ workingSetName = new Combo(composite, SWT.BORDER);
GridData gd_workingSet = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
gd_workingSet.horizontalIndent = 20;
workingSetName.setLayoutData(gd_workingSet);
@@ -414,6 +420,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
}
public void dispose() {
+ existingWorkingSets = null;
super.dispose();
}
@@ -452,11 +459,21 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
if(projects != null && projects.size() == 1) {
rootProject = projects.get(0);
}
+
+ String name;
+ Set<String> workingSetNames = new LinkedHashSet<String>();
if(rootProject != null) {
- workingSetName.setText(getImportConfiguration().getProjectName(rootProject.getModel()));
+ name = getImportConfiguration().getProjectName(rootProject.getModel());
+ workingSetNames.add(name);
} else {
- workingSetName.setText(""); //$NON-NLS-1$
+ name = "";//$NON-NLS-1$
}
+ workingSetNames.addAll(getExistingWorkingSets());
+
+ String[] workingSetNameArray = new String[workingSetNames.size()];
+ workingSetName.setItems(workingSetNames.toArray(workingSetNameArray));
+ workingSetName.setText(name);
+
if(rootProject != null && !rootProject.getProjects().isEmpty()) {
createWorkingSet.setSelection(true);
workingSetName.setEnabled(true);
@@ -594,6 +611,19 @@ 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