blob: e2a73ef7244c67cdf440d778a89699f5d52bc319 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ote.ui.test.manager.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
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.operations.AddIFileToTestManager;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
public class AddToTestManagerPopupAction implements IWorkbenchWindowActionDelegate {
public static String[] getSelection() {
StructuredSelection sel = AWorkspace.getSelection();
Iterator<?> i = sel.iterator();
List<String> selection = new ArrayList<>();
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());
}
}
}
return selection.toArray(new String[0]);
}
IWorkbenchWindow activeWindow = null;
// IWorkbenchWindowActionDelegate method
@Override
public void dispose() {
// nothing to do
}
// IWorkbenchWindowActionDelegate method
@Override
public void init(IWorkbenchWindow window) {
activeWindow = window;
}
@Override
public void run(IAction proxyAction) {
String[] files = getSelection();
if (files.length == 0) {
AWorkbench.popup("ERROR", "Can't retrieve file");
return;
}
AddIFileToTestManager.getOperation().addIFileToScriptsPage(files);
}
// IActionDelegate method
@Override
public void selectionChanged(IAction proxyAction, ISelection selection) {
}
}
|