Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.ui.navigator.resources/plugin.xml11
-rw-r--r--bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/FoldersAsProjectsActionProvider.java58
-rw-r--r--bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/OpenFolderAsProjectAction.java66
-rw-r--r--bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/SelectProjectForFolderAction.java48
-rw-r--r--bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorMessages.java6
-rw-r--r--bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/messages.properties6
6 files changed, 193 insertions, 2 deletions
diff --git a/bundles/org.eclipse.ui.navigator.resources/plugin.xml b/bundles/org.eclipse.ui.navigator.resources/plugin.xml
index 64405193e54..c489d6926a7 100644
--- a/bundles/org.eclipse.ui.navigator.resources/plugin.xml
+++ b/bundles/org.eclipse.ui.navigator.resources/plugin.xml
@@ -150,6 +150,15 @@
</commonWizard>
</navigatorContent>
<actionProvider
+ id="org.eclipse.ui.navigator.resources.FoldersAsProjectsActionProvider"
+ class="org.eclipse.ui.internal.navigator.resources.actions.FoldersAsProjectsActionProvider">
+ <enablement>
+ <or>
+ <adapt type="org.eclipse.core.resources.IFolder" />
+ </or>
+ </enablement>
+ </actionProvider>
+ <actionProvider
id="org.eclipse.ui.navigator.resources.OpenActions"
class="org.eclipse.ui.internal.navigator.resources.actions.OpenActionProvider">
<enablement>
@@ -392,5 +401,5 @@
<perspectiveExtension targetID = "org.eclipse.ui.resourcePerspective">
<showInPart id = "org.eclipse.ui.navigator.ProjectExplorer"/>
</perspectiveExtension>
- </extension>
+ </extension>
</plugin>
diff --git a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/FoldersAsProjectsActionProvider.java b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/FoldersAsProjectsActionProvider.java
new file mode 100644
index 00000000000..d777b498351
--- /dev/null
+++ b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/FoldersAsProjectsActionProvider.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael Istria (Red Hat Inc.) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.internal.navigator.AdaptabilityUtility;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+public class FoldersAsProjectsActionProvider extends CommonActionProvider {
+
+ private CommonViewer viewer;
+
+ @Override
+ public void init(ICommonActionExtensionSite aSite) {
+ viewer = (CommonViewer) aSite.getStructuredViewer();
+ }
+
+ @Override
+ public void fillContextMenu(IMenuManager aMenu) {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+ if (selection.size() != 1) {
+ return;
+ }
+ Object object = selection.getFirstElement();
+ IFolder folder = (IFolder)AdaptabilityUtility.getAdapter(object, IFolder.class);
+ if (folder == null) {
+ return;
+ }
+ if (folder.getFile(IProjectDescription.DESCRIPTION_FILE_NAME).exists()) {
+ for (IProject project : folder.getWorkspace().getRoot().getProjects()) {
+ if (project.getLocation().equals(folder.getLocation())) {
+ // project already in workspace
+ SelectProjectForFolderAction action = new SelectProjectForFolderAction(project, this.viewer);
+ aMenu.insertAfter(ICommonMenuConstants.GROUP_OPEN, action);
+ return;
+ }
+ }
+ OpenFolderAsProjectAction action = new OpenFolderAsProjectAction(folder, this.viewer);
+ aMenu.insertAfter(ICommonMenuConstants.GROUP_BUILD, action);
+ }
+ }
+
+}
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
new file mode 100644
index 00000000000..b1f35c3f71a
--- /dev/null
+++ b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/OpenFolderAsProjectAction.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael Istria (Red Hat Inc.) - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+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.IProjectDescription;
+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.PlatformUI;
+import org.eclipse.ui.ide.IDE.SharedImages;
+import org.eclipse.ui.ide.undo.CreateProjectOperation;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * @since 3.3
+ *
+ */
+public class OpenFolderAsProjectAction extends Action {
+
+ private IFolder folder;
+ private CommonViewer viewer;
+
+ /**
+ * @param folder
+ * @param viewer
+ */
+ public OpenFolderAsProjectAction(IFolder folder, CommonViewer viewer) {
+ super(WorkbenchNavigatorMessages.OpenProjectAction_OpenExistingProject);
+ this.folder = folder;
+ this.viewer = viewer;
+ setDescription(WorkbenchNavigatorMessages.OpenProjectAction_OpenExistingProject_desc);
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(SharedImages.IMG_OBJ_PROJECT));
+ }
+
+ public void run() {
+ try {
+ 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()));
+ } else {
+ WorkbenchNavigatorPlugin.getDefault().getLog().log(status);
+ }
+ } catch (Exception ex) {
+ WorkbenchNavigatorPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, WorkbenchNavigatorPlugin.getDefault().getBundle().getSymbolicName(), ex.getMessage()));
+ }
+ }
+}
diff --git a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/SelectProjectForFolderAction.java b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/SelectProjectForFolderAction.java
new file mode 100644
index 00000000000..fd1257e5358
--- /dev/null
+++ b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/SelectProjectForFolderAction.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mickael Istria (Red Hat Inc.) - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE.SharedImages;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * @since 3.3
+ *
+ */
+public class SelectProjectForFolderAction extends Action {
+
+ private IProject project;
+ private CommonViewer viewer;
+
+ /**
+ * @param project
+ * @param viewer
+ */
+ public SelectProjectForFolderAction(IProject project, CommonViewer viewer) {
+ super(NLS.bind(WorkbenchNavigatorMessages.SelectProjectForFolderAction_SelectProject, project.getName()));
+ this.project = project;
+ this.viewer = viewer;
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(SharedImages.IMG_OBJ_PROJECT));
+ }
+
+ @Override
+ public void run() {
+ viewer.setSelection(new StructuredSelection( new Object[] { this.project } ));
+ }
+
+}
diff --git a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorMessages.java b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorMessages.java
index d73093bf4e7..9fc0879c84c 100644
--- a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorMessages.java
+++ b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorMessages.java
@@ -22,6 +22,7 @@ public class WorkbenchNavigatorMessages extends NLS {
/** The bundle properties file */
public static final String BUNDLE_NAME = "org.eclipse.ui.internal.navigator.resources.plugin.messages"; //$NON-NLS-1$
+
public static String PortingActionProvider_ImportResourcesMenu_label;
public static String PortingActionProvider_ExportResourcesMenu_label;
@@ -64,6 +65,11 @@ public class WorkbenchNavigatorMessages extends NLS {
public static String ProjectExplorerPart_workspace;
public static String ProjectExplorerPart_workingSetModel;
+ public static String OpenProjectAction_OpenExistingProject;
+ public static String OpenProjectAction_OpenExistingProject_desc;
+
+ public static String SelectProjectForFolderAction_SelectProject;
+
static {
initializeMessages(BUNDLE_NAME, WorkbenchNavigatorMessages.class);
diff --git a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/messages.properties b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/messages.properties
index 2fd30abae2b..375ac21118d 100644
--- a/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/messages.properties
+++ b/bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2013 IBM Corporation and others.
+# Copyright (c) 2005, 2014 IBM Corporation and others.
# 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
@@ -7,6 +7,7 @@
#
# Contributors:
# IBM Corporation - initial API and implementation
+# Mickael Istria (Red Hat Inc.) - 427774
###############################################################################
#String externalization, key=value
#Tue Aug 15 11:29:14 EDT 2006
@@ -39,3 +40,6 @@ ProjectExplorer_toolTip3= {0}/{1}
ProjectExplorerPart_workspace=Workspace
ProjectExplorerPart_workingSetModel=Working Sets
ResourceMgmtActionProvider_logTitle=Exception in {0}. run: {1}
+OpenProjectAction_OpenExistingProject=Open As Project
+OpenProjectAction_OpenExistingProject_desc=Open this existing Project into Workspace
+SelectProjectForFolderAction_SelectProject=Go to project ''{0}'' \ No newline at end of file

Back to the top