diff options
-rw-r--r-- | plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java index 9289e547737..bdb5e58dcbe 100644 --- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java +++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java @@ -13,16 +13,24 @@ package org.eclipse.osee.ote.ui.test.manager.actions; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IMember; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; import org.eclipse.osee.framework.ui.ws.AWorkspace; +import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin; import org.eclipse.osee.ote.ui.test.manager.operations.AddIFileToTestManager; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; @@ -33,28 +41,38 @@ public class AddToTestManagerPopupAction implements IWorkbenchWindowActionDelega List<String> selection = new ArrayList<String>(); ISelection sel1 = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection(); if(sel1 instanceof StructuredSelection){ - Iterator<?> i = ((StructuredSelection)sel1).iterator(); - - while (i.hasNext()) { - Object obj = i.next(); - if (obj instanceof IResource) { - IResource resource = (IResource) obj; - if (resource != null) { - selection.add(resource.getLocation().toOSString()); - } - } else if (obj instanceof ICompilationUnit) { - ICompilationUnit resource = (ICompilationUnit) obj; - if (resource != null) { - selection.add(resource.getResource().getLocation().toOSString()); + Iterator<?> i = ((StructuredSelection)sel1).iterator(); + + while (i.hasNext()) { + Object obj = i.next(); + if (obj instanceof IResource) { + IResource resource = (IResource) obj; + if (resource != null) { + selection.add(resource.getLocation().toOSString()); + } + } else if (obj instanceof ICompilationUnit) { + ICompilationUnit resource = (ICompilationUnit) obj; + if (resource != null) { + selection.add(resource.getResource().getLocation().toOSString()); + } + } else if (obj instanceof IMember){ + ICompilationUnit resource = ((IMember) obj).getCompilationUnit(); + if (resource != null) { + selection.add(resource.getResource().getLocation().toOSString()); + } } - } else if (obj instanceof IMember){ - ICompilationUnit resource = ((IMember) obj).getCompilationUnit(); - if (resource != null) { - selection.add(resource.getResource().getLocation().toOSString()); + } + } else if (sel1 instanceof TextSelection){ + IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + IEditorInput editorInput = editorPart.getEditorInput(); + IFile iFile = null; + if (editorInput instanceof IFileEditorInput) { + iFile = ((IFileEditorInput) editorInput).getFile(); + if (iFile != null) { + selection.add(iFile.getLocation().toOSString()); } } } - } return selection.toArray(new String[0]); } |