|
Lines 12-19
Link Here
|
| 12 |
package org.eclipse.hyades.test.ui.util; |
12 |
package org.eclipse.hyades.test.ui.util; |
| 13 |
|
13 |
|
| 14 |
import java.io.File; |
14 |
import java.io.File; |
|
|
15 |
import java.util.ArrayList; |
| 16 |
import java.util.Collection; |
| 15 |
import java.util.Iterator; |
17 |
import java.util.Iterator; |
| 16 |
import java.util.List; |
18 |
import java.util.List; |
|
|
19 |
import java.util.Set; |
| 17 |
|
20 |
|
| 18 |
import org.eclipse.core.resources.IFile; |
21 |
import org.eclipse.core.resources.IFile; |
| 19 |
import org.eclipse.core.runtime.IAdaptable; |
22 |
import org.eclipse.core.runtime.IAdaptable; |
|
Lines 22-27
Link Here
|
| 22 |
import org.eclipse.hyades.models.common.facades.behavioral.INamedElement; |
25 |
import org.eclipse.hyades.models.common.facades.behavioral.INamedElement; |
| 23 |
import org.eclipse.hyades.test.core.util.EMFUtil; |
26 |
import org.eclipse.hyades.test.core.util.EMFUtil; |
| 24 |
import org.eclipse.hyades.test.ui.UiPlugin; |
27 |
import org.eclipse.hyades.test.ui.UiPlugin; |
|
|
28 |
import org.eclipse.hyades.test.ui.internal.navigator.TestNavigator; |
| 29 |
import org.eclipse.hyades.test.ui.internal.navigator.proxy.reference.ReferenceTypeRegistry; |
| 30 |
import org.eclipse.hyades.test.ui.navigator.EObjectProxyNode; |
| 31 |
import org.eclipse.hyades.test.ui.navigator.IFileProxyManager; |
| 32 |
import org.eclipse.hyades.test.ui.navigator.IProxyNode; |
| 25 |
import org.eclipse.hyades.ui.internal.util.UIUtil; |
33 |
import org.eclipse.hyades.ui.internal.util.UIUtil; |
| 26 |
import org.eclipse.ui.IEditorDescriptor; |
34 |
import org.eclipse.ui.IEditorDescriptor; |
| 27 |
import org.eclipse.ui.IEditorPart; |
35 |
import org.eclipse.ui.IEditorPart; |
|
Lines 40-50
Link Here
|
| 40 |
* |
48 |
* |
| 41 |
* @author Marcelo Paternostro |
49 |
* @author Marcelo Paternostro |
| 42 |
* @author Paul E. Slauenwhite |
50 |
* @author Paul E. Slauenwhite |
| 43 |
* @version February 28, 2008 |
51 |
* @author jbozier |
|
|
52 |
* @version April 16, 2008 |
| 44 |
* @since February 1, 2005 |
53 |
* @since February 1, 2005 |
| 45 |
*/ |
54 |
*/ |
| 46 |
public class TestUIUtil |
55 |
public class TestUIUtil |
| 47 |
{ |
56 |
{ |
|
|
57 |
|
| 58 |
/** |
| 59 |
* Return list of all file representing EMF resource that are explicitly referenced by the EMF object stored in file |
| 60 |
* @param file EMF resource used to calculate references |
| 61 |
* @return list of depending resource, NULL if file is not representing an EMF object |
| 62 |
*/ |
| 63 |
public static List getExplicitDependencies(IFile file) { |
| 64 |
if (file == null) { |
| 65 |
return null; |
| 66 |
} |
| 67 |
// get active proxy manager |
| 68 |
IFileProxyManager proxManager = null; |
| 69 |
if(PlatformUI.getWorkbench() != null) { |
| 70 |
TestNavigator nav = TestNavigator.getTestNavigator(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); |
| 71 |
if (nav != null) { |
| 72 |
proxManager = nav.getCurrentFileProxyManager(); |
| 73 |
} |
| 74 |
} |
| 75 |
IProxyNode prox = proxManager.getProxy(file, null); |
| 76 |
if (prox == null) { |
| 77 |
return null; // no proxy for this resource |
| 78 |
} |
| 79 |
|
| 80 |
List ret = new ArrayList(); |
| 81 |
EObjectProxyNode eproxy = null; |
| 82 |
if (prox instanceof EObjectProxyNode) { |
| 83 |
eproxy = (EObjectProxyNode)prox; |
| 84 |
} else { |
| 85 |
return null; |
| 86 |
} |
| 87 |
Set allTypes = eproxy.getReferenceTypes(); |
| 88 |
for (Iterator it = allTypes.iterator(); it.hasNext(); ) { |
| 89 |
String type = (String)it.next(); |
| 90 |
if (ReferenceTypeRegistry.getInstance().isExplicit(type)) { |
| 91 |
Collection references = eproxy.getReferences(type); |
| 92 |
for (Iterator it2 = references.iterator(); it2.hasNext();) { |
| 93 |
IProxyNode proxy = (IProxyNode) it2.next(); |
| 94 |
IFile childFile = (IFile) proxy.getUnderlyingResource(); |
| 95 |
if (childFile != null) { |
| 96 |
ret.add(childFile); |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
return ret; |
| 102 |
} |
| 103 |
|
| 48 |
/** |
104 |
/** |
| 49 |
* Returns a unique name based on the specified base and list of CMNNamedElement. |
105 |
* Returns a unique name based on the specified base and list of CMNNamedElement. |
| 50 |
* @param baseName |
106 |
* @param baseName |