# HG changeset patch # User dadubrow # Date 1277930064 18000 # Node ID 1c3ed56966df409da7b4ed1df840ae99714f9e13 # Parent cc9cfb62406b6b9a1763099f0e9d3ced01fc2b36 remove show in explorer/command prompt from editor context menu diff -r cc9cfb62406b -r 1c3ed56966df core/com.nokia.carbide.win32.utils/META-INF/MANIFEST.MF --- a/core/com.nokia.carbide.win32.utils/META-INF/MANIFEST.MF Wed Jun 30 14:00:29 2010 -0500 +++ b/core/com.nokia.carbide.win32.utils/META-INF/MANIFEST.MF Wed Jun 30 15:34:24 2010 -0500 @@ -9,5 +9,6 @@ org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.cdt.core, - org.eclipse.cdt.ui + org.eclipse.cdt.ui, + org.eclipse.core.expressions;bundle-version="3.4.100" Bundle-ActivationPolicy: lazy diff -r cc9cfb62406b -r 1c3ed56966df core/com.nokia.carbide.win32.utils/plugin.xml --- a/core/com.nokia.carbide.win32.utils/plugin.xml Wed Jun 30 14:00:29 2010 -0500 +++ b/core/com.nokia.carbide.win32.utils/plugin.xml Wed Jun 30 15:34:24 2010 -0500 @@ -1,23 +1,58 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r cc9cfb62406b -r 1c3ed56966df core/com.nokia.carbide.win32.utils/src/com/nokia/carbide/internal/win32/utils/actions/OpenInCmdPromptHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.win32.utils/src/com/nokia/carbide/internal/win32/utils/actions/OpenInCmdPromptHandler.java Wed Jun 30 15:34:24 2010 -0500 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.carbide.internal.win32.utils.actions; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; + +public class OpenInCmdPromptHandler extends AbstractHandler { + + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection s = HandlerUtil.getActiveMenuSelection(event); + if (s != null && s instanceof IStructuredSelection) { + Object o = ((IStructuredSelection) s).getFirstElement(); + if (o instanceof IAdaptable) { + IResource r = (IResource) ((IAdaptable) o).getAdapter(IResource.class); + if (r != null) + WindowsOpenFileUtils.executeAction(WindowsOpenFileUtils.OPEN_IN_COMMAND_PROMPT, r); + } + } + return null; + } + +} diff -r cc9cfb62406b -r 1c3ed56966df core/com.nokia.carbide.win32.utils/src/com/nokia/carbide/internal/win32/utils/actions/OpenInExplorerHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.win32.utils/src/com/nokia/carbide/internal/win32/utils/actions/OpenInExplorerHandler.java Wed Jun 30 15:34:24 2010 -0500 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.carbide.internal.win32.utils.actions; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; + +public class OpenInExplorerHandler extends AbstractHandler { + + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection s = HandlerUtil.getActiveMenuSelection(event); + if (s != null && s instanceof IStructuredSelection) { + Object o = ((IStructuredSelection) s).getFirstElement(); + if (o instanceof IAdaptable) { + IResource r = (IResource) ((IAdaptable) o).getAdapter(IResource.class); + if (r != null) + WindowsOpenFileUtils.executeAction(WindowsOpenFileUtils.OPEN_IN_EXPLORER, r); + } + } + return null; + } + +} diff -r cc9cfb62406b -r 1c3ed56966df core/com.nokia.carbide.win32.utils/src/com/nokia/carbide/internal/win32/utils/actions/WindowsOpenFileUtils.java --- a/core/com.nokia.carbide.win32.utils/src/com/nokia/carbide/internal/win32/utils/actions/WindowsOpenFileUtils.java Wed Jun 30 14:00:29 2010 -0500 +++ b/core/com.nokia.carbide.win32.utils/src/com/nokia/carbide/internal/win32/utils/actions/WindowsOpenFileUtils.java Wed Jun 30 15:34:24 2010 -0500 @@ -22,13 +22,15 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IActionDelegate; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; public class WindowsOpenFileUtils extends ActionResourceAction implements IViewActionDelegate { + public final static int OPEN_IN_EXPLORER = 1; + public final static int OPEN_IN_COMMAND_PROMPT = 2; + /** * ProcessResourceTree default constructor. */ @@ -50,14 +52,22 @@ // First get the folder name for the selected workspace resource. // Then our simple operations will work on the folder where the resource lives. - Shell shell = new Shell(); - IResource res = (IResource) selection.getFirstElement(); String pathList = ""; //$NON-NLS-1$ pathList = pathList.concat(Messages.getString("WindowsOpenFileUtils.2") + res + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ traceEnabled = false; + int actionType = 0; + if (action.getId().equals("openInWindowsExplorer")) + actionType = OPEN_IN_EXPLORER; + else if (action.getId().equals("openInCmdPrompt")) + actionType = OPEN_IN_COMMAND_PROMPT; + + executeAction(actionType, res); + } + + public static void executeAction(int actionType, IResource res) { String folderFullPath = ""; //$NON-NLS-1$ if (res instanceof IFolder || res instanceof IProject){ folderFullPath = res.getLocation().toOSString(); @@ -66,7 +76,7 @@ } // figure out what action logic to run based on xml id - if (action.getId().equals("openInWindowsExplorer")) //$NON-NLS-1$ + if (actionType == OPEN_IN_EXPLORER) { String exeCmd = "explorer.exe "; //$NON-NLS-1$ exeCmd += "\""; //$NON-NLS-1$ @@ -80,12 +90,12 @@ catch (CoreException e) { MessageDialog.openInformation( - shell, + null, Messages.getString("WindowsOpenFileUtils.10"), //$NON-NLS-1$ ""); //$NON-NLS-1$ } } - else if (action.getId().equals("openInCmdPrompt")) //$NON-NLS-1$ + else if (actionType == OPEN_IN_COMMAND_PROMPT) { String exeCmd = "cmd.exe /c start cd /d "; //$NON-NLS-1$ exeCmd += folderFullPath; @@ -96,7 +106,7 @@ catch (CoreException e) { MessageDialog.openInformation( - shell, + null, Messages.getString("WindowsOpenFileUtils.14"), //$NON-NLS-1$ ""); //$NON-NLS-1$ }