Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Finkbeiner2016-08-09 16:03:27 -0400
committerAndrew M. Finkbeiner2016-10-06 21:12:14 -0400
commitc84f1ba8ba1aa88e1f3ec114a9af59109c9f562a (patch)
tree0ee07ca6fcd986f6bb917ff0a32c8f523dd38a5c
parent68076b5b0ade629638cff1c485556eb10ab1dc21 (diff)
downloadorg.eclipse.osee-c84f1ba8ba1aa88e1f3ec114a9af59109c9f562a.tar.gz
org.eclipse.osee-c84f1ba8ba1aa88e1f3ec114a9af59109c9f562a.tar.xz
org.eclipse.osee-c84f1ba8ba1aa88e1f3ec114a9af59109c9f562a.zip
bug: rework a right-clk action
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/actions/AddToTestManagerPopupAction.java55
1 files changed, 37 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 8deb8eb5f5..000f0b8d33 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,15 +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;
@@ -32,28 +41,38 @@ public class AddToTestManagerPopupAction implements IWorkbenchWindowActionDelega
List<String> selection = new ArrayList<>();
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]);
}

Back to the top