Skip to content

Package: ProjectInstallerWizard

ProjectInstallerWizard

nameinstructionbranchcomplexitylinemethod
ProjectInstallerWizard()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
installExample(IProgressMonitor)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
loadFromExtensionPoints()
M: 28 C: 126
82%
M: 9 C: 11
55%
M: 8 C: 3
27%
M: 9 C: 39
81%
M: 0 C: 1
100%

Coverage

1: /**
2: *
3: */
4: package org.eclipse.emf.ecp.ide.view.service.test;
5:
6: import java.util.ArrayList;
7:
8: import org.eclipse.core.runtime.IConfigurationElement;
9: import org.eclipse.core.runtime.IExtensionPoint;
10: import org.eclipse.core.runtime.IProgressMonitor;
11: import org.eclipse.core.runtime.Platform;
12: import org.eclipse.emf.common.ui.CommonUIPlugin;
13: import org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard;
14: import org.eclipse.emf.common.ui.wizard.ExampleInstallerWizard;
15: import org.eclipse.emf.common.util.URI;
16:
17: /**
18: * @author Alexandra Buzila
19: *
20: */
21: public class ProjectInstallerWizard extends ExampleInstallerWizard {
22:
23:         private final String projectName = "TestIDEViewRegistryProjectResources";
24:
25:         /*
26:          * (non-Javadoc)
27:          * @see org.eclipse.emf.common.ui.wizard.AbstractExampleInstallerWizard#installExample(org.eclipse.core.runtime.
28:          * IProgressMonitor)
29:          */
30:         @Override
31:         protected void installExample(IProgressMonitor progressMonitor)
32:                 throws Exception {
33:                 super.installExample(progressMonitor);
34:         }
35:
36:         /*
37:          * (non-Javadoc)
38:          * @see org.eclipse.emf.common.ui.wizard.ExampleInstallerWizard#
39:          * loadFromExtensionPoints()
40:          */
41:         @Override
42:         protected void loadFromExtensionPoints() {
43:
44:                 projectDescriptors = new ArrayList<ProjectDescriptor>();
45:                 filesToOpen = new ArrayList<FileToOpen>();
46:                 final String wizardID = "org.eclipse.emf.ecp.ide.view.service.test.ProjectInstallerWizard"; //$NON-NLS-1$
47:
48:                 final IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
49:                         .getExtensionPoint(CommonUIPlugin.INSTANCE.getSymbolicName(), "examples"); //$NON-NLS-1$
50:                 final IConfigurationElement[] exampleElements = extensionPoint
51:                         .getConfigurationElements();
52:•                for (int i = 0; i < exampleElements.length; i++) {
53:                         final IConfigurationElement exampleElement = exampleElements[i];
54:•                        if ("example".equals(exampleElement.getName()) //$NON-NLS-1$
55:•                                && wizardID.equals(exampleElement.getAttribute("wizardID"))) { //$NON-NLS-1$
56:                                 final IConfigurationElement[] projectDescriptorElements = exampleElement
57:                                         .getChildren("projectDescriptor"); //$NON-NLS-1$
58:•                                for (int j = 0; j < projectDescriptorElements.length; j++) {
59:
60:                                         final IConfigurationElement projectDescriptorElement = projectDescriptorElements[j];
61:                                         final String contentURI = projectDescriptorElement
62:                                                 .getAttribute("contentURI"); //$NON-NLS-1$
63:•                                        if (projectName != null && contentURI != null) {
64:                                                 final AbstractExampleInstallerWizard.ProjectDescriptor projectDescriptor = new AbstractExampleInstallerWizard.ProjectDescriptor();
65:                                                 projectDescriptor.setName(projectName);
66:
67:                                                 URI uri = URI.createURI(contentURI);
68:•                                                if (uri.isRelative()) {
69:                                                         uri = URI
70:                                                                 .createPlatformPluginURI(
71:                                                                         projectDescriptorElement
72:                                                                                 .getContributor().getName()
73:                                                                                 + "/" + contentURI, //$NON-NLS-1$
74:                                                                         true);
75:                                                 }
76:                                                 projectDescriptor.setContentURI(uri);
77:                                                 projectDescriptor
78:                                                         .setDescription(projectDescriptorElement
79:                                                                 .getAttribute("description")); //$NON-NLS-1$
80:                                                 projectDescriptors.add(projectDescriptor);
81:                                         }
82:                                 }
83:
84:•                                if (!projectDescriptors.isEmpty()) {
85:                                         final IConfigurationElement[] openElements = exampleElement
86:                                                 .getChildren("fileToOpen"); //$NON-NLS-1$
87:•                                        for (int j = 0; j < openElements.length; j++) {
88:                                                 final IConfigurationElement openElement = openElements[j];
89:                                                 final String location = openElement
90:                                                         .getAttribute("location"); //$NON-NLS-1$
91:•                                                if (location != null) {
92:                                                         final AbstractExampleInstallerWizard.FileToOpen fileToOpen = new AbstractExampleInstallerWizard.FileToOpen();
93:                                                         fileToOpen.setLocation(location);
94:                                                         fileToOpen.setEditorID(openElement
95:                                                                 .getAttribute("editorID")); //$NON-NLS-1$
96:                                                         filesToOpen.add(fileToOpen);
97:                                                 }
98:                                         }
99:
100:                                         // Only one example per wizard
101:                                         break;
102:                                 }
103:                         }
104:                 }
105:         }
106: }