|
1 | 1 | package net.servicestack.eclipse.popup.actions; |
2 | 2 |
|
3 | 3 | import org.eclipse.jface.action.IAction; |
4 | | -import org.eclipse.jface.dialogs.MessageDialog; |
5 | 4 | import org.eclipse.jface.viewers.ISelection; |
| 5 | +import org.eclipse.jface.viewers.IStructuredSelection; |
6 | 6 | import org.eclipse.swt.widgets.Shell; |
7 | 7 | import org.eclipse.ui.IObjectActionDelegate; |
| 8 | +import org.eclipse.ui.ISelectionService; |
8 | 9 | import org.eclipse.ui.IWorkbenchPart; |
| 10 | +import org.eclipse.jdt.internal.core.PackageFragment; |
9 | 11 |
|
10 | 12 | public class AddReferenceAction implements IObjectActionDelegate { |
11 | 13 |
|
12 | 14 | private Shell shell; |
| 15 | + private ISelectionService selectionService; |
13 | 16 |
|
14 | 17 | /** |
15 | 18 | * Constructor for Action1. |
16 | 19 | */ |
17 | 20 | public AddReferenceAction() { |
18 | 21 | super(); |
19 | 22 | } |
20 | | - |
| 23 | + |
21 | 24 | /** |
22 | 25 | * @see IObjectActionDelegate |
23 | 26 | */ |
24 | 27 | public void setActivePart(IAction action, IWorkbenchPart targetPart) { |
25 | 28 | shell = targetPart.getSite().getShell(); |
| 29 | + selectionService = targetPart.getSite().getWorkbenchWindow().getSelectionService(); |
26 | 30 | } |
27 | 31 |
|
28 | 32 | /** |
29 | 33 | * @see IActionDelegate#run(IAction) |
30 | 34 | */ |
31 | 35 | public void run(IAction action) { |
| 36 | + IStructuredSelection structured = (IStructuredSelection) selectionService |
| 37 | + .getSelection("org.eclipse.jdt.ui.PackageExplorer"); |
| 38 | + Object firstElement = structured.getFirstElement(); |
| 39 | + if(firstElement instanceof PackageFragment) { //NoClassDefFoundError... |
| 40 | + PackageFragment packFrag = (PackageFragment)firstElement; |
| 41 | + } |
| 42 | +// IFolder folder = (IFolder) structured.getFirstElement(); |
| 43 | +// if(folder == null) { |
| 44 | +// return; |
| 45 | +// } |
| 46 | +// IPath path = folder.getLocation(); |
| 47 | +// |
| 48 | +// ObjectPluginAction pluginAction = (ObjectPluginAction)action; |
32 | 49 | AddRefDialog dialog = new AddRefDialog(); |
33 | 50 | dialog.pack(); |
34 | 51 | dialog.setLocationRelativeTo(null); |
|
0 commit comments