author | dadubrow |
Wed, 30 Jun 2010 15:34:24 -0500 | |
changeset 1564 | 1c3ed56966df |
permissions | -rw-r--r-- |
1564
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
1 |
/* |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
3 |
* All rights reserved. |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
8 |
* |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
9 |
* Initial Contributors: |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
11 |
* |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
12 |
* Contributors: |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
13 |
* |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
14 |
* Description: |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
15 |
* |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
16 |
*/ |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
17 |
package com.nokia.carbide.internal.win32.utils.actions; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
18 |
|
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
19 |
import org.eclipse.core.commands.AbstractHandler; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
20 |
import org.eclipse.core.commands.ExecutionEvent; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
21 |
import org.eclipse.core.commands.ExecutionException; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
22 |
import org.eclipse.core.resources.IResource; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
23 |
import org.eclipse.core.runtime.IAdaptable; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
24 |
import org.eclipse.jface.viewers.ISelection; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
25 |
import org.eclipse.jface.viewers.IStructuredSelection; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
26 |
import org.eclipse.ui.handlers.HandlerUtil; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
27 |
|
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
28 |
public class OpenInExplorerHandler extends AbstractHandler { |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
29 |
|
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
30 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
31 |
ISelection s = HandlerUtil.getActiveMenuSelection(event); |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
32 |
if (s != null && s instanceof IStructuredSelection) { |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
33 |
Object o = ((IStructuredSelection) s).getFirstElement(); |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
34 |
if (o instanceof IAdaptable) { |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
35 |
IResource r = (IResource) ((IAdaptable) o).getAdapter(IResource.class); |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
36 |
if (r != null) |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
37 |
WindowsOpenFileUtils.executeAction(WindowsOpenFileUtils.OPEN_IN_EXPLORER, r); |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
38 |
} |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
39 |
} |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
40 |
return null; |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
41 |
} |
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
42 |
|
1c3ed56966df
remove show in explorer/command prompt from editor context menu
dadubrow
parents:
diff
changeset
|
43 |
} |