1 package com.proalpha.pds.ui;
3 import org.eclipse.core.commands.AbstractHandler;
4 import org.eclipse.core.commands.ExecutionEvent;
5 import org.eclipse.core.commands.ExecutionException;
6 import org.eclipse.core.resources.IFile;
7 import org.eclipse.core.resources.IProject;
8 import org.eclipse.core.resources.IResource;
9 import org.eclipse.core.runtime.IAdaptable;
10 import org.eclipse.jface.text.ITextSelection;
11 import org.eclipse.jface.viewers.ISelection;
12 import org.eclipse.jface.viewers.IStructuredSelection;
13 import org.eclipse.ui.handlers.HandlerUtil;
15 import com.openedge.pdt.project.IOpenEdgeProject;
16 import com.openedge.pdt.project.OEProject;
17 import com.openedge.pdt.project.OEProjectPlugin;
18 import com.proalpha.pds.exception.ProALPHANotAvailableException;
19 import com.proalpha.pds.paconnector.Activator;
20 import com.proalpha.pds.paconnector.PaProject;
31 public Object execute(ExecutionEvent arg0)
throws ExecutionException {
32 throw new ExecutionException(
"AbstractProAlphaHandler must be extended by an existing proALPHA handler!");
46 IProject project =
null;
47 Object firstElement =
null;
49 ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
51 if (selection ==
null)
56 if (selection instanceof IStructuredSelection) {
57 IStructuredSelection structuredSelection = (IStructuredSelection) selection;
58 firstElement = structuredSelection.getFirstElement();
63 else if (selection instanceof ITextSelection)
64 firstElement = HandlerUtil.getActiveEditorInput(event);
71 if (firstElement instanceof IResource) {
72 IResource res = (IResource) firstElement;
73 project = res.getProject();
76 else if (firstElement instanceof IFile) {
77 IFile file = (IFile) firstElement;
78 project = file.getProject();
81 else if (firstElement instanceof IAdaptable) {
82 project = ((IAdaptable) firstElement).getAdapter(IProject.class);
84 if (project ==
null) {
85 IResource resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
86 if (resource !=
null) {
87 project = resource.getProject();
95 IOpenEdgeProject currProj = OEProjectPlugin.getDefault().getOpenEdgeModel()
96 .getOpenEdgeProject((IResource) project);
100 if (paProject ==
null || !paProject.isAvailable())
116 String fileName =
null;
117 Object firstElement =
null;
119 ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
121 if (selection ==
null)
126 if (selection instanceof IStructuredSelection) {
127 IStructuredSelection structuredSelection = (IStructuredSelection) selection;
128 firstElement = structuredSelection.getFirstElement();
133 else if (selection instanceof ITextSelection)
134 firstElement = HandlerUtil.getActiveEditorInput(event);
141 if (firstElement instanceof IFile) {
142 IFile file = (IFile) firstElement;
143 fileName = file.getName();
146 else if (firstElement instanceof IAdaptable) {
147 IResource resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
148 if (resource !=
null) {
149 fileName = resource.getName();
153 if (fileName ==
null)
static Activator getDefault()
PaProject getPaProjectOfEvent(ExecutionEvent event)
String getOeFileOfEvent(ExecutionEvent event)