1
19 package com.qasystems.qstudio.java.integration.eclipse.actions;
20
21 import com.qasystems.qstudio.java.integration.eclipse.EclipseEnvironment;
22
23 import org.eclipse.jdt.core.IJavaProject;
24 import org.eclipse.jface.action.IAction;
25 import org.eclipse.jface.viewers.ISelectionProvider;
26 import org.eclipse.jface.viewers.StructuredSelection;
27 import org.eclipse.ui.IObjectActionDelegate;
28 import org.eclipse.ui.IWorkbenchPage;
29 import org.eclipse.ui.IWorkbenchPart;
30 import org.eclipse.ui.IWorkbenchPartSite;
31 import org.eclipse.ui.actions.ActionDelegate;
32
33 public class SaveAsProjectAction extends ActionDelegate
34 implements IObjectActionDelegate {
35
36 private IWorkbenchPage page;
37
38
39 private IWorkbenchPart part;
40
41
47 public void setActivePart(IAction iAction, IWorkbenchPart iWorkbenchPart) {
48 part = iWorkbenchPart;
49 page = part.getSite().getPage();
50 }
51
52
57 public void run(final IAction action) {
58 IJavaProject ideProject = null;
59
60 final IWorkbenchPartSite site = part.getSite();
61 final ISelectionProvider provider = site.getSelectionProvider();
62 final StructuredSelection selection =
63 (StructuredSelection) provider.getSelection();
64 final Object object = selection.getFirstElement();
65
66 if (object instanceof IJavaProject) {
67 ideProject = (IJavaProject) object;
68 EclipseEnvironment.saveQSJavaProject(
69 EclipseEnvironment.toQSJavaProject(ideProject)
70 );
71 }
72 }
73 }
74