diff options
| author | Stephan Herrmann | 2017-09-17 16:33:55 +0000 |
|---|---|---|
| committer | Stephan Herrmann | 2017-09-17 16:47:17 +0000 |
| commit | cd3a5636d6fef999a2566de32bba8762a47c7cac (patch) | |
| tree | 7546bb33df9135a95bf7ce24817792fdc68af073 | |
| parent | 4b4529874a08549cf67a56313804a4ea90484254 (diff) | |
| download | eclipse.jdt.ui-cd3a5636d6fef999a2566de32bba8762a47c7cac.tar.gz eclipse.jdt.ui-cd3a5636d6fef999a2566de32bba8762a47c7cac.tar.xz eclipse.jdt.ui-cd3a5636d6fef999a2566de32bba8762a47c7cac.zip | |
support in IDE
- use default set of system modules
Change-Id: I4eff0cda47e412a89e4d975d69c3aedeefdc0141
| -rw-r--r-- | org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java index fbc0899ae9..5b5266302c 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ModuleDialog.java @@ -18,6 +18,7 @@ import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -668,6 +669,7 @@ public class ModuleDialog extends StatusDialog { private void initializeValues() { fModule2RequiredModules= new HashMap<>(); + boolean isJava9JRE= isJava9JRE(); List<String> availableNames= new ArrayList<>(moduleNames()); List<String> includedNames= new ArrayList<>(); List<LimitModules> limits= fCurrCPElement.getModuleEncapsulationDetails(LimitModules.class); @@ -676,6 +678,9 @@ public class ModuleDialog extends StatusDialog { includedNames.addAll(limitModules.fExplicitlyIncludedModules); availableNames.removeAll(limitModules.fExplicitlyIncludedModules); } + } else if (isJava9JRE) { + includedNames= defaultIncludedModuleNames(); + availableNames.removeAll(includedNames); } else { includedNames= availableNames; availableNames= new ArrayList<>(); @@ -687,10 +692,8 @@ public class ModuleDialog extends StatusDialog { // access to widgets may trigger validation, which needs all values to be initialized (non-null): - if (fCurrCPElement.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { - IPackageFragmentRoot[] roots= findRoots(fCurrCPElement); - if (roots.length > 1 && roots[0].getModuleDescription() != null) - fIsModuleCheckbox.setEnabled(false); // assume multi-module container is Java 9 JRE + if (isJava9JRE) { + fIsModuleCheckbox.setEnabled(false); } List<ModulePatch> patchedModules= fCurrCPElement.getModuleEncapsulationDetails(ModulePatch.class); @@ -700,6 +703,14 @@ public class ModuleDialog extends StatusDialog { fPatchedModule.setText(patchedModules.iterator().next().fModule); } + private boolean isJava9JRE() { + if (fCurrCPElement.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { + IPackageFragmentRoot[] roots= findRoots(fCurrCPElement); + if (roots.length > 1 && roots[0].getModuleDescription() != null) + return true; // assume multi-module container is Java 9 JRE + } + return false; + } private IPackageFragmentRoot[] findRoots(CPListElement element) { IClasspathEntry entry= element.getClasspathEntry(); IPackageFragmentRoot[] roots= element.getJavaProject().findPackageFragmentRoots(entry); @@ -752,6 +763,19 @@ public class ModuleDialog extends StatusDialog { return fModuleNames= moduleNames; } + private List<String> defaultIncludedModuleNames() { + if (fJavaElements != null) { + List<IPackageFragmentRoot> roots= new ArrayList<>(); + for (int i= 0; i < fJavaElements.length; i++) { + if (fJavaElements[i] instanceof IPackageFragmentRoot) { + roots.add((IPackageFragmentRoot) fJavaElements[i]); + } + } + return JavaModelAccess.defaultRootModules(roots); + } + return Collections.emptyList(); + } + private void recordModule(IModuleDescription module, Set<String> moduleNames) { String moduleName= module.getElementName(); if (moduleNames.add(moduleName)) { |
