1+ package net .servicestack .eclipse .popup .actions ;
2+
3+ import net .servicestack .eclipse .wizard .AddReferenceWizard ;
4+
5+ import org .eclipse .core .resources .IFolder ;
6+ import org .eclipse .jdt .core .IPackageFragment ;
7+ import org .eclipse .jface .action .IAction ;
8+ import org .eclipse .jface .viewers .ISelection ;
9+ import org .eclipse .jface .viewers .IStructuredSelection ;
10+ import org .eclipse .jface .wizard .WizardDialog ;
11+ import org .eclipse .swt .widgets .Shell ;
12+ import org .eclipse .ui .IObjectActionDelegate ;
13+ import org .eclipse .ui .ISelectionService ;
14+ import org .eclipse .ui .IWorkbenchPart ;
15+
16+ public class UpdateReference implements IObjectActionDelegate {
17+
18+ private Shell shell ;
19+ private IFolder _selection ;
20+ private IPackageFragment _packageFragment ;
21+ private ISelectionService selectionService ;
22+ /**
23+ * Constructor for Action1.
24+ */
25+ public UpdateReference () {
26+ super ();
27+ }
28+
29+ /**
30+ * @see IObjectActionDelegate
31+ */
32+ public void setActivePart (IAction action , IWorkbenchPart targetPart ) {
33+ shell = targetPart .getSite ().getShell ();
34+ targetPart .getSite ().getWorkbenchWindow ().getSelectionService ();
35+ selectionService = targetPart .getSite ().getWorkbenchWindow ().getSelectionService ();
36+ }
37+
38+ /**
39+ * @see IActionDelegate#run(IAction)
40+ */
41+ public void run (IAction action ) {
42+ if (_selection != null ) {
43+ IStructuredSelection packageSelection = (IStructuredSelection ) selectionService
44+ .getSelection ("org.eclipse.jdt.ui.PackageExplorer" );
45+
46+ AddReferenceWizard generationWizard = new AddReferenceWizard (_selection , packageSelection );
47+ WizardDialog dialog = new WizardDialog (shell , generationWizard );
48+
49+ if (dialog .open () == WizardDialog .OK ){
50+ // MessageDialog.openInformation(shell, "CTE tree generation", "CTE trees are being generated, checking the process view for details!");
51+ }
52+ }
53+ }
54+
55+ /**
56+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
57+ */
58+ @ Override
59+ public void selectionChanged (IAction action , ISelection selection ) {
60+ if (selection instanceof IStructuredSelection ) {
61+ IStructuredSelection structured = (IStructuredSelection )selection ;
62+ Object firstElement = structured .getFirstElement ();
63+ if (firstElement instanceof IFolder ) {
64+ _selection = (IFolder ) firstElement ;
65+ }
66+ }
67+ }
68+
69+ }
0 commit comments