Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2015-01-08 18:02:25 +0000
committerDani Megert2015-02-12 12:09:58 +0000
commit7c14722eba0de1fbd567ebd5ce2be64316a3ff6f (patch)
tree418ababece9641dea0a5619f2bc67322660609f4
parent2339c884e54f50138b505b16a2f1d558134bbbb6 (diff)
downloadeclipse.platform.ui-7c14722eba0de1fbd567ebd5ce2be64316a3ff6f.tar.gz
eclipse.platform.ui-7c14722eba0de1fbd567ebd5ce2be64316a3ff6f.tar.xz
eclipse.platform.ui-7c14722eba0de1fbd567ebd5ce2be64316a3ff6f.zip
Bug 442459: Import project from context menu inherits parent working
sets Change-Id: I3ce639c2634d82b46937f5fe56c2f91f12f42b22 Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/OpenFolderAsProjectAction.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/OpenFolderAsProjectAction.java b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/OpenFolderAsProjectAction.java
index e96d431df0d..70bf9d03018 100644
--- a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/OpenFolderAsProjectAction.java
+++ b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/OpenFolderAsProjectAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Red Hat Inc.
+ * Copyright (c) 2014, 2015 Red Hat Inc.
* 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
@@ -12,16 +12,22 @@
package org.eclipse.ui.internal.navigator.resources.actions;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.core.internal.resources.ProjectDescriptionReader;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE.SharedImages;
import org.eclipse.ui.ide.undo.CreateProjectOperation;
@@ -53,12 +59,25 @@ public class OpenFolderAsProjectAction extends Action {
@Override
public void run() {
try {
+ IProject parentProject = this.folder.getProject();
+ Set<IWorkingSet> parentWorkingSets = new HashSet<IWorkingSet>();
+ IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ for (IWorkingSet workingSet : workingSetManager.getWorkingSets()) {
+ for (IAdaptable element : workingSet.getElements()) {
+ if (parentProject.equals(element.getAdapter(IProject.class))) {
+ parentWorkingSets.add(workingSet);
+ break;
+ }
+ }
+ }
IProjectDescription desc = new ProjectDescriptionReader().read(folder.getLocation().append(IProjectDescription.DESCRIPTION_FILE_NAME));
desc.setLocation(folder.getLocation());
CreateProjectOperation operation = new CreateProjectOperation(desc, desc.getName());
IStatus status = OperationHistoryFactory.getOperationHistory().execute(operation, null, null);
if (status.isOK()) {
- viewer.setSelection(new StructuredSelection(operation.getAffectedObjects()));
+ IProject newProject = (IProject) operation.getAffectedObjects()[0];
+ workingSetManager.addToWorkingSets(newProject, parentWorkingSets.toArray(new IWorkingSet[parentWorkingSets.size()]));
+ viewer.setSelection(new StructuredSelection(newProject));
} else {
WorkbenchNavigatorPlugin.getDefault().getLog().log(status);
}

Back to the top